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)
|
return getAppIconForSource(source.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAppIconForSource(sourceId: Long): Drawable? {
|
private fun getAppIconForSource(sourceId: Long): Drawable? {
|
||||||
val pkgName =
|
val pkgName =
|
||||||
installedExtensions.find { ext -> ext.sources.any { it.id == sourceId } }?.pkgName
|
installedExtensions.find { ext -> ext.sources.any { it.id == sourceId } }?.pkgName
|
||||||
return if (pkgName != null) {
|
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.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.system.awaitSingle
|
import eu.kanade.tachiyomi.util.system.awaitSingle
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -86,6 +87,18 @@ interface Source {
|
||||||
suspend fun getPageList(chapter: SChapter): List<Page> {
|
suspend fun getPageList(chapter: SChapter): List<Page> {
|
||||||
return fetchPageList(chapter).awaitSingle()
|
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)
|
fun Source.icon(): Drawable? = Injekt.get<ExtensionManager>().getAppIconForSource(this)
|
||||||
|
|
|
@ -95,9 +95,11 @@ abstract class HttpSource : CatalogueSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getExtension(): Extension.Installed? {
|
fun getExtension(extensionManager: ExtensionManager? = null): Extension.Installed? =
|
||||||
return Injekt.get<ExtensionManager>().installedExtensions.find { it.sources.contains(this) }
|
(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.
|
* Returns the request for the popular manga given the page.
|
||||||
|
|
|
@ -438,13 +438,7 @@ class MangaHeaderHolder(
|
||||||
.filterNot { it == "all" }
|
.filterNot { it == "all" }
|
||||||
|
|
||||||
text = buildSpannedString {
|
text = buildSpannedString {
|
||||||
append(
|
append(presenter.source.nameBasedOnEnabledLanguages(enabledLanguages.size > 1))
|
||||||
if (enabledLanguages.size > 1 && presenter.extension?.lang == "all") {
|
|
||||||
presenter.source.toString()
|
|
||||||
} else {
|
|
||||||
presenter.source.name
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if (presenter.source is SourceManager.StubSource &&
|
if (presenter.source is SourceManager.StubSource &&
|
||||||
presenter.source.name != presenter.source.id.toString()
|
presenter.source.name != presenter.source.id.toString()
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration.manga.design
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -17,7 +18,8 @@ class MigrationSourceAdapter(
|
||||||
true,
|
true,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val isMultiLanguage =
|
val extensionManager: ExtensionManager = Injekt.get()
|
||||||
|
val isMultiLingual =
|
||||||
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
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.icon
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
@ -17,13 +16,7 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
||||||
// Set capitalized title.
|
binding.title.text = source.nameBasedOnEnabledLanguages(adapter.isMultiLingual, adapter.extensionManager)
|
||||||
val sourceName = if (adapter.isMultiLanguage) {
|
|
||||||
source.toString()
|
|
||||||
} else {
|
|
||||||
source.name.replaceFirstChar { it.titlecase(Locale.getDefault()) }
|
|
||||||
}
|
|
||||||
binding.title.text = sourceName
|
|
||||||
// Update circle letter image.
|
// Update circle letter image.
|
||||||
itemView.post {
|
itemView.post {
|
||||||
val icon = source.icon()
|
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.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
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 eu.kanade.tachiyomi.util.system.withUIContext
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
@ -35,7 +37,7 @@ import kotlin.math.roundToInt
|
||||||
|
|
||||||
class StatsDetailsPresenter(
|
class StatsDetailsPresenter(
|
||||||
private val db: DatabaseHelper = Injekt.get(),
|
private val db: DatabaseHelper = Injekt.get(),
|
||||||
prefs: PreferencesHelper = Injekt.get(),
|
private val prefs: PreferencesHelper = Injekt.get(),
|
||||||
val trackManager: TrackManager = Injekt.get(),
|
val trackManager: TrackManager = Injekt.get(),
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
) : BaseCoroutinePresenter<StatsDetailsController>() {
|
) : BaseCoroutinePresenter<StatsDetailsController>() {
|
||||||
|
@ -48,6 +50,7 @@ class StatsDetailsPresenter(
|
||||||
}
|
}
|
||||||
private var mangasDistinct = libraryMangas.distinct()
|
private var mangasDistinct = libraryMangas.distinct()
|
||||||
val sources = getEnabledSources()
|
val sources = getEnabledSources()
|
||||||
|
val extensionManager by injectLazy<ExtensionManager>()
|
||||||
|
|
||||||
var selectedStat: Stats? = null
|
var selectedStat: Stats? = null
|
||||||
var selectedSeriesType = mutableSetOf<String>()
|
var selectedSeriesType = mutableSetOf<String>()
|
||||||
|
@ -272,10 +275,10 @@ class StatsDetailsPresenter(
|
||||||
private fun setupSources() {
|
private fun setupSources() {
|
||||||
currentStats = ArrayList()
|
currentStats = ArrayList()
|
||||||
val libraryFormat = mangasDistinct.filterByChip().groupBy { it.source }
|
val libraryFormat = mangasDistinct.filterByChip().groupBy { it.source }
|
||||||
|
val isMultiLingual = prefs.enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||||
|
|
||||||
libraryFormat.forEach { (sourceId, mangaList) ->
|
libraryFormat.forEach { (sourceId, mangaList) ->
|
||||||
val source = sources.find { it.id == sourceId }
|
val source = sourceManager.getOrStub(sourceId)
|
||||||
val sourceName = source?.toString() ?: sourceId.toString()
|
|
||||||
currentStats?.add(
|
currentStats?.add(
|
||||||
StatsData(
|
StatsData(
|
||||||
color = pieColorList[1],
|
color = pieColorList[1],
|
||||||
|
@ -283,8 +286,8 @@ class StatsDetailsPresenter(
|
||||||
meanScore = mangaList.getMeanScoreRounded(),
|
meanScore = mangaList.getMeanScoreRounded(),
|
||||||
chaptersRead = mangaList.sumOf { it.read },
|
chaptersRead = mangaList.sumOf { it.read },
|
||||||
totalChapters = mangaList.sumOf { it.totalChapters },
|
totalChapters = mangaList.sumOf { it.totalChapters },
|
||||||
label = sourceName.uppercase(),
|
label = source.nameBasedOnEnabledLanguages(isMultiLingual, extensionManager).uppercase(),
|
||||||
icon = source?.icon(),
|
icon = source.icon(),
|
||||||
readDuration = mangaList.getReadDuration(),
|
readDuration = mangaList.getReadDuration(),
|
||||||
casedLabel = source?.name,
|
casedLabel = source?.name,
|
||||||
id = sourceId,
|
id = sourceId,
|
||||||
|
|
|
@ -20,9 +20,11 @@ class SourceAdapter(val controller: BrowseController) :
|
||||||
|
|
||||||
val sourceListener: SourceListener = controller
|
val sourceListener: SourceListener = controller
|
||||||
|
|
||||||
val isMultiLanguage =
|
val isMultiLingual =
|
||||||
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
Injekt.get<PreferencesHelper>().enabledLanguages().get().filterNot { it == "all" }.size > 1
|
||||||
|
|
||||||
|
val extensionManager = controller.presenter.extensionManager
|
||||||
|
|
||||||
override fun onItemSwiped(position: Int, direction: Int) {
|
override fun onItemSwiped(position: Int, direction: Int) {
|
||||||
super.onItemSwiped(position, direction)
|
super.onItemSwiped(position, direction)
|
||||||
controller.hideCatalogue(position)
|
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 underPinnedSection = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
|
||||||
val underLastUsedSection = item.header?.code?.equals(SourcePresenter.LAST_USED_KEY) ?: false
|
val underLastUsedSection = item.header?.code?.equals(SourcePresenter.LAST_USED_KEY) ?: false
|
||||||
val isPinned = item.isPinned ?: underPinnedSection
|
val isPinned = item.isPinned ?: underPinnedSection
|
||||||
// Set source name
|
val showLanguage = source.includeLangInName(adapter.isMultiLingual, adapter.extensionManager)
|
||||||
val sourceName =
|
val sourceName = if (showLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name
|
||||||
if (adapter.isMultiLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name
|
|
||||||
binding.title.text = sourceName
|
binding.title.text = sourceName
|
||||||
|
|
||||||
binding.sourcePin.apply {
|
binding.sourcePin.apply {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.source
|
package eu.kanade.tachiyomi.ui.source
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
@ -26,6 +27,7 @@ import java.util.TreeMap
|
||||||
class SourcePresenter(
|
class SourcePresenter(
|
||||||
val controller: BrowseController,
|
val controller: BrowseController,
|
||||||
val sourceManager: SourceManager = Injekt.get(),
|
val sourceManager: SourceManager = Injekt.get(),
|
||||||
|
val extensionManager: ExtensionManager = Injekt.get(),
|
||||||
private val preferences: PreferencesHelper = Injekt.get(),
|
private val preferences: PreferencesHelper = Injekt.get(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue