From c4f712be3a1d541331d12e58666831fb9316349d Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 29 Mar 2020 20:29:10 +0300 Subject: [PATCH] Improve download notification --- .../koitharu/kotatsu/ui/download/DownloadNotification.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/download/DownloadNotification.kt b/app/src/main/java/org/koitharu/kotatsu/ui/download/DownloadNotification.kt index 825b4e5a2..2ec22af54 100644 --- a/app/src/main/java/org/koitharu/kotatsu/ui/download/DownloadNotification.kt +++ b/app/src/main/java/org/koitharu/kotatsu/ui/download/DownloadNotification.kt @@ -8,6 +8,7 @@ import android.content.Context import android.graphics.drawable.Drawable import android.os.Build import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.toBitmap import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.model.Manga @@ -31,9 +32,13 @@ class DownloadNotification(private val context: Context) { NotificationManager.IMPORTANCE_LOW ) channel.enableVibration(false) + channel.enableLights(false) + channel.setSound(null, null) manager.createNotificationChannel(channel) } builder.setOnlyAlertOnce(true) + builder.setDefaults(0) + builder.color = ContextCompat.getColor(context, R.color.blue_primary) } fun fillFrom(manga: Manga) { @@ -70,6 +75,7 @@ class DownloadNotification(private val context: Context) { builder.setContentText(e.getDisplayMessage(context.resources)) builder.setAutoCancel(true) builder.setContentIntent(null) + builder.setCategory(NotificationCompat.CATEGORY_ERROR) } fun setLargeIcon(icon: Drawable?) { @@ -83,6 +89,7 @@ class DownloadNotification(private val context: Context) { val percent = (progress / max.toFloat() * 100).roundToInt() builder.setProgress(max, progress, false) builder.setContentText("%d%%".format(percent)) + builder.setCategory(NotificationCompat.CATEGORY_PROGRESS) } fun setPostProcessing() { @@ -96,6 +103,7 @@ class DownloadNotification(private val context: Context) { builder.setContentIntent(createIntent(context, manga)) builder.setAutoCancel(true) builder.setSmallIcon(android.R.drawable.stat_sys_download_done) + builder.setCategory(null) } fun setCancelling() {