Search in sources :

Example 16 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class SettingsSearchIndexablesProvider method getSearchIndexableRawFromProvider.

private List<SearchIndexableRaw> getSearchIndexableRawFromProvider(Context context) {
    final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
    final List<SearchIndexableRaw> rawList = new ArrayList<>();
    for (SearchIndexableData bundle : bundles) {
        Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
        final List<SearchIndexableRaw> providerRaws = provider.getRawDataToIndex(context, true);
        if (providerRaws == null) {
            continue;
        }
        for (SearchIndexableRaw raw : providerRaws) {
            // The classname and intent information comes from the PreIndexData
            // This will be more clear when provider conversion is done at PreIndex time.
            raw.className = bundle.getTargetClass().getName();
        }
        rawList.addAll(providerRaws);
    }
    return rawList;
}
Also used : SearchIndexableData(com.android.settingslib.search.SearchIndexableData) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Indexable(com.android.settingslib.search.Indexable)

Example 17 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class SettingsSearchIndexablesProvider method getInjectionIndexableRawData.

@VisibleForTesting
List<SearchIndexableRaw> getInjectionIndexableRawData(Context context) {
    final DashboardFeatureProvider dashboardFeatureProvider = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
    final List<SearchIndexableRaw> rawList = new ArrayList<>();
    final String currentPackageName = context.getPackageName();
    for (DashboardCategory category : dashboardFeatureProvider.getAllCategories()) {
        if (mSearchEnabledByCategoryKeyMap.containsKey(category.key) && !mSearchEnabledByCategoryKeyMap.get(category.key)) {
            Log.i(TAG, "Skip indexing category: " + category.key);
            continue;
        }
        for (Tile tile : category.getTiles()) {
            if (!isEligibleForIndexing(currentPackageName, tile)) {
                continue;
            }
            final SearchIndexableRaw raw = new SearchIndexableRaw(context);
            final CharSequence title = tile.getTitle(context);
            raw.title = TextUtils.isEmpty(title) ? null : title.toString();
            if (TextUtils.isEmpty(raw.title)) {
                continue;
            }
            raw.key = dashboardFeatureProvider.getDashboardKeyForTile(tile);
            final CharSequence summary = tile.getSummary(context);
            raw.summaryOn = TextUtils.isEmpty(summary) ? null : summary.toString();
            raw.summaryOff = raw.summaryOn;
            raw.className = CATEGORY_KEY_TO_PARENT_MAP.get(tile.getCategory());
            rawList.add(raw);
        }
    }
    return rawList;
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) DashboardFeatureProvider(com.android.settings.dashboard.DashboardFeatureProvider) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) ActivityTile(com.android.settingslib.drawer.ActivityTile) Tile(com.android.settingslib.drawer.Tile) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 18 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class SettingsSearchIndexablesProvider method queryRawData.

/**
 * Gets a Cursor of RawData. We use those data in search indexing time
 */
@Override
public Cursor queryRawData(String[] projection) {
    final MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
    final List<SearchIndexableRaw> raws = getSearchIndexableRawFromProvider(getContext());
    for (SearchIndexableRaw val : raws) {
        cursor.addRow(createIndexableRawColumnObjects(val));
    }
    return cursor;
}
Also used : SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) MatrixCursor(android.database.MatrixCursor)

Example 19 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class TrustAgentListPreferenceControllerTest method updateDynamicRawDataToIndex_shouldIndexAgents.

@Test
public void updateDynamicRawDataToIndex_shouldIndexAgents() {
    final List<TrustAgentManager.TrustAgentComponentInfo> agents = new ArrayList<>();
    final TrustAgentManager.TrustAgentComponentInfo agent = mock(TrustAgentManager.TrustAgentComponentInfo.class);
    agent.title = "Test_title";
    agent.summary = "test summary";
    agent.componentName = new ComponentName("pkg", "agent");
    agent.admin = null;
    agents.add(agent);
    when(mTrustAgentManager.getActiveTrustAgents(mActivity, mLockPatternUtils)).thenReturn(agents);
    final List<SearchIndexableRaw> indexRaws = new ArrayList<>();
    mController.updateDynamicRawDataToIndex(indexRaws);
    assertThat(indexRaws).hasSize(1);
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Aggregations

SearchIndexableRaw (com.android.settingslib.search.SearchIndexableRaw)19 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)10 UserInfo (android.content.pm.UserInfo)8 Indexable (com.android.settingslib.search.Indexable)3 Resources (android.content.res.Resources)2 MatrixCursor (android.database.MatrixCursor)2 SearchIndexableData (com.android.settingslib.search.SearchIndexableData)2 Account (android.accounts.Account)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 CallSuper (androidx.annotation.CallSuper)1 Nullable (androidx.annotation.Nullable)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 BasePreferenceController (com.android.settings.core.BasePreferenceController)1 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)1 DashboardFeatureProvider (com.android.settings.dashboard.DashboardFeatureProvider)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1