Search in sources :

Example 1 with SearchableInfo

use of android.app.SearchableInfo in project cw-omnibus by commonsguy.

the class SearchView method onVoiceClicked.

private void onVoiceClicked() {
    // guard against possible race conditions
    if (mSearchable == null) {
        return;
    }
    SearchableInfo searchable = mSearchable;
    try {
        if (searchable.getVoiceSearchLaunchWebSearch()) {
            Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent, searchable);
            getContext().startActivity(webSearchIntent);
        } else if (searchable.getVoiceSearchLaunchRecognizer()) {
            Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent, searchable);
            getContext().startActivity(appSearchIntent);
        }
    } catch (ActivityNotFoundException e) {
        // Should not happen, since we check the availability of
        // voice search before showing the button. But just in case...
        Log.w(LOG_TAG, "Could not find voice search activity");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) SearchableInfo(android.app.SearchableInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 2 with SearchableInfo

use of android.app.SearchableInfo in project Libraries-for-Android-Developers by eoecn.

the class SearchView method onVoiceClicked.

private void onVoiceClicked() {
    // guard against possible race conditions
    if (mSearchable == null) {
        return;
    }
    SearchableInfo searchable = mSearchable;
    try {
        if (searchable.getVoiceSearchLaunchWebSearch()) {
            Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent, searchable);
            getContext().startActivity(webSearchIntent);
        } else if (searchable.getVoiceSearchLaunchRecognizer()) {
            Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent, searchable);
            getContext().startActivity(appSearchIntent);
        }
    } catch (ActivityNotFoundException e) {
        // Should not happen, since we check the availability of
        // voice search before showing the button. But just in case...
        Log.w(LOG_TAG, "Could not find voice search activity");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) SearchableInfo(android.app.SearchableInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 3 with SearchableInfo

use of android.app.SearchableInfo in project android_frameworks_base by ParanoidAndroid.

the class SearchablesTest method testSearchablesListReal.

/**
     * This is an attempt to run the searchable info list with a mocked context.  Here are some
     * things I'd like to test.
     *
     *  Confirm OK with "zero" searchables
     *  Confirm "good" metadata read properly
     *  Confirm "bad" metadata skipped properly
     *  Confirm ordering of searchables
     *  Confirm "good" actionkeys
     *  confirm "bad" actionkeys are rejected
     *  confirm XML ordering enforced (will fail today - bug in SearchableInfo)
     *  findActionKey works
     *  getIcon works

     */
public void testSearchablesListReal() {
    MyMockPackageManager mockPM = new MyMockPackageManager(mContext.getPackageManager());
    MyMockContext mockContext = new MyMockContext(mContext, mockPM);
    // build item list with real-world source data
    mockPM.setSearchablesMode(MyMockPackageManager.SEARCHABLES_PASSTHROUGH);
    Searchables searchables = new Searchables(mockContext, 0);
    searchables.buildSearchableList();
    // tests with "real" searchables (deprecate, this should be a unit test)
    ArrayList<SearchableInfo> searchablesList = searchables.getSearchablesList();
    int count = searchablesList.size();
    // this isn't really a unit test
    assertTrue(count >= 1);
    checkSearchables(searchablesList);
    ArrayList<SearchableInfo> global = searchables.getSearchablesInGlobalSearchList();
    checkSearchables(global);
}
Also used : SearchableInfo(android.app.SearchableInfo) Searchables(com.android.server.search.Searchables)

Example 4 with SearchableInfo

use of android.app.SearchableInfo in project platform_frameworks_base by android.

the class SearchablesTest method checkSearchables.

/**
     * Generic health checker for an array of searchables.
     * 
     * This is designed to pass for any semi-legal searchable, without knowing much about
     * the format of the underlying data.  It's fairly easy for a non-compliant application
     * to provide meta-data that will pass here (e.g. a non-existent suggestions authority).
     * 
     * @param searchables The list of searchables to examine.
     */
private void checkSearchables(ArrayList<SearchableInfo> searchablesList) {
    assertNotNull(searchablesList);
    int count = searchablesList.size();
    for (int ii = 0; ii < count; ii++) {
        SearchableInfo si = searchablesList.get(ii);
        checkSearchable(si);
    }
}
Also used : SearchableInfo(android.app.SearchableInfo)

Example 5 with SearchableInfo

use of android.app.SearchableInfo in project platform_frameworks_base by android.

the class SearchablesTest method testSearchablesListEmpty.

/**
     * This round of tests confirms good operations with "zero" searchables found
     */
public void testSearchablesListEmpty() {
    MyMockPackageManager mockPM = new MyMockPackageManager(mContext.getPackageManager());
    MyMockContext mockContext = new MyMockContext(mContext, mockPM);
    mockPM.setSearchablesMode(MyMockPackageManager.SEARCHABLES_MOCK_ZERO);
    Searchables searchables = new Searchables(mockContext, 0);
    searchables.updateSearchableList();
    ArrayList<SearchableInfo> searchablesList = searchables.getSearchablesList();
    assertNotNull(searchablesList);
    MoreAsserts.assertEmpty(searchablesList);
    ArrayList<SearchableInfo> global = searchables.getSearchablesInGlobalSearchList();
    MoreAsserts.assertEmpty(global);
}
Also used : SearchableInfo(android.app.SearchableInfo) Searchables(com.android.server.search.Searchables)

Aggregations

SearchableInfo (android.app.SearchableInfo)54 Intent (android.content.Intent)22 ComponentName (android.content.ComponentName)17 PendingIntent (android.app.PendingIntent)15 ActivityNotFoundException (android.content.ActivityNotFoundException)15 RecognizerIntent (android.speech.RecognizerIntent)15 Searchables (com.android.server.search.Searchables)15 ActivityInfo (android.content.pm.ActivityInfo)12 ResolveInfo (android.content.pm.ResolveInfo)6 Bundle (android.os.Bundle)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 RemoteException (android.os.RemoteException)5 SearchManager (android.app.SearchManager)2 PackageManager (android.content.pm.PackageManager)2 MenuItem (android.view.MenuItem)1 CompositeSubscription (rx.subscriptions.CompositeSubscription)1