summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-10-13 16:36:46 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-13 16:36:46 +0000
commit20305d23538c75989ade544572f3b1a285277640 (patch)
tree243b38e4b46df61701217bb935c0edb879901fdc
parent252692e2a47888fff020b4ee730167fd76387aee (diff)
parentebd05f0e5afb6766050d2d85df1aaa3b37a554eb (diff)
downloadandroid_packages_providers_DownloadProvider-20305d23538c75989ade544572f3b1a285277640.tar.gz
android_packages_providers_DownloadProvider-20305d23538c75989ade544572f3b1a285277640.tar.bz2
android_packages_providers_DownloadProvider-20305d23538c75989ade544572f3b1a285277640.zip
am ebd05f0e: am 3befe49d: am 250a1ebc: Fix internationalization of percentage formatting in DownloadProvider.
* commit 'ebd05f0e5afb6766050d2d85df1aaa3b37a554eb': Fix internationalization of percentage formatting in DownloadProvider.
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/com/android/providers/downloads/DownloadNotifier.java6
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java4
3 files changed, 8 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c5712194..5ebb97db 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -190,9 +190,6 @@
[CHAR LIMIT=25] -->
<string name="button_start_now">Start now</string>
- <!-- Short representation of download progress percentage. [CHAR LIMIT=8] -->
- <string name="download_percent"><xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
-
<!-- Title summarizing active downloads. [CHAR LIMIT=32] -->
<plurals name="notif_summary_active">
<item quantity="one">1 file downloading</item>
@@ -227,6 +224,6 @@
<string name="download_error">Unsuccessful</string>
<!-- Representation of download progress percentage when running. [CHAR LIMIT=24] -->
- <string name="download_running_percent">In progress, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
+ <string name="download_running_percent">In progress, <xliff:g id="percentage" example="50%">%s</xliff:g></string>
</resources>
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);