From f03c49850b2842a3c31fdc68aa0175ff06f3406c Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 17 Feb 2020 15:29:03 -0500 Subject: [PATCH] Separate group for extensions with updates --- .../tachiyomi/ui/extension/ExtensionGroupHolder.kt | 7 ++++++- .../kanade/tachiyomi/ui/extension/ExtensionGroupItem.kt | 2 +- .../kanade/tachiyomi/ui/extension/ExtensionPresenter.kt | 9 ++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupHolder.kt index 85c2a597ce..61faf00e13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupHolder.kt @@ -11,6 +11,11 @@ class ExtensionGroupHolder(view: View, adapter: FlexibleAdapter<*>) : @SuppressLint("SetTextI18n") fun bind(item: ExtensionGroupItem) { - title.text = item.name + var text = item.name + if (item.showSize) { + text += " (${item.size})" + } + + title.text = text } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupItem.kt index 14c976910d..b90e6f8701 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionGroupItem.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.R * @param name The header name. * @param size The number of items in the group. */ -data class ExtensionGroupItem(val name: String, val size: Int) : AbstractHeaderItem() { +data class ExtensionGroupItem(val name: String, val size: Int, val showSize: Boolean = false) : AbstractHeaderItem() { /** * Returns the layout resource of this item. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionPresenter.kt index d932ae0877..499dca1258 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionPresenter.kt @@ -62,7 +62,8 @@ open class ExtensionPresenter( val items = mutableListOf() - val installedSorted = installed.sortedWith(compareBy({ !it.hasUpdate }, { !it.isObsolete }, { it.pkgName })) + val updatesSorted = installed.filter { it.hasUpdate }.sortedBy { it.pkgName } + val installedSorted = installed.filter { !it.hasUpdate }.sortedWith(compareBy({ !it.isObsolete }, { it.pkgName })) val untrustedSorted = untrusted.sortedBy { it.pkgName } val availableSorted = available // Filter out already installed extensions and disabled languages @@ -71,6 +72,12 @@ open class ExtensionPresenter( && (avail.lang in activeLangs || avail.lang == "all")} .sortedBy { it.pkgName } + if (updatesSorted.isNotEmpty()) { + val header = ExtensionGroupItem(context.getString(R.string.ext_updates_pending), updatesSorted.size, true) + items += updatesSorted.map { extension -> + ExtensionItem(extension, header, currentDownloads[extension.pkgName]) + } + } if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) { val header = ExtensionGroupItem(context.getString(R.string.ext_installed), installedSorted.size + untrustedSorted.size) items += installedSorted.map { extension -> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4fdffe9234..2040111b16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -163,6 +163,7 @@ All Details + Updates pending Update Obsolete Install