Search in sources :

Example 76 with AbstractPreferenceController

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;
}
Also used : VirtualKeyboardPreferenceController(com.android.settings.inputmethod.VirtualKeyboardPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) SpellCheckerPreferenceController(com.android.settings.inputmethod.SpellCheckerPreferenceController) ArrayList(java.util.ArrayList) PhysicalKeyboardPreferenceController(com.android.settings.inputmethod.PhysicalKeyboardPreferenceController) TtsEngines(android.speech.tts.TtsEngines) DefaultAutofillPreferenceController(com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController) GameControllerPreferenceController(com.android.settings.inputmethod.GameControllerPreferenceController)

Example 77 with AbstractPreferenceController

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);
}
Also used : Context(android.content.Context) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 78 with AbstractPreferenceController

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();
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 79 with AbstractPreferenceController

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;
    }
}
Also used : Context(android.content.Context) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Indexable(com.android.settings.search.Indexable) Fragment(android.app.Fragment)

Example 80 with AbstractPreferenceController

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);
    }
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) SecondaryUserController(com.android.settings.deviceinfo.storage.SecondaryUserController)

Aggregations

AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)298 ArrayList (java.util.ArrayList)211 Test (org.junit.Test)75 Context (android.content.Context)29 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)29 UserInfo (android.content.pm.UserInfo)28 SettingsActivity (com.android.settings.SettingsActivity)15 StorageManager (android.os.storage.StorageManager)14 StorageItemPreferenceController (com.android.settings.deviceinfo.storage.StorageItemPreferenceController)14 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)14 PreferenceScreen (android.support.v7.preference.PreferenceScreen)12 AdditionalSystemUpdatePreferenceController (com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController)12 TimeoutPreferenceController (com.android.settings.display.TimeoutPreferenceController)10 Activity (android.app.Activity)9 AmbientDisplayConfiguration (com.android.internal.hardware.AmbientDisplayConfiguration)9 AmbientDisplayPreferenceController (com.android.settings.display.AmbientDisplayPreferenceController)9 AutoBrightnessPreferenceController (com.android.settings.display.AutoBrightnessPreferenceController)9 Config (org.robolectric.annotation.Config)7 Bundle (android.os.Bundle)6 SecondaryUserController (com.android.settings.deviceinfo.storage.SecondaryUserController)6