mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 13:31:51 +01:00
Separating Backup/Restore Progress/Complete
This commit is contained in:
parent
4af4b9fb9d
commit
110807bd49
@ -19,14 +19,14 @@ class BackupNotifier(private val context: Context) {
|
|||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
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))
|
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher))
|
||||||
setSmallIcon(R.drawable.ic_tachi)
|
setSmallIcon(R.drawable.ic_tachi)
|
||||||
setAutoCancel(false)
|
setAutoCancel(false)
|
||||||
setOngoing(true)
|
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))
|
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher))
|
||||||
setSmallIcon(R.drawable.ic_tachi)
|
setSmallIcon(R.drawable.ic_tachi)
|
||||||
setAutoCancel(false)
|
setAutoCancel(false)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.data.notification
|
package eu.kanade.tachiyomi.data.notification
|
||||||
|
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationChannelGroup
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -46,12 +47,13 @@ object Notifications {
|
|||||||
const val CHANNEL_UPDATES_TO_EXTS = "updates_ext_channel"
|
const val CHANNEL_UPDATES_TO_EXTS = "updates_ext_channel"
|
||||||
const val ID_UPDATES_TO_EXTS = -401
|
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_PROGRESS = -501
|
||||||
const val ID_RESTORE_COMPLETE = -502
|
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_PROGRESS = -502
|
||||||
const val ID_BACKUP_COMPLETE = -503
|
const val ID_BACKUP_COMPLETE = -503
|
||||||
const val ID_RESTORE_ERROR = -504
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the notification channels introduced in Android Oreo.
|
* Creates the notification channels introduced in Android Oreo.
|
||||||
@ -61,6 +63,10 @@ object Notifications {
|
|||||||
fun createChannels(context: Context) {
|
fun createChannels(context: Context) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
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(
|
val channels = listOf(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
CHANNEL_COMMON,
|
CHANNEL_COMMON,
|
||||||
@ -92,11 +98,21 @@ object Notifications {
|
|||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
),
|
),
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
CHANNEL_BACKUP_RESTORE,
|
CHANNEL_BACKUP_RESTORE_PROGRESS,
|
||||||
context.getString(R.string.restoring_backup),
|
context.getString(R.string.progress),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW
|
||||||
).apply {
|
).apply {
|
||||||
|
group = GROUP_BACKUP_RESTORE
|
||||||
setShowBadge(false)
|
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)
|
context.notificationManager.createNotificationChannels(channels)
|
||||||
|
@ -547,6 +547,7 @@
|
|||||||
|
|
||||||
<!-- Backup -->
|
<!-- Backup -->
|
||||||
<string name="backup">Backup</string>
|
<string name="backup">Backup</string>
|
||||||
|
<string name="backup_and_restore">Backup and restore</string>
|
||||||
<string name="create_backup">Create backup</string>
|
<string name="create_backup">Create backup</string>
|
||||||
<string name="can_be_used_to_restore">Can be used to restore current library</string>
|
<string name="can_be_used_to_restore">Can be used to restore current library</string>
|
||||||
<string name="create_legacy_backup">Create legacy backup</string>
|
<string name="create_legacy_backup">Create legacy backup</string>
|
||||||
@ -581,6 +582,8 @@
|
|||||||
<string name="restoring_backup">Restoring backup</string>
|
<string name="restoring_backup">Restoring backup</string>
|
||||||
<string name="restoring_progress">Restoring (%1$d/%2$d)</string>
|
<string name="restoring_progress">Restoring (%1$d/%2$d)</string>
|
||||||
<string name="restore_duration">%02d min, %02d sec</string>
|
<string name="restore_duration">%02d min, %02d sec</string>
|
||||||
|
<string name="progress">Progress</string>
|
||||||
|
<string name="complete">Complete</string>
|
||||||
<plurals name="restore_completed_message">
|
<plurals name="restore_completed_message">
|
||||||
<item quantity="one">Done in %1$s with %2$s error</item>
|
<item quantity="one">Done in %1$s with %2$s error</item>
|
||||||
<item quantity="other">Done in %1$s with %2$s errors</item>
|
<item quantity="other">Done in %1$s with %2$s errors</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user