Update API around brandColor.
This commit is contained in:
parent
71c853d1a7
commit
64ff19c808
12 changed files with 29 additions and 6 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit c5465c95792004409e0eaa7342171e1cd652914a
|
Subproject commit 51fe0a48eb11c7d67da6d598820b06d7d30bf8e9
|
||||||
|
|
@ -23,7 +23,7 @@ interface EnterpriseService {
|
||||||
* Override the brand color.
|
* Override the brand color.
|
||||||
* @param brandColor the color in hex format (#RRGGBBAA or #RRGGBB), or null to reset to default.
|
* @param brandColor the color in hex format (#RRGGBBAA or #RRGGBB), or null to reset to default.
|
||||||
*/
|
*/
|
||||||
fun overrideBrandColor(brandColor: String?)
|
suspend fun overrideBrandColor(brandColor: String?)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun semanticColorsLight(): State<SemanticColors>
|
fun semanticColorsLight(): State<SemanticColors>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class DefaultEnterpriseService : EnterpriseService {
|
||||||
override fun defaultHomeserverList(): List<String> = emptyList()
|
override fun defaultHomeserverList(): List<String> = emptyList()
|
||||||
override suspend fun isAllowedToConnectToHomeserver(homeserverUrl: String) = true
|
override suspend fun isAllowedToConnectToHomeserver(homeserverUrl: String) = true
|
||||||
|
|
||||||
override fun overrideBrandColor(brandColor: String?) = Unit
|
override suspend fun overrideBrandColor(brandColor: String?) = Unit
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun semanticColorsLight(): State<SemanticColors> {
|
override fun semanticColorsLight(): State<SemanticColors> {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class FakeEnterpriseService(
|
||||||
isAllowedToConnectToHomeserverResult(homeserverUrl)
|
isAllowedToConnectToHomeserverResult(homeserverUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun overrideBrandColor(brandColor: String?) {
|
override suspend fun overrideBrandColor(brandColor: String?) = simulateLongTask {
|
||||||
overrideBrandColorResult(brandColor)
|
overrideBrandColorResult(brandColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ class DeveloperSettingsPresenter(
|
||||||
}
|
}
|
||||||
appPreferencesStore.setTracingLogPacks(currentPacks)
|
appPreferencesStore.setTracingLogPacks(currentPacks)
|
||||||
}
|
}
|
||||||
is DeveloperSettingsEvents.ChangeBrandColor -> {
|
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
|
||||||
showColorPicker = false
|
showColorPicker = false
|
||||||
val color = event.color?.value?.toHexString(HexFormat.UpperCase)?.substring(2, 8)
|
val color = event.color?.value?.toHexString(HexFormat.UpperCase)?.substring(2, 8)
|
||||||
enterpriseService.overrideBrandColor(color)
|
enterpriseService.overrideBrandColor(color)
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,7 @@ class DeveloperSettingsPresenterTest {
|
||||||
assertThat(awaitItem().showColorPicker).isTrue()
|
assertThat(awaitItem().showColorPicker).isTrue()
|
||||||
initialState.eventSink(DeveloperSettingsEvents.ChangeBrandColor(Color.Green))
|
initialState.eventSink(DeveloperSettingsEvents.ChangeBrandColor(Color.Green))
|
||||||
assertThat(awaitItem().showColorPicker).isFalse()
|
assertThat(awaitItem().showColorPicker).isFalse()
|
||||||
|
skipItems(1)
|
||||||
overrideBrandColorResult.assertions().isCalledOnce()
|
overrideBrandColorResult.assertions().isCalledOnce()
|
||||||
.with(value("00FF00"))
|
.with(value("00FF00"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,3 +73,15 @@ fun List<SessionData>.toUserList(): List<String> {
|
||||||
fun Flow<List<SessionData>>.toUserListFlow(): Flow<List<String>> {
|
fun Flow<List<SessionData>>.toUserListFlow(): Flow<List<String>> {
|
||||||
return map { it.toUserList() }
|
return map { it.toUserList() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a flow emitting the userId of the latest session if logged in, null otherwise.
|
||||||
|
*/
|
||||||
|
fun SessionStore.userIdFlow(): Flow<String?> {
|
||||||
|
return loggedInStateFlow().map {
|
||||||
|
when (it) {
|
||||||
|
is LoggedInState.LoggedIn -> it.sessionId
|
||||||
|
is LoggedInState.NotLoggedIn -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ data class ElementWellKnown(
|
||||||
val registrationHelperUrl: String?,
|
val registrationHelperUrl: String?,
|
||||||
val enforceElementPro: Boolean?,
|
val enforceElementPro: Boolean?,
|
||||||
val rageshakeUrl: String?,
|
val rageshakeUrl: String?,
|
||||||
|
val brandColor: String?,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,6 @@ data class InternalElementWellKnown(
|
||||||
val enforceElementPro: Boolean? = null,
|
val enforceElementPro: Boolean? = null,
|
||||||
@SerialName("rageshake_url")
|
@SerialName("rageshake_url")
|
||||||
val rageshakeUrl: String? = null,
|
val rageshakeUrl: String? = null,
|
||||||
|
@SerialName("brand_color")
|
||||||
|
val brandColor: String? = null,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ internal fun InternalElementWellKnown.map() = ElementWellKnown(
|
||||||
registrationHelperUrl = registrationHelperUrl,
|
registrationHelperUrl = registrationHelperUrl,
|
||||||
enforceElementPro = enforceElementPro,
|
enforceElementPro = enforceElementPro,
|
||||||
rageshakeUrl = rageshakeUrl,
|
rageshakeUrl = rageshakeUrl,
|
||||||
|
brandColor = brandColor,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun InternalWellKnown.map() = WellKnown(
|
internal fun InternalWellKnown.map() = WellKnown(
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ class DefaultSessionWellknownRetrieverTest {
|
||||||
registrationHelperUrl = null,
|
registrationHelperUrl = null,
|
||||||
enforceElementPro = null,
|
enforceElementPro = null,
|
||||||
rageshakeUrl = null,
|
rageshakeUrl = null,
|
||||||
|
brandColor = null,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
getUrlLambda.assertions().isCalledOnce()
|
getUrlLambda.assertions().isCalledOnce()
|
||||||
|
|
@ -175,7 +176,8 @@ class DefaultSessionWellknownRetrieverTest {
|
||||||
"""{
|
"""{
|
||||||
"registration_helper_url": "a_registration_url",
|
"registration_helper_url": "a_registration_url",
|
||||||
"enforce_element_pro": true,
|
"enforce_element_pro": true,
|
||||||
"rageshake_url": "a_rageshake_url"
|
"rageshake_url": "a_rageshake_url",
|
||||||
|
"brand_color": "#FF0000"
|
||||||
}""".trimIndent().toByteArray()
|
}""".trimIndent().toByteArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -185,6 +187,7 @@ class DefaultSessionWellknownRetrieverTest {
|
||||||
registrationHelperUrl = "a_registration_url",
|
registrationHelperUrl = "a_registration_url",
|
||||||
enforceElementPro = true,
|
enforceElementPro = true,
|
||||||
rageshakeUrl = "a_rageshake_url",
|
rageshakeUrl = "a_rageshake_url",
|
||||||
|
brandColor = "#FF0000",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -208,6 +211,7 @@ class DefaultSessionWellknownRetrieverTest {
|
||||||
registrationHelperUrl = "a_registration_url",
|
registrationHelperUrl = "a_registration_url",
|
||||||
enforceElementPro = true,
|
enforceElementPro = true,
|
||||||
rageshakeUrl = "a_rageshake_url",
|
rageshakeUrl = "a_rageshake_url",
|
||||||
|
brandColor = null,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ fun anElementWellKnown(
|
||||||
registrationHelperUrl: String? = null,
|
registrationHelperUrl: String? = null,
|
||||||
enforceElementPro: Boolean? = null,
|
enforceElementPro: Boolean? = null,
|
||||||
rageshakeUrl: String? = null,
|
rageshakeUrl: String? = null,
|
||||||
|
brandColor: String? = null,
|
||||||
) = ElementWellKnown(
|
) = ElementWellKnown(
|
||||||
registrationHelperUrl = registrationHelperUrl,
|
registrationHelperUrl = registrationHelperUrl,
|
||||||
enforceElementPro = enforceElementPro,
|
enforceElementPro = enforceElementPro,
|
||||||
rageshakeUrl = rageshakeUrl,
|
rageshakeUrl = rageshakeUrl,
|
||||||
|
brandColor = brandColor,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue