diff options
-rw-r--r-- | res/values/cm_plurals.xml | 33 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 2 | ||||
-rwxr-xr-x | src/com/android/providers/downloads/DownloadNotifier.java | 33 |
3 files changed, 61 insertions, 7 deletions
diff --git a/res/values/cm_plurals.xml b/res/values/cm_plurals.xml new file mode 100644 index 00000000..b201ff51 --- /dev/null +++ b/res/values/cm_plurals.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 The CyanogenMod Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Phrase describing a time duration using seconds [CHAR LIMIT=16] --> + <plurals name="duration_seconds"> + <item quantity="one"><xliff:g id="count">%d</xliff:g> sec</item> + <item quantity="other"><xliff:g id="count">%d</xliff:g> secs</item> + </plurals> + <!-- Phrase describing a time duration using minutes [CHAR LIMIT=16] --> + <plurals name="duration_minutes"> + <item quantity="one"><xliff:g id="count">%d</xliff:g> min</item> + <item quantity="other"><xliff:g id="count">%d</xliff:g> mins</item> + </plurals> + <!-- Phrase describing a time duration using hours [CHAR LIMIT=16] --> + <plurals name="duration_hours"> + <item quantity="one"><xliff:g id="count">%d</xliff:g> hr</item> + <item quantity="other"><xliff:g id="count">%d</xliff:g> hrs</item> + </plurals> +</resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index a1c98b98..fed08101 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -25,4 +25,6 @@ <string name="download_paused_percent">Paused, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> <!-- Representation of download progress percentage when queued. [CHAR LIMIT=24] --> <string name="download_queued_percent">Queued, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string> + + <string name="download_speed_text"><xliff:g id="text">%1$s</xliff:g>, <xliff:g id="size" example="230 kB">%2$s</xliff:g>/s</string> </resources> diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java index 63e12ea8..809347fd 100755 --- a/src/com/android/providers/downloads/DownloadNotifier.java +++ b/src/com/android/providers/downloads/DownloadNotifier.java @@ -35,6 +35,7 @@ import android.os.SystemClock; import android.provider.Downloads; import android.text.TextUtils; import android.text.format.DateUtils; +import android.text.format.Formatter; import android.util.Log; import android.util.LongSparseLongArray; @@ -218,6 +219,7 @@ public class DownloadNotifier { // Calculate and show progress String remainingText = null; String percentText = null; + String speedAsSizeText = null; if (type == TYPE_ACTIVE) { long current = 0; long total = 0; @@ -238,8 +240,26 @@ public class DownloadNotifier { if (speed > 0) { final long remainingMillis = ((total - current) * 1000) / speed; + final int duration, durationResId; + + // This duplicates DateUtils.formatDuration(), but uses our + // abbreviated plurals. + if (remainingMillis >= DateUtils.HOUR_IN_MILLIS) { + duration = (int) ((remainingMillis + 1800000) + / DateUtils.HOUR_IN_MILLIS); + durationResId = R.plurals.duration_hours; + } else if (remainingMillis >= DateUtils.MINUTE_IN_MILLIS) { + duration = (int) ((remainingMillis + 30000) + / DateUtils.MINUTE_IN_MILLIS); + durationResId = R.plurals.duration_minutes; + } else { + duration = (int) ((remainingMillis + 500) + / DateUtils.SECOND_IN_MILLIS); + durationResId = R.plurals.duration_seconds; + } remainingText = res.getString(R.string.download_remaining, - DateUtils.formatDuration(remainingMillis)); + res.getQuantityString(durationResId, duration, duration)); + speedAsSizeText = Formatter.formatFileSize(mContext, speed); } builder.setProgress(100, percent, false); @@ -252,7 +272,6 @@ public class DownloadNotifier { final Notification notif; if (cluster.size() == 1) { final DownloadInfo info = cluster.iterator().next(); - builder.setContentTitle(getDownloadTitle(res, info)); if (type == TYPE_ACTIVE) { @@ -261,10 +280,9 @@ public class DownloadNotifier { builder.setContentText(res.getText(R.string.download_paused)); else builder.setContentText(res.getText(R.string.download_queued)); - } else if (!TextUtils.isEmpty(info.mDescription)) { - builder.setContentText(info.mDescription); - } else { - builder.setContentText(remainingText); + } else if (speedAsSizeText != null) { + builder.setContentText(res.getString(R.string.download_speed_text, + remainingText, speedAsSizeText)); } builder.setContentInfo(percentText); @@ -298,7 +316,8 @@ public class DownloadNotifier { R.plurals.notif_summary_active, cluster.size(), cluster.size())); } builder.setContentText(remainingText); - builder.setContentInfo(percentText); + builder.setContentInfo(res.getString(R.string.download_speed_text, + percentText, speedAsSizeText)); inboxStyle.setSummaryText(remainingText); } else if (type == TYPE_WAITING) { |