Seperate pending updates for extensions into a seperate heading

Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
Jays2Kings 2021-06-23 17:29:20 -04:00
parent cee7c30a02
commit 3f1869cab6
2 changed files with 21 additions and 2 deletions

View File

@ -152,8 +152,10 @@ class ExtensionBottomPresenter(
val items = mutableListOf<ExtensionItem>()
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 ->

View File

@ -302,6 +302,10 @@
<string name="may_contain_nsfw">May contain NSFW (18+) content</string>
<string name="app_info">App info</string>
<string name="_must_be_enabled_first">%1$s must be enabled first</string>
<plurals name="_updates_pending">
<item quantity="one">%d update pending</item>
<item quantity="other">%d updates pending</item>
</plurals>
<plurals name="extension_updates_available">
<item quantity="one">Extension update available</item>
<item quantity="other">%d extension updates available</item>