Don't assume backup is running when success or error notifications are shown

This commit is contained in:
Torsten Grote 2020-10-16 09:49:18 -03:00
parent ef443f70a5
commit df788ba9a4
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 5 additions and 3 deletions

View file

@ -79,6 +79,7 @@ internal class SettingsViewModel(
} }
internal fun backupNow() { internal fun backupNow() {
// maybe replace the check below with one that checks if our transport service is running
if (notificationManager.hasActiveBackupNotifications()) { if (notificationManager.hasActiveBackupNotifications()) {
Toast.makeText(app, R.string.notification_backup_already_running, LENGTH_LONG).show() Toast.makeText(app, R.string.notification_backup_already_running, LENGTH_LONG).show()
} else { } else {

View file

@ -207,9 +207,10 @@ internal class BackupNotificationManager(private val context: Context) {
fun hasActiveBackupNotifications(): Boolean { fun hasActiveBackupNotifications(): Boolean {
nm.activeNotifications.forEach { nm.activeNotifications.forEach {
if (it.packageName == context.packageName && if (it.packageName == context.packageName) {
(it.id == NOTIFICATION_ID_OBSERVER || it.id == NOTIFICATION_ID_BACKGROUND) if (it.id == NOTIFICATION_ID_BACKGROUND) return true
) return true if (it.id == NOTIFICATION_ID_OBSERVER) return it.isOngoing
}
} }
return false return false
} }