Remove "Download complete" notification

It wasn't really consistent with other notifications considering there's no
action to be taken in this state.
This commit is contained in:
arkon 2022-11-10 23:03:47 -05:00
parent c6c4c1c393
commit a0f49b16c5
5 changed files with 4 additions and 58 deletions

View File

@ -1,8 +1,6 @@
package eu.kanade.tachiyomi.data.download package eu.kanade.tachiyomi.data.download
import android.content.Context 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.category.interactor.GetCategories
import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.download.service.DownloadPreferences import eu.kanade.domain.download.service.DownloadPreferences
@ -52,12 +50,6 @@ class DownloadManager(
val queue: DownloadQueue val queue: DownloadQueue
get() = downloader.queue get() = downloader.queue
/**
* Subject for subscribing to downloader status.
*/
val runningRelay: BehaviorRelay<Boolean>
get() = downloader.runningRelay
/** /**
* Tells the downloader to begin downloads. * Tells the downloader to begin downloads.
* *
@ -167,16 +159,7 @@ class DownloadManager(
* @return an observable containing the list of pages from the chapter. * @return an observable containing the list of pages from the chapter.
*/ */
fun buildPageList(source: Source, manga: Manga, chapter: Chapter): Observable<List<Page>> { fun buildPageList(source: Source, manga: Manga, chapter: Chapter): Observable<List<Page>> {
return buildPageList(provider.findChapterDir(chapter.name, chapter.scanlator, manga.title, source)) val chapterDir = 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<List<Page>> {
return Observable.fromCallable { return Observable.fromCallable {
val files = chapterDir?.listFiles().orEmpty() val files = chapterDir?.listFiles().orEmpty()
.filter { "image" in it.type.orEmpty() } .filter { "image" in it.type.orEmpty() }

View File

@ -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 { private val errorNotificationBuilder by lazy {
context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_ERROR) { context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_ERROR) {
setAutoCancel(false) 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() { fun onComplete() {
dismissProgress() 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 // Reset states to default
errorThrown = false errorThrown = false
isDownloading = false isDownloading = false

View File

@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.download
import android.content.Context import android.content.Context
import com.hippo.unifile.UniFile import com.hippo.unifile.UniFile
import com.jakewharton.rxrelay.BehaviorRelay
import com.jakewharton.rxrelay.PublishRelay import com.jakewharton.rxrelay.PublishRelay
import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.chapter.model.toDbChapter
@ -91,11 +90,6 @@ class Downloader(
*/ */
private val downloadsRelay = PublishRelay.create<List<Download>>() private val downloadsRelay = PublishRelay.create<List<Download>>()
/**
* Relay to subscribe to the downloader status.
*/
val runningRelay: BehaviorRelay<Boolean> = BehaviorRelay.create(false)
/** /**
* Whether the downloader is running. * Whether the downloader is running.
*/ */
@ -197,10 +191,8 @@ class Downloader(
private fun initializeSubscriptions() { private fun initializeSubscriptions() {
if (isRunning) return if (isRunning) return
isRunning = true isRunning = true
runningRelay.call(true)
subscriptions.clear() subscriptions.clear()
subscriptions += downloadsRelay.concatMapIterable { it } subscriptions += downloadsRelay.concatMapIterable { it }
// Concurrently download from 5 different sources // Concurrently download from 5 different sources
.groupBy { it.source } .groupBy { it.source }
@ -232,7 +224,6 @@ class Downloader(
private fun destroySubscriptions() { private fun destroySubscriptions() {
if (!isRunning) return if (!isRunning) return
isRunning = false isRunning = false
runningRelay.call(false)
subscriptions.clear() subscriptions.clear()
} }

View File

@ -38,8 +38,6 @@ object Notifications {
private const val GROUP_DOWNLOADER = "group_downloader" private const val GROUP_DOWNLOADER = "group_downloader"
const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel" const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel"
const val ID_DOWNLOAD_CHAPTER_PROGRESS = -201 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 CHANNEL_DOWNLOADER_ERROR = "downloader_error_channel"
const val ID_DOWNLOAD_CHAPTER_ERROR = -202 const val ID_DOWNLOAD_CHAPTER_ERROR = -202
const val CHANNEL_DOWNLOADER_CACHE = "downloader_cache_renewal" const val CHANNEL_DOWNLOADER_CACHE = "downloader_cache_renewal"
@ -88,6 +86,7 @@ object Notifications {
private val deprecatedChannels = listOf( private val deprecatedChannels = listOf(
"downloader_channel", "downloader_channel",
"downloader_complete_channel",
"backup_restore_complete_channel", "backup_restore_complete_channel",
"library_channel", "library_channel",
"library_progress_channel", "library_progress_channel",
@ -151,11 +150,6 @@ object Notifications {
setGroup(GROUP_DOWNLOADER) setGroup(GROUP_DOWNLOADER)
setShowBadge(false) 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) { buildNotificationChannel(CHANNEL_DOWNLOADER_ERROR, IMPORTANCE_LOW) {
setName(context.getString(R.string.channel_errors)) setName(context.getString(R.string.channel_errors))
setGroup(GROUP_DOWNLOADER) setGroup(GROUP_DOWNLOADER)

View File

@ -868,8 +868,7 @@
<string name="download_notifier_unknown_error">Could not download chapter due to unexpected error</string> <string name="download_notifier_unknown_error">Could not download chapter due to unexpected error</string>
<string name="download_notifier_text_only_wifi">No Wi-Fi connection available</string> <string name="download_notifier_text_only_wifi">No Wi-Fi connection available</string>
<string name="download_notifier_no_network">No network connection available</string> <string name="download_notifier_no_network">No network connection available</string>
<string name="download_notifier_download_paused">Download paused</string> <string name="download_notifier_download_paused">Downloads paused</string>
<string name="download_notifier_download_finish">Download completed</string>
<string name="download_notifier_split_page_not_found">Page %d not found while splitting</string> <string name="download_notifier_split_page_not_found">Page %d not found while splitting</string>
<string name="download_notifier_split_page_path_not_found">Couldn\'t find file path of page %d</string> <string name="download_notifier_split_page_path_not_found">Couldn\'t find file path of page %d</string>
<string name="download_notifier_split_failed">Couldn\'t split downloaded image</string> <string name="download_notifier_split_failed">Couldn\'t split downloaded image</string>