Ensure the color has a # prefix.
This commit is contained in:
parent
56d15d2eaf
commit
399ad6ea03
2 changed files with 7 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||||
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
import io.element.android.features.enterprise.api.EnterpriseService
|
import io.element.android.features.enterprise.api.EnterpriseService
|
||||||
import io.element.android.features.preferences.impl.developer.tracing.toLogLevel
|
import io.element.android.features.preferences.impl.developer.tracing.toLogLevel
|
||||||
|
|
@ -140,7 +141,11 @@ class DeveloperSettingsPresenter(
|
||||||
}
|
}
|
||||||
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
|
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
|
||||||
showColorPicker = false
|
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)
|
enterpriseService.overrideBrandColor(sessionId, color)
|
||||||
}
|
}
|
||||||
is DeveloperSettingsEvents.SetShowColorPicker -> {
|
is DeveloperSettingsEvents.SetShowColorPicker -> {
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ class DeveloperSettingsPresenterTest {
|
||||||
assertThat(awaitItem().showColorPicker).isFalse()
|
assertThat(awaitItem().showColorPicker).isFalse()
|
||||||
skipItems(1)
|
skipItems(1)
|
||||||
overrideBrandColorResult.assertions().isCalledOnce()
|
overrideBrandColorResult.assertions().isCalledOnce()
|
||||||
.with(value(A_SESSION_ID), value("00FF00"))
|
.with(value(A_SESSION_ID), value("#00FF00"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue