Shows trash category in Storage Settings

If there is APP which supports VIEW_TRASH intent,
use it to show trash files. Otherwise popup a dialog
to guide users to empty trash files.

Bug: 189109564
Test: manual visual
      Observe size information are the same as files in Files APP.
      Observe if empty trash button empty trash files.
      Observe if Trash category update summary and order after emptying
      trash files.
Change-Id: Ia3c46dcb1b4fadcdfb865f7dd315c27f8f98cb2c
This commit is contained in:
Arc Wang
2021-05-25 00:53:54 +08:00
parent a4fc228b55
commit 8fde6ca821
5 changed files with 101 additions and 24 deletions

View File

@@ -17,8 +17,6 @@
package com.android.settings.deviceinfo;
import android.content.Context;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.AttributeSet;
import android.widget.ProgressBar;
@@ -26,6 +24,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settings.deviceinfo.storage.StorageUtils;
public class StorageItemPreference extends Preference {
public int userHandle;
@@ -49,7 +48,7 @@ public class StorageItemPreference extends Preference {
public void setStorageSize(long size, long total) {
mStorageSize = size;
setSummary(getStorageSummary(size));
setSummary(StorageUtils.getStorageSizeLabel(getContext(), size));
if (total == 0) {
mProgressPercent = 0;
@@ -77,11 +76,4 @@ public class StorageItemPreference extends Preference {
updateProgressBar();
super.onBindViewHolder(view);
}
private String getStorageSummary(long bytes) {
final Formatter.BytesResult result = Formatter.formatBytes(getContext().getResources(),
bytes, Formatter.FLAG_SHORTER);
return TextUtils.expandTemplate(getContext().getText(R.string.storage_size_large),
result.value, result.units).toString();
}
}