summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadNotifier.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-11-16 10:37:56 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-11-16 10:37:56 -0800
commit7d3713fcf620b182a7bac31f42e7b71d872194dd (patch)
tree4f1383a1ec60afcd403d3898873d6a13ce18f931 /src/com/android/providers/downloads/DownloadNotifier.java
parent790a840e9663ecd927c1142fe3f1409ef57e7595 (diff)
parent37771cd722c670792c4d9fa8b02e19a15306a035 (diff)
downloadandroid_packages_providers_DownloadProvider-7d3713fcf620b182a7bac31f42e7b71d872194dd.tar.gz
android_packages_providers_DownloadProvider-7d3713fcf620b182a7bac31f42e7b71d872194dd.tar.bz2
android_packages_providers_DownloadProvider-7d3713fcf620b182a7bac31f42e7b71d872194dd.zip
am 37771cd7: am 253e36a9: Merge "Show remaining time in download notifications." into jb-mr1.1-dev
* commit '37771cd722c670792c4d9fa8b02e19a15306a035': Show remaining time in download notifications.
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotifier.java')
-rw-r--r--src/com/android/providers/downloads/DownloadNotifier.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index a1805e5e..f6e7a2ee 100644
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -31,16 +31,15 @@ import android.content.res.Resources;
import android.net.Uri;
import android.provider.Downloads;
import android.text.TextUtils;
+import android.text.format.DateUtils;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Set;
import javax.annotation.concurrent.GuardedBy;
@@ -160,18 +159,26 @@ public class DownloadNotifier {
String remainingText = null;
String percentText = null;
if (type == TYPE_ACTIVE) {
+ final DownloadHandler handler = DownloadHandler.getInstance();
+
long current = 0;
long total = 0;
+ long remainingMillis = -1;
for (DownloadInfo info : cluster) {
if (info.mTotalBytes != -1) {
current += info.mCurrentBytes;
total += info.mTotalBytes;
+ remainingMillis = Math.max(
+ handler.getRemainingMillis(info.mId), remainingMillis);
}
}
if (total > 0) {
final int percent = (int) ((current * 100) / total);
- // TODO: calculate remaining time based on recent bandwidth
+ if (remainingMillis != -1) {
+ remainingText = res.getString(R.string.download_remaining,
+ DateUtils.formatDuration(remainingMillis));
+ }
percentText = res.getString(R.string.download_percent, percent);
builder.setProgress(100, percent, false);