Search in sources :

Example 1 with DashboardFeatureProvider

use of com.android.settings.dashboard.DashboardFeatureProvider 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)

Aggregations

VisibleForTesting (androidx.annotation.VisibleForTesting)1 DashboardFeatureProvider (com.android.settings.dashboard.DashboardFeatureProvider)1 ActivityTile (com.android.settingslib.drawer.ActivityTile)1 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)1 Tile (com.android.settingslib.drawer.Tile)1 SearchIndexableRaw (com.android.settingslib.search.SearchIndexableRaw)1 ArrayList (java.util.ArrayList)1