summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-06-15 10:11:46 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-06-15 10:11:46 -0700
commit30f5b68b7543489c7415de7cf4d2e458507072a1 (patch)
treeb335f376ac60d30a0b9e75e19c09bb1b1e202a9f /src
parentd43446058378dc965d5568139f07979a9759445f (diff)
parenta78edb54182da5881f2f1e6bc76ae027a9a6f3e3 (diff)
downloadpackages_apps_Settings-30f5b68b7543489c7415de7cf4d2e458507072a1.tar.gz
packages_apps_Settings-30f5b68b7543489c7415de7cf4d2e458507072a1.tar.bz2
packages_apps_Settings-30f5b68b7543489c7415de7cf4d2e458507072a1.zip
am a78edb54: Merge change 4127 into donut
Merge commit 'a78edb54182da5881f2f1e6bc76ae027a9a6f3e3' * commit 'a78edb54182da5881f2f1e6bc76ae027a9a6f3e3': Make the SD Card settings use the system file size formatter.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/SdCardSettings.java25
-rw-r--r--src/com/android/settings/deviceinfo/Memory.java21
2 files changed, 4 insertions, 42 deletions
diff --git a/src/com/android/settings/SdCardSettings.java b/src/com/android/settings/SdCardSettings.java
index 6033c4296..67f3550c0 100644
--- a/src/com/android/settings/SdCardSettings.java
+++ b/src/com/android/settings/SdCardSettings.java
@@ -27,6 +27,7 @@ import android.os.Environment;
import android.os.IMountService;
import android.os.ServiceManager;
import android.os.StatFs;
+import android.text.format.Formatter;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -146,29 +147,7 @@ public class SdCardSettings extends Activity
}
private String formatSize(long size) {
- String suffix = null;
-
- // add K or M suffix if size is greater than 1K or 1M
- if (size >= 1024) {
- suffix = "K";
- size /= 1024;
- if (size >= 1024) {
- suffix = "M";
- size /= 1024;
- }
- }
-
- StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
-
- int commaOffset = resultBuffer.length() - 3;
- while (commaOffset > 0) {
- resultBuffer.insert(commaOffset, ',');
- commaOffset -= 3;
- }
-
- if (suffix != null)
- resultBuffer.append(suffix);
- return resultBuffer.toString();
+ return Formatter.formatFileSize(this, size);
}
OnClickListener mMassStorageListener = new OnClickListener() {
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 75a84b719..53e2a69c9 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -31,6 +31,7 @@ import android.os.StatFs;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
+import android.text.format.Formatter;
import android.util.Log;
import com.android.settings.R;
@@ -194,25 +195,7 @@ public class Memory extends PreferenceActivity {
}
private String formatSize(long size) {
- String suffix = null;
-
- // add KB or MB suffix if size is greater than 1K or 1M
- if (size >= 1024) {
- suffix = " KB";
- size /= 1024;
- if (size >= 1024) {
- suffix = " MB";
- size /= 1024;
- }
- }
-
- DecimalFormat formatter = new DecimalFormat();
- formatter.setGroupingSize(3);
- String result = formatter.format(size);
-
- if (suffix != null)
- result = result + suffix;
- return result;
+ return Formatter.formatFileSize(this, size);
}
}