Fix language info extensions (#1341)

This commit is contained in:
nzoba 2022-07-15 01:30:58 +02:00 committed by GitHub
parent bffdd2c959
commit fe53f158c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View file

@ -26,10 +26,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
val source = item.source
// Set source name
val sourceName =
if (adapter.isMultiLanguage) source.toString() else source.name.replaceFirstChar {
it.titlecase(Locale.getDefault())
} + " (${item.numberOfItems})"
val sourceName = source.name.replaceFirstChar { it.titlecase(Locale.getDefault()) } + " (${item.numberOfItems})"
binding.title.text = sourceName
binding.lang.text = when {
item.isUninstalled -> itemView.context.getString(R.string.source_not_installed)

View file

@ -30,10 +30,11 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
// setCardEdges(item)
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) source.toString() else source.name
if (adapter.isMultiLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name
binding.title.text = sourceName
binding.sourcePin.apply {

View file

@ -109,7 +109,7 @@ class SourcePresenter(
val pinnedCatalogues = preferences.pinnedCatalogues().get()
val isPinned = source.id.toString() in pinnedCatalogues
if (isPinned) null
else SourceItem(source, null, isPinned)
else SourceItem(source, LangItem(LAST_USED_KEY), isPinned)
}
}