Search in sources :

Example 86 with AbstractPreferenceController

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

the class DashboardFragment method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    Collection<AbstractPreferenceController> controllers = mPreferenceControllers.values();
    // If preference contains intent, log it before handling.
    mMetricsFeatureProvider.logDashboardStartIntent(getContext(), preference.getIntent(), getMetricsCategory());
    // Give all controllers a chance to handle click.
    for (AbstractPreferenceController controller : controllers) {
        if (controller.handlePreferenceTreeClick(preference)) {
            return true;
        }
    }
    return super.onPreferenceTreeClick(preference);
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController)

Example 87 with AbstractPreferenceController

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

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

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

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

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

the class BluetoothSettings method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Lifecycle lifecycle = getLifecycle();
    mDeviceNamePrefController = new BluetoothDeviceNamePreferenceController(context, lifecycle);
    mPairingPrefController = new BluetoothPairingPreferenceController(context, this, (SettingsActivity) getActivity());
    controllers.add(mDeviceNamePrefController);
    controllers.add(mPairingPrefController);
    controllers.add(new BluetoothFilesPreferenceController(context));
    controllers.add(new BluetoothDeviceRenamePreferenceController(context, this, lifecycle));
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ArrayList(java.util.ArrayList) SettingsActivity(com.android.settings.SettingsActivity)

Example 90 with AbstractPreferenceController

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

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)

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