From 5ce6c4cf661c55468f2ebe378da77e616b634091 Mon Sep 17 00:00:00 2001 From: seven332 Date: Fri, 26 Feb 2016 19:05:04 +0800 Subject: [PATCH] Improve download notification --- .../ehviewer/download/DownloadService.java | 19 ++++++++++++++++--- app/src/main/res/values-zh-rCN/strings.xml | 13 ++++++++----- app/src/main/res/values-zh-rHK/strings.xml | 13 ++++++++----- app/src/main/res/values-zh-rTW/strings.xml | 13 ++++++++----- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java index 5cabeb00d..afe49aecd 100644 --- a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java +++ b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java @@ -21,6 +21,8 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.IBinder; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; @@ -69,6 +71,8 @@ public class DownloadService extends Service implements DownloadManager.Download private int mFinishedCount; private int mDownloadedCount; + private Bitmap mLargeIcon; + public void init(SparseBooleanArray stateArray, SparseArray titleArray, int failedCount, int finishedCount, int downloadedCount) { mItemStateArray = stateArray; @@ -76,6 +80,7 @@ public class DownloadService extends Service implements DownloadManager.Download mFailedCount = failedCount; mFinishedCount = finishedCount; mDownloadedCount = downloadedCount; + mLargeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); } public void clear() { @@ -88,6 +93,7 @@ public class DownloadService extends Service implements DownloadManager.Download if (mItemTitleArray != null) { mItemTitleArray.clear(); } + mLargeIcon = null; } @Override @@ -175,7 +181,9 @@ public class DownloadService extends Service implements DownloadManager.Download mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(android.R.drawable.stat_sys_download) .setOngoing(true) - .setAutoCancel(false); + .setAutoCancel(false) + .setCategory(NotificationCompat.CATEGORY_PROGRESS) + .setColor(getResources().getColor(R.color.colorPrimary)); } private void ensureDownloadedBuilder() { @@ -188,6 +196,7 @@ public class DownloadService extends Service implements DownloadManager.Download PendingIntent piClear = PendingIntent.getService(this, 0, clearIntent, 0); mDownloadedBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(android.R.drawable.stat_sys_download_done) + .setLargeIcon(mLargeIcon) .setContentTitle(getString(R.string.stat_download_done_title)) .setDeleteIntent(piClear) .setOngoing(false) @@ -201,10 +210,12 @@ public class DownloadService extends Service implements DownloadManager.Download m509dBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.drawable.ic_stat_alert) + .setLargeIcon(mLargeIcon) .setContentText(getString(R.string.stat_509_alert_title)) .setContentText(getString(R.string.stat_509_alert_text)) .setAutoCancel(true) - .setOngoing(false); + .setOngoing(false) + .setCategory(NotificationCompat.CATEGORY_ERROR); } @Override @@ -349,7 +360,9 @@ public class DownloadService extends Service implements DownloadManager.Download style = null; } - mDownloadedBuilder.setContentText(text).setStyle(style); + mDownloadedBuilder.setContentText(text) + .setStyle(style) + .setNumber(mDownloadedCount); mNotifyManager.notify(ID_DOWNLOADED, mDownloadedBuilder.build()); diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 87b5b4d0a..8b5f922a9 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -182,11 +182,14 @@ 509 警告 图片配额已用尽。请停止下载,休息一下。 下载结束 - %d 成功 - %d 失败 - %1$d 成功,%2$d 失败 - 成功:%s - 失败:%s + %d 项下载成功 + %d 项下载失败 + %1$d 项下载成功,%2$d 项下载失败 + 下载成功:%s + 下载失败:%s + 移除画廊 + 从下载列表移除 %s ? + 删除图片文件 第 %d 页 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 2b6ba4eb6..5ae5dc12d 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -182,11 +182,14 @@ 509 警告 圖片配額已用盡。請停止下載,休息一下。 下載結束 - %d 成功 - %d 失敗 - %1$d 成功,%2$d 失敗 - 成功:%s - 失敗:%s + %d 項下載成功 + %d 項下載失敗 + %1$d 項下載成功,%2$d 項下載失敗 + 下載成功:%s + 下載失敗:%s + 移除畫廊 + 從下載列表移除 %s ? + 刪除圖片文件 第 %d 頁 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 89bb2b61f..71b2e8aea 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -182,11 +182,14 @@ 509 警告 圖片配額已用盡。請停止下載,休息一下。 下載結束 - %d 成功 - %d 失敗 - %1$d 成功,%2$d 失敗 - 成功:%s - 失敗:%s + %d 項下載成功 + %d 項下載失敗 + %1$d 項下載成功,%2$d 項下載失敗 + 下載成功:%s + 下載失敗:%s + 移除畫廊 + 從下載列表移除 %s ? + 刪除圖片檔案 第 %d 頁 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c17ae4b27..a16f008f0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -229,7 +229,7 @@ Failed: %s Remove Gallery Remove %s from download list ? - Remove image files + Delete image files Page %d