From 6ef6eab994b33770234f488b4060c197bb260a8b Mon Sep 17 00:00:00 2001 From: FourTOne5 <59261191+FourTOne5@users.noreply.github.com> Date: Sat, 30 Apr 2022 05:33:00 -0700 Subject: [PATCH] Remove source lang on migrate screen also seperate removed source on alphabetical sort (#7041) * Remove source lang on migrate screen also seperate removed source on alphabetical sort * Review changes * Rename Variable --- .../interactor/GetSourcesWithFavoriteCount.kt | 7 +++++-- .../source/MigrateSourceScreen.kt | 1 + .../source/components/BaseSourceItem.kt | 21 +++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/GetSourcesWithFavoriteCount.kt b/app/src/main/java/eu/kanade/domain/source/interactor/GetSourcesWithFavoriteCount.kt index 37b791c25d..54c43e3f15 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/GetSourcesWithFavoriteCount.kt +++ b/app/src/main/java/eu/kanade/domain/source/interactor/GetSourcesWithFavoriteCount.kt @@ -37,11 +37,14 @@ class GetSourcesWithFavoriteCount( val id2 = b.first.name.toLongOrNull() when (sorting) { SetMigrateSorting.Mode.ALPHABETICAL -> { - collator.compare(a.first.name.lowercase(locale), b.first.name.lowercase(locale)) + when { + id1 != null && id2 == null -> -1 + id2 != null && id1 == null -> 1 + else -> collator.compare(a.first.name.lowercase(locale), b.first.name.lowercase(locale)) + } } SetMigrateSorting.Mode.TOTAL -> { when { - id1 != null && id2 != null -> a.second.compareTo(b.second) id1 != null && id2 == null -> -1 id2 != null && id1 == null -> 1 else -> a.second.compareTo(b.second) diff --git a/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt index 454386553e..dcfcffea3c 100644 --- a/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt @@ -99,6 +99,7 @@ fun MigrateSourceItem( BaseSourceItem( modifier = modifier, source = source, + showLanguageInContent = source.lang != "", onClickItem = onClickItem, onLongClickItem = onLongClickItem, action = { diff --git a/app/src/main/java/eu/kanade/presentation/source/components/BaseSourceItem.kt b/app/src/main/java/eu/kanade/presentation/source/components/BaseSourceItem.kt index 87681db7ee..0e49eced84 100644 --- a/app/src/main/java/eu/kanade/presentation/source/components/BaseSourceItem.kt +++ b/app/src/main/java/eu/kanade/presentation/source/components/BaseSourceItem.kt @@ -21,11 +21,12 @@ import eu.kanade.tachiyomi.util.system.LocaleHelper fun BaseSourceItem( modifier: Modifier = Modifier, source: Source, + showLanguageInContent: Boolean = true, onClickItem: () -> Unit = {}, onLongClickItem: () -> Unit = {}, icon: @Composable RowScope.(Source) -> Unit = defaultIcon, action: @Composable RowScope.(Source) -> Unit = {}, - content: @Composable RowScope.(Source) -> Unit = defaultContent, + content: @Composable RowScope.(Source, Boolean) -> Unit = defaultContent, ) { Row( modifier = modifier @@ -37,7 +38,7 @@ fun BaseSourceItem( verticalAlignment = Alignment.CenterVertically ) { icon.invoke(this, source) - content.invoke(this, source) + content.invoke(this, source, showLanguageInContent) action.invoke(this, source) } } @@ -46,7 +47,7 @@ private val defaultIcon: @Composable RowScope.(Source) -> Unit = { source -> SourceIcon(source = source) } -private val defaultContent: @Composable RowScope.(Source) -> Unit = { source -> +private val defaultContent: @Composable RowScope.(Source, Boolean) -> Unit = { source, showLanguageInContent -> Column( modifier = Modifier .padding(horizontal = horizontalPadding) @@ -58,11 +59,13 @@ private val defaultContent: @Composable RowScope.(Source) -> Unit = { source -> overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodyMedium ) - Text( - text = LocaleHelper.getDisplayName(source.lang), - maxLines = 1, - overflow = TextOverflow.Ellipsis, - style = MaterialTheme.typography.bodySmall - ) + if (showLanguageInContent) { + Text( + text = LocaleHelper.getDisplayName(source.lang), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + style = MaterialTheme.typography.bodySmall + ) + } } }