Fix cosplayer tag translation in download label
This commit is contained in:
1 parent
31ce4eac92
commit
cae02acfc4
2 files changed
+11
-6
No files matched your search
@@ -152,7 +152,10 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
val density = LocalDensity.current
|
||||
val canTranslate = Settings.showTagTranslations && EhTagDatabase.isTranslatable(implicit<Context>()) && EhTagDatabase.initialized
|
||||
val ehTags = EhTagDatabase.takeIf { canTranslate }
|
||||
fun String.translateArtist() = ehTags?.getTranslation(TagNamespace.Artist.toPrefix(), this) ?: this
|
||||
fun getTranslation(tag: String) = ehTags?.run {
|
||||
getTranslation(TagNamespace.Artist.toPrefix(), tag)
|
||||
?: getTranslation(TagNamespace.Cosplayer.toPrefix(), tag)
|
||||
} ?: tag
|
||||
val allName = stringResource(R.string.download_all)
|
||||
val defaultName = stringResource(R.string.default_download_label_name)
|
||||
val unknownName = stringResource(R.string.unknown_artists)
|
||||
@@ -166,7 +169,7 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
when (label) {
|
||||
"" -> allName
|
||||
null -> emptyLabelName
|
||||
else -> if (mode == DownloadsFilterMode.ARTIST) label.translateArtist() else label
|
||||
else -> if (mode == DownloadsFilterMode.ARTIST) getTranslation(label) else label
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -381,7 +384,7 @@ fun AnimatedVisibilityScope.DownloadsScreen(navigator: DestinationsNavigator) =
|
||||
tonalElevation = 1.dp,
|
||||
shadowElevation = elevation,
|
||||
headlineContent = {
|
||||
val name = if (filterMode == DownloadsFilterMode.ARTIST) label.translateArtist() else label
|
||||
val name = if (filterMode == DownloadsFilterMode.ARTIST) getTranslation(label) else label
|
||||
Text("$name [${downloadsCount.getOrDefault(item, 0)}]")
|
||||
},
|
||||
trailingContent = editEnable.ifTrueThen {
|
||||
|
||||
@@ -201,10 +201,12 @@ private fun getRatingText(rating: Float): Int = when ((rating * 2).roundToInt())
|
||||
}
|
||||
|
||||
private fun List<GalleryTagGroup>.getArtistTag(): String? {
|
||||
val namespace = TagNamespace.Artist.value
|
||||
for (tagGroup in this) {
|
||||
if (tagGroup.groupName == namespace && tagGroup.size > 0) {
|
||||
return "$namespace:${tagGroup[0].removePrefix("_")}"
|
||||
if (tagGroup.isNotEmpty()) {
|
||||
val namespace = tagGroup.groupName
|
||||
if (namespace == TagNamespace.Artist.value || namespace == TagNamespace.Cosplayer.value) {
|
||||
return "$namespace:${tagGroup[0].removePrefix("_")}"
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in new issue
Block a user