use of com.android.settings.core.PreferenceControllerMixin in project android_packages_apps_Settings by crdroidandroid.
the class DatabaseIndexingUtils method getPreferenceControllerUriMap.
/**
* @param className which wil provide the map between from {@link Uri}s to
* {@link PreferenceControllerMixin}
* @param context
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
public static Map<String, PreferenceControllerMixin> getPreferenceControllerUriMap(String className, Context context) {
if (context == null) {
return null;
}
final Class<?> clazz = getIndexableClass(className);
if (clazz == null) {
Log.d(TAG, "SearchIndexableResource '" + className + "' should implement the " + Indexable.class.getName() + " interface!");
return null;
}
// Will be non null only for a Local provider implementing a
// SEARCH_INDEX_DATA_PROVIDER field
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(clazz);
List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(context);
if (controllers == null) {
return null;
}
ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof PreferenceControllerMixin) {
map.put(controller.getPreferenceKey(), (PreferenceControllerMixin) controller);
} else {
throw new IllegalStateException(controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName());
}
}
return map;
}
use of com.android.settings.core.PreferenceControllerMixin in project android_packages_apps_Settings by SudaMod.
the class DatabaseIndexingUtils method getPreferenceControllerUriMap.
/**
* @param className which wil provide the map between from {@link Uri}s to
* {@link PreferenceControllerMixin}
* @param context
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
public static Map<String, PreferenceControllerMixin> getPreferenceControllerUriMap(String className, Context context) {
if (context == null) {
return null;
}
final Class<?> clazz = getIndexableClass(className);
if (clazz == null) {
Log.d(TAG, "SearchIndexableResource '" + className + "' should implement the " + Indexable.class.getName() + " interface!");
return null;
}
// Will be non null only for a Local provider implementing a
// SEARCH_INDEX_DATA_PROVIDER field
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(clazz);
List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(context);
if (controllers == null) {
return null;
}
ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof PreferenceControllerMixin) {
map.put(controller.getPreferenceKey(), (PreferenceControllerMixin) controller);
} else {
throw new IllegalStateException(controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName());
}
}
return map;
}
use of com.android.settings.core.PreferenceControllerMixin in project android_packages_apps_Settings by SudaMod.
the class DatabaseIndexingUtilsTest method testGetPayloadFromMap_MatchingKey_ReturnsPayload.
@Test
public void testGetPayloadFromMap_MatchingKey_ReturnsPayload() {
final String key = "key";
PreferenceControllerMixin prefController = new PreferenceControllerMixin() {
@Override
public ResultPayload getResultPayload() {
return new ResultPayload(null);
}
};
ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
map.put(key, prefController);
ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(map, key);
assertThat(payload).isInstanceOf(ResultPayload.class);
}
use of com.android.settings.core.PreferenceControllerMixin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BaseSearchIndexProvider method getNonIndexableKeys.
@Override
@CallSuper
public List<String> getNonIndexableKeys(Context context) {
if (!isPageSearchEnabled(context)) {
// Entire page should be suppressed, mark all keys from this page as non-indexable.
return getNonIndexableKeysFromXml(context, true);
}
final List<String> nonIndexableKeys = new ArrayList<>();
nonIndexableKeys.addAll(getNonIndexableKeysFromXml(context, false));
final List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
if (controllers != null && !controllers.isEmpty()) {
for (AbstractPreferenceController controller : controllers) {
if (controller instanceof PreferenceControllerMixin) {
((PreferenceControllerMixin) controller).updateNonIndexableKeys(nonIndexableKeys);
} else if (controller instanceof BasePreferenceController) {
((BasePreferenceController) controller).updateNonIndexableKeys(nonIndexableKeys);
} else {
Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the key non-indexable");
nonIndexableKeys.add(controller.getPreferenceKey());
}
}
}
return nonIndexableKeys;
}
Aggregations