Search in sources :

Example 91 with AbstractPreferenceController

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

the class DisplaySettingsTest method testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen.

@Test
@Config(shadows = ShadowPowerManagerWrapper.class)
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
    final Context context = RuntimeEnvironment.application;
    // PowerManager wrapper = mock(PowerManager.class);
    // doReturn(wrapper).when(context).getSystemService(Context.POWER_SERVICE);
    final DisplaySettings fragment = new DisplaySettings();
    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());
    }
    // Nightmode is currently hidden
    preferenceKeys.remove("night_mode");
    assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
}
Also used : Context(android.content.Context) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 92 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project platform_packages_apps_Settings by BlissRoms.

the class DefaultAppSettings method buildPreferenceControllers.

private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    controllers.add(new DefaultAssistPreferenceController(context, KEY_ASSIST_VOICE_INPUT, false));
    controllers.add(new DefaultBrowserPreferenceController(context));
    controllers.add(new DefaultWorkBrowserPreferenceController(context));
    controllers.add(new DefaultPhonePreferenceController(context));
    controllers.add(new DefaultWorkPhonePreferenceController(context));
    controllers.add(new DefaultSmsPreferenceController(context));
    controllers.add(new DefaultEmergencyPreferenceController(context));
    controllers.add(new DefaultHomePreferenceController(context));
    controllers.add(new DefaultPaymentSettingsPreferenceController(context));
    return controllers;
}
Also used : DefaultWorkPhonePreferenceController(com.android.settings.applications.defaultapps.DefaultWorkPhonePreferenceController) DefaultPhonePreferenceController(com.android.settings.applications.defaultapps.DefaultPhonePreferenceController) DefaultBrowserPreferenceController(com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) DefaultHomePreferenceController(com.android.settings.applications.defaultapps.DefaultHomePreferenceController) DefaultPaymentSettingsPreferenceController(com.android.settings.applications.defaultapps.DefaultPaymentSettingsPreferenceController) ArrayList(java.util.ArrayList) DefaultWorkBrowserPreferenceController(com.android.settings.applications.defaultapps.DefaultWorkBrowserPreferenceController) DefaultEmergencyPreferenceController(com.android.settings.applications.defaultapps.DefaultEmergencyPreferenceController) DefaultAssistPreferenceController(com.android.settings.applications.assist.DefaultAssistPreferenceController) DefaultSmsPreferenceController(com.android.settings.applications.defaultapps.DefaultSmsPreferenceController)

Example 93 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project platform_packages_apps_Settings by BlissRoms.

the class ConnectedDeviceDashboardFragment method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Lifecycle lifecycle = getLifecycle();
    final NfcPreferenceController nfcPreferenceController = new NfcPreferenceController(context);
    lifecycle.addObserver(nfcPreferenceController);
    controllers.add(nfcPreferenceController);
    mUsbPrefController = new UsbModePreferenceController(context, new UsbBackend(context));
    lifecycle.addObserver(mUsbPrefController);
    controllers.add(mUsbPrefController);
    final BluetoothMasterSwitchPreferenceController bluetoothPreferenceController = new BluetoothMasterSwitchPreferenceController(context, Utils.getLocalBtManager(context), this, (SettingsActivity) getActivity());
    lifecycle.addObserver(bluetoothPreferenceController);
    controllers.add(bluetoothPreferenceController);
    SmsMirroringFeatureProvider smsMirroringFeatureProvider = FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
    AbstractPreferenceController smsMirroringController = smsMirroringFeatureProvider.getController(context);
    controllers.add(smsMirroringController);
    return controllers;
}
Also used : BluetoothMasterSwitchPreferenceController(com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ArrayList(java.util.ArrayList) NfcPreferenceController(com.android.settings.nfc.NfcPreferenceController) UsbBackend(com.android.settings.deviceinfo.UsbBackend)

Example 94 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project platform_packages_apps_Settings by BlissRoms.

the class StorageDashboardFragment method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    mSummaryController = new StorageSummaryDonutPreferenceController(context);
    controllers.add(mSummaryController);
    StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, mVolume, new StorageManagerVolumeProvider(sm));
    controllers.add(mPreferenceController);
    UserManagerWrapper userManager = new UserManagerWrapperImpl(context.getSystemService(UserManager.class));
    mSecondaryUsers = SecondaryUserController.getSecondaryUserControllers(context, userManager);
    controllers.addAll(mSecondaryUsers);
    final AutomaticStorageManagementSwitchPreferenceController asmController = new AutomaticStorageManagementSwitchPreferenceController(context, mMetricsFeatureProvider, getFragmentManager());
    getLifecycle().addObserver(asmController);
    controllers.add(asmController);
    return controllers;
}
Also used : AutomaticStorageManagementSwitchPreferenceController(com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) UserManager(android.os.UserManager) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) UserManagerWrapperImpl(com.android.settings.applications.UserManagerWrapperImpl) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider) StorageSummaryDonutPreferenceController(com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController) UserManagerWrapper(com.android.settings.applications.UserManagerWrapper)

Example 95 with AbstractPreferenceController

use of com.android.settingslib.core.AbstractPreferenceController in project platform_packages_apps_Settings by BlissRoms.

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