From a0f49b16c5b76d493857840c1012b9df7086f35c Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 10 Nov 2022 23:03:47 -0500 Subject: [PATCH] Remove "Download complete" notification It wasn't really consistent with other notifications considering there's no action to be taken in this state. --- .../data/download/DownloadManager.kt | 19 +-------------- .../data/download/DownloadNotifier.kt | 23 +------------------ .../tachiyomi/data/download/Downloader.kt | 9 -------- .../data/notification/Notifications.kt | 8 +------ i18n/src/main/res/values/strings.xml | 3 +-- 5 files changed, 4 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index f4a12ab37..a2f032b22 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -1,8 +1,6 @@ package eu.kanade.tachiyomi.data.download import android.content.Context -import com.hippo.unifile.UniFile -import com.jakewharton.rxrelay.BehaviorRelay import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.download.service.DownloadPreferences @@ -52,12 +50,6 @@ class DownloadManager( val queue: DownloadQueue get() = downloader.queue - /** - * Subject for subscribing to downloader status. - */ - val runningRelay: BehaviorRelay - get() = downloader.runningRelay - /** * Tells the downloader to begin downloads. * @@ -167,16 +159,7 @@ class DownloadManager( * @return an observable containing the list of pages from the chapter. */ fun buildPageList(source: Source, manga: Manga, chapter: Chapter): Observable> { - return buildPageList(provider.findChapterDir(chapter.name, chapter.scanlator, manga.title, source)) - } - - /** - * Builds the page list of a downloaded chapter. - * - * @param chapterDir the file where the chapter is downloaded. - * @return an observable containing the list of pages from the chapter. - */ - private fun buildPageList(chapterDir: UniFile?): Observable> { + val chapterDir = provider.findChapterDir(chapter.name, chapter.scanlator, manga.title, source) return Observable.fromCallable { val files = chapterDir?.listFiles().orEmpty() .filter { "image" in it.type.orEmpty() } 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 be54abc30..d8b3af8d4 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 @@ -33,12 +33,6 @@ internal class DownloadNotifier(private val context: Context) { } } - private val completeNotificationBuilder by lazy { - context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_COMPLETE) { - setAutoCancel(false) - } - } - private val errorNotificationBuilder by lazy { context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_ERROR) { setAutoCancel(false) @@ -167,26 +161,11 @@ internal class DownloadNotifier(private val context: Context) { } /** - * This function shows a notification to inform download tasks are done. + * Resets the state once downloads are completed. */ fun onComplete() { dismissProgress() - if (!errorThrown) { - // Create notification - with(completeNotificationBuilder) { - setContentTitle(context.getString(R.string.download_notifier_downloader_title)) - setContentText(context.getString(R.string.download_notifier_download_finish)) - setSmallIcon(android.R.drawable.stat_sys_download_done) - clearActions() - setAutoCancel(true) - setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context)) - setProgress(0, 0, false) - - show(Notifications.ID_DOWNLOAD_CHAPTER_COMPLETE) - } - } - // Reset states to default errorThrown = false isDownloading = false 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 c916a88a3..a86709316 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 @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import com.hippo.unifile.UniFile -import com.jakewharton.rxrelay.BehaviorRelay import com.jakewharton.rxrelay.PublishRelay import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.chapter.model.toDbChapter @@ -91,11 +90,6 @@ class Downloader( */ private val downloadsRelay = PublishRelay.create>() - /** - * Relay to subscribe to the downloader status. - */ - val runningRelay: BehaviorRelay = BehaviorRelay.create(false) - /** * Whether the downloader is running. */ @@ -197,10 +191,8 @@ class Downloader( private fun initializeSubscriptions() { if (isRunning) return isRunning = true - runningRelay.call(true) subscriptions.clear() - subscriptions += downloadsRelay.concatMapIterable { it } // Concurrently download from 5 different sources .groupBy { it.source } @@ -232,7 +224,6 @@ class Downloader( private fun destroySubscriptions() { if (!isRunning) return isRunning = false - runningRelay.call(false) subscriptions.clear() } 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 d89df8dab..b091a78bb 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 @@ -38,8 +38,6 @@ object Notifications { private const val GROUP_DOWNLOADER = "group_downloader" const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel" const val ID_DOWNLOAD_CHAPTER_PROGRESS = -201 - const val CHANNEL_DOWNLOADER_COMPLETE = "downloader_complete_channel" - const val ID_DOWNLOAD_CHAPTER_COMPLETE = -203 const val CHANNEL_DOWNLOADER_ERROR = "downloader_error_channel" const val ID_DOWNLOAD_CHAPTER_ERROR = -202 const val CHANNEL_DOWNLOADER_CACHE = "downloader_cache_renewal" @@ -88,6 +86,7 @@ object Notifications { private val deprecatedChannels = listOf( "downloader_channel", + "downloader_complete_channel", "backup_restore_complete_channel", "library_channel", "library_progress_channel", @@ -151,11 +150,6 @@ object Notifications { setGroup(GROUP_DOWNLOADER) setShowBadge(false) }, - buildNotificationChannel(CHANNEL_DOWNLOADER_COMPLETE, IMPORTANCE_LOW) { - setName(context.getString(R.string.channel_complete)) - setGroup(GROUP_DOWNLOADER) - setShowBadge(false) - }, buildNotificationChannel(CHANNEL_DOWNLOADER_ERROR, IMPORTANCE_LOW) { setName(context.getString(R.string.channel_errors)) setGroup(GROUP_DOWNLOADER) diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 7d37e8442..c1e24da30 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -868,8 +868,7 @@ Could not download chapter due to unexpected error No Wi-Fi connection available No network connection available - Download paused - Download completed + Downloads paused Page %d not found while splitting Couldn\'t find file path of page %d Couldn\'t split downloaded image