|
|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
package org.koitharu.kotatsu.settings.newsources
|
|
|
|
|
|
|
|
|
|
import androidx.core.os.LocaleListCompat
|
|
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
|
|
import org.koitharu.kotatsu.base.ui.BaseViewModel
|
|
|
|
|
import org.koitharu.kotatsu.core.model.getLocaleTitle
|
|
|
|
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
|
|
|
|
import org.koitharu.kotatsu.settings.sources.model.SourceConfigItem
|
|
|
|
|
import org.koitharu.kotatsu.utils.ext.mapToSet
|
|
|
|
|
|
|
|
|
|
class NewSourcesViewModel(
|
|
|
|
|
private val settings: AppSettings,
|
|
|
|
|
@ -30,12 +32,14 @@ class NewSourcesViewModel(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun buildList() {
|
|
|
|
|
val locales = LocaleListCompat.getDefault().mapToSet { it.language }
|
|
|
|
|
val hidden = settings.hiddenSources
|
|
|
|
|
sources.value = initialList.map {
|
|
|
|
|
val locale = it.locale
|
|
|
|
|
SourceConfigItem.SourceItem(
|
|
|
|
|
source = it,
|
|
|
|
|
summary = it.getLocaleTitle(),
|
|
|
|
|
isEnabled = it.name !in hidden,
|
|
|
|
|
isEnabled = it.name !in hidden && (locale == null || locale in locales),
|
|
|
|
|
isDraggable = false,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|