Improve API and documentation
This commit is contained in:
Submodule enterprise updated: f9178b5a11...f662f079f9
@@ -21,9 +21,10 @@ interface EnterpriseService {
|
||||
|
||||
/**
|
||||
* Override the brand color.
|
||||
* @param sessionId the session to override the brand color for, or null to set the brand color to use when there is no session.
|
||||
* @param brandColor the color in hex format (#RRGGBBAA or #RRGGBB), or null to reset to default.
|
||||
*/
|
||||
suspend fun overrideBrandColor(brandColor: String?)
|
||||
suspend fun overrideBrandColor(sessionId: SessionId?, brandColor: String?)
|
||||
|
||||
@Composable
|
||||
fun semanticColorsLight(): State<SemanticColors>
|
||||
|
||||
@@ -32,7 +32,7 @@ class DefaultEnterpriseService : EnterpriseService {
|
||||
override fun defaultHomeserverList(): List<String> = emptyList()
|
||||
override suspend fun isAllowedToConnectToHomeserver(homeserverUrl: String) = true
|
||||
|
||||
override suspend fun overrideBrandColor(brandColor: String?) = Unit
|
||||
override suspend fun overrideBrandColor(sessionId: SessionId?, brandColor: String?) = Unit
|
||||
|
||||
@Composable
|
||||
override fun semanticColorsLight(): State<SemanticColors> {
|
||||
|
||||
@@ -51,7 +51,7 @@ class DefaultEnterpriseServiceTest {
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState).isEqualTo(compoundColorsLight)
|
||||
defaultEnterpriseService.overrideBrandColor("#87654321")
|
||||
defaultEnterpriseService.overrideBrandColor(A_SESSION_ID, "#87654321")
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class DefaultEnterpriseServiceTest {
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState).isEqualTo(compoundColorsDark)
|
||||
defaultEnterpriseService.overrideBrandColor("#87654321")
|
||||
defaultEnterpriseService.overrideBrandColor(A_SESSION_ID, "#87654321")
|
||||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class FakeEnterpriseService(
|
||||
private val isAllowedToConnectToHomeserverResult: (String) -> Boolean = { lambdaError() },
|
||||
private val semanticColorsLightResult: () -> State<SemanticColors> = { lambdaError() },
|
||||
private val semanticColorsDarkResult: () -> State<SemanticColors> = { lambdaError() },
|
||||
private val overrideBrandColorResult: (String?) -> Unit = { lambdaError() },
|
||||
private val overrideBrandColorResult: (SessionId?, String?) -> Unit = { _, _ -> lambdaError() },
|
||||
private val firebasePushGatewayResult: () -> String? = { lambdaError() },
|
||||
private val unifiedPushDefaultPushGatewayResult: () -> String? = { lambdaError() },
|
||||
) : EnterpriseService {
|
||||
@@ -42,8 +42,8 @@ class FakeEnterpriseService(
|
||||
isAllowedToConnectToHomeserverResult(homeserverUrl)
|
||||
}
|
||||
|
||||
override suspend fun overrideBrandColor(brandColor: String?) = simulateLongTask {
|
||||
overrideBrandColorResult(brandColor)
|
||||
override suspend fun overrideBrandColor(sessionId: SessionId?, brandColor: String?) = simulateLongTask {
|
||||
overrideBrandColorResult(sessionId, brandColor)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -38,6 +38,7 @@ import io.element.android.libraries.core.meta.BuildType
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.featureflag.ui.model.FeatureUiModel
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
@@ -50,6 +51,7 @@ import java.net.URL
|
||||
|
||||
@Inject
|
||||
class DeveloperSettingsPresenter(
|
||||
private val sessionId: SessionId,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
private val computeCacheSizeUseCase: ComputeCacheSizeUseCase,
|
||||
private val clearCacheUseCase: ClearCacheUseCase,
|
||||
@@ -138,7 +140,7 @@ class DeveloperSettingsPresenter(
|
||||
is DeveloperSettingsEvents.ChangeBrandColor -> coroutineScope.launch {
|
||||
showColorPicker = false
|
||||
val color = event.color?.value?.toHexString(HexFormat.UpperCase)?.substring(2, 8)
|
||||
enterpriseService.overrideBrandColor(color)
|
||||
enterpriseService.overrideBrandColor(sessionId, color)
|
||||
}
|
||||
is DeveloperSettingsEvents.SetShowColorPicker -> {
|
||||
showColorPicker = event.show
|
||||
|
||||
@@ -25,6 +25,8 @@ import io.element.android.libraries.featureflag.api.Feature
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.featureflag.test.FakeFeature
|
||||
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
@@ -184,7 +186,7 @@ class DeveloperSettingsPresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - enterprise build can change the brand color`() = runTest {
|
||||
val overrideBrandColorResult = lambdaRecorder<String?, Unit> { }
|
||||
val overrideBrandColorResult = lambdaRecorder<SessionId?, String?, Unit> { _, _ -> }
|
||||
val presenter = createDeveloperSettingsPresenter(
|
||||
enterpriseService = FakeEnterpriseService(
|
||||
isEnterpriseBuild = true,
|
||||
@@ -205,11 +207,12 @@ class DeveloperSettingsPresenterTest {
|
||||
assertThat(awaitItem().showColorPicker).isFalse()
|
||||
skipItems(1)
|
||||
overrideBrandColorResult.assertions().isCalledOnce()
|
||||
.with(value("00FF00"))
|
||||
.with(value(A_SESSION_ID), value("00FF00"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createDeveloperSettingsPresenter(
|
||||
sessionId: SessionId = A_SESSION_ID,
|
||||
featureFlagService: FakeFeatureFlagService = FakeFeatureFlagService(
|
||||
getAvailableFeaturesResult = { _, _ ->
|
||||
listOf(
|
||||
@@ -228,6 +231,7 @@ class DeveloperSettingsPresenterTest {
|
||||
enterpriseService: EnterpriseService = FakeEnterpriseService(),
|
||||
): DeveloperSettingsPresenter {
|
||||
return DeveloperSettingsPresenter(
|
||||
sessionId = sessionId,
|
||||
featureFlagService = featureFlagService,
|
||||
computeCacheSizeUseCase = cacheSizeUseCase,
|
||||
clearCacheUseCase = clearCacheUseCase,
|
||||
|
||||
@@ -36,7 +36,7 @@ import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.tracing.TracingService
|
||||
import io.element.android.libraries.network.useragent.UserAgentProvider
|
||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||
import io.element.android.libraries.sessionstorage.api.userIdFlow
|
||||
import io.element.android.libraries.sessionstorage.api.sessionIdFlow
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
@@ -107,7 +107,7 @@ class DefaultBugReporter(
|
||||
sessionStore.getLatestSession()
|
||||
}?.userId?.let(::UserId)?.domainName
|
||||
setCurrentLogDirectory(logSubfolder)
|
||||
sessionStore.userIdFlow()
|
||||
sessionStore.sessionIdFlow()
|
||||
.map {
|
||||
it?.let(::UserId)?.domainName
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ fun Flow<List<SessionData>>.toUserListFlow(): Flow<List<String>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a flow emitting the userId of the latest session if logged in, null otherwise.
|
||||
* @return a flow emitting the sessionId of the latest session if logged in, null otherwise.
|
||||
*/
|
||||
fun SessionStore.userIdFlow(): Flow<String?> {
|
||||
fun SessionStore.sessionIdFlow(): Flow<String?> {
|
||||
return loggedInStateFlow().map {
|
||||
when (it) {
|
||||
is LoggedInState.LoggedIn -> it.sessionId
|
||||
|
||||
Reference in New Issue
Block a user