From 2034b1c5876f61309a720a1ddbeec00ca757b142 Mon Sep 17 00:00:00 2001 From: juntao Date: Wed, 23 Sep 2020 15:30:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E5=8E=9F=E7=94=9F=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=9A=84=E9=80=9A=E7=9F=A5ICON=E6=8D=A2=E4=B8=BA=E4=B8=8E?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E6=8E=A8=E9=80=81=E9=80=9A=E7=9F=A5=E4=B8=80?= =?UTF-8?q?=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/common/util/DownloadNotificationHelper.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/gh/common/util/DownloadNotificationHelper.kt b/app/src/main/java/com/gh/common/util/DownloadNotificationHelper.kt index 2c1b26b2e9..68b0520d0b 100644 --- a/app/src/main/java/com/gh/common/util/DownloadNotificationHelper.kt +++ b/app/src/main/java/com/gh/common/util/DownloadNotificationHelper.kt @@ -16,6 +16,7 @@ import com.gh.gamecenter.R import com.halo.assistant.HaloApp import com.lightgame.download.DownloadEntity import com.lightgame.download.DownloadStatus +import com.walkud.rom.checker.RomIdentifier object DownloadNotificationHelper { @@ -29,6 +30,7 @@ object DownloadNotificationHelper { const val ACTION_DOWNLOAD = "com.gh.gamecenter.DOWNLOAD" private val mNotifyMap: MutableMap = mutableMapOf() + private val mShouldUseAlternativeNotificationIcon by lazy { RomIdentifier.getRom().versionName == null } private fun getNotificationManager(): NotificationManager { return HaloApp.getInstance().application.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager @@ -65,7 +67,7 @@ object DownloadNotificationHelper { val whenTime = 1000 * 60 * (System.currentTimeMillis() / 1000 / 60) val builder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID) .setContentTitle(entity.name) - .setSmallIcon(R.mipmap.logo) + .setSmallIcon(getNotificationIcon()) .setContentIntent(pendingIntent) .setGroup(DOWNLOAD_GROUP_KEY) .setWhen(whenTime) @@ -160,7 +162,7 @@ object DownloadNotificationHelper { notificationManager.cancel(DOWNLOAD_NOTIFICATION_FOLD_ID) } else if (downloadNotificationSize != 0 && downloadGroupNotificationSize == 0) { val groupBuilder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID) - .setSmallIcon(R.mipmap.logo) + .setSmallIcon(getNotificationIcon()) .setGroup(DOWNLOAD_GROUP_KEY) .setGroupSummary(true) .setStyle(NotificationCompat.BigTextStyle().bigText("下载任务")) @@ -178,4 +180,8 @@ object DownloadNotificationHelper { addOrUpdateDownloadNotification(downloadTask) } } + + private fun getNotificationIcon(): Int { + return if (mShouldUseAlternativeNotificationIcon) R.drawable.ic_notification else R.mipmap.logo + } } \ No newline at end of file