From 3eecdf55dd94708d92539151ba83953be5aca5fe Mon Sep 17 00:00:00 2001 From: T8RIN Date: Sun, 26 Jan 2025 06:41:33 +0300 Subject: [PATCH] clear code --- .../core/settings/domain/SettingsInteractor.kt | 2 +- .../core/ui/utils/helper/ContextUtils.kt | 2 -- .../presentation/screenLogic/RootComponent.kt | 4 +--- .../settings/data/AndroidSettingsManager.kt | 15 ++++++++------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/core/settings/src/main/java/ru/tech/imageresizershrinker/core/settings/domain/SettingsInteractor.kt b/core/settings/src/main/java/ru/tech/imageresizershrinker/core/settings/domain/SettingsInteractor.kt index 0554aa308..f1ef4d4b9 100644 --- a/core/settings/src/main/java/ru/tech/imageresizershrinker/core/settings/domain/SettingsInteractor.kt +++ b/core/settings/src/main/java/ru/tech/imageresizershrinker/core/settings/domain/SettingsInteractor.kt @@ -51,7 +51,7 @@ interface SettingsInteractor : SimpleSettingsInteractor { suspend fun setColorTuple(colorTuple: String) - suspend fun setPresets(newPresets: String) + suspend fun setPresets(newPresets: List) suspend fun toggleDynamicColors() diff --git a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/utils/helper/ContextUtils.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/utils/helper/ContextUtils.kt index a7dac6ae8..f68ac28a2 100644 --- a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/utils/helper/ContextUtils.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/utils/helper/ContextUtils.kt @@ -364,7 +364,6 @@ object ContextUtils { else -> null } - /** Save a text into the clipboard. */ fun Context.copyToClipboard( value: String, ) { @@ -381,7 +380,6 @@ object ContextUtils { Configuration(resources.configuration).apply { setLocale(locale) } ).getText(resId).toString() - /** Receive the clipboard data. */ fun Context.pasteColorFromClipboard( onPastedColor: (Int) -> Unit, onPastedColorFailure: (String) -> Unit, diff --git a/feature/root/src/main/java/ru/tech/imageresizershrinker/feature/root/presentation/screenLogic/RootComponent.kt b/feature/root/src/main/java/ru/tech/imageresizershrinker/feature/root/presentation/screenLogic/RootComponent.kt index da8080944..8084e2580 100644 --- a/feature/root/src/main/java/ru/tech/imageresizershrinker/feature/root/presentation/screenLogic/RootComponent.kt +++ b/feature/root/src/main/java/ru/tech/imageresizershrinker/feature/root/presentation/screenLogic/RootComponent.kt @@ -189,9 +189,7 @@ class RootComponent @AssistedInject internal constructor( fun setPresets(newPresets: List) { componentScope.launch { - settingsManager.setPresets( - newPresets.joinToString("*") - ) + settingsManager.setPresets(newPresets) } } diff --git a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/data/AndroidSettingsManager.kt b/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/data/AndroidSettingsManager.kt index 5db7e352a..633d5130c 100644 --- a/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/data/AndroidSettingsManager.kt +++ b/feature/settings/src/main/java/ru/tech/imageresizershrinker/feature/settings/data/AndroidSettingsManager.kt @@ -132,13 +132,14 @@ internal class AndroidSettingsManager @Inject constructor( it[APP_COLOR_TUPLE] = colorTuple } - override suspend fun setPresets(newPresets: String) = edit { - if (newPresets.split("*").size > 3) { - it[PRESETS] = newPresets.split("*") - .map { it.toIntOrNull()?.coerceIn(10..500) ?: 0 } - .toSortedSet() - .toList().reversed() - .joinToString("*") + override suspend fun setPresets(newPresets: List) = edit { + if (newPresets.size > 3) { + it[PRESETS] = newPresets + .map { it.coerceIn(10..500) } + .toSortedSet() + .toList() + .reversed() + .joinToString("*") } }