mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 10:58:24 +01:00
Remove unnecessary usages of NotificationManagerCompat to actually create notifications
This commit is contained in:
parent
dd71c76a8f
commit
d400ac2a49
@ -11,7 +11,6 @@ import android.content.IntentFilter
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
@ -43,6 +42,7 @@ import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
|||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.notification
|
import eu.kanade.tachiyomi.util.system.notification
|
||||||
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -96,7 +96,6 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
|||||||
// Show notification to disable Incognito Mode when it's enabled
|
// Show notification to disable Incognito Mode when it's enabled
|
||||||
basePreferences.incognitoMode().changes()
|
basePreferences.incognitoMode().changes()
|
||||||
.onEach { enabled ->
|
.onEach { enabled ->
|
||||||
val notificationManager = NotificationManagerCompat.from(this)
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
disableIncognitoReceiver.register()
|
disableIncognitoReceiver.register()
|
||||||
val notification = notification(Notifications.CHANNEL_INCOGNITO_MODE) {
|
val notification = notification(Notifications.CHANNEL_INCOGNITO_MODE) {
|
||||||
|
@ -9,7 +9,6 @@ import android.graphics.BitmapFactory
|
|||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import coil.imageLoader
|
import coil.imageLoader
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
@ -158,9 +157,8 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||||||
* @param updates a list of manga with new updates.
|
* @param updates a list of manga with new updates.
|
||||||
*/
|
*/
|
||||||
fun showUpdateNotifications(updates: List<Pair<Manga, Array<Chapter>>>) {
|
fun showUpdateNotifications(updates: List<Pair<Manga, Array<Chapter>>>) {
|
||||||
NotificationManagerCompat.from(context).apply {
|
|
||||||
// Parent group notification
|
// Parent group notification
|
||||||
notify(
|
context.notificationManager.notify(
|
||||||
Notifications.ID_NEW_CHAPTERS,
|
Notifications.ID_NEW_CHAPTERS,
|
||||||
context.notification(Notifications.CHANNEL_NEW_CHAPTERS) {
|
context.notification(Notifications.CHANNEL_NEW_CHAPTERS) {
|
||||||
setContentTitle(context.getString(R.string.notification_new_chapters))
|
setContentTitle(context.getString(R.string.notification_new_chapters))
|
||||||
@ -197,8 +195,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||||||
if (!preferences.hideNotificationContent().get()) {
|
if (!preferences.hideNotificationContent().get()) {
|
||||||
launchUI {
|
launchUI {
|
||||||
updates.forEach { (manga, chapters) ->
|
updates.forEach { (manga, chapters) ->
|
||||||
notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters))
|
context.notificationManager.notify(manga.id.hashCode(), createNewChaptersNotification(manga, chapters))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
package eu.kanade.tachiyomi.extension.api
|
package eu.kanade.tachiyomi.extension.api
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.util.system.notification
|
import eu.kanade.tachiyomi.util.system.notification
|
||||||
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
|
|
||||||
class ExtensionUpdateNotifier(private val context: Context) {
|
class ExtensionUpdateNotifier(private val context: Context) {
|
||||||
|
|
||||||
fun promptUpdates(names: List<String>) {
|
fun promptUpdates(names: List<String>) {
|
||||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
context.notificationManager.notify(
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationManagerCompat.from(context).apply {
|
|
||||||
notify(
|
|
||||||
Notifications.ID_UPDATES_TO_EXTS,
|
Notifications.ID_UPDATES_TO_EXTS,
|
||||||
context.notification(Notifications.CHANNEL_EXTENSIONS_UPDATE) {
|
context.notification(Notifications.CHANNEL_EXTENSIONS_UPDATE) {
|
||||||
setContentTitle(
|
setContentTitle(
|
||||||
@ -38,5 +30,4 @@ class ExtensionUpdateNotifier(private val context: Context) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user