summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/widget
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-06-15 21:08:56 -0700
committerJeff Sharkey <jsharkey@android.com>2015-06-15 21:44:21 -0700
commit2597625fd9704ff9eab94987d332378f806dae83 (patch)
tree4b0c82350dc83acbfa7242fd93b4ce02ddbad69d /src/com/android/settings/widget
parentedb7b0d9a900a4a560d0777032600b52f38efd23 (diff)
downloadpackages_apps_Settings-2597625fd9704ff9eab94987d332378f806dae83.zip
packages_apps_Settings-2597625fd9704ff9eab94987d332378f806dae83.tar.gz
packages_apps_Settings-2597625fd9704ff9eab94987d332378f806dae83.tar.bz2
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
Diffstat (limited to 'src/com/android/settings/widget')
-rw-r--r--src/com/android/settings/widget/ChartDataUsageView.java36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/com/android/settings/widget/ChartDataUsageView.java b/src/com/android/settings/widget/ChartDataUsageView.java
index c20a8db..cc9acd6 100644
--- a/src/com/android/settings/widget/ChartDataUsageView.java
+++ b/src/com/android/settings/widget/ChartDataUsageView.java
@@ -16,7 +16,6 @@
package com.android.settings.widget;
-import static android.net.TrafficStats.GB_IN_BYTES;
import static android.net.TrafficStats.MB_IN_BYTES;
import android.content.Context;
@@ -29,8 +28,11 @@ import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateUtils;
+import android.text.format.Formatter;
+import android.text.format.Formatter.BytesResult;
import android.text.format.Time;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@@ -533,33 +535,11 @@ public class ChartDataUsageView extends ChartView {
@Override
public long buildLabel(Resources res, SpannableStringBuilder builder, long value) {
-
- final CharSequence unit;
- final long unitFactor;
- if (value < 1000 * MB_IN_BYTES) {
- unit = res.getText(com.android.internal.R.string.megabyteShort);
- unitFactor = MB_IN_BYTES;
- } else {
- unit = res.getText(com.android.internal.R.string.gigabyteShort);
- unitFactor = GB_IN_BYTES;
- }
-
- final double result = (double) value / unitFactor;
- final double resultRounded;
- final CharSequence size;
-
- if (result < 10) {
- size = String.format("%.1f", result);
- resultRounded = (unitFactor * Math.round(result * 10)) / 10;
- } else {
- size = String.format("%.0f", result);
- resultRounded = unitFactor * Math.round(result);
- }
-
- setText(builder, sSpanSize, size, "^1");
- setText(builder, sSpanUnit, unit, "^2");
-
- return (long) resultRounded;
+ final BytesResult result = Formatter.formatBytes(res, value,
+ Formatter.FLAG_SHORTER | Formatter.FLAG_CALCULATE_ROUNDED);
+ setText(builder, sSpanSize, result.value, "^1");
+ setText(builder, sSpanUnit, result.units, "^2");
+ return result.roundedBytes;
}
@Override