From cb4699a5bb1e940292db57c738ae26ceb612f5bb Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 22 Mar 2023 22:58:42 -0400 Subject: [PATCH] Bump dependencies --- .../tachiyomi/data/backup/BackupNotifier.kt | 3 ++- .../tachiyomi/data/download/DownloadNotifier.kt | 3 ++- .../data/library/LibraryUpdateNotifier.kt | 11 +++++++---- .../tachiyomi/data/notification/Notifications.kt | 8 ++++---- .../tachiyomi/data/updater/AppUpdateNotifier.kt | 4 ++-- .../tachiyomi/ui/reader/SaveImageNotifier.kt | 3 ++- .../util/system/NotificationExtensions.kt | 16 +++++++++++++++- gradle/androidx.versions.toml | 10 +++++----- gradle/compose.versions.toml | 2 +- gradle/libs.versions.toml | 2 +- 10 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index c38fb2f2d..95e5224ba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager +import eu.kanade.tachiyomi.util.system.notify import uy.kohesive.injekt.injectLazy import java.io.File import java.util.concurrent.TimeUnit @@ -34,7 +35,7 @@ class BackupNotifier(private val context: Context) { } private fun NotificationCompat.Builder.show(id: Int) { - context.notificationManager.notify(id, build()) + context.notify(id, build()) } fun showBackupProgress(): NotificationCompat.Builder { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt index d028e57c5..37035fb35 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager +import eu.kanade.tachiyomi.util.system.notify import uy.kohesive.injekt.injectLazy import java.util.regex.Pattern @@ -50,7 +51,7 @@ internal class DownloadNotifier(private val context: Context) { * @param id the id of the notification. */ private fun NotificationCompat.Builder.show(id: Int) { - context.notificationManager.notify(id, build()) + context.notify(id, build()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index 92930c063..f273eb749 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -9,6 +9,7 @@ import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.net.Uri import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat import coil.imageLoader import coil.request.ImageRequest import coil.transform.CircleCropTransformation @@ -82,7 +83,7 @@ class LibraryUpdateNotifier(private val context: Context) { .setStyle(NotificationCompat.BigTextStyle().bigText(updatingText)) } - context.notificationManager.notify( + context.notify( Notifications.ID_LIBRARY_PROGRESS, progressNotificationBuilder .setProgress(total, current, false) @@ -190,9 +191,11 @@ class LibraryUpdateNotifier(private val context: Context) { // Per-manga notification if (!preferences.hideNotificationContent().get()) { launchUI { - updates.forEach { (manga, chapters) -> - context.notificationManager.notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters)) - } + context.notify( + updates.map { (manga, chapters) -> + NotificationManagerCompat.NotificationWithIdAndTag(manga.id.hashCode(), createNewChaptersNotification(manga, chapters)) + }, + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index ab0e75e14..bebce9749 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -99,12 +99,12 @@ object Notifications { * @param context The application context. */ fun createChannels(context: Context) { - val notificationService = NotificationManagerCompat.from(context) + val notificationManager = NotificationManagerCompat.from(context) // Delete old notification channels - deprecatedChannels.forEach(notificationService::deleteNotificationChannel) + deprecatedChannels.forEach(notificationManager::deleteNotificationChannel) - notificationService.createNotificationChannelGroupsCompat( + notificationManager.createNotificationChannelGroupsCompat( listOf( buildNotificationChannelGroup(GROUP_BACKUP_RESTORE) { setName(context.getString(R.string.label_backup)) @@ -121,7 +121,7 @@ object Notifications { ), ) - notificationService.createNotificationChannelsCompat( + notificationManager.createNotificationChannelsCompat( listOf( buildNotificationChannel(CHANNEL_COMMON, IMPORTANCE_LOW) { setName(context.getString(R.string.channel_common)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt index 53aacd4cf..96d6a7e0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt @@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationHandler import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.system.notificationBuilder -import eu.kanade.tachiyomi.util.system.notificationManager +import eu.kanade.tachiyomi.util.system.notify internal class AppUpdateNotifier(private val context: Context) { @@ -24,7 +24,7 @@ internal class AppUpdateNotifier(private val context: Context) { * @param id id of the notification channel. */ private fun NotificationCompat.Builder.show(id: Int = Notifications.ID_APP_UPDATER) { - context.notificationManager.notify(id, build()) + context.notify(id, build()) } @SuppressLint("LaunchActivityFromNotification") diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt index 46d6a63a6..2d9603ccc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt @@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.system.notificationBuilder import eu.kanade.tachiyomi.util.system.notificationManager +import eu.kanade.tachiyomi.util.system.notify /** * Class used to show BigPictureStyle notifications @@ -97,6 +98,6 @@ class SaveImageNotifier(private val context: Context) { private fun updateNotification() { // Displays the progress bar on notification - context.notificationManager.notify(notificationId, notificationBuilder.build()) + context.notify(notificationId, notificationBuilder.build()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/NotificationExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/NotificationExtensions.kt index 5ad11e189..99ab90ec4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/NotificationExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/NotificationExtensions.kt @@ -1,12 +1,14 @@ package eu.kanade.tachiyomi.util.system import android.Manifest +import android.app.Notification import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationChannelCompat import androidx.core.app.NotificationChannelGroupCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.core.app.NotificationManagerCompat.NotificationWithIdAndTag import androidx.core.content.PermissionChecker import androidx.core.content.getSystemService import eu.kanade.tachiyomi.R @@ -15,14 +17,26 @@ val Context.notificationManager: NotificationManager get() = getSystemService()!! fun Context.notify(id: Int, channelId: String, block: (NotificationCompat.Builder.() -> Unit)? = null) { + val notification = notificationBuilder(channelId, block).build() + this.notify(id, notification) +} + +fun Context.notify(id: Int, notification: Notification) { if (PermissionChecker.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PermissionChecker.PERMISSION_GRANTED) { return } - val notification = notificationBuilder(channelId, block).build() NotificationManagerCompat.from(this).notify(id, notification) } +fun Context.notify(notificationWithIdAndTags: List) { + if (PermissionChecker.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PermissionChecker.PERMISSION_GRANTED) { + return + } + + NotificationManagerCompat.from(this).notify(notificationWithIdAndTags) +} + /** * Helper method to create a notification builder. * diff --git a/gradle/androidx.versions.toml b/gradle/androidx.versions.toml index a28382abe..d12bc0e29 100644 --- a/gradle/androidx.versions.toml +++ b/gradle/androidx.versions.toml @@ -1,27 +1,27 @@ [versions] agp_version = "7.4.2" -lifecycle_version = "2.6.0" +lifecycle_version = "2.6.1" [libraries] gradle = { module = "com.android.tools.build:gradle", version.ref = "agp_version" } -annotation = "androidx.annotation:annotation:1.6.0" +annotation = "androidx.annotation:annotation:1.7.0-alpha01" appcompat = "androidx.appcompat:appcompat:1.6.1" biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha05" constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4" coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.2.0" -corektx = "androidx.core:core-ktx:1.10.0-rc01" +corektx = "androidx.core:core-ktx:1.11.0-alpha01" splashscreen = "androidx.core:core-splashscreen:1.0.0-alpha02" recyclerview = "androidx.recyclerview:recyclerview:1.3.0" viewpager = "androidx.viewpager:viewpager:1.1.0-alpha01" glance = "androidx.glance:glance-appwidget:1.0.0-alpha03" -profileinstaller = "androidx.profileinstaller:profileinstaller:1.2.2" +profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.0" lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "lifecycle_version" } lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle_version" } lifecycle-runtimektx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle_version" } -work-runtime = "androidx.work:work-runtime-ktx:2.8.0" +work-runtime = "androidx.work:work-runtime-ktx:2.8.1" guava = "com.google.guava:guava:31.1-android" paging-runtime = "androidx.paging:paging-runtime:3.1.1" diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index a18f82e43..7aa0acbac 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -4,7 +4,7 @@ compose-bom = "2023.02.00-rc02" accompanist = "0.29.1-alpha" [libraries] -activity = "androidx.activity:activity-compose:1.6.1" +activity = "androidx.activity:activity-compose:1.7.0" bom = { group = "dev.chrisbanes.compose", name = "compose-bom", version.ref = "compose-bom" } foundation = { module = "androidx.compose.foundation:foundation" } animation = { module = "androidx.compose.animation:animation" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 99ff7bc5b..8bdcfa4ca 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ aboutlib_version = "10.6.1" okhttp_version = "5.0.0-alpha.11" coil_version = "2.2.2" shizuku_version = "12.2.0" -sqlite = "2.3.0" +sqlite = "2.3.1" sqldelight = "1.5.5" leakcanary = "2.10" voyager = "1.0.0-rc07"