Ensure the color has a # prefix.

This commit is contained in:
Benoit Marty 2025-10-29 11:45:50 +01:00
parent 38448f7f1e
commit a586299900
2 changed files with 7 additions and 2 deletions

View file

@ -21,6 +21,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.graphics.toArgb
import dev.zacsweers.metro.Inject
import io.element.android.features.enterprise.api.EnterpriseService
import io.element.android.features.preferences.impl.developer.tracing.toLogLevel
@ -140,7 +141,11 @@ class DeveloperSettingsPresenter(
}
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
showColorPicker = false
val color = event.color?.value?.toHexString(HexFormat.UpperCase)?.substring(2, 8)
val color = event.color
?.toArgb()
?.toHexString(HexFormat.UpperCase)
?.substring(2, 8)
?.padStart(7, '#')
enterpriseService.overrideBrandColor(sessionId, color)
}
is DeveloperSettingsEvents.SetShowColorPicker -> {

View file

@ -208,7 +208,7 @@ class DeveloperSettingsPresenterTest {
assertThat(awaitItem().showColorPicker).isFalse()
skipItems(1)
overrideBrandColorResult.assertions().isCalledOnce()
.with(value(A_SESSION_ID), value("00FF00"))
.with(value(A_SESSION_ID), value("#00FF00"))
}
}