am 96b09cf5: am 3538eb24: am 71c89a17: Merge "More storage UI updates." into mnc-dev

* commit '96b09cf59f7554b05004fa7f8ad6da1c73e8f545':
  More storage UI updates.
This commit is contained in:
Jeff Sharkey
2015-06-16 05:16:43 +00:00
committed by Android Git Automerger
17 changed files with 576 additions and 280 deletions

View File

@@ -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