Search in sources :

Example 16 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project android_packages_apps_Settings by SudaMod.

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 17 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project platform_packages_apps_Settings by BlissRoms.

the class StorageProfileFragment method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, mVolume, new StorageManagerVolumeProvider(sm), /* isWorkProfile */
    true);
    controllers.add(mPreferenceController);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)

Example 18 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LowStorageSlice method getSlice.

@Override
public Slice getSlice() {
    // Get used storage percentage from StorageManager.
    final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(new StorageManagerVolumeProvider(mContext.getSystemService(StorageManager.class)));
    final double usedPercentage = (double) (info.totalBytes - info.freeBytes) / info.totalBytes;
    // Generate Low storage Slice.
    final String percentageString = NumberFormat.getPercentInstance().format(usedPercentage);
    final String freeSizeString = Formatter.formatFileSize(mContext, info.freeBytes);
    final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.LOW_STORAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_storage);
    if (usedPercentage < LOW_STORAGE_THRESHOLD) {
        // For clients that ignore error checking, a generic storage slice will be given.
        final CharSequence titleStorage = mContext.getText(R.string.storage_settings);
        final String summaryStorage = mContext.getString(R.string.storage_summary, percentageString, freeSizeString);
        return listBuilder.addRow(buildRowBuilder(titleStorage, summaryStorage, icon)).setIsError(true).build();
    }
    final CharSequence titleLowStorage = mContext.getText(R.string.storage_menu_free);
    final String summaryLowStorage = mContext.getString(R.string.low_storage_summary, percentageString, freeSizeString);
    return listBuilder.addRow(buildRowBuilder(titleLowStorage, summaryLowStorage, icon)).build();
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) IconCompat(androidx.core.graphics.drawable.IconCompat) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider) ListBuilder(androidx.slice.builders.ListBuilder)

Example 19 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project android_packages_apps_Settings by omnirom.

the class StorageDashboardFragment method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final StorageManager sm = context.getSystemService(StorageManager.class);
    mPreferenceController = new StorageItemPreferenceController(context, this, null, /* volume */
    new StorageManagerVolumeProvider(sm), mIsWorkProfile);
    controllers.add(mPreferenceController);
    mSecondaryUsers = SecondaryUserController.getSecondaryUserControllers(context, mUserManager, mIsWorkProfile);
    controllers.addAll(mSecondaryUsers);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) StorageItemPreferenceController(com.android.settings.deviceinfo.storage.StorageItemPreferenceController) ArrayList(java.util.ArrayList) StorageManager(android.os.storage.StorageManager) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)

Example 20 with StorageManagerVolumeProvider

use of com.android.settingslib.deviceinfo.StorageManagerVolumeProvider in project android_packages_apps_Settings by omnirom.

the class LowStorageSlice method getSlice.

@Override
public Slice getSlice() {
    // Get used storage percentage from StorageManager.
    final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(new StorageManagerVolumeProvider(mContext.getSystemService(StorageManager.class)));
    final double usedPercentage = (double) (info.totalBytes - info.freeBytes) / info.totalBytes;
    // Generate Low storage Slice.
    final String percentageString = NumberFormat.getPercentInstance().format(usedPercentage);
    final String freeSizeString = Formatter.formatFileSize(mContext, info.freeBytes);
    final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.LOW_STORAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_storage);
    if (usedPercentage < LOW_STORAGE_THRESHOLD) {
        // For clients that ignore error checking, a generic storage slice will be given.
        final CharSequence titleStorage = mContext.getText(R.string.storage_settings);
        final String summaryStorage = mContext.getString(R.string.storage_summary, percentageString, freeSizeString);
        return listBuilder.addRow(buildRowBuilder(titleStorage, summaryStorage, icon)).setIsError(true).build();
    }
    final CharSequence titleLowStorage = mContext.getText(R.string.storage_menu_free);
    final String summaryLowStorage = mContext.getString(R.string.low_storage_summary, percentageString, freeSizeString);
    return listBuilder.addRow(buildRowBuilder(titleLowStorage, summaryLowStorage, icon)).build();
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) IconCompat(androidx.core.graphics.drawable.IconCompat) StorageManagerVolumeProvider(com.android.settingslib.deviceinfo.StorageManagerVolumeProvider) ListBuilder(androidx.slice.builders.ListBuilder)

Aggregations

StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)20 StorageManager (android.os.storage.StorageManager)17 StorageItemPreferenceController (com.android.settings.deviceinfo.storage.StorageItemPreferenceController)16 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)16 ArrayList (java.util.ArrayList)16 UserManager (android.os.UserManager)7 StorageSummaryDonutPreferenceController (com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController)7 UserManagerWrapper (com.android.settings.applications.UserManagerWrapper)6 UserManagerWrapperImpl (com.android.settings.applications.UserManagerWrapperImpl)6 AutomaticStorageManagementSwitchPreferenceController (com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController)6 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)3 IconCompat (androidx.core.graphics.drawable.IconCompat)2 ListBuilder (androidx.slice.builders.ListBuilder)2 Context (android.content.Context)1 Bundle (android.os.Bundle)1 DiskInfo (android.os.storage.DiskInfo)1 VolumeInfo (android.os.storage.VolumeInfo)1 VolumeRecord (android.os.storage.VolumeRecord)1 BytesResult (android.text.format.Formatter.BytesResult)1 Preference (androidx.preference.Preference)1