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;
}
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;
}
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;
}
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);
}
Aggregations