Skip to content

Commit

Permalink
API 34: Implement workaround to keep sticky notifications non-dismiss…
Browse files Browse the repository at this point in the history
…ible
  • Loading branch information
iSoron committed Nov 25, 2023
1 parent 4975ba2 commit f0ce05e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ class ReminderController @Inject constructor(
}

fun onDismiss(habit: Habit) {
notificationTray.cancel(habit)
if (preferences.shouldMakeNotificationsSticky()) {
// This is a workaround to keep sticky notifications non-dismissible in Android 14+.
// If the notification is dismissed, we immediately reshow it.
notificationTray.reshow(habit)
} else {
notificationTray.cancel(habit)
}
}

private fun showSnoozeDelayPicker(habit: Habit, context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class NotificationTray @Inject constructor(
}
}

fun reshow(habit: Habit) {
active[habit]?.let {
taskRunner.execute(ShowNotificationTask(habit, it))
}
}

interface SystemTray {
fun removeNotification(notificationId: Int)
fun showNotification(
Expand Down

0 comments on commit f0ce05e

Please sign in to comment.