Switch from SI to IEC unit when formatting data usage bytes
- Created a new helper method DataUsageUtils.formatDataUsage() to format data usage bytes using IEC formatting. - Switch from Formatter.formatFileSize() to DataUsageUtils.formatDataUsage() everywhere in datausage package. Change-Id: I9323beed8bf5126b153fc9a3cdd9591c97ca6fd2 Bug: 76159924 Test: robotests
This commit is contained in:
@@ -27,6 +27,7 @@ import android.text.format.Formatter;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.graph.UsageView;
|
||||
@@ -155,7 +156,7 @@ public class ChartDataUsagePreference extends Preference {
|
||||
|
||||
private CharSequence getLabel(long bytes, int str, int mLimitColor) {
|
||||
Formatter.BytesResult result = Formatter.formatBytes(getContext().getResources(),
|
||||
bytes, Formatter.FLAG_SHORTER);
|
||||
bytes, Formatter.FLAG_SHORTER | Formatter.FLAG_IEC_UNITS);
|
||||
CharSequence label = TextUtils.expandTemplate(getContext().getText(str),
|
||||
result.value, result.units);
|
||||
return new SpannableStringBuilder().append(label, new ForegroundColorSpan(mLimitColor), 0);
|
||||
|
Reference in New Issue
Block a user