|
@@ -3,6 +3,8 @@ package eu.kanade.tachiyomi.ui.extension
|
|
|
import android.app.Application
|
|
|
import android.os.Bundle
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
+import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
|
+import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
|
|
import eu.kanade.tachiyomi.extension.model.Extension
|
|
|
import eu.kanade.tachiyomi.extension.model.InstallStep
|
|
@@ -22,7 +24,8 @@ private typealias ExtensionTuple
|
|
|
* Presenter of [ExtensionController].
|
|
|
*/
|
|
|
open class ExtensionPresenter(
|
|
|
- private val extensionManager: ExtensionManager = Injekt.get()
|
|
|
+ private val extensionManager: ExtensionManager = Injekt.get(),
|
|
|
+ private val preferences: PreferencesHelper = Injekt.get()
|
|
|
) : BasePresenter<ExtensionController>() {
|
|
|
|
|
|
private var extensions = emptyList<ExtensionItem>()
|
|
@@ -53,6 +56,7 @@ open class ExtensionPresenter(
|
|
|
@Synchronized
|
|
|
private fun toItems(tuple: ExtensionTuple): List<ExtensionItem> {
|
|
|
val context = Injekt.get<Application>()
|
|
|
+ val activeLangs = preferences.enabledLanguages().getOrDefault()
|
|
|
|
|
|
val (installed, untrusted, available) = tuple
|
|
|
|
|
@@ -61,9 +65,10 @@ open class ExtensionPresenter(
|
|
|
val installedSorted = installed.sortedWith(compareBy({ !it.hasUpdate }, { it.pkgName }))
|
|
|
val untrustedSorted = untrusted.sortedBy { it.pkgName }
|
|
|
val availableSorted = available
|
|
|
- // Filter out already installed extensions
|
|
|
+ // Filter out already installed extensions and disabled languages
|
|
|
.filter { avail -> installed.none { it.pkgName == avail.pkgName }
|
|
|
- && untrusted.none { it.pkgName == avail.pkgName } }
|
|
|
+ && untrusted.none { it.pkgName == avail.pkgName }
|
|
|
+ && (avail.lang in activeLangs || avail.lang == "all")}
|
|
|
.sortedBy { it.pkgName }
|
|
|
|
|
|
if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) {
|