diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index ac74588c30..d2ce39e695 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -19,14 +19,14 @@ class BackupNotifier(private val context: Context) { private val preferences: PreferencesHelper by injectLazy() - private val progressNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE) { + private val progressNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE_PROGRESS) { setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)) setSmallIcon(R.drawable.ic_tachi) setAutoCancel(false) setOngoing(true) } - private val completeNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE) { + private val completeNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE_COMPLETE) { setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)) setSmallIcon(R.drawable.ic_tachi) setAutoCancel(false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index 7da05fa80b..ef9771ae19 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.data.notification import android.app.NotificationChannel +import android.app.NotificationChannelGroup import android.app.NotificationManager import android.content.Context import android.os.Build @@ -46,12 +47,13 @@ object Notifications { const val CHANNEL_UPDATES_TO_EXTS = "updates_ext_channel" const val ID_UPDATES_TO_EXTS = -401 - const val CHANNEL_BACKUP_RESTORE = "backup_restore_channel" + private const val GROUP_BACKUP_RESTORE = "group_backup_restore" + const val CHANNEL_BACKUP_RESTORE_PROGRESS = "backup_restore_progress_channel" const val ID_RESTORE_PROGRESS = -501 const val ID_RESTORE_COMPLETE = -502 + const val CHANNEL_BACKUP_RESTORE_COMPLETE = "backup_restore_complete_channel_v2" const val ID_BACKUP_PROGRESS = -502 const val ID_BACKUP_COMPLETE = -503 - const val ID_RESTORE_ERROR = -504 /** * Creates the notification channels introduced in Android Oreo. @@ -61,6 +63,10 @@ object Notifications { fun createChannels(context: Context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return + listOf( + NotificationChannelGroup(GROUP_BACKUP_RESTORE, context.getString(R.string.backup_and_restore)), + ).forEach(context.notificationManager::createNotificationChannelGroup) + val channels = listOf( NotificationChannel( CHANNEL_COMMON, @@ -92,11 +98,21 @@ object Notifications { NotificationManager.IMPORTANCE_DEFAULT ), NotificationChannel( - CHANNEL_BACKUP_RESTORE, - context.getString(R.string.restoring_backup), + CHANNEL_BACKUP_RESTORE_PROGRESS, + context.getString(R.string.progress), NotificationManager.IMPORTANCE_LOW ).apply { + group = GROUP_BACKUP_RESTORE setShowBadge(false) + }, + NotificationChannel( + CHANNEL_BACKUP_RESTORE_COMPLETE, + context.getString(R.string.complete), + NotificationManager.IMPORTANCE_HIGH + ).apply { + group = GROUP_BACKUP_RESTORE + setShowBadge(false) + setSound(null, null) } ) context.notificationManager.createNotificationChannels(channels) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e8cadf2b21..c8d2866c6c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -547,6 +547,7 @@ Backup + Backup and restore Create backup Can be used to restore current library Create legacy backup @@ -581,6 +582,8 @@ Restoring backup Restoring (%1$d/%2$d) %02d min, %02d sec + Progress + Complete Done in %1$s with %2$s error Done in %1$s with %2$s errors