Cleanup element call and UI (#4641)

* Use ElementTheme.colors.bgCanvasDefault instead of MaterialTheme.colorScheme.background

Even if the value is the same, we should use color from ElementTheme.

* Remove background management of ElementCallActivity. It does not work as expected and also changing theme during a call would require to load the url again with the new theme.

* Do not use isSystemInDarkTheme() directly.

* Use bgSubtleSecondary for background color of Preview.

* Use default colors for Preview.

* Fix copy paste issue.

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
Benoit Marty 2025-04-25 17:30:54 +02:00 committed by GitHub
parent b636c69843
commit f6fe5fda35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 12 additions and 38 deletions

View file

@ -10,7 +10,6 @@ package io.element.android.features.call.impl.ui
import android.Manifest
import android.app.PictureInPictureParams
import android.content.Intent
import android.content.res.Configuration
import android.media.AudioAttributes
import android.media.AudioFocusRequest
import android.media.AudioManager
@ -78,7 +77,6 @@ class ElementCallActivity :
private val requestPermissionsLauncher = registerPermissionResultLauncher()
private var isDarkMode = false
private val webViewTarget = mutableStateOf<CallType?>(null)
private var eventSink: ((CallScreenEvents) -> Unit)? = null
@ -102,10 +100,6 @@ class ElementCallActivity :
return
}
if (savedInstanceState == null) {
updateUiMode(resources.configuration)
}
pictureInPicturePresenter.setPipView(this)
audioManager = getSystemService(AUDIO_SERVICE) as AudioManager
@ -174,11 +168,6 @@ class ElementCallActivity :
}
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
updateUiMode(newConfig)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setCallType(intent)
@ -283,19 +272,6 @@ class ElementCallActivity :
}
}
private fun updateUiMode(configuration: Configuration) {
val prevDarkMode = isDarkMode
val currentNightMode = configuration.uiMode and Configuration.UI_MODE_NIGHT_YES
isDarkMode = currentNightMode != 0
if (prevDarkMode != isDarkMode) {
if (isDarkMode) {
window.setBackgroundDrawableResource(android.R.drawable.screen_background_dark)
} else {
window.setBackgroundDrawableResource(android.R.drawable.screen_background_light)
}
}
}
@RequiresApi(Build.VERSION_CODES.O)
override fun setPipParams() {
setPictureInPictureParams(getPictureInPictureParams())

View file

@ -49,8 +49,8 @@ fun AdvancedSettingsView(
title = stringResource(id = CommonStrings.common_appearance),
selectedOption = state.theme,
options = ThemeOption.entries.toPersistentList(),
onSelectOption = { logLevel ->
state.eventSink(AdvancedSettingsEvents.SetTheme(logLevel))
onSelectOption = { themeOption ->
state.eventSink(AdvancedSettingsEvents.SetTheme(themeOption))
}
)
ListItem(

View file

@ -10,7 +10,6 @@ package io.element.android.libraries.designsystem.atomic.atoms
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
@ -38,7 +37,7 @@ fun ElementLogoAtom(
size: ElementLogoAtomSize,
modifier: Modifier = Modifier,
useBlurredShadow: Boolean = canUseBlurMaskFilter(),
darkTheme: Boolean = isSystemInDarkTheme(),
darkTheme: Boolean = ElementTheme.isLightTheme.not(),
) {
val blur = if (darkTheme) 160.dp else 24.dp
val shadowColor = if (darkTheme) size.shadowColorDark else size.shadowColorLight

View file

@ -8,7 +8,6 @@
package io.element.android.libraries.designsystem.atomic.molecules
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -20,6 +19,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
@ -62,7 +62,7 @@ fun InfoListItemMolecule(
@Composable
internal fun InfoListItemMoleculePreview() {
ElementPreview {
val color = if (isSystemInDarkTheme()) Color.DarkGray else Color.LightGray
val color = ElementTheme.colors.bgSubtleSecondary
Column(
modifier = Modifier.padding(10.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),

View file

@ -111,7 +111,6 @@ internal fun InfoListOrganismPreview() = ElementPreview {
InfoListItem(message = "A bottom item"),
)
InfoListOrganism(
items,
backgroundColor = ElementTheme.materialColors.surfaceVariant,
items = items,
)
}

View file

@ -10,12 +10,12 @@ package io.element.android.libraries.designsystem.theme.components
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.FabPosition
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import io.element.android.compound.theme.ElementTheme
@Composable
fun Scaffold(
@ -25,7 +25,7 @@ fun Scaffold(
snackbarHost: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
containerColor: Color = MaterialTheme.colorScheme.background,
containerColor: Color = ElementTheme.colors.bgCanvasDefault,
contentColor: Color = contentColorFor(containerColor),
contentWindowInsets: WindowInsets = ScaffoldDefaults.contentWindowInsets,
content: @Composable (PaddingValues) -> Unit

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0a1ad0dcf6187838d37d7a6f9362e6fed44af4687b0494404a5343bc2de24723
size 17311
oid sha256:d4e6027ed8a8c11bc294add70bb67986fc52c70a51a3410e35f6bab2a8a71a9a
size 17211

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8dfb1d166afbd78aa6807be751cd98cb4f5f704dafa46a7b9c98e9376c9f7f1c
size 16678
oid sha256:7201f6fb1368435a944b07a557a595509afa01d70cafa9ec0f4d8ff46db95482
size 16521