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