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
@@ -25,6 +25,7 @@ import coil.imageLoader
import coil.request.ImageRequest
import coil.size.Scale
import de.mm20.launcher2.crashreporter.CrashReporter
import de.mm20.launcher2.notifications.Notification
import de.mm20.launcher2.notifications.NotificationRepository
import de.mm20.launcher2.preferences.LauncherDataStore
import kotlinx.coroutines.CoroutineScope
@@ -114,11 +115,11 @@ internal class MusicServiceImpl(
settings.allowListList.toSet(),
settings.denyListList.toSet()
)
val sbn: StatusBarNotification? = notifications.filter {
it.notification.extras.getParcelable(NotificationCompat.EXTRA_MEDIA_SESSION) as? MediaSession.Token != null && musicApps.contains(it.packageName)
val sbn: Notification? = notifications.filter {
it.mediaSessionToken != null && musicApps.contains(it.packageName)
}.maxByOrNull { it.postTime }
return@withContext (sbn?.notification?.extras?.get(NotificationCompat.EXTRA_MEDIA_SESSION) as? MediaSession.Token)
return@withContext sbn?.mediaSessionToken
}
}
.distinctUntilChanged()