Skip to content

Commit

Permalink
clear code
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Jan 26, 2025
1 parent 2e62e5a commit 3eecdf5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface SettingsInteractor : SimpleSettingsInteractor {

suspend fun setColorTuple(colorTuple: String)

suspend fun setPresets(newPresets: String)
suspend fun setPresets(newPresets: List<Int>)

suspend fun toggleDynamicColors()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ object ContextUtils {
else -> null
}

/** Save a text into the clipboard. */
fun Context.copyToClipboard(
value: String,
) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ class RootComponent @AssistedInject internal constructor(

fun setPresets(newPresets: List<Int>) {
componentScope.launch {
settingsManager.setPresets(
newPresets.joinToString("*")
)
settingsManager.setPresets(newPresets)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>) = edit {
if (newPresets.size > 3) {
it[PRESETS] = newPresets
.map { it.coerceIn(10..500) }
.toSortedSet()
.toList()
.reversed()
.joinToString("*")
}
}

Expand Down

0 comments on commit 3eecdf5

Please sign in to comment.