use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class EmergencyInfoPreferenceController method updateRawDataToIndex.
@Override
public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
if (isAvailable()) {
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
final Resources res = mContext.getResources();
data.title = res.getString(com.android.settings.R.string.emergency_info_title);
data.screenTitle = res.getString(com.android.settings.R.string.emergency_info_title);
rawData.add(data);
}
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class BaseSearchIndexProvider method getDynamicRawDataToIndex.
@Override
@CallSuper
public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context, boolean enabled) {
final List<SearchIndexableRaw> dynamicRaws = new ArrayList<>();
if (!isPageSearchEnabled(context)) {
// Entire page should be suppressed, do not add dynamic raw data.
return dynamicRaws;
}
final List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
if (controllers == null || controllers.isEmpty()) {
return dynamicRaws;
}
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof PreferenceControllerMixin) {
((PreferenceControllerMixin) controller).updateDynamicRawDataToIndex(dynamicRaws);
} else if (controller instanceof BasePreferenceController) {
((BasePreferenceController) controller).updateDynamicRawDataToIndex(dynamicRaws);
} else {
Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the dynamic indexable");
}
}
return dynamicRaws;
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class SettingsSearchIndexablesProvider method getDynamicSearchIndexableRawData.
private List<SearchIndexableRaw> getDynamicSearchIndexableRawData(Context context, SearchIndexableData bundle) {
final Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
final List<SearchIndexableRaw> providerRaws = provider.getDynamicRawDataToIndex(context, true);
if (providerRaws == null) {
return new ArrayList<>();
}
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();
}
return providerRaws;
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class SettingsSearchIndexablesProvider method queryDynamicRawData.
/**
* Gets a Cursor of dynamic Raw data similar to queryRawData. We use those data in search query
* time
*/
@Nullable
@Override
public Cursor queryDynamicRawData(String[] projection) {
final Context context = getContext();
final List<SearchIndexableRaw> rawList = new ArrayList<>();
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
for (SearchIndexableData bundle : bundles) {
rawList.addAll(getDynamicSearchIndexableRawData(context, bundle));
// Refresh the search enabled state for indexing injection raw data
final Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
if (provider instanceof BaseSearchIndexProvider) {
refreshSearchEnabledState(context, (BaseSearchIndexProvider) provider);
}
}
rawList.addAll(getInjectionIndexableRawData(context));
final MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
for (SearchIndexableRaw raw : rawList) {
cursor.addRow(createIndexableRawColumnObjects(raw));
}
return cursor;
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class AccountPreferenceControllerTest method updateRawDataToIndex_DisabledUser_shouldNotUpdate.
@Test
public void updateRawDataToIndex_DisabledUser_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_DISABLED));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
mController.updateRawDataToIndex(data);
assertThat(data).isEmpty();
}
Aggregations