mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
show source langauge when using an ALL langauge source if the extension supports multiple langauge
ie "Special Source Name" will show "Special Source Name (ALL)" when using that using the ALL source, even if English & All id the only languages on, but the Eng source will only show "Special Source Name"
This commit is contained in:
parent
8b918e370f
commit
93d8ce7918
10 changed files with 39 additions and 29 deletions
|
@ -84,7 +84,7 @@ class ExtensionManager(
|
|||
return getAppIconForSource(source.id)
|
||||
}
|
||||
|
||||
fun getAppIconForSource(sourceId: Long): Drawable? {
|
||||
private fun getAppIconForSource(sourceId: Long): Drawable? {
|
||||
val pkgName =
|
||||
installedExtensions.find { ext -> ext.sources.any { it.id == sourceId } }?.pkgName
|
||||
return if (pkgName != null) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.extension.ExtensionManager
|
|||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.system.awaitSingle
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
@ -86,6 +87,18 @@ interface Source {
|
|||
suspend fun getPageList(chapter: SChapter): List<Page> {
|
||||
return fetchPageList(chapter).awaitSingle()
|
||||
}
|
||||
|
||||
fun includeLangInName(isMultiLingual: Boolean, extensionManager: ExtensionManager? = null): Boolean {
|
||||
val httpSource = this as? HttpSource ?: return true
|
||||
val extManager = extensionManager ?: Injekt.get()
|
||||
val allExt = httpSource.getExtension(extManager)?.lang == "all"
|
||||
val onlyAll = httpSource.extOnlyHasAllLanguage(extManager)
|
||||
return (isMultiLingual && allExt) || (lang == "all" && !onlyAll)
|
||||
}
|
||||
|
||||
fun nameBasedOnEnabledLanguages(isMultiLingual: Boolean, extensionManager: ExtensionManager? = null): String {
|
||||
return if (includeLangInName(isMultiLingual, extensionManager)) toString() else name
|
||||
}
|
||||
}
|
||||
|
||||
fun Source.icon(): Drawable? = Injekt.get<ExtensionManager>().getAppIconForSource(this)
|
||||
|
|
|
@ -95,9 +95,11 @@ abstract class HttpSource : CatalogueSource {
|
|||
}
|
||||
}
|
||||
|
||||
fun getExtension(): Extension.Installed? {
|
||||
return Injekt.get<ExtensionManager>().installedExtensions.find { it.sources.contains(this) }
|
||||
}
|
||||
fun getExtension(extensionManager: ExtensionManager? = null): Extension.Installed? =
|
||||
(extensionManager ?: Injekt.get()).installedExtensions.find { it.sources.contains(this) }
|
||||
|
||||
fun extOnlyHasAllLanguage(extensionManager: ExtensionManager? = null) =
|
||||
getExtension(extensionManager)?.sources?.all { it.lang == "all" } ?: true
|
||||
|
||||
/**
|
||||
* Returns the request for the popular manga given the page.
|
||||
|
|
|
@ -438,13 +438,7 @@ class MangaHeaderHolder(
|
|||
.filterNot { it == "all" }
|
||||
|
||||
text = buildSpannedString {
|
||||
append(
|
||||
if (enabledLanguages.size > 1 && presenter.extension?.lang == "all") {
|
||||
presenter.source.toString()
|
||||
} else {
|
||||
presenter.source.name
|
||||
},
|
||||
)
|
||||
append(presenter.source.nameBasedOnEnabledLanguages(enabledLanguages.size > 1))
|
||||
if (presenter.source is SourceManager.StubSource &&
|
||||
presenter.source.name != presenter.source.id.toString()
|
||||
) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
|||
import android.os.Bundle
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -17,7 +18,8 @@ class MigrationSourceAdapter(
|
|||
true,
|
||||
) {
|
||||
|
||||
val isMultiLanguage =
|
||||
val extensionManager: ExtensionManager = Injekt.get()
|
||||
val isMultiLingual =
|
||||
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.databinding.MigrationSourceItemBinding
|
|||
import eu.kanade.tachiyomi.source.icon
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import java.util.Locale
|
||||
|
||||
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
||||
|
@ -17,13 +16,7 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
|||
}
|
||||
|
||||
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
||||
// Set capitalized title.
|
||||
val sourceName = if (adapter.isMultiLanguage) {
|
||||
source.toString()
|
||||
} else {
|
||||
source.name.replaceFirstChar { it.titlecase(Locale.getDefault()) }
|
||||
}
|
||||
binding.title.text = sourceName
|
||||
binding.title.text = source.nameBasedOnEnabledLanguages(adapter.isMultiLingual, adapter.extensionManager)
|
||||
// Update circle letter image.
|
||||
itemView.post {
|
||||
val icon = source.icon()
|
||||
|
|
|
@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
|||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
|
@ -28,6 +29,7 @@ import eu.kanade.tachiyomi.util.system.roundToTwoDecimal
|
|||
import eu.kanade.tachiyomi.util.system.withUIContext
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -35,7 +37,7 @@ import kotlin.math.roundToInt
|
|||
|
||||
class StatsDetailsPresenter(
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
prefs: PreferencesHelper = Injekt.get(),
|
||||
private val prefs: PreferencesHelper = Injekt.get(),
|
||||
val trackManager: TrackManager = Injekt.get(),
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
) : BaseCoroutinePresenter<StatsDetailsController>() {
|
||||
|
@ -48,6 +50,7 @@ class StatsDetailsPresenter(
|
|||
}
|
||||
private var mangasDistinct = libraryMangas.distinct()
|
||||
val sources = getEnabledSources()
|
||||
val extensionManager by injectLazy<ExtensionManager>()
|
||||
|
||||
var selectedStat: Stats? = null
|
||||
var selectedSeriesType = mutableSetOf<String>()
|
||||
|
@ -272,10 +275,10 @@ class StatsDetailsPresenter(
|
|||
private fun setupSources() {
|
||||
currentStats = ArrayList()
|
||||
val libraryFormat = mangasDistinct.filterByChip().groupBy { it.source }
|
||||
val isMultiLingual = prefs.enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||
|
||||
libraryFormat.forEach { (sourceId, mangaList) ->
|
||||
val source = sources.find { it.id == sourceId }
|
||||
val sourceName = source?.toString() ?: sourceId.toString()
|
||||
val source = sourceManager.getOrStub(sourceId)
|
||||
currentStats?.add(
|
||||
StatsData(
|
||||
color = pieColorList[1],
|
||||
|
@ -283,8 +286,8 @@ class StatsDetailsPresenter(
|
|||
meanScore = mangaList.getMeanScoreRounded(),
|
||||
chaptersRead = mangaList.sumOf { it.read },
|
||||
totalChapters = mangaList.sumOf { it.totalChapters },
|
||||
label = sourceName.uppercase(),
|
||||
icon = source?.icon(),
|
||||
label = source.nameBasedOnEnabledLanguages(isMultiLingual, extensionManager).uppercase(),
|
||||
icon = source.icon(),
|
||||
readDuration = mangaList.getReadDuration(),
|
||||
casedLabel = source?.name,
|
||||
id = sourceId,
|
||||
|
|
|
@ -20,9 +20,11 @@ class SourceAdapter(val controller: BrowseController) :
|
|||
|
||||
val sourceListener: SourceListener = controller
|
||||
|
||||
val isMultiLanguage =
|
||||
val isMultiLingual =
|
||||
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||
|
||||
val extensionManager = controller.presenter.extensionManager
|
||||
|
||||
override fun onItemSwiped(position: Int, direction: Int) {
|
||||
super.onItemSwiped(position, direction)
|
||||
controller.hideCatalogue(position)
|
||||
|
|
|
@ -32,9 +32,8 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
|||
val underPinnedSection = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
|
||||
val underLastUsedSection = item.header?.code?.equals(SourcePresenter.LAST_USED_KEY) ?: false
|
||||
val isPinned = item.isPinned ?: underPinnedSection
|
||||
// Set source name
|
||||
val sourceName =
|
||||
if (adapter.isMultiLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name
|
||||
val showLanguage = source.includeLangInName(adapter.isMultiLingual, adapter.extensionManager)
|
||||
val sourceName = if (showLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name
|
||||
binding.title.text = sourceName
|
||||
|
||||
binding.sourcePin.apply {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.ui.source
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
|
@ -26,6 +27,7 @@ import java.util.TreeMap
|
|||
class SourcePresenter(
|
||||
val controller: BrowseController,
|
||||
val sourceManager: SourceManager = Injekt.get(),
|
||||
val extensionManager: ExtensionManager = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get(),
|
||||
) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue