From 3f1869cab6b0cd1a2dca987ac9837204fc8bf371 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 23 Jun 2021 17:29:20 -0400 Subject: [PATCH] Seperate pending updates for extensions into a seperate heading Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com> --- .../ui/extension/ExtensionBottomPresenter.kt | 19 +++++++++++++++++-- app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt index ea4f60f383..3598a89e79 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt @@ -152,8 +152,10 @@ class ExtensionBottomPresenter( val items = mutableListOf() - val installedSorted = installed.filter { showNsfwExtensions || !it.isNsfw } - .sortedWith(compareBy({ !it.hasUpdate }, { !it.isObsolete }, { it.pkgName })) + val updatesSorted = installed.filter { it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedBy { it.pkgName } + val installedSorted = installed + .filter { !it.hasUpdate && showNsfwExtensions || !it.isNsfw } + .sortedWith(compareBy({ !it.isObsolete }, { it.pkgName })) val untrustedSorted = untrusted.sortedBy { it.pkgName } val availableSorted = available // Filter out already installed extensions and disabled languages @@ -165,6 +167,19 @@ class ExtensionBottomPresenter( } .sortedBy { it.pkgName } + if (updatesSorted.isNotEmpty()) { + val header = ExtensionGroupItem( + context.resources.getQuantityString( + R.plurals._updates_pending, + updatesSorted.size, + updatesSorted.size + ), + updatesSorted.size + ) + items += updatesSorted.map { extension -> + ExtensionItem(extension, header, currentDownloads[extension.pkgName]) + } + } if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) { val header = ExtensionGroupItem(context.getString(R.string.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 775026c18a..5fb544506f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -302,6 +302,10 @@ May contain NSFW (18+) content App info %1$s must be enabled first + + %d update pending + %d updates pending + Extension update available %d extension updates available