Respect notification badge settings

This commit is contained in:
MM20
2023-05-09 00:03:40 +02:00
parent b5a4d459d3
commit b678662121
8 changed files with 151 additions and 64 deletions
@@ -117,18 +117,12 @@ fun AppItem(
val notifications by viewModel.notifications.collectAsState(emptyList())
for (not in notifications) {
val title =
not.notification.extras.getString(NotificationCompat.EXTRA_TITLE, null)
?.takeIf { it.isNotBlank() }
?: not.notification.extras.getString(
NotificationCompat.EXTRA_TEXT,
null
)
?.takeIf { it.isNotBlank() }
val title = not.title?.takeIf { it.isNotBlank() }
?: not.text?.takeIf { it.isNotBlank() }
?: continue
val icon =
remember { not.notification.smallIcon?.loadDrawable(context) }?.let {
remember { not.smallIcon?.loadDrawable(context) }?.let {
rememberAsyncImagePainter(
it
)
@@ -143,7 +137,7 @@ fun AppItem(
},
onClick = {
try {
not.notification.contentIntent?.send()
not.contentIntent?.send()
} catch (e: PendingIntent.CanceledException) {}
}
)
@@ -16,6 +16,7 @@ import de.mm20.launcher2.appshortcuts.AppShortcutRepository
import de.mm20.launcher2.badges.BadgeService
import de.mm20.launcher2.files.FileRepository
import de.mm20.launcher2.icons.IconService
import de.mm20.launcher2.notifications.Notification
import de.mm20.launcher2.notifications.NotificationRepository
import de.mm20.launcher2.search.SavableSearchable
import de.mm20.launcher2.search.data.AppShortcut
@@ -122,7 +123,7 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
return false
}
fun clearNotification(notification: StatusBarNotification) {
fun clearNotification(notification: Notification) {
notificationRepository.cancelNotification(notification)
}