From 4c462c7e93b77fb28768b18fb08c580e952bb2ac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:29:31 +0000 Subject: [PATCH 01/10] Update wysiwyg to v2.38.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 17f4c7a15f..bf3ae417f1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -46,7 +46,7 @@ coil = "2.7.0" showkase = "1.0.3" appyx = "1.5.1" sqldelight = "2.0.2" -wysiwyg = "2.37.14" +wysiwyg = "2.38.0" telephoto = "0.14.0" # Dependency analysis From 6ea25275ce48e14971962abb4aad5c47fb6d43ed Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 08:31:48 +0000 Subject: [PATCH 02/10] Update dependency io.sentry:sentry-android to v7.20.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 77142d08c0..3965a56320 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -195,7 +195,7 @@ zxing_cpp = "io.github.zxing-cpp:android:2.2.0" # Analytics posthog = "com.posthog:posthog-android:3.10.0" -sentry = "io.sentry:sentry-android:7.19.1" +sentry = "io.sentry:sentry-android:7.20.0" # main branch can be tested replacing the version with main-SNAPSHOT matrix_analytics_events = "com.github.matrix-org:matrix-analytics-events:0.28.0" From f50b87e2373f7d438cbdd5e707ad5e4287bdb7e1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:11:04 +0000 Subject: [PATCH 03/10] Update kotlin --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 77142d08c0..7b234ede76 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,7 @@ test_core = "1.6.1" # Jetbrain datetime = "0.6.1" -serialization_json = "1.7.3" +serialization_json = "1.8.0" #other coil = "2.7.0" @@ -61,7 +61,7 @@ autoservice = "1.1.1" # quality androidx-test-ext-junit = "1.2.1" -kover = "0.9.0" +kover = "0.9.1" [libraries] # Project From d54f836d3fd5586e2104d5047609246143a8e358 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:31:43 +0000 Subject: [PATCH 04/10] Update plugin dependencycheck to v12 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5ca84812c3..5fb5e1e056 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -235,7 +235,7 @@ anvil = { id = "dev.zacsweers.anvil", version.ref = "anvil" } detekt = "io.gitlab.arturbosch.detekt:1.23.7" ktlint = "org.jlleitschuh.gradle.ktlint:12.1.2" dependencygraph = "com.savvasdalkitsis.module-dependency-graph:0.12" -dependencycheck = "org.owasp.dependencycheck:11.1.1" +dependencycheck = "org.owasp.dependencycheck:12.0.0" dependencyanalysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependencyAnalysis" } paparazzi = "app.cash.paparazzi:1.3.5" sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } From 331f6928818ee2be42d4be95c471afa4673ede25 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 14 Jan 2025 12:30:57 +0100 Subject: [PATCH 05/10] fix(coroutine) : make sure to switch coroutine context as rust sdk is not safe to use on main thread. --- .../libraries/matrix/impl/RustMatrixClient.kt | 10 +- .../matrix/impl/room/RustMatrixRoom.kt | 144 ++++++++++-------- .../matrix/impl/sync/RustSyncService.kt | 42 ++--- .../matrix/impl/timeline/RustTimeline.kt | 8 +- 4 files changed, 118 insertions(+), 86 deletions(-) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt index 0b7ae4f407..bd85a7f849 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt @@ -137,7 +137,11 @@ class RustMatrixClient( private val innerRoomListService = innerSyncService.roomListService() - private val rustSyncService = RustSyncService(innerSyncService, sessionCoroutineScope) + private val rustSyncService = RustSyncService( + inner = innerSyncService, + dispatcher = sessionDispatcher, + sessionCoroutineScope = sessionCoroutineScope + ) private val pushersService = RustPushersService( client = innerClient, dispatchers = dispatchers, @@ -283,8 +287,8 @@ class RustMatrixClient( } } - override suspend fun findDM(userId: UserId): RoomId? { - return innerClient.getDmRoom(userId.value)?.use { RoomId(it.id()) } + override suspend fun findDM(userId: UserId): RoomId? = withContext(sessionDispatcher) { + innerClient.getDmRoom(userId.value)?.use { RoomId(it.id()) } } override suspend fun ignoreUser(userId: UserId): Result = withContext(sessionDispatcher) { diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt index bffbba5fef..7217b25dcd 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt @@ -329,7 +329,7 @@ class RustMatrixRoom( } } - override suspend fun updateRoomNotificationSettings(): Result = withContext(coroutineDispatchers.io) { + override suspend fun updateRoomNotificationSettings(): Result = withContext(roomDispatcher) { val currentState = _roomNotificationSettingsStateFlow.value val currentRoomNotificationSettings = currentState.roomNotificationSettings() _roomNotificationSettingsStateFlow.value = MatrixRoomNotificationSettingsState.Pending(prevRoomNotificationSettings = currentRoomNotificationSettings) @@ -345,7 +345,7 @@ class RustMatrixRoom( } } - override suspend fun userRole(userId: UserId): Result = withContext(coroutineDispatchers.io) { + override suspend fun userRole(userId: UserId): Result = withContext(roomDispatcher) { runCatching { RoomMemberMapper.mapRole(innerRoom.suggestedRoleForUser(userId.value)) } @@ -429,56 +429,56 @@ class RustMatrixRoom( } } - override suspend fun canUserInvite(userId: UserId): Result { - return runCatching { + override suspend fun canUserInvite(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserInvite(userId.value) } } - override suspend fun canUserKick(userId: UserId): Result { - return runCatching { + override suspend fun canUserKick(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserKick(userId.value) } } - override suspend fun canUserBan(userId: UserId): Result { - return runCatching { + override suspend fun canUserBan(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserBan(userId.value) } } - override suspend fun canUserRedactOwn(userId: UserId): Result { - return runCatching { + override suspend fun canUserRedactOwn(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserRedactOwn(userId.value) } } - override suspend fun canUserRedactOther(userId: UserId): Result { - return runCatching { + override suspend fun canUserRedactOther(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserRedactOther(userId.value) } } - override suspend fun canUserSendState(userId: UserId, type: StateEventType): Result { - return runCatching { + override suspend fun canUserSendState(userId: UserId, type: StateEventType): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserSendState(userId.value, type.map()) } } - override suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result { - return runCatching { + override suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserSendMessage(userId.value, type.map()) } } - override suspend fun canUserTriggerRoomNotification(userId: UserId): Result { - return runCatching { + override suspend fun canUserTriggerRoomNotification(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserTriggerRoomNotification(userId.value) } } - override suspend fun canUserPinUnpin(userId: UserId): Result { - return runCatching { + override suspend fun canUserPinUnpin(userId: UserId): Result = withContext(roomDispatcher) { + runCatching { innerRoom.canUserPinUnpin(userId.value) } } @@ -676,8 +676,10 @@ class RustMatrixRoom( return liveTimeline.sendVoiceMessage(file, audioInfo, waveform, progressCallback) } - override suspend fun typingNotice(isTyping: Boolean) = runCatching { - innerRoom.typingNotice(isTyping) + override suspend fun typingNotice(isTyping: Boolean) = withContext(roomDispatcher) { + runCatching { + innerRoom.typingNotice(isTyping) + } } override suspend fun generateWidgetWebViewUrl( @@ -685,32 +687,42 @@ class RustMatrixRoom( clientId: String, languageTag: String?, theme: String?, - ) = runCatching { - widgetSettings.generateWidgetWebViewUrl(innerRoom, clientId, languageTag, theme) + ) = withContext(roomDispatcher) { + runCatching { + widgetSettings.generateWidgetWebViewUrl(innerRoom, clientId, languageTag, theme) + } } - override fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result = runCatching { - RustWidgetDriver( - widgetSettings = widgetSettings, - room = innerRoom, - widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider { - override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities { - return getElementCallRequiredPermissions(sessionId.value, deviceId.value) - } - }, - ) + override fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result { + return runCatching { + RustWidgetDriver( + widgetSettings = widgetSettings, + room = innerRoom, + widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider { + override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities { + return getElementCallRequiredPermissions(sessionId.value, deviceId.value) + } + }, + ) + } } - override suspend fun getPermalink(): Result = runCatching { - innerRoom.matrixToPermalink() + override suspend fun getPermalink(): Result = withContext(roomDispatcher) { + runCatching { + innerRoom.matrixToPermalink() + } } - override suspend fun getPermalinkFor(eventId: EventId): Result = runCatching { - innerRoom.matrixToEventPermalink(eventId.value) + override suspend fun getPermalinkFor(eventId: EventId): Result = withContext(roomDispatcher) { + runCatching { + innerRoom.matrixToEventPermalink(eventId.value) + } } - override suspend fun sendCallNotificationIfNeeded(): Result = runCatching { - innerRoom.sendCallNotificationIfNeeded() + override suspend fun sendCallNotificationIfNeeded(): Result = withContext(roomDispatcher) { + runCatching { + innerRoom.sendCallNotificationIfNeeded() + } } override suspend fun setSendQueueEnabled(enabled: Boolean) { @@ -722,35 +734,45 @@ class RustMatrixRoom( } } - override suspend fun saveComposerDraft(composerDraft: ComposerDraft): Result = runCatching { - Timber.d("saveComposerDraft: $composerDraft into $roomId") - innerRoom.saveComposerDraft(composerDraft.into()) + override suspend fun saveComposerDraft(composerDraft: ComposerDraft): Result = withContext(roomDispatcher) { + runCatching { + Timber.d("saveComposerDraft: $composerDraft into $roomId") + innerRoom.saveComposerDraft(composerDraft.into()) + } } - override suspend fun loadComposerDraft(): Result = runCatching { - Timber.d("loadComposerDraft for $roomId") - innerRoom.loadComposerDraft()?.into() + override suspend fun loadComposerDraft(): Result = withContext(roomDispatcher) { + runCatching { + Timber.d("loadComposerDraft for $roomId") + innerRoom.loadComposerDraft()?.into() + } } - override suspend fun clearComposerDraft(): Result = runCatching { - Timber.d("clearComposerDraft for $roomId") - innerRoom.clearComposerDraft() + override suspend fun clearComposerDraft(): Result = withContext(roomDispatcher) { + runCatching { + Timber.d("clearComposerDraft for $roomId") + innerRoom.clearComposerDraft() + } } - override suspend fun ignoreDeviceTrustAndResend(devices: Map>, sendHandle: SendHandle) = runCatching { - innerRoom.ignoreDeviceTrustAndResend( - devices = devices.entries.associate { entry -> - entry.key.value to entry.value.map { it.value } - }, - sendHandle = (sendHandle as RustSendHandle).inner, - ) + override suspend fun ignoreDeviceTrustAndResend(devices: Map>, sendHandle: SendHandle) = withContext(roomDispatcher) { + runCatching { + innerRoom.ignoreDeviceTrustAndResend( + devices = devices.entries.associate { entry -> + entry.key.value to entry.value.map { it.value } + }, + sendHandle = (sendHandle as RustSendHandle).inner, + ) + } } - override suspend fun withdrawVerificationAndResend(userIds: List, sendHandle: SendHandle) = runCatching { - innerRoom.withdrawVerificationAndResend( - userIds = userIds.map { it.value }, - sendHandle = (sendHandle as RustSendHandle).inner, - ) + override suspend fun withdrawVerificationAndResend(userIds: List, sendHandle: SendHandle) = withContext(roomDispatcher) { + runCatching { + innerRoom.withdrawVerificationAndResend( + userIds = userIds.map { it.value }, + sendHandle = (sendHandle as RustSendHandle).inner, + ) + } } private fun createTimeline( diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/RustSyncService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/RustSyncService.kt index 667f571201..dffe6f1b71 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/RustSyncService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/RustSyncService.kt @@ -9,6 +9,7 @@ package io.element.android.libraries.matrix.impl.sync import io.element.android.libraries.matrix.api.sync.SyncService import io.element.android.libraries.matrix.api.sync.SyncState +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.flow.SharingStarted @@ -24,31 +25,36 @@ import java.util.concurrent.atomic.AtomicBoolean import org.matrix.rustcomponents.sdk.SyncService as InnerSyncService class RustSyncService( - private val innerSyncService: InnerSyncService, + private val inner: InnerSyncService, + private val dispatcher: CoroutineDispatcher, sessionCoroutineScope: CoroutineScope ) : SyncService { private val isServiceReady = AtomicBoolean(true) - override suspend fun startSync() = runCatching { - if (!isServiceReady.get()) { - Timber.d("Can't start sync: service is not ready") - return@runCatching + override suspend fun startSync() = withContext(dispatcher) { + runCatching { + if (!isServiceReady.get()) { + Timber.d("Can't start sync: service is not ready") + return@runCatching + } + Timber.i("Start sync") + inner.start() + }.onFailure { + Timber.d("Start sync failed: $it") } - Timber.i("Start sync") - innerSyncService.start() - }.onFailure { - Timber.d("Start sync failed: $it") } - override suspend fun stopSync() = runCatching { - if (!isServiceReady.get()) { - Timber.d("Can't stop sync: service is not ready") - return@runCatching + override suspend fun stopSync() = withContext(dispatcher) { + runCatching { + if (!isServiceReady.get()) { + Timber.d("Can't stop sync: service is not ready") + return@runCatching + } + Timber.i("Stop sync") + inner.stop() + }.onFailure { + Timber.d("Stop sync failed: $it") } - Timber.i("Stop sync") - innerSyncService.stop() - }.onFailure { - Timber.d("Stop sync failed: $it") } suspend fun destroy() = withContext(NonCancellable) { @@ -59,7 +65,7 @@ class RustSyncService( } override val syncState: StateFlow = - innerSyncService.stateFlow() + inner.stateFlow() .map(SyncServiceState::toSyncState) .onEach { state -> Timber.i("Sync state=$state") diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt index 9f5ce3a606..7013b4bb78 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt @@ -158,8 +158,8 @@ class RustTimeline( override val membershipChangeEventReceived: Flow = timelineDiffProcessor.membershipChangeEventReceived - override suspend fun sendReadReceipt(eventId: EventId, receiptType: ReceiptType): Result { - return runCatching { + override suspend fun sendReadReceipt(eventId: EventId, receiptType: ReceiptType): Result = withContext(dispatcher) { + runCatching { inner.sendReadReceipt(receiptType.toRustReceiptType(), eventId.value) } } @@ -590,8 +590,8 @@ class RustTimeline( } } - private suspend fun fetchDetailsForEvent(eventId: EventId): Result { - return runCatching { + private suspend fun fetchDetailsForEvent(eventId: EventId): Result = withContext(dispatcher) { + runCatching { inner.fetchDetailsForEvent(eventId.value) } } From dff29fa270d0322a32a6e6cd0a417b1e7532966e Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 14 Jan 2025 16:12:43 +0100 Subject: [PATCH 06/10] change(design) : introduce Announcement component --- .../designsystem/components/Announcement.kt | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt new file mode 100644 index 0000000000..e47570981f --- /dev/null +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt @@ -0,0 +1,208 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.libraries.designsystem.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement.spacedBy +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.stringResource +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 +import io.element.android.libraries.designsystem.theme.components.Button +import io.element.android.libraries.designsystem.theme.components.ButtonSize +import io.element.android.libraries.designsystem.theme.components.Icon +import io.element.android.libraries.designsystem.theme.components.Surface +import io.element.android.libraries.designsystem.theme.components.Text +import io.element.android.libraries.ui.strings.CommonStrings + +@Composable +fun Announcement( + title: String, + description: String?, + type: AnnouncementType, + modifier: Modifier = Modifier, +) { + when (type) { + is AnnouncementType.Informative -> InformativeAnnouncement( + title = title, + description = description, + isError = type.isError, + modifier = modifier, + ) + is AnnouncementType.Actionable -> ActionableAnnouncement( + title = title, + description = description, + actionText = type.actionText, + onActionClick = type.onActionClick, + onDismissClick = type.onDismissClick, + modifier = modifier, + ) + } +} + +@Immutable +sealed interface AnnouncementType { + data class Informative(val isError: Boolean = false) : AnnouncementType + data class Actionable( + val actionText: String, + val onActionClick: () -> Unit, + val onDismissClick: (() -> Unit)?, + ) : AnnouncementType +} + +@Composable +private fun ActionableAnnouncement( + title: String, + description: String?, + actionText: String, + onActionClick: () -> Unit, + onDismissClick: (() -> Unit)?, + modifier: Modifier = Modifier, +) { + AnnouncementSurface(modifier) { + Column { + TitleAndDescription( + title = title, + description = description, + trailingContent = onDismissClick?.let { + { + Icon( + modifier = Modifier.clickable(onClick = onDismissClick), + imageVector = CompoundIcons.Close(), + contentDescription = stringResource(CommonStrings.action_close) + ) + } + } + ) + Spacer(Modifier.height(16.dp)) + Button( + text = actionText, + size = ButtonSize.Medium, + onClick = onActionClick, + modifier = Modifier.fillMaxWidth(), + ) + } + } +} + +@Composable +private fun InformativeAnnouncement( + title: String, + description: String?, + isError: Boolean, + modifier: Modifier = Modifier, +) { + AnnouncementSurface(modifier = modifier) { + Row { + Icon( + imageVector = if (isError) CompoundIcons.Error() else CompoundIcons.Info(), + tint = if (isError) ElementTheme.colors.iconCriticalPrimary else ElementTheme.colors.iconPrimary, + contentDescription = null, + ) + Spacer(Modifier.width(12.dp)) + TitleAndDescription( + title = title, + description = description, + titleColor = if (isError) ElementTheme.colors.textCriticalPrimary else ElementTheme.colors.textPrimary, + ) + } + } +} + +@Composable +private fun TitleAndDescription( + title: String, + description: String?, + modifier: Modifier = Modifier, + titleColor: Color = ElementTheme.colors.textPrimary, + descriptionColor: Color = ElementTheme.colors.textSecondary, + trailingContent: (@Composable () -> Unit)? = null, +) { + Column(modifier = modifier) { + Row { + Text( + text = title, + style = ElementTheme.typography.fontBodyLgMedium, + color = titleColor, + modifier = Modifier.weight(1f), + ) + if (trailingContent != null) { + Spacer(Modifier.width(12.dp)) + trailingContent() + } + } + if (description != null) { + Spacer(Modifier.height(4.dp)) + Text( + text = description, + style = ElementTheme.typography.fontBodyMdRegular, + color = descriptionColor, + ) + } + } +} + +@Composable +private fun AnnouncementSurface( + modifier: Modifier = Modifier, + content: @Composable () -> Unit, +) { + Surface( + modifier = modifier.fillMaxWidth(), + shape = RoundedCornerShape(size = 12.dp), + color = ElementTheme.colors.bgSubtleSecondary + ) { + Box(modifier = Modifier.padding(16.dp)) { + content() + } + } +} + +@PreviewsDayNight +@Composable +internal fun AnnouncementPreview() = ElementPreview { + Column( + verticalArrangement = spacedBy(16.dp), + modifier = Modifier.padding(16.dp) + ) { + Announcement( + title = "Headline", + description = "Text description goes here.", + type = AnnouncementType.Informative(isError = false), + ) + Announcement( + title = "Headline", + description = "Text description goes here.", + type = AnnouncementType.Informative(isError = true), + ) + Announcement( + title = "Headline", + description = "Text description goes here.", + type = AnnouncementType.Actionable( + actionText = "Label", + onActionClick = {}, + onDismissClick = {}, + ), + ) + } +} From b8c0e5257bf691e74074ac294d51e2f4df62ac37 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 14 Jan 2025 16:13:03 +0100 Subject: [PATCH 07/10] change(design) : replace DialogLikeBannerMolecule by Announcement component --- .../notifications/NotificationSettingsView.kt | 19 ++-- .../roomlist/impl/components/BannerPadding.kt | 17 ++++ .../components/ConfirmRecoveryKeyBanner.kt | 17 ++-- .../FullScreenIntentPermissionBanner.kt | 22 +++-- .../NativeSlidingSyncMigrationBanner.kt | 17 ++-- .../impl/components/RoomListContentView.kt | 10 +- .../impl/components/SetUpRecoveryKeyBanner.kt | 17 ++-- .../molecules/DialogLikeBannerMolecule.kt | 97 ------------------- 8 files changed, 82 insertions(+), 134 deletions(-) create mode 100644 features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/BannerPadding.kt delete mode 100644 libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules/DialogLikeBannerMolecule.kt diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt index d4e1de68fd..d74ed8581c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt @@ -7,6 +7,7 @@ package io.element.android.features.preferences.impl.notifications +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.progressSemantics import androidx.compose.runtime.Composable @@ -20,7 +21,8 @@ import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.features.preferences.impl.R import io.element.android.libraries.androidutils.system.startNotificationSettingsIntent import io.element.android.libraries.architecture.AsyncData -import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule +import io.element.android.libraries.designsystem.components.Announcement +import io.element.android.libraries.designsystem.components.AnnouncementType import io.element.android.libraries.designsystem.components.async.AsyncActionView import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog import io.element.android.libraries.designsystem.components.dialogs.ListOption @@ -132,7 +134,7 @@ private fun NotificationSettingsContentView( PreferenceText( icon = CompoundIcons.VoiceCall(), title = stringResource(id = R.string.full_screen_intent_banner_title), - subtitle = stringResource(R.string.full_screen_intent_banner_message,), + subtitle = stringResource(R.string.full_screen_intent_banner_message), onClick = { state.fullScreenIntentPermissionsState.openFullScreenIntentSettings() } @@ -247,12 +249,17 @@ private fun InvalidNotificationSettingsView( showError: Boolean, onContinueClick: () -> Unit, onDismissError: () -> Unit, + modifier: Modifier = Modifier, ) { - DialogLikeBannerMolecule( + Announcement( title = stringResource(R.string.screen_notification_settings_configuration_mismatch), - content = stringResource(R.string.screen_notification_settings_configuration_mismatch_description), - onSubmitClick = onContinueClick, - onDismissClick = null, + description = stringResource(R.string.screen_notification_settings_configuration_mismatch_description), + type = AnnouncementType.Actionable( + onActionClick = onContinueClick, + actionText = stringResource(CommonStrings.action_continue), + onDismissClick = null, + ), + modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp), ) if (showError) { diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/BannerPadding.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/BannerPadding.kt new file mode 100644 index 0000000000..a609d5dc7d --- /dev/null +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/BannerPadding.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.features.roomlist.impl.components + +import androidx.compose.foundation.layout.padding +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +/** + * Common padding for RoomList banners. + */ +internal fun Modifier.roomListBannerPadding() = padding(horizontal = 16.dp, vertical = 8.dp) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/ConfirmRecoveryKeyBanner.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/ConfirmRecoveryKeyBanner.kt index e84f0696ad..3ae7750fa3 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/ConfirmRecoveryKeyBanner.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/ConfirmRecoveryKeyBanner.kt @@ -11,9 +11,11 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import io.element.android.features.roomlist.impl.R -import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule +import io.element.android.libraries.designsystem.components.Announcement +import io.element.android.libraries.designsystem.components.AnnouncementType import io.element.android.libraries.designsystem.preview.ElementPreview import io.element.android.libraries.designsystem.preview.PreviewsDayNight +import io.element.android.libraries.ui.strings.CommonStrings @Composable internal fun ConfirmRecoveryKeyBanner( @@ -21,12 +23,15 @@ internal fun ConfirmRecoveryKeyBanner( onDismissClick: () -> Unit, modifier: Modifier = Modifier, ) { - DialogLikeBannerMolecule( - modifier = modifier, + Announcement( + modifier = modifier.roomListBannerPadding(), title = stringResource(R.string.confirm_recovery_key_banner_title), - content = stringResource(R.string.confirm_recovery_key_banner_message), - onSubmitClick = onContinueClick, - onDismissClick = onDismissClick, + description = stringResource(R.string.confirm_recovery_key_banner_message), + type = AnnouncementType.Actionable( + actionText = stringResource(CommonStrings.action_continue), + onActionClick = onContinueClick, + onDismissClick = onDismissClick, + ), ) } diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/FullScreenIntentPermissionBanner.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/FullScreenIntentPermissionBanner.kt index 0ee2d22291..7e84a26ab3 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/FullScreenIntentPermissionBanner.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/FullScreenIntentPermissionBanner.kt @@ -8,21 +8,31 @@ package io.element.android.features.roomlist.impl.components import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import io.element.android.features.roomlist.impl.R -import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule +import io.element.android.libraries.designsystem.components.Announcement +import io.element.android.libraries.designsystem.components.AnnouncementType import io.element.android.libraries.designsystem.preview.ElementPreview import io.element.android.libraries.designsystem.preview.PreviewsDayNight import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState import io.element.android.libraries.fullscreenintent.api.aFullScreenIntentPermissionsState +import io.element.android.libraries.ui.strings.CommonStrings @Composable -fun FullScreenIntentPermissionBanner(state: FullScreenIntentPermissionsState) { - DialogLikeBannerMolecule( +fun FullScreenIntentPermissionBanner( + state: FullScreenIntentPermissionsState, + modifier: Modifier = Modifier +) { + Announcement( title = stringResource(R.string.full_screen_intent_banner_title), - content = stringResource(R.string.full_screen_intent_banner_message), - onDismissClick = state.dismissFullScreenIntentBanner, - onSubmitClick = state.openFullScreenIntentSettings, + description = stringResource(R.string.full_screen_intent_banner_message), + type = AnnouncementType.Actionable( + actionText = stringResource(CommonStrings.action_continue), + onDismissClick = state.dismissFullScreenIntentBanner, + onActionClick = state.openFullScreenIntentSettings, + ), + modifier = modifier.roomListBannerPadding(), ) } diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/NativeSlidingSyncMigrationBanner.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/NativeSlidingSyncMigrationBanner.kt index 73672769e7..132f0a0dc9 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/NativeSlidingSyncMigrationBanner.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/NativeSlidingSyncMigrationBanner.kt @@ -11,7 +11,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import io.element.android.features.roomlist.impl.R -import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule +import io.element.android.libraries.designsystem.components.Announcement +import io.element.android.libraries.designsystem.components.AnnouncementType import io.element.android.libraries.designsystem.preview.ElementPreview import io.element.android.libraries.designsystem.preview.PreviewsDayNight @@ -21,13 +22,15 @@ internal fun NativeSlidingSyncMigrationBanner( onDismissClick: () -> Unit, modifier: Modifier = Modifier, ) { - DialogLikeBannerMolecule( - modifier = modifier, + Announcement( + modifier = modifier.roomListBannerPadding(), title = stringResource(R.string.banner_migrate_to_native_sliding_sync_title), - content = stringResource(R.string.banner_migrate_to_native_sliding_sync_description), - actionText = stringResource(R.string.banner_migrate_to_native_sliding_sync_action), - onSubmitClick = onContinueClick, - onDismissClick = onDismissClick, + description = stringResource(R.string.banner_migrate_to_native_sliding_sync_description), + type = AnnouncementType.Actionable( + actionText = stringResource(R.string.banner_migrate_to_native_sliding_sync_action), + onActionClick = onContinueClick, + onDismissClick = onDismissClick, + ) ) } diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt index 2e278eed57..f719a9c9c9 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt @@ -139,13 +139,13 @@ private fun EmptyView( SecurityBannerState.SetUpRecovery -> { SetUpRecoveryKeyBanner( onContinueClick = onSetUpRecoveryClick, - onDismissClick = { eventSink(RoomListEvents.DismissBanner) } + onDismissClick = { eventSink(RoomListEvents.DismissBanner) }, ) } SecurityBannerState.RecoveryKeyConfirmation -> { ConfirmRecoveryKeyBanner( onContinueClick = onConfirmRecoveryKeyClick, - onDismissClick = { eventSink(RoomListEvents.DismissBanner) } + onDismissClick = { eventSink(RoomListEvents.DismissBanner) }, ) } else -> Unit @@ -217,7 +217,7 @@ private fun RoomsViewList( item { SetUpRecoveryKeyBanner( onContinueClick = onSetUpRecoveryClick, - onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) } + onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }, ) } } @@ -225,7 +225,7 @@ private fun RoomsViewList( item { ConfirmRecoveryKeyBanner( onContinueClick = onConfirmRecoveryKeyClick, - onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) } + onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }, ) } } @@ -233,7 +233,7 @@ private fun RoomsViewList( item { NativeSlidingSyncMigrationBanner( onContinueClick = onMigrateToNativeSlidingSyncClick, - onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) } + onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }, ) } } diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/SetUpRecoveryKeyBanner.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/SetUpRecoveryKeyBanner.kt index 4831d94a6e..e1d251de8b 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/SetUpRecoveryKeyBanner.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/SetUpRecoveryKeyBanner.kt @@ -11,7 +11,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import io.element.android.features.roomlist.impl.R -import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule +import io.element.android.libraries.designsystem.components.Announcement +import io.element.android.libraries.designsystem.components.AnnouncementType import io.element.android.libraries.designsystem.preview.ElementPreview import io.element.android.libraries.designsystem.preview.PreviewsDayNight @@ -21,13 +22,15 @@ internal fun SetUpRecoveryKeyBanner( onDismissClick: () -> Unit, modifier: Modifier = Modifier, ) { - DialogLikeBannerMolecule( - modifier = modifier, + Announcement( + modifier = modifier.roomListBannerPadding(), title = stringResource(R.string.banner_set_up_recovery_title), - content = stringResource(R.string.banner_set_up_recovery_content), - actionText = stringResource(R.string.banner_set_up_recovery_submit), - onSubmitClick = onContinueClick, - onDismissClick = onDismissClick, + description = stringResource(R.string.banner_set_up_recovery_content), + type = AnnouncementType.Actionable( + actionText = stringResource(R.string.banner_set_up_recovery_submit), + onActionClick = onContinueClick, + onDismissClick = onDismissClick, + ), ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules/DialogLikeBannerMolecule.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules/DialogLikeBannerMolecule.kt deleted file mode 100644 index 5be47d3256..0000000000 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/molecules/DialogLikeBannerMolecule.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2023, 2024 New Vector Ltd. - * - * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial - * Please see LICENSE files in the repository root for full details. - */ - -package io.element.android.libraries.designsystem.atomic.molecules - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign -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 -import io.element.android.libraries.designsystem.theme.components.Button -import io.element.android.libraries.designsystem.theme.components.ButtonSize -import io.element.android.libraries.designsystem.theme.components.Icon -import io.element.android.libraries.designsystem.theme.components.Surface -import io.element.android.libraries.designsystem.theme.components.Text -import io.element.android.libraries.ui.strings.CommonStrings - -@Composable -fun DialogLikeBannerMolecule( - title: String, - content: String, - onSubmitClick: () -> Unit, - onDismissClick: (() -> Unit)?, - modifier: Modifier = Modifier, - actionText: String = stringResource(CommonStrings.action_continue), -) { - Box(modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp)) { - Surface( - Modifier.fillMaxWidth(), - shape = MaterialTheme.shapes.small, - color = MaterialTheme.colorScheme.surfaceVariant - ) { - Column( - Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 12.dp) - ) { - Row { - Text( - text = title, - modifier = Modifier.weight(1f), - style = ElementTheme.typography.fontBodyLgMedium, - color = MaterialTheme.colorScheme.primary, - textAlign = TextAlign.Start, - ) - if (onDismissClick != null) { - Icon( - modifier = Modifier.clickable(onClick = onDismissClick), - imageVector = CompoundIcons.Close(), - contentDescription = stringResource(CommonStrings.action_close) - ) - } - } - Spacer(modifier = Modifier.height(4.dp)) - Text( - text = content, - style = ElementTheme.typography.fontBodyMdRegular, - ) - Spacer(modifier = Modifier.height(12.dp)) - Button( - text = actionText, - size = ButtonSize.Medium, - modifier = Modifier.fillMaxWidth(), - onClick = onSubmitClick, - ) - } - } - } -} - -@PreviewsDayNight -@Composable -internal fun DialogLikeBannerMoleculePreview() = ElementPreview { - DialogLikeBannerMolecule( - title = "Title", - content = "Content", - onSubmitClick = {}, - onDismissClick = {} - ) -} From d183e9f4b31770f9a9695a4a80897ffa00cf3b58 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Tue, 14 Jan 2025 15:47:56 +0000 Subject: [PATCH 08/10] Update screenshots --- ....impl.notifications_NotificationSettingsView_Day_10_en.png | 4 ++-- ...s.impl.notifications_NotificationSettingsView_Day_9_en.png | 4 ++-- ...mpl.notifications_NotificationSettingsView_Night_10_en.png | 4 ++-- ...impl.notifications_NotificationSettingsView_Night_9_en.png | 4 ++-- ...list.impl.components_ConfirmRecoveryKeyBanner_Day_0_en.png | 4 ++-- ...st.impl.components_ConfirmRecoveryKeyBanner_Night_0_en.png | 4 ++-- ...l.components_FullScreenIntentPermissionBanner_Day_0_en.png | 4 ++-- ...components_FullScreenIntentPermissionBanner_Night_0_en.png | 4 ++-- ...l.components_NativeSlidingSyncMigrationBanner_Day_0_en.png | 4 ++-- ...components_NativeSlidingSyncMigrationBanner_Night_0_en.png | 4 ++-- ....roomlist.impl.components_RoomListContentView_Day_4_en.png | 4 ++-- ....roomlist.impl.components_RoomListContentView_Day_5_en.png | 4 ++-- ...oomlist.impl.components_RoomListContentView_Night_4_en.png | 4 ++-- ...oomlist.impl.components_RoomListContentView_Night_5_en.png | 4 ++-- ...omlist.impl.components_SetUpRecoveryKeyBanner_Day_0_en.png | 4 ++-- ...list.impl.components_SetUpRecoveryKeyBanner_Night_0_en.png | 4 ++-- .../images/features.roomlist.impl_RoomListView_Day_10_en.png | 4 ++-- .../images/features.roomlist.impl_RoomListView_Day_6_en.png | 4 ++-- .../features.roomlist.impl_RoomListView_Night_10_en.png | 4 ++-- .../images/features.roomlist.impl_RoomListView_Night_6_en.png | 4 ++-- ...tem.atomic.molecules_DialogLikeBannerMolecule_Day_0_en.png | 3 --- ...m.atomic.molecules_DialogLikeBannerMolecule_Night_0_en.png | 3 --- ...ibraries.designsystem.components_Announcement_Day_0_en.png | 3 +++ ...raries.designsystem.components_Announcement_Night_0_en.png | 3 +++ 24 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Day_0_en.png delete mode 100644 tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Night_0_en.png create mode 100644 tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Day_0_en.png create mode 100644 tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Night_0_en.png diff --git a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_10_en.png b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_10_en.png index 0af0869507..c410722f8e 100644 --- a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_10_en.png +++ b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_10_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65ad692c5886f2b6b7ff4a092f76f78aa1e2399a20bc868338f16e909d005e48 -size 43300 +oid sha256:16d1a40f1236f2b0070c05851cfb5f1e73e420361d62aafb8ac5776e20b94db4 +size 42127 diff --git a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_9_en.png b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_9_en.png index 2ca82f8ba6..3c0f9ab6ba 100644 --- a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_9_en.png +++ b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Day_9_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a73919f6f52477978e6344b25bc5a53a76c1301847dc6feae60412991c4fb017 -size 44694 +oid sha256:f96978e1ea1f0ccf62d977e5d41e7036523304b6b42b27b82281756fb5546b39 +size 45057 diff --git a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_10_en.png b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_10_en.png index 78a6b91865..5c76e11e08 100644 --- a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_10_en.png +++ b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_10_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e63be8118802e41f0ab0c292da98bd9b9c58454a67b45f0e61ab5493ff81e138 -size 41085 +oid sha256:8dd44e2127936e2e01d99933a2f18e50ca760f614f6a3e1c3162e3387d4931ee +size 39759 diff --git a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_9_en.png b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_9_en.png index b616239ad0..43ceee5310 100644 --- a/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_9_en.png +++ b/tests/uitests/src/test/snapshots/images/features.preferences.impl.notifications_NotificationSettingsView_Night_9_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55a69297fbe88c14e96a0c1c1f283fbd51b8ac8f172e844ea6965e2ce5dda5d4 -size 42314 +oid sha256:4f22b7825bfa438f55514a3d09696de34450c16f9d4481c4892be9c8dcb45191 +size 42486 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Day_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Day_0_en.png index 91b2b38a0d..a2442e5378 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7a0cd7a14b159d7833d5bb6e24941a19b8b4cfcf3f644f0427815ae0b5c2ac7 -size 25903 +oid sha256:608bc04aa68ecc8842ad896b6aae593b7c0d0c8874b6a7ba41c51655ee1420dc +size 26143 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Night_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Night_0_en.png index 1548f1aa6a..98f8b84e56 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_ConfirmRecoveryKeyBanner_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6d6997626425814ca7bd8a222db596598b37850eaa5f5dd410ea0acc294d66f -size 24896 +oid sha256:75056895683a4ac0c72a1a7b02715b613cbbc6cb8f2af6ef8aff0892d9fbc0fc +size 25034 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Day_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Day_0_en.png index 5763c30434..02696591e3 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2725f52055cb30320d4233630ae4d5f6eeafd1849e6d05c7c82f70c2917e0fe2 -size 29619 +oid sha256:8c54f8490dde1d413eb8fd0dd0f15c059fe78b7a88826bce3be3e6d32890f210 +size 29784 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Night_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Night_0_en.png index 2531d678da..e72f962731 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_FullScreenIntentPermissionBanner_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04f6f95aed2ea83db78068c321b82a84e9c12b2b1f343461d53551cc752ddc2f -size 28969 +oid sha256:a56dc221bfdd24f17d7a1ef5ebbf6c0702f446c2959ac813cec7f5dc1aaea2d5 +size 29138 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Day_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Day_0_en.png index b79a75f1de..575c6f033d 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89827f64e3999f5310926ba3846d76c7f67ac463696bf45d801705dcd1565683 -size 36576 +oid sha256:bd29991ad9e550e5f1e997bffd89bd26d68a97a11213819e6f646c594deb0a32 +size 37054 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Night_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Night_0_en.png index 920833b31d..c34aca9a8c 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_NativeSlidingSyncMigrationBanner_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e94f093da8e30f0aa7110c09d0cee380882b0df22ab38f3b89f0cfe220452b81 -size 35461 +oid sha256:d0abbd15a76d2b3b6a4d66e2ed7df83f1cff94ca03c38b7b2e4ca1e4075229ce +size 35731 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png index bd037bb9ec..95d69eece5 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d124a4ee6f34031b0d122330c6c84b467be4a3ff363fa01c36e07db092dac1c4 -size 46785 +oid sha256:9b00197e010e15b647faba1d6db9cf7e8a1bf7177814e25b07d7207554810107 +size 47084 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png index 717a443891..333bc47ff9 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5574716fab5b8e24fb9d4289f1ca259718bd45a93130588c0f08687e7cf73267 -size 73041 +oid sha256:e1f630cfee64876a7143dff8720de4166248607d2c1247c857ed35290d08ab07 +size 73216 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png index 7f312a37af..3728c0cf7b 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d810f71b03757c41a70a8a06ab2b60755b4fc42a00f81f4e6a99d6a63d6bf13 -size 45276 +oid sha256:c20373e670c4066fef2ca3980ef3d4080a34992a8735bef9a3a87ea095309852 +size 45540 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png index a0726477df..d6d3773dd5 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:84b3f2c25e6a8956e305d279f6a77cd7d8aa1b35715f2c2e975d772e0dc56682 -size 71833 +oid sha256:a8dfdf6bf277bee38b0e63dc4da4c28c7cff394419486681c4ddf8cff20bfb34 +size 71739 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Day_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Day_0_en.png index 0dedb2f15f..c72d72b854 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70d5cdbd0b5944106aef135ee7865838f06faee1fbfe3c94d46c8c048dcdbc58 -size 32440 +oid sha256:17923c7b4c89f8c349710517e96764802ed73f8faba219a87b158812c5dc3c82 +size 32754 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Night_0_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Night_0_en.png index 86b654635d..9376f2ab24 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_SetUpRecoveryKeyBanner_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75c42e75b758b877cf6d2d805976a1ccbd902399e77de6539e4e4e57db532409 -size 31319 +oid sha256:7b1e2c1996dc3b1bb7b7583f62c386baa10f177d8863ed36635ac8214b721324 +size 31589 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_10_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_10_en.png index 139048f09d..e7e953fd68 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_10_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_10_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7359635c38513c10f53126ac545fd08ccfba47c5221f4daf0bb8b74286260e0 -size 107309 +oid sha256:edb52d5fc252ee719f6aec12faf98b8976eb9a61992dba510c06386999975ed2 +size 105988 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_6_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_6_en.png index 0591450ac9..96cd13c035 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_6_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Day_6_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:008877f559e22bf08b70f0b3c5dc0d65ccbcb0cd0a75b61620f65ae076fbc6a3 -size 101728 +oid sha256:85925c39a59d3ceca4da5234084a3218a33670a9e3fbd3121ef601e06fb93297 +size 100367 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_10_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_10_en.png index 917a2cad98..3bb6183058 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_10_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_10_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6f8312ca8182e8d5b106cb7e9023a9a577571054770bd02b7d2f08896127a08 -size 113159 +oid sha256:1ee1b7d094db4cd00af34d1ef79c6e71ed61cec585612c538a0bc870c64b9966 +size 111814 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_6_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_6_en.png index eed0d061ec..3543bb4fb2 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_6_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl_RoomListView_Night_6_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c2963502d9de945d1555d29dfe4229303043c9271de080242fa8d6b1efa4bcc -size 107186 +oid sha256:49097acd61396b5190aa1820c61d826b04738dd56acb4cdfb5df5b04c486e961 +size 106227 diff --git a/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Day_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Day_0_en.png deleted file mode 100644 index 9fdd5b42c6..0000000000 --- a/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Day_0_en.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:35ff9d95c3d01ca74f2792ae4b116946537467be54fa40cea473ef089048a571 -size 10043 diff --git a/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Night_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Night_0_en.png deleted file mode 100644 index 4590d1dbe3..0000000000 --- a/tests/uitests/src/test/snapshots/images/libraries.designsystem.atomic.molecules_DialogLikeBannerMolecule_Night_0_en.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e8855bd1114f0aab03cfea1f495493e43e3680f954209944c1e6718160bdfac -size 9598 diff --git a/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Day_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Day_0_en.png new file mode 100644 index 0000000000..343694057f --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Day_0_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:297a71fec7335294de0cdd9100e64454102711ff76e1df7a5f1e32e719310ad4 +size 27062 diff --git a/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Night_0_en.png b/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Night_0_en.png new file mode 100644 index 0000000000..87012bc30e --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/libraries.designsystem.components_Announcement_Night_0_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c986e1494b1c09606b12cf68270c54bda48034caea60dd911cac6cd976f4dc5 +size 26082 From a74a62c09027af259cedd06336967e98d6b8d1a3 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Wed, 15 Jan 2025 10:43:26 +0100 Subject: [PATCH 09/10] Remove or replace unnecessary `BackHandler` calls (#4148) * Remove/replace `BackHandler` calls: - For `UserProfileView`, remove the redundant `BackHandler` -> `navigateUp()` call. - For `SetupBiometricView`, remove the `enabled = true` parameter, as this is the default value. --- .../impl/setup/biometric/SetupBiometricView.kt | 2 +- .../qrcode/confirmation/QrCodeConfirmationView.kt | 5 ++--- .../impl/screens/qrcode/error/QrCodeErrorView.kt | 6 ++---- .../features/userprofile/shared/UserProfileView.kt | 2 -- .../features/userprofile/UserProfileViewTest.kt | 11 ----------- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/biometric/SetupBiometricView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/biometric/SetupBiometricView.kt index e565dc78fe..761d48ec38 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/biometric/SetupBiometricView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/setup/biometric/SetupBiometricView.kt @@ -31,7 +31,7 @@ fun SetupBiometricView( state: SetupBiometricState, modifier: Modifier = Modifier, ) { - BackHandler(true) { + BackHandler { state.eventSink(SetupBiometricEvents.UsePin) } HeaderFooterPage( diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/confirmation/QrCodeConfirmationView.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/confirmation/QrCodeConfirmationView.kt index 9b6da699d1..99bb11662e 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/confirmation/QrCodeConfirmationView.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/confirmation/QrCodeConfirmationView.kt @@ -45,9 +45,8 @@ fun QrCodeConfirmationView( onCancel: () -> Unit, modifier: Modifier = Modifier, ) { - BackHandler { - onCancel() - } + BackHandler(onBack = onCancel) + val icon = when (step) { is QrCodeConfirmationStep.DisplayCheckCode -> CompoundIcons.Computer() is QrCodeConfirmationStep.DisplayVerificationCode -> CompoundIcons.LockSolid() diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/error/QrCodeErrorView.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/error/QrCodeErrorView.kt index 26ba62c81c..6f3731bd75 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/error/QrCodeErrorView.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/error/QrCodeErrorView.kt @@ -45,16 +45,14 @@ fun QrCodeErrorView( onRetry: () -> Unit, modifier: Modifier = Modifier, ) { - BackHandler { - onRetry() - } + BackHandler(onBack = onRetry) FlowStepPage( modifier = modifier, iconStyle = BigIcon.Style.AlertSolid, title = titleText(errorScreenType, appName), subTitle = subtitleText(errorScreenType, appName), content = { Content(errorScreenType) }, - buttons = { Buttons(onRetry) } + buttons = { Buttons(onRetry) }, ) } diff --git a/features/userprofile/shared/src/main/kotlin/io/element/android/features/userprofile/shared/UserProfileView.kt b/features/userprofile/shared/src/main/kotlin/io/element/android/features/userprofile/shared/UserProfileView.kt index 93d93043b8..6fb3e5ccb7 100644 --- a/features/userprofile/shared/src/main/kotlin/io/element/android/features/userprofile/shared/UserProfileView.kt +++ b/features/userprofile/shared/src/main/kotlin/io/element/android/features/userprofile/shared/UserProfileView.kt @@ -7,7 +7,6 @@ package io.element.android.features.userprofile.shared -import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.consumeWindowInsets @@ -51,7 +50,6 @@ fun UserProfileView( openAvatarPreview: (username: String, url: String) -> Unit, modifier: Modifier = Modifier, ) { - BackHandler { goBack() } Scaffold( modifier = modifier, topBar = { diff --git a/features/userprofile/shared/src/test/kotlin/io/element/android/features/userprofile/UserProfileViewTest.kt b/features/userprofile/shared/src/test/kotlin/io/element/android/features/userprofile/UserProfileViewTest.kt index db444b13a8..6c81acd00a 100644 --- a/features/userprofile/shared/src/test/kotlin/io/element/android/features/userprofile/UserProfileViewTest.kt +++ b/features/userprofile/shared/src/test/kotlin/io/element/android/features/userprofile/UserProfileViewTest.kt @@ -34,7 +34,6 @@ import io.element.android.tests.testutils.ensureCalledOnce import io.element.android.tests.testutils.ensureCalledOnceWithParam import io.element.android.tests.testutils.ensureCalledOnceWithTwoParams import io.element.android.tests.testutils.pressBack -import io.element.android.tests.testutils.pressBackKey import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.Test @@ -46,16 +45,6 @@ import org.robolectric.annotation.Config class UserProfileViewTest { @get:Rule val rule = createAndroidComposeRule() - @Test - fun `on back key press - the expected callback is called`() = runTest { - ensureCalledOnce { callback -> - rule.setUserProfileView( - goBack = callback, - ) - rule.pressBackKey() - } - } - @Test fun `on back button click - the expected callback is called`() = runTest { ensureCalledOnce { callback -> From 24a1b31df5b252028dc7d0724694d3915c66fd8a Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 15 Jan 2025 11:17:25 +0100 Subject: [PATCH 10/10] change(design) : Announcement clean up. --- .../libraries/designsystem/components/Announcement.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt index e47570981f..ee0a13466e 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Announcement.kt @@ -35,6 +35,9 @@ import io.element.android.libraries.designsystem.theme.components.Surface import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.ui.strings.CommonStrings +/** + * Announcement component following design system https://www.figma.com/design/G1xy0HDZKJf5TCRFmKb5d5/Compound-Android-Components?node-id=2002-2154. + */ @Composable fun Announcement( title: String, @@ -46,7 +49,7 @@ fun Announcement( is AnnouncementType.Informative -> InformativeAnnouncement( title = title, description = description, - isError = type.isError, + isError = type.isCritical, modifier = modifier, ) is AnnouncementType.Actionable -> ActionableAnnouncement( @@ -62,7 +65,7 @@ fun Announcement( @Immutable sealed interface AnnouncementType { - data class Informative(val isError: Boolean = false) : AnnouncementType + data class Informative(val isCritical: Boolean = false) : AnnouncementType data class Actionable( val actionText: String, val onActionClick: () -> Unit, @@ -188,12 +191,12 @@ internal fun AnnouncementPreview() = ElementPreview { Announcement( title = "Headline", description = "Text description goes here.", - type = AnnouncementType.Informative(isError = false), + type = AnnouncementType.Informative(isCritical = false), ) Announcement( title = "Headline", description = "Text description goes here.", - type = AnnouncementType.Informative(isError = true), + type = AnnouncementType.Informative(isCritical = true), ) Announcement( title = "Headline",