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;
}
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);
}
}
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);
}
}
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));
}
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);
}
Aggregations