Skip to content

Commit

Permalink
Dismiss only content provider specific notification
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkup committed Feb 12, 2025
1 parent 5d5ffab commit 291b21d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class SyncNotificationManager @AssistedInject constructor(
fun dismiss(notificationTag: String) = NotificationManagerCompat.from(context)
.cancel(notificationTag, NotificationRegistry.NOTIFY_SYNC_ERROR)

fun notifyContentProviderError() = notificationRegistry.notifyIfPossible(
fun notifyContentProviderError(authority: String) = notificationRegistry.notifyIfPossible(
NotificationRegistry.NOTIFY_SYNC_ERROR,
tag = NOTIFICATION_TAG_CONTENT_PROVIDER_ERROR
tag = authority
) {
NotificationCompat.Builder(context, notificationRegistry.CHANNEL_SYNC_ERRORS)
.setSmallIcon(R.drawable.ic_sync_problem_notify)
Expand Down Expand Up @@ -229,8 +229,4 @@ class SyncNotificationManager @AssistedInject constructor(
null
}

companion object {
const val NOTIFICATION_TAG_CONTENT_PROVIDER_ERROR = "content-provider-error"
}

}
4 changes: 2 additions & 2 deletions app/src/main/kotlin/at/bitfire/davdroid/sync/Syncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ abstract class Syncer<StoreType: LocalDataStore<CollectionType>, CollectionType:
- the content provider is not available at all, for instance because the tasks app has been uninstalled
or the respective system app (like "calendar storage") is disabled */
logger.warning("Couldn't connect to content provider of authority ${dataStore.authority}")
syncNotificationManager.notifyContentProviderError()
syncNotificationManager.notifyContentProviderError(dataStore.authority)
syncResult.contentProviderError = true

return // Don't continue without provider
}

// Dismiss previous content provider error notification
syncNotificationManager.dismiss(SyncNotificationManager.NOTIFICATION_TAG_CONTENT_PROVIDER_ERROR)
syncNotificationManager.dismiss(dataStore.authority)

// run sync
try {
Expand Down

0 comments on commit 291b21d

Please sign in to comment.