diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotifier.java')
-rwxr-xr-x[-rw-r--r--] | src/com/android/providers/downloads/DownloadNotifier.java | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java index ac52eba2..63e12ea8 100644..100755 --- a/src/com/android/providers/downloads/DownloadNotifier.java +++ b/src/com/android/providers/downloads/DownloadNotifier.java @@ -150,9 +150,25 @@ public class DownloadNotifier { } builder.setWhen(firstShown); + // Check paused status about these downloads. If exists, will + // update icon and content title/content text in notification. + boolean hasPausedStatus = false; + int pausedStatus = -1; + for (DownloadInfo info : cluster) { + if (isPausedStatus(info.mStatus)) { + hasPausedStatus = true; + pausedStatus = info.mStatus; + break; + } + } + // Show relevant icon if (type == TYPE_ACTIVE) { - builder.setSmallIcon(android.R.drawable.stat_sys_download); + if (hasPausedStatus) { + builder.setSmallIcon(R.drawable.download_pause); + } else { + builder.setSmallIcon(android.R.drawable.stat_sys_download); + } } else if (type == TYPE_WAITING) { builder.setSmallIcon(android.R.drawable.stat_sys_warning); } else if (type == TYPE_COMPLETE) { @@ -240,7 +256,12 @@ public class DownloadNotifier { builder.setContentTitle(getDownloadTitle(res, info)); if (type == TYPE_ACTIVE) { - if (!TextUtils.isEmpty(info.mDescription)) { + if (hasPausedStatus) { + if (pausedStatus == Downloads.Impl.STATUS_PAUSED_BY_MANUAL) + 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); @@ -270,8 +291,12 @@ public class DownloadNotifier { } if (type == TYPE_ACTIVE) { - builder.setContentTitle(res.getQuantityString( - R.plurals.notif_summary_active, cluster.size(), cluster.size())); + if (hasPausedStatus) { + builder.setContentTitle(res.getString(R.string.download_queued)); + } else { + builder.setContentTitle(res.getQuantityString( + R.plurals.notif_summary_active, cluster.size(), cluster.size())); + } builder.setContentText(remainingText); builder.setContentInfo(percentText); inboxStyle.setSummaryText(remainingText); @@ -356,7 +381,7 @@ public class DownloadNotifier { } private static boolean isActiveAndVisible(DownloadInfo download) { - return download.mStatus == STATUS_RUNNING && + return Downloads.Impl.isStatusInformational(download.mStatus) && (download.mVisibility == VISIBILITY_VISIBLE || download.mVisibility == VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } @@ -366,4 +391,10 @@ public class DownloadNotifier { (download.mVisibility == VISIBILITY_VISIBLE_NOTIFY_COMPLETED || download.mVisibility == VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION); } + + private static boolean isPausedStatus(int status) { + return status == Downloads.Impl.STATUS_WAITING_FOR_NETWORK || + status == Downloads.Impl.STATUS_PAUSED_BY_MANUAL; + } + } |