Search in sources :

Example 1 with SearchIndexProvider

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

the class SliceDataConverter method getSliceData.

/**
 * @return a list of {@link SliceData} to be indexed and later referenced as a Slice.
 *
 * The collection works as follows:
 * - Collects a list of Fragments from
 * {@link FeatureFactory#getSearchFeatureProvider()}.
 * - From each fragment, grab a {@link SearchIndexProvider}.
 * - For each provider, collect XML resource layout and a list of
 * {@link com.android.settings.core.BasePreferenceController}.
 */
public List<SliceData> getSliceData() {
    List<SliceData> sliceData = new ArrayList<>();
    final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
    for (SearchIndexableData bundle : bundles) {
        final String fragmentName = bundle.getTargetClass().getName();
        final SearchIndexProvider provider = bundle.getSearchIndexProvider();
        // CodeInspection test guards against the null check. Keep check in case of bad actors.
        if (provider == null) {
            Log.e(TAG, fragmentName + " dose not implement Search Index Provider");
            continue;
        }
        final List<SliceData> providerSliceData = getSliceDataFromProvider(provider, fragmentName);
        sliceData.addAll(providerSliceData);
    }
    final List<SliceData> a11ySliceData = getAccessibilitySliceData();
    sliceData.addAll(a11ySliceData);
    return sliceData;
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableData(com.android.settingslib.search.SearchIndexableData) SearchIndexProvider(com.android.settingslib.search.Indexable.SearchIndexProvider)

Aggregations

SearchIndexProvider (com.android.settingslib.search.Indexable.SearchIndexProvider)1 SearchIndexableData (com.android.settingslib.search.SearchIndexableData)1 ArrayList (java.util.ArrayList)1