Search in sources :

Example 11 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by LineageOS.

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 12 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by LineageOS.

the class LanguageAndInputSettingsTest method testGetPreferenceControllers_shouldRegisterLifecycleObservers.

@Test
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
    final List<AbstractPreferenceController> controllers = mFragment.getPreferenceControllers(mActivity);
    int lifecycleObserverCount = 0;
    for (AbstractPreferenceController controller : controllers) {
        if (controller instanceof LifecycleObserver) {
            lifecycleObserverCount++;
        }
    }
    verify(mFragment.getLifecycle(), times(lifecycleObserverCount)).addObserver(any(LifecycleObserver.class));
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) LifecycleObserver(com.android.settingslib.core.lifecycle.LifecycleObserver) Test(org.junit.Test)

Example 13 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by LineageOS.

the class LanguageAndInputSettingsTest method testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen.

@Test
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
    final Context context = RuntimeEnvironment.application;
    final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
    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 14 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by LineageOS.

the class DashboardFragmentTest method onAttach_shouldCreatePlaceholderPreferenceController.

@Test
public void onAttach_shouldCreatePlaceholderPreferenceController() {
    final AbstractPreferenceController controller = mTestFragment.getPreferenceController(DashboardTilePlaceholderPreferenceController.class);
    assertThat(controller).isNotNull();
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Test(org.junit.Test)

Example 15 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by LineageOS.

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)344 ArrayList (java.util.ArrayList)245 Test (org.junit.Test)86 UserInfo (android.content.pm.UserInfo)33 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)33 Context (android.content.Context)31 SettingsActivity (com.android.settings.SettingsActivity)18 StorageManager (android.os.storage.StorageManager)16 StorageItemPreferenceController (com.android.settings.deviceinfo.storage.StorageItemPreferenceController)16 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)16 AdditionalSystemUpdatePreferenceController (com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController)12 Activity (android.app.Activity)11 BasePreferenceController (com.android.settings.core.BasePreferenceController)11 PreferenceScreen (android.support.v7.preference.PreferenceScreen)10 UserManager (android.os.UserManager)9 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)9 TimeoutPreferenceController (com.android.settings.display.TimeoutPreferenceController)9 Intent (android.content.Intent)8 AmbientDisplayConfiguration (com.android.internal.hardware.AmbientDisplayConfiguration)8 PreferenceScreen (androidx.preference.PreferenceScreen)7