Search in sources :

Example 21 with AbstractPreferenceController

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

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

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

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

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

the class StorageDashboardFragment method updateSecondaryUserControllers.

/**
 * Updates the secondary user controller sizes.
 */
private void updateSecondaryUserControllers(List<AbstractPreferenceController> controllers, SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
    for (int i = 0, size = controllers.size(); i < size; i++) {
        AbstractPreferenceController controller = controllers.get(i);
        if (controller instanceof StorageAsyncLoader.ResultHandler) {
            StorageAsyncLoader.ResultHandler userController = (StorageAsyncLoader.ResultHandler) controller;
            userController.handleResult(stats);
        }
    }
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageAsyncLoader(com.android.settings.deviceinfo.storage.StorageAsyncLoader)

Example 24 with AbstractPreferenceController

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

the class SecondaryUserController method getSecondaryUserControllers.

/**
 * Adds the appropriate controllers to a controller list for handling all secondary users on
 * a device.
 * @param context Context for initializing the preference controllers.
 * @param userManager UserManagerWrapper for figuring out which controllers to add.
 */
public static List<AbstractPreferenceController> getSecondaryUserControllers(Context context, UserManagerWrapper userManager) {
    List<AbstractPreferenceController> controllers = new ArrayList<>();
    UserInfo primaryUser = userManager.getPrimaryUser();
    boolean addedUser = false;
    List<UserInfo> infos = userManager.getUsers();
    for (int i = 0, size = infos.size(); i < size; i++) {
        UserInfo info = infos.get(i);
        if (info.isPrimary()) {
            continue;
        }
        if (info == null || Utils.isProfileOf(primaryUser, info)) {
            controllers.add(new UserProfileController(context, info, userManager, USER_PROFILE_INSERTION_LOCATION));
            continue;
        }
        controllers.add(new SecondaryUserController(context, info));
        addedUser = true;
    }
    if (!addedUser) {
        controllers.add(new NoSecondaryUserController(context));
    }
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo)

Example 25 with AbstractPreferenceController

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

the class AdvancedPowerUsageDetail method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Bundle bundle = getArguments();
    final int uid = bundle.getInt(EXTRA_UID, 0);
    final String packageName = bundle.getString(EXTRA_PACKAGE_NAME);
    controllers.add(new BackgroundActivityPreferenceController(context, uid));
    controllers.add(new BatteryOptimizationPreferenceController((SettingsActivity) getActivity(), this, packageName));
    mAppButtonsPreferenceController = new AppButtonsPreferenceController((SettingsActivity) getActivity(), this, getLifecycle(), packageName, mState, mDpm, mUserManager, mPackageManager, REQUEST_UNINSTALL, REQUEST_REMOVE_DEVICE_ADMIN);
    controllers.add(mAppButtonsPreferenceController);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) SettingsActivity(com.android.settings.SettingsActivity)

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