mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
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:
parent
c6c4c1c393
commit
a0f49b16c5
@ -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<Boolean>
|
||||
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<List<Page>> {
|
||||
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<List<Page>> {
|
||||
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() }
|
||||
|
@ -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
|
||||
|
@ -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<List<Download>>()
|
||||
|
||||
/**
|
||||
* Relay to subscribe to the downloader status.
|
||||
*/
|
||||
val runningRelay: BehaviorRelay<Boolean> = 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()
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -868,8 +868,7 @@
|
||||
<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_no_network">No network connection available</string>
|
||||
<string name="download_notifier_download_paused">Download paused</string>
|
||||
<string name="download_notifier_download_finish">Download completed</string>
|
||||
<string name="download_notifier_download_paused">Downloads paused</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_failed">Couldn\'t split downloaded image</string>
|
||||
|
Loading…
Reference in New Issue
Block a user