mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Auto dismiss warning messages about large updates
dismisses after 30 seconds (Android 8+, too bad those on older devices)
This commit is contained in:
parent
758816428c
commit
16e3f643c6
4 changed files with 22 additions and 1 deletions
|
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
|||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.lang.chop
|
||||
import eu.kanade.tachiyomi.util.system.notificationBuilder
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.regex.Pattern
|
||||
|
@ -217,6 +218,24 @@ internal class DownloadNotifier(private val context: Context) {
|
|||
isDownloading = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the downloader has too many downloads from one source.
|
||||
*/
|
||||
fun massDownloadWarning() {
|
||||
val notification = context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER) {
|
||||
setContentTitle(context.getString(R.string.warning))
|
||||
setSmallIcon(R.drawable.ic_warning_white_24dp)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.download_queue_size_warning)))
|
||||
setTimeoutAfter(30000)
|
||||
}
|
||||
.build()
|
||||
|
||||
context.notificationManager.notify(
|
||||
Notifications.ID_DOWNLOAD_SIZE_WARNING,
|
||||
notification,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the downloader receives an error. It's shown as a separate notification to avoid
|
||||
* being overwritten.
|
||||
|
|
|
@ -295,7 +295,7 @@ class Downloader(
|
|||
.filterKeys { it !is UnmeteredSource }
|
||||
.maxOfOrNull { it.value.size } ?: 0
|
||||
if (largestSourceSize > CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD) {
|
||||
notifier.onWarning(context.getString(R.string.download_queue_size_warning))
|
||||
notifier.massDownloadWarning()
|
||||
}
|
||||
DownloadService.start(context)
|
||||
} else if (!isRunning && !LibraryUpdateService.isRunning()) {
|
||||
|
|
|
@ -252,6 +252,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
setContentTitle(context.getString(R.string.warning))
|
||||
setSmallIcon(R.drawable.ic_warning_white_24dp)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_size_warning)))
|
||||
setTimeoutAfter(30000)
|
||||
}
|
||||
.build()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ object Notifications {
|
|||
const val CHANNEL_DOWNLOADER = "downloader_channel"
|
||||
const val ID_DOWNLOAD_CHAPTER = -201
|
||||
const val ID_DOWNLOAD_CHAPTER_ERROR = -202
|
||||
const val ID_DOWNLOAD_SIZE_WARNING = -203
|
||||
|
||||
/**
|
||||
* Notification channel and ids used by the library updater.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue