Example usage for android.content Context SEARCH_SERVICE

List of usage examples for android.content Context SEARCH_SERVICE

Introduction

In this page you can find the example usage for android.content Context SEARCH_SERVICE.

Prototype

String SEARCH_SERVICE

To view the source code for android.content Context SEARCH_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.SearchManager for handling searches.

Usage

From source file:com.android.launcher2.Launcher.java

private boolean updateVoiceSearchIcon(boolean searchVisible) {
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);
    final View voiceButtonProxy = findViewById(R.id.voice_button_proxy);

    // We only show/update the voice search icon if the search icon is enabled as well
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();

    ComponentName activityName = null;//from   w  w w  . ja  va  2  s.c  o  m
    if (globalSearchActivity != null) {
        // Check if the global search activity handles voice search
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setPackage(globalSearchActivity.getPackageName());
        activityName = intent.resolveActivity(getPackageManager());
    }

    if (activityName == null) {
        // Fallback: check if an activity other than the global search activity
        // resolves this
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (searchVisible && activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName,
                R.drawable.ic_home_voice_search_holo, TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME);
        if (sVoiceSearchIcon[coi] == null) {
            sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName,
                    R.drawable.ic_home_voice_search_holo, TOOLBAR_ICON_METADATA_NAME);
        }
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.VISIBLE);
        voiceButton.setVisibility(View.VISIBLE);
        if (voiceButtonProxy != null) {
            voiceButtonProxy.setVisibility(View.VISIBLE);
        }
        invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
        return true;
    } else {
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        voiceButton.setVisibility(View.GONE);
        if (voiceButtonProxy != null) {
            voiceButtonProxy.setVisibility(View.GONE);
        }
        return false;
    }
}

From source file:com.android.soma.Launcher.java

protected boolean updateGlobalSearchIcon() {
    final View searchButtonContainer = findViewById(R.id.search_button_container);
    final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);

    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName activityName = searchManager.getGlobalSearchActivity();
    if (activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName,
                R.drawable.ic_home_search_normal_holo, TOOLBAR_SEARCH_ICON_METADATA_NAME);
        if (sGlobalSearchIcon[coi] == null) {
            sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.search_button, activityName,
                    R.drawable.ic_home_search_normal_holo, TOOLBAR_ICON_METADATA_NAME);
        }/*from   www  .j  a  v  a  2s .c  om*/

        if (searchButtonContainer != null)
            searchButtonContainer.setVisibility(View.VISIBLE);
        searchButton.setVisibility(View.VISIBLE);
        invalidatePressedFocusedStates(searchButtonContainer, searchButton);
        return true;
    } else {
        // We disable both search and voice search when there is no global search provider
        if (searchButtonContainer != null)
            searchButtonContainer.setVisibility(View.GONE);
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        if (searchButton != null)
            searchButton.setVisibility(View.GONE);
        if (voiceButton != null)
            voiceButton.setVisibility(View.GONE);
        updateVoiceButtonProxyVisible(false);
        return false;
    }
}

From source file:com.android.soma.Launcher.java

protected boolean updateVoiceSearchIcon(boolean searchVisible) {
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);

    // We only show/update the voice search icon if the search icon is enabled as well
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();

    ComponentName activityName = null;/*from www  .ja v  a  2  s.c  om*/
    if (globalSearchActivity != null) {
        // Check if the global search activity handles voice search
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setPackage(globalSearchActivity.getPackageName());
        activityName = intent.resolveActivity(getPackageManager());
    }

    if (activityName == null) {
        // Fallback: check if an activity other than the global search activity
        // resolves this
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (searchVisible && activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName,
                R.drawable.ic_home_voice_search_holo, TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME);
        if (sVoiceSearchIcon[coi] == null) {
            sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName,
                    R.drawable.ic_home_voice_search_holo, TOOLBAR_ICON_METADATA_NAME);
        }
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.VISIBLE);
        voiceButton.setVisibility(View.VISIBLE);
        updateVoiceButtonProxyVisible(false);
        invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
        return true;
    } else {
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        if (voiceButton != null)
            voiceButton.setVisibility(View.GONE);
        updateVoiceButtonProxyVisible(false);
        return false;
    }
}

From source file:org.tvbrowser.tvbrowser.TvBrowser.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.tv_browser, menu);
    //new MenuInflater(getSupportActionBar().getThemedContext()).inflate(R.menu.tv_browser, menu);
    mMainMenu = menu;//ww w. j  a v a  2s .co m

    //  Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    mUpdateItem = menu.findItem(R.id.menu_tvbrowser_action_update_data);

    if (!PrefUtils.getStringValue(R.string.PREF_AUTO_UPDATE_TYPE, R.string.pref_auto_update_type_default)
            .equals("0")) {
        mUpdateItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    mFilterItem = menu.findItem(R.id.action_filter_channels);
    mCreateFavorite = menu.findItem(R.id.menu_tvbrowser_action_create_favorite);

    Fragment fragment = mSectionsPagerAdapter.getItem(mViewPager.getCurrentItem());

    mFilterItem.setVisible(!(fragment instanceof FragmentFavorites));
    mCreateFavorite.setVisible(fragment instanceof FragmentFavorites);
    mScrollTimeItem = menu.findItem(R.id.action_scroll);

    updateFromFilterEdit();

    mPluginPreferencesMenuItem = menu.findItem(R.id.menu_tvbrowser_action_settings_plugins);

    mPluginPreferencesMenuItem.setEnabled(PluginHandler.pluginsAvailable());

    menu.findItem(R.id.action_reset).setVisible(TEST_VERSION);

    mSearchExpanded = false;

    // if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    addOnActionExpandListener(menu.findItem(R.id.search));
    // }

    // menu.findItem(R.id.action_synchronize_dont_want_to_see).setVisible(false);
    menu.findItem(R.id.action_synchronize_favorites).setVisible(false);

    if (mUpdateItem != null && TvDataUpdateService.IS_RUNNING) {
        updateProgressIcon(true);
    }

    mDebugMenuItem = menu.findItem(R.id.action_debug);
    mSendDataUpdateLogItem = menu.findItem(R.id.action_send_data_update_log);
    mDeleteDataUpdateLogItem = menu.findItem(R.id.action_delete_data_update_log);
    mSendReminderLogItem = menu.findItem(R.id.action_send_reminder_log);
    mDeleteReminderLogItem = menu.findItem(R.id.action_delete_reminder_log);

    mPauseReminder = menu.findItem(R.id.action_pause_reminder);
    mContinueReminder = menu.findItem(R.id.action_continue_reminder);

    mPauseReminder.setVisible(!SettingConstants.isReminderPaused(TvBrowser.this));
    mContinueReminder.setVisible(SettingConstants.isReminderPaused(TvBrowser.this));

    mScrollTimeItem.setVisible(mViewPager.getCurrentItem() != 2 && !mSearchExpanded);

    boolean dataUpdateLogEnabled = PrefUtils.getBooleanValue(R.string.WRITE_DATA_UPDATE_LOG,
            R.bool.write_data_update_log_default);
    boolean reminderLogEnabled = PrefUtils.getBooleanValue(R.string.WRITE_REMINDER_LOG,
            R.bool.write_reminder_log_default);

    mDebugMenuItem.setVisible(dataUpdateLogEnabled || reminderLogEnabled);

    mSendDataUpdateLogItem.setEnabled(dataUpdateLogEnabled);
    mDeleteDataUpdateLogItem.setEnabled(dataUpdateLogEnabled);
    mSendReminderLogItem.setEnabled(reminderLogEnabled);
    mDeleteReminderLogItem.setEnabled(reminderLogEnabled);

    updateScrollMenu();

    mOptionsMenu = menu;

    updateSynchroMenu();

    return true;
}