From 0721de5b81a0c63829becaa4a5fdb77724a3334b Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 27 Apr 2022 22:45:31 -0400 Subject: [PATCH] Add links to website FAQ for library update and download warning notifications (cherry picked from commit 70698e64940eb01032e948245a01c4191ccd60f0) --- .../eu/kanade/tachiyomi/data/download/DownloadNotifier.kt | 4 +++- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 3 +++ .../kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt | 5 +++++ app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) 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 5d9f729f67..9c5f376993 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 @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.data.download +import android.app.PendingIntent import android.content.Context import android.graphics.BitmapFactory import androidx.core.app.NotificationCompat @@ -187,7 +188,7 @@ internal class DownloadNotifier(private val context: Context) { * @param timeout duration after which to automatically dismiss the notification. * Only works on Android 8+. */ - fun onWarning(reason: String, timeout: Long? = null) { + fun onWarning(reason: String, timeout: Long? = null, contentIntent: PendingIntent? = null) { with(errorNotificationBuilder) { setContentTitle(context.getString(R.string.download_notifier_downloader_title)) setStyle(NotificationCompat.BigTextStyle().bigText(reason)) @@ -197,6 +198,7 @@ internal class DownloadNotifier(private val context: Context) { setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context)) setProgress(0, 0, false) timeout?.let { setTimeoutAfter(it) } + contentIntent?.let { setContentIntent(it) } show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index e60046be52..e2f84f646e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -11,6 +11,8 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.DownloadQueue +import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier +import eu.kanade.tachiyomi.data.notification.NotificationHandler import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.UnmeteredSource @@ -285,6 +287,7 @@ class Downloader( notifier.onWarning( context.getString(R.string.download_queue_size_warning), WARNING_NOTIF_TIMEOUT_MS, + NotificationHandler.openUrl(context, LibraryUpdateNotifier.HELP_WARNING_URL), ) } } 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 5bcef312ef..b855332678 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 @@ -96,6 +96,7 @@ class LibraryUpdateNotifier(private val context: Context) { setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_size_warning))) setSmallIcon(R.drawable.ic_warning_white_24dp) setTimeoutAfter(Downloader.WARNING_NOTIF_TIMEOUT_MS) + setContentIntent(NotificationHandler.openUrl(context, HELP_WARNING_URL)) } context.notificationManager.notify( @@ -340,6 +341,10 @@ class LibraryUpdateNotifier(private val context: Context) { } return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } + + companion object { + const val HELP_WARNING_URL = "https://tachiyomi.org/help/faq/#why-does-the-app-warn-about-large-bulk-updates-and-downloads" + } } private const val NOTIF_MAX_CHAPTERS = 5 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d3fba8367f..2105a2a120 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -721,12 +721,12 @@ Couldn\'t download chapters. You can try again in the downloads section Couldn\'t download chapters due to low storage space - Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi + Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi. Tap to learn more. Checking for new chapters Updating library… (%1$d/%2$d) - Large updates harm sources and may lead to slower updates and also increased battery usage + Large updates harm sources and may lead to slower updates and also increased battery usage. Tap to learn more. New chapters found For %d title