More storage UI updates.

Storage volumes now have headers with larger fonts and progress bars
to show used versus free space.  Updated Memory to use new formatting
template, and Data Usage to use consistent display logic.

Allocate a unique color for each private volume, and yell when a
volume is running low on space.  Update private volume details to
launch into MediaStore-backed storage backends in a management mode,
and only show detailed items when hosting emulated storage.  Show
details dialog about "Other" and user storage items.

Shortcut into single private volume when it's the only device.  Add
real eject icon.

Bug: 21756698, 20275574, 21326612
Change-Id: If3ecd1d912d3e709c09d3e4da24f368e04dd3f9d
This commit is contained in:
Jeff Sharkey
2015-06-15 21:08:56 -07:00
parent edb7b0d9a9
commit 2597625fd9
17 changed files with 576 additions and 280 deletions

View File

@@ -30,7 +30,9 @@ import android.os.storage.VolumeRecord;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.DocumentsContract;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.text.format.Formatter.BytesResult;
import android.util.Log;
import com.android.internal.logging.MetricsLogger;
@@ -58,18 +60,13 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
private int mNextOrder = 0;
private UsageBarPreference mGraph;
private StorageItemPreference mTotal;
private StorageItemPreference mAvailable;
private StorageSummaryPreference mSummary;
private Preference mMount;
private Preference mUnmount;
private Preference mFormatPublic;
private Preference mFormatPrivate;
private long mTotalSize;
private long mAvailSize;
@Override
protected int getMetricsCategory() {
return MetricsLogger.DEVICEINFO_STORAGE;
@@ -103,9 +100,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
addPreferencesFromResource(R.xml.device_info_storage_volume);
mGraph = buildGraph();
mTotal = buildItem(R.string.memory_size, 0);
mAvailable = buildItem(R.string.memory_available, R.color.memory_avail);
mSummary = new StorageSummaryPreference(context);
mMount = buildAction(R.string.storage_menu_mount);
mUnmount = buildAction(R.string.storage_menu_unmount);
@@ -128,21 +123,19 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
}
if (mVolume.isMountedReadable()) {
screen.addPreference(mGraph);
screen.addPreference(mTotal);
screen.addPreference(mAvailable);
screen.addPreference(mSummary);
final File file = mVolume.getPath();
mTotalSize = file.getTotalSpace();
mAvailSize = file.getFreeSpace();
final long totalBytes = file.getTotalSpace();
final long freeBytes = file.getFreeSpace();
final long usedBytes = totalBytes - freeBytes;
mTotal.setSummary(Formatter.formatFileSize(context, mTotalSize));
mAvailable.setSummary(Formatter.formatFileSize(context, mAvailSize));
mGraph.clear();
mGraph.addEntry(0, (mTotalSize - mAvailSize) / (float) mTotalSize,
android.graphics.Color.GRAY);
mGraph.commit();
final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
result.value, result.units));
mSummary.setSummary(getString(R.string.storage_volume_used,
Formatter.formatFileSize(context, totalBytes)));
mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
}
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
@@ -157,19 +150,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
}
}
private UsageBarPreference buildGraph() {
final UsageBarPreference pref = new UsageBarPreference(getActivity());
pref.setOrder(mNextOrder++);
return pref;
}
private StorageItemPreference buildItem(int titleRes, int colorRes) {
final StorageItemPreference pref = new StorageItemPreference(getActivity(), titleRes,
colorRes);
pref.setOrder(mNextOrder++);
return pref;
}
private Preference buildAction(int titleRes) {
final Preference pref = new Preference(getActivity());
pref.setTitle(titleRes);