|
@@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.download
|
|
|
|
|
|
import android.content.Context
|
|
|
import android.webkit.MimeTypeMap
|
|
|
-import android.widget.Toast
|
|
|
import com.hippo.unifile.UniFile
|
|
|
import com.jakewharton.rxrelay.BehaviorRelay
|
|
|
import com.jakewharton.rxrelay.PublishRelay
|
|
@@ -27,7 +26,6 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|
|
import eu.kanade.tachiyomi.util.storage.saveTo
|
|
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
|
|
import eu.kanade.tachiyomi.util.system.logcat
|
|
|
-import eu.kanade.tachiyomi.util.system.toast
|
|
|
import kotlinx.coroutines.async
|
|
|
import logcat.LogPriority
|
|
|
import okhttp3.Response
|
|
@@ -274,13 +272,20 @@ class Downloader(
|
|
|
|
|
|
// Start downloader if needed
|
|
|
if (autoStart && wasEmpty) {
|
|
|
+ val queuedDownloads = queue.filter { it.source !is UnmeteredSource }.count()
|
|
|
val maxDownloadsFromSource = queue
|
|
|
.groupBy { it.source }
|
|
|
.filterKeys { it !is UnmeteredSource }
|
|
|
.maxOf { it.value.size }
|
|
|
- if (maxDownloadsFromSource > CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD) {
|
|
|
+ if (
|
|
|
+ queuedDownloads > DOWNLOADS_QUEUED_WARNING_THRESHOLD ||
|
|
|
+ maxDownloadsFromSource > CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD
|
|
|
+ ) {
|
|
|
withUIContext {
|
|
|
- context.toast(R.string.download_queue_size_warning, Toast.LENGTH_LONG)
|
|
|
+ notifier.onWarning(
|
|
|
+ context.getString(R.string.download_queue_size_warning),
|
|
|
+ WARNING_NOTIF_TIMEOUT_MS,
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
DownloadService.start(context)
|
|
@@ -559,7 +564,9 @@ class Downloader(
|
|
|
|
|
|
companion object {
|
|
|
const val TMP_DIR_SUFFIX = "_tmp"
|
|
|
+ const val WARNING_NOTIF_TIMEOUT_MS = 30_000L
|
|
|
const val CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD = 15
|
|
|
+ private const val DOWNLOADS_QUEUED_WARNING_THRESHOLD = 30
|
|
|
}
|
|
|
}
|
|
|
|