From 1972cc25a9214709dac59cf0bbba02c0d60b1a99 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 28 Apr 2020 19:44:02 -0400 Subject: [PATCH] Show download progress in MoreController --- .../kanade/tachiyomi/ui/more/MoreController.kt | 17 +++++++++++++++++ app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt index 713dd612b2..e44d2f3069 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import androidx.preference.Preference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController import eu.kanade.tachiyomi.ui.base.controller.RootController @@ -25,12 +26,15 @@ import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.openInBrowser import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy class MoreController : SettingsController(), RootController, NoToolbarElevationController { + private val downloadManager: DownloadManager by injectLazy() + override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.label_more @@ -49,6 +53,19 @@ class MoreController : preferenceCategory { preference { titleRes = R.string.label_download_queue + + if (downloadManager.queue.isNotEmpty()) { + downloadManager.queue.getUpdatedObservable() + .doOnNext { + summary = if (it.isNullOrEmpty()) { + null + } else { + resources?.getQuantityString(R.plurals.download_queue_summary, it.size, it.size) + } + } + .subscribe() + } + iconRes = R.drawable.ic_file_download_black_24dp iconTint = tintColor onClick { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 659bb9bc54..ca52cb56be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -366,6 +366,10 @@ Downloaded only Filters all manga in your library + + 1 remaining + %1$s remaining +