use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by DirtyUnicorns.
the class LanguageAndInputSettings method buildPreferenceControllers.
private static List<AbstractPreferenceController> buildPreferenceControllers(@NonNull Context context, @Nullable Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
// Language
controllers.add(new PhoneLanguagePreferenceController(context));
controllers.add(new SpellCheckerPreferenceController(context));
controllers.add(new UserDictionaryPreferenceController(context));
controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
// Input
controllers.add(new VirtualKeyboardPreferenceController(context));
controllers.add(new PhysicalKeyboardPreferenceController(context, lifecycle));
final GameControllerPreferenceController gameControllerPreferenceController = new GameControllerPreferenceController(context);
if (lifecycle != null) {
lifecycle.addObserver(gameControllerPreferenceController);
}
controllers.add(gameControllerPreferenceController);
controllers.add(new DefaultAutofillPreferenceController(context));
return controllers;
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by DirtyUnicorns.
the class PowerUsageSummaryTest method testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen.
@Test
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
final Context context = RuntimeEnvironment.application;
final PowerUsageSummary fragment = new PowerUsageSummary();
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context, fragment.getPreferenceScreenResId());
final List<String> preferenceKeys = new ArrayList<>();
for (AbstractPreferenceController controller : fragment.getPreferenceControllers(context)) {
preferenceKeys.add(controller.getPreferenceKey());
}
assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by DirtyUnicorns.
the class GesturesSettingsPreferenceControllerTest method isAvailable_hasGesture_shouldReturnTrue.
@Test
public void isAvailable_hasGesture_shouldReturnTrue() {
final List<AbstractPreferenceController> mControllers = new ArrayList<>();
mControllers.add(new AbstractPreferenceController(RuntimeEnvironment.application) {
@Override
public boolean isAvailable() {
return true;
}
@Override
public String getPreferenceKey() {
return "test_key";
}
});
ReflectionHelpers.setField(mController, "mGestureControllers", mControllers);
assertThat(mController.isAvailable()).isTrue();
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by DirtyUnicorns.
the class DashboardFragmentSearchIndexProviderInspector method isSharingPreferenceControllers.
public static boolean isSharingPreferenceControllers(Class clazz) {
final Context context = RuntimeEnvironment.application;
final Fragment fragment;
try {
fragment = Fragment.instantiate(context, clazz.getName());
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
if (!(fragment instanceof DashboardFragment)) {
return true;
}
final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz);
if (provider == null) {
return true;
}
final List<AbstractPreferenceController> controllersFromSearchIndexProvider;
final List<AbstractPreferenceController> controllersFromFragment;
try {
controllersFromSearchIndexProvider = provider.getPreferenceControllers(context);
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
try {
controllersFromFragment = ((DashboardFragment) fragment).getPreferenceControllers(context);
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
if (controllersFromFragment == controllersFromSearchIndexProvider) {
return true;
} else if (controllersFromFragment != null && controllersFromSearchIndexProvider != null) {
return controllersFromFragment.size() == controllersFromSearchIndexProvider.size();
} else {
return false;
}
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by DirtyUnicorns.
the class StorageDashboardFragment method onReceivedSizes.
private void onReceivedSizes() {
if (mStorageInfo != null) {
long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
mSummaryController.updateBytes(privateUsedBytes, mStorageInfo.totalBytes);
mPreferenceController.setVolume(mVolume);
mPreferenceController.setUsedSize(privateUsedBytes);
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
AbstractPreferenceController controller = mSecondaryUsers.get(i);
if (controller instanceof SecondaryUserController) {
SecondaryUserController userController = (SecondaryUserController) controller;
userController.setTotalSize(mStorageInfo.totalBytes);
}
}
}
if (mAppsResult == null) {
return;
}
mPreferenceController.onLoadFinished(mAppsResult, UserHandle.myUserId());
updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
// setLoading always causes a flicker, so let's avoid doing it.
if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
setLoading(false, true);
}
}
Aggregations