Search in sources :

Example 31 with AbstractPreferenceController

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

the class ConfigureWifiSettings method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final NetworkScoreManagerWrapper networkScoreManagerWrapper = new NetworkScoreManagerWrapper(context.getSystemService(NetworkScoreManager.class));
    mWifiWakeupPreferenceController = new WifiWakeupPreferenceController(context, getLifecycle());
    mUseOpenWifiPreferenceController = new UseOpenWifiPreferenceController(context, this, networkScoreManagerWrapper, getLifecycle());
    final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    controllers.add(mWifiWakeupPreferenceController);
    controllers.add(new NetworkScorerPickerPreferenceController(context, networkScoreManagerWrapper));
    controllers.add(new NotifyOpenNetworksPreferenceController(context, getLifecycle()));
    controllers.add(mUseOpenWifiPreferenceController);
    controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), wifiManager));
    controllers.add(new CellularFallbackPreferenceController(context));
    controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), wifiManager));
    controllers.add(new WifiCallingPreferenceController(context));
    controllers.add(new WpsPreferenceController(context, getLifecycle(), wifiManager, getFragmentManager()));
    return controllers;
}
Also used : WifiManager(android.net.wifi.WifiManager) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) NetworkScorerPickerPreferenceController(com.android.settings.network.NetworkScorerPickerPreferenceController) WifiP2pPreferenceController(com.android.settings.wifi.p2p.WifiP2pPreferenceController) ArrayList(java.util.ArrayList) WifiCallingPreferenceController(com.android.settings.network.WifiCallingPreferenceController) NetworkScoreManager(android.net.NetworkScoreManager) NetworkScoreManagerWrapper(com.android.settings.network.NetworkScoreManagerWrapper)

Example 32 with AbstractPreferenceController

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

the class DashboardFragment method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    mDashboardFeatureProvider = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
    mProgressiveDisclosureMixin = mDashboardFeatureProvider.getProgressiveDisclosureMixin(context, this, getArguments());
    getLifecycle().addObserver(mProgressiveDisclosureMixin);
    List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
    if (controllers == null) {
        controllers = new ArrayList<>();
    }
    mPlaceholderPreferenceController = new DashboardTilePlaceholderPreferenceController(context);
    controllers.add(mPlaceholderPreferenceController);
    for (AbstractPreferenceController controller : controllers) {
        addPreferenceController(controller);
    }
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController)

Example 33 with AbstractPreferenceController

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

the class DashboardFragment method updatePreferenceStates.

/**
 * Update state of each preference managed by PreferenceController.
 */
protected void updatePreferenceStates() {
    Collection<AbstractPreferenceController> controllers = mPreferenceControllers.values();
    final PreferenceScreen screen = getPreferenceScreen();
    for (AbstractPreferenceController controller : controllers) {
        if (!controller.isAvailable()) {
            continue;
        }
        final String key = controller.getPreferenceKey();
        final Preference preference = mProgressiveDisclosureMixin.findPreference(screen, key);
        if (preference == null) {
            Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s", key, controller.getClass().getSimpleName()));
            continue;
        }
        controller.updateState(preference);
    }
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference)

Example 34 with AbstractPreferenceController

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

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

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

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)

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