Bump dependencies

This commit is contained in:
arkon
2023-03-22 22:58:42 -04:00
parent 2e5efadf42
commit cb4699a5bb
10 changed files with 41 additions and 21 deletions

View File

@ -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 {

View File

@ -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())
}
/**

View File

@ -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))
},
)
}
}
}

View File

@ -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))

View File

@ -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")

View File

@ -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())
}
}

View File

@ -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<NotificationWithIdAndTag>) {
if (PermissionChecker.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PermissionChecker.PERMISSION_GRANTED) {
return
}
NotificationManagerCompat.from(this).notify(notificationWithIdAndTags)
}
/**
* Helper method to create a notification builder.
*