Search in sources :

Example 36 with SearchManager

use of android.app.SearchManager in project ActionBarSherlock by JakeWharton.

the class Issue659 method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.issue659, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) MenuInflater(com.actionbarsherlock.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 37 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.

the class AssistUtils method getAssistComponentForUser.

public ComponentName getAssistComponentForUser(int userId) {
    final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId);
    if (setting != null) {
        return ComponentName.unflattenFromString(setting);
    }
    // Fallback to keep backward compatible behavior when there is no user setting.
    if (activeServiceSupportsAssistGesture()) {
        return getActiveServiceComponentName();
    }
    Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(false);
    PackageManager pm = mContext.getPackageManager();
    ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, userId);
    if (info != null) {
        return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) SearchManager(android.app.SearchManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 38 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.

the class SearchManagerTest method testSearchManagerInvocations.

/**
     * The goal of this test is to confirm that we can start and then
     * stop a simple search.
     */
public void testSearchManagerInvocations() throws Exception {
    SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager);
    // These tests should simply run to completion w/o exceptions
    searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
    searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
    searchManager.stopSearch();
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager)

Example 39 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.

the class PhoneWindowManager method launchAssistLongPressAction.

private void launchAssistLongPressAction() {
    performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
    // launch the search activity
    Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {
        // TODO: This only stops the factory-installed search manager.
        // Need to formalize an API to handle others
        SearchManager searchManager = getSearchManager();
        if (searchManager != null) {
            searchManager.stopSearch();
        }
        startActivityAsUser(intent, UserHandle.CURRENT);
    } catch (ActivityNotFoundException e) {
        Slog.w(TAG, "No activity to handle assist long press action.", e);
    }
}
Also used : SearchManager(android.app.SearchManager) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 40 with SearchManager

use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.

the class PhoneWindowManager method launchAssistAction.

private void launchAssistAction(String hint, int deviceId) {
    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
    if (!isUserSetupComplete()) {
        // Disable opening assist window during setup
        return;
    }
    Bundle args = null;
    if (deviceId > Integer.MIN_VALUE) {
        args = new Bundle();
        args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
    }
    if ((mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
        // On TV, use legacy handling until assistants are implemented in the proper way.
        ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).launchLegacyAssist(hint, UserHandle.myUserId(), args);
    } else {
        if (hint != null) {
            if (args == null) {
                args = new Bundle();
            }
            args.putBoolean(hint, true);
        }
        StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
        if (statusbar != null) {
            statusbar.startAssist(args);
        }
    }
}
Also used : StatusBarManagerInternal(com.android.server.statusbar.StatusBarManagerInternal) SearchManager(android.app.SearchManager) Bundle(android.os.Bundle)

Aggregations

SearchManager (android.app.SearchManager)101 Intent (android.content.Intent)31 ISearchManager (android.app.ISearchManager)26 ActivityNotFoundException (android.content.ActivityNotFoundException)20 ComponentName (android.content.ComponentName)20 Bundle (android.os.Bundle)14 SearchView (android.support.v7.widget.SearchView)14 MenuItem (android.view.MenuItem)14 RecognizerIntent (android.speech.RecognizerIntent)12 UserHandle (android.os.UserHandle)10 View (android.view.View)9 ImageView (android.widget.ImageView)8 SearchView (android.widget.SearchView)8 TextView (android.widget.TextView)8 ActivityOptions (android.app.ActivityOptions)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 MenuInflater (android.view.MenuInflater)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5