API 34: Implement workaround to keep sticky notifications non-dismissible

pull/1863/head
Alinson S. Xavier 2 years ago
parent 4975ba2752
commit f0ce05e06e
Signed by: isoron
GPG Key ID: 0DA8E4B9E1109DCA

@ -66,8 +66,14 @@ class ReminderController @Inject constructor(
} }
fun onDismiss(habit: Habit) { fun onDismiss(habit: 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) notificationTray.cancel(habit)
} }
}
private fun showSnoozeDelayPicker(habit: Habit, context: Context) { private fun showSnoozeDelayPicker(habit: Habit, context: Context) {
context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))

@ -89,6 +89,12 @@ class NotificationTray @Inject constructor(
} }
} }
fun reshow(habit: Habit) {
active[habit]?.let {
taskRunner.execute(ShowNotificationTask(habit, it))
}
}
interface SystemTray { interface SystemTray {
fun removeNotification(notificationId: Int) fun removeNotification(notificationId: Int)
fun showNotification( fun showNotification(

Loading…
Cancel
Save