mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 21:47:28 +01:00
Make restore a foreground service
This commit is contained in:
@@ -269,7 +269,6 @@ class SettingsBackupController : SettingsController() {
|
||||
.positiveButton(R.string.action_restore) {
|
||||
val context = applicationContext
|
||||
if (context != null) {
|
||||
(targetController as SettingsBackupController).notifier.showRestoreProgress()
|
||||
BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
|
||||
isRestoreStarted = true
|
||||
}
|
||||
@@ -296,12 +295,6 @@ class SettingsBackupController : SettingsController() {
|
||||
|
||||
notifier.showBackupError(intent.getStringExtra(BackupConst.EXTRA_ERROR_MESSAGE))
|
||||
}
|
||||
BackupConst.ACTION_RESTORE_PROGRESS -> {
|
||||
val progress = intent.getIntExtra(BackupConst.EXTRA_PROGRESS, 0)
|
||||
val amount = intent.getIntExtra(BackupConst.EXTRA_AMOUNT, 0)
|
||||
val content = intent.getStringExtra(BackupConst.EXTRA_CONTENT)
|
||||
notifier.showRestoreProgress(content, progress, amount)
|
||||
}
|
||||
BackupConst.ACTION_RESTORE_COMPLETED -> {
|
||||
isRestoreStarted = false
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ internal class BackupNotifier(private val context: Context) {
|
||||
notificationBuilder.show(Notifications.ID_BACKUP)
|
||||
}
|
||||
|
||||
fun showRestoreProgress(content: String = "", progress: Int = 0, maxAmount: Int = 100) {
|
||||
with(notificationBuilder) {
|
||||
fun showRestoreProgress(content: String = "", progress: Int = 0, maxAmount: Int = 100): NotificationCompat.Builder {
|
||||
val builder = with(notificationBuilder) {
|
||||
setContentTitle(context.getString(R.string.restoring_backup))
|
||||
setContentText(content)
|
||||
|
||||
@@ -89,7 +89,9 @@ internal class BackupNotifier(private val context: Context) {
|
||||
NotificationReceiver.cancelRestorePendingBroadcast(context, Notifications.ID_RESTORE))
|
||||
}
|
||||
|
||||
notificationBuilder.show(Notifications.ID_RESTORE)
|
||||
builder.show(Notifications.ID_RESTORE)
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
fun showRestoreError(error: String?) {
|
||||
|
||||
Reference in New Issue
Block a user