diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt new file mode 100644 index 0000000000..c273cc9ce4 --- /dev/null +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Element Creations 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.home.impl.roomlist + +/** + * The banners which can be displayed at the top of the room list. At most one banner is displayed at a time. + */ +internal enum class RoomListBanner { + SetUpRecovery, + RecoveryKeyConfirmation, + FullScreenIntentPermission, + BatteryOptimization, + NewNotificationSound, + SwipeAvatar, +} + +internal fun SecurityBannerState.toRoomListBanner(): RoomListBanner? = when (this) { + SecurityBannerState.SetUpRecovery -> RoomListBanner.SetUpRecovery + SecurityBannerState.RecoveryKeyConfirmation -> RoomListBanner.RecoveryKeyConfirmation + SecurityBannerState.None -> null +} + +/** + * Banner precedence (top-to-bottom): security > full-screen-intent > battery-optimization > + * new-notification-sound > swipe-avatar. At most one renders at a time. + */ +internal fun RoomListContentState.Rooms.toRoomListBanner(): RoomListBanner? { + return securityBannerState.toRoomListBanner() ?: when { + fullScreenIntentPermissionsState.shouldDisplayBanner -> RoomListBanner.FullScreenIntentPermission + batteryOptimizationState.shouldDisplayBanner -> RoomListBanner.BatteryOptimization + showNewNotificationSoundBanner -> RoomListBanner.NewNotificationSound + showSwipeAvatarBanner -> RoomListBanner.SwipeAvatar + else -> null + } +} diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt index f77695399b..6d3d85ab56 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt @@ -61,18 +61,6 @@ enum class SecurityBannerState { RecoveryKeyConfirmation, } -/** - * The banners which can be displayed at the top of the room list. At most one banner is displayed at a time. - */ -internal enum class RoomListBanner { - SetUpRecovery, - RecoveryKeyConfirmation, - FullScreenIntentPermission, - BatteryOptimization, - NewNotificationSound, - SwipeAvatar, -} - @Immutable sealed interface RoomListContentState { data class Skeleton(val count: Int) : RoomListContentState @@ -92,24 +80,3 @@ sealed interface RoomListContentState { val showAllActivity: Boolean, ) : RoomListContentState } - -internal fun SecurityBannerState.toRoomListBanner(): RoomListBanner? = when (this) { - SecurityBannerState.SetUpRecovery -> RoomListBanner.SetUpRecovery - SecurityBannerState.RecoveryKeyConfirmation -> RoomListBanner.RecoveryKeyConfirmation - SecurityBannerState.None -> null -} - -/** - * Banner precedence (top-to-bottom): security > full-screen-intent > battery-optimization > - * new-notification-sound > swipe-avatar. At most one renders at a time. - */ -internal fun RoomListContentState.Rooms.toRoomListBanner(): RoomListBanner? { - return securityBannerState.toRoomListBanner() ?: when { - fullScreenIntentPermissionsState.shouldDisplayBanner -> RoomListBanner.FullScreenIntentPermission - batteryOptimizationState.shouldDisplayBanner -> RoomListBanner.BatteryOptimization - showNewNotificationSoundBanner -> RoomListBanner.NewNotificationSound - showSwipeAvatarBanner -> RoomListBanner.SwipeAvatar - else -> null - } -} -