diff options
author | Elliott Hughes <enh@google.com> | 2014-10-10 12:11:13 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-10-10 12:11:13 -0700 |
commit | 250a1ebc4cf52edf4e55a594f05f4a351ee8e126 (patch) | |
tree | 6ddde9e01a7719ca26cdefec9a6192c9bd875121 /src | |
parent | 9292533d4b80fbffdce5499f199a55505d287f18 (diff) | |
download | android_packages_providers_DownloadProvider-250a1ebc4cf52edf4e55a594f05f4a351ee8e126.tar.gz android_packages_providers_DownloadProvider-250a1ebc4cf52edf4e55a594f05f4a351ee8e126.tar.bz2 android_packages_providers_DownloadProvider-250a1ebc4cf52edf4e55a594f05f4a351ee8e126.zip |
Fix internationalization of percentage formatting in DownloadProvider.
Bug: 15476051
Change-Id: I085c074f1bb66631872712cab68bcaf6ee7ba7dc
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/providers/downloads/DownloadNotifier.java | 6 | ||||
-rw-r--r-- | src/com/android/providers/downloads/DownloadStorageProvider.java | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java index bfd5568d..60c249f9 100644 --- a/src/com/android/providers/downloads/DownloadNotifier.java +++ b/src/com/android/providers/downloads/DownloadNotifier.java @@ -42,6 +42,7 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; +import java.text.NumberFormat; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -219,8 +220,8 @@ public class DownloadNotifier { } if (total > 0) { - final int percent = (int) ((current * 100) / total); - percentText = res.getString(R.string.download_percent, percent); + percentText = + NumberFormat.getPercentInstance().format((double) current / total); if (speed > 0) { final long remainingMillis = ((total - current) * 1000) / speed; @@ -228,6 +229,7 @@ public class DownloadNotifier { DateUtils.formatDuration(remainingMillis)); } + final int percent = (int) ((current * 100) / total); builder.setProgress(100, percent, false); } else { builder.setProgress(100, 0, true); diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index 78b3c430..80d78551 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -42,6 +42,7 @@ import libcore.io.IoUtils; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.text.NumberFormat; /** * Presents a {@link DocumentsContract} view of {@link DownloadManager} @@ -321,7 +322,8 @@ public class DownloadStorageProvider extends DocumentsProvider { final long progress = cursor.getLong(cursor.getColumnIndexOrThrow( DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); if (size != null) { - final long percent = progress * 100 / size; + String percent = + NumberFormat.getPercentInstance().format((double) progress / size); summary = getContext().getString(R.string.download_running_percent, percent); } else { summary = getContext().getString(R.string.download_running); |