Separate group for extensions with updates

This commit is contained in:
arkon 2020-02-17 15:29:03 -05:00
parent 6677c10173
commit f03c49850b
4 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,11 @@ class ExtensionGroupHolder(view: View, adapter: FlexibleAdapter<*>) :
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun bind(item: ExtensionGroupItem) { fun bind(item: ExtensionGroupItem) {
title.text = item.name var text = item.name
if (item.showSize) {
text += " (${item.size})"
}
title.text = text
} }
} }

View File

@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.R
* @param name The header name. * @param name The header name.
* @param size The number of items in the group. * @param size The number of items in the group.
*/ */
data class ExtensionGroupItem(val name: String, val size: Int) : AbstractHeaderItem<ExtensionGroupHolder>() { data class ExtensionGroupItem(val name: String, val size: Int, val showSize: Boolean = false) : AbstractHeaderItem<ExtensionGroupHolder>() {
/** /**
* Returns the layout resource of this item. * Returns the layout resource of this item.

View File

@ -62,7 +62,8 @@ open class ExtensionPresenter(
val items = mutableListOf<ExtensionItem>() val items = mutableListOf<ExtensionItem>()
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 untrustedSorted = untrusted.sortedBy { it.pkgName }
val availableSorted = available val availableSorted = available
// Filter out already installed extensions and disabled languages // Filter out already installed extensions and disabled languages
@ -71,6 +72,12 @@ open class ExtensionPresenter(
&& (avail.lang in activeLangs || avail.lang == "all")} && (avail.lang in activeLangs || avail.lang == "all")}
.sortedBy { it.pkgName } .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()) { if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) {
val header = ExtensionGroupItem(context.getString(R.string.ext_installed), installedSorted.size + untrustedSorted.size) val header = ExtensionGroupItem(context.getString(R.string.ext_installed), installedSorted.size + untrustedSorted.size)
items += installedSorted.map { extension -> items += installedSorted.map { extension ->

View File

@ -163,6 +163,7 @@
<!-- Extension section --> <!-- Extension section -->
<string name="all_lang">All</string> <string name="all_lang">All</string>
<string name="ext_details">Details</string> <string name="ext_details">Details</string>
<string name="ext_updates_pending">Updates pending</string>
<string name="ext_update">Update</string> <string name="ext_update">Update</string>
<string name="ext_obsolete">Obsolete</string> <string name="ext_obsolete">Obsolete</string>
<string name="ext_install">Install</string> <string name="ext_install">Install</string>