Always use GB as the unit in Storage Settings.
Bug: 36901322 Test: Settings unit tests Change-Id: I08c711db6a271522942a01d1adf3e8e5223010f7
This commit is contained in:
@@ -17,14 +17,15 @@
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.utils.FileSizeFormatter;
|
||||
|
||||
public class StorageItemPreference extends Preference {
|
||||
public int userHandle;
|
||||
@@ -44,9 +45,12 @@ public class StorageItemPreference extends Preference {
|
||||
}
|
||||
|
||||
public void setStorageSize(long size, long total) {
|
||||
setSummary(size == 0
|
||||
? String.valueOf(0)
|
||||
: Formatter.formatFileSize(getContext(), size));
|
||||
setSummary(
|
||||
FileSizeFormatter.formatFileSize(
|
||||
getContext(),
|
||||
size,
|
||||
getGigabyteSuffix(getContext().getResources()),
|
||||
FileSizeFormatter.GIGABYTE_IN_BYTES));
|
||||
if (total == 0) {
|
||||
mProgressPercent = 0;
|
||||
} else {
|
||||
@@ -75,4 +79,8 @@ public class StorageItemPreference extends Preference {
|
||||
updateProgressBar();
|
||||
super.onBindViewHolder(view);
|
||||
}
|
||||
|
||||
private static int getGigabyteSuffix(Resources res) {
|
||||
return res.getIdentifier("gigabyteShort", "string", "android");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user