Update icon shown for world_readable rooms (#6111)
* Update icon shown for world_readable rooms Followup to #6090: having discussed this in the team, we want to show a different icon (with different text) for rooms where the history_visibility is `world_readable` rather than `shared`. * delint * Update screenshots --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
parent
f579a015ac
commit
8ed69c03d2
8 changed files with 75 additions and 21 deletions
|
|
@ -210,10 +210,7 @@ class MessagesPresenter(
|
||||||
// * History sharing is enabled,
|
// * History sharing is enabled,
|
||||||
// * The room is encrypted, and:
|
// * The room is encrypted, and:
|
||||||
// * The room's history_visibility allows future users to see content.
|
// * The room's history_visibility allows future users to see content.
|
||||||
val showSharedHistoryIcon = isKeyShareOnInviteEnabled &&
|
val topBarSharedHistoryIcon = if (isKeyShareOnInviteEnabled) roomInfo.sharedHistoryIcon() else SharedHistoryIcon.NONE
|
||||||
roomInfo.isEncrypted == true &&
|
|
||||||
(roomInfo.historyVisibility == RoomHistoryVisibility.Shared ||
|
|
||||||
roomInfo.historyVisibility == RoomHistoryVisibility.WorldReadable)
|
|
||||||
|
|
||||||
LifecycleResumeEffect(dmRoomMember, roomInfo.isEncrypted) {
|
LifecycleResumeEffect(dmRoomMember, roomInfo.isEncrypted) {
|
||||||
if (roomInfo.isEncrypted == true) {
|
if (roomInfo.isEncrypted == true) {
|
||||||
|
|
@ -297,12 +294,24 @@ class MessagesPresenter(
|
||||||
pinnedMessagesBannerState = pinnedMessagesBannerState,
|
pinnedMessagesBannerState = pinnedMessagesBannerState,
|
||||||
dmUserVerificationState = dmUserVerificationState,
|
dmUserVerificationState = dmUserVerificationState,
|
||||||
roomMemberModerationState = roomMemberModerationState,
|
roomMemberModerationState = roomMemberModerationState,
|
||||||
showSharedHistoryIcon = showSharedHistoryIcon,
|
topBarSharedHistoryIcon = topBarSharedHistoryIcon,
|
||||||
successorRoom = roomInfo.successorRoom,
|
successorRoom = roomInfo.successorRoom,
|
||||||
eventSink = ::handleEvent,
|
eventSink = ::handleEvent,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun RoomInfo.sharedHistoryIcon(): SharedHistoryIcon {
|
||||||
|
if (isEncrypted == true) {
|
||||||
|
if (historyVisibility == RoomHistoryVisibility.Shared) {
|
||||||
|
return SharedHistoryIcon.SHARED
|
||||||
|
} else if (historyVisibility == RoomHistoryVisibility.WorldReadable) {
|
||||||
|
return SharedHistoryIcon.WORLD_READABLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SharedHistoryIcon.NONE
|
||||||
|
}
|
||||||
|
|
||||||
private fun RoomInfo.avatarData(): AvatarData {
|
private fun RoomInfo.avatarData(): AvatarData {
|
||||||
return AvatarData(
|
return AvatarData(
|
||||||
id = id.value,
|
id = id.value,
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,22 @@ data class MessagesState(
|
||||||
val pinnedMessagesBannerState: PinnedMessagesBannerState,
|
val pinnedMessagesBannerState: PinnedMessagesBannerState,
|
||||||
val dmUserVerificationState: IdentityState?,
|
val dmUserVerificationState: IdentityState?,
|
||||||
val roomMemberModerationState: RoomMemberModerationState,
|
val roomMemberModerationState: RoomMemberModerationState,
|
||||||
/** Should the top bar include the "history" icon? */
|
/** Type of "shared history" icon to show in the top bar. */
|
||||||
val showSharedHistoryIcon: Boolean,
|
val topBarSharedHistoryIcon: SharedHistoryIcon,
|
||||||
val successorRoom: SuccessorRoom?,
|
val successorRoom: SuccessorRoom?,
|
||||||
val eventSink: (MessagesEvent) -> Unit
|
val eventSink: (MessagesEvent) -> Unit
|
||||||
) {
|
) {
|
||||||
val isTombstoned = successorRoom != null
|
val isTombstoned = successorRoom != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Type of "shared history" icon to show in the top bar. */
|
||||||
|
enum class SharedHistoryIcon {
|
||||||
|
/** Show no icon at all. */
|
||||||
|
NONE,
|
||||||
|
|
||||||
|
/** history_visibility: shared. */
|
||||||
|
SHARED,
|
||||||
|
|
||||||
|
/** history_visibility: world_readable. */
|
||||||
|
WORLD_READABLE
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ fun aMessagesState(
|
||||||
pinnedMessagesBannerState: PinnedMessagesBannerState = aLoadedPinnedMessagesBannerState(),
|
pinnedMessagesBannerState: PinnedMessagesBannerState = aLoadedPinnedMessagesBannerState(),
|
||||||
dmUserVerificationState: IdentityState? = null,
|
dmUserVerificationState: IdentityState? = null,
|
||||||
roomMemberModerationState: RoomMemberModerationState = aRoomMemberModerationState(),
|
roomMemberModerationState: RoomMemberModerationState = aRoomMemberModerationState(),
|
||||||
showSharedHistoryIcon: Boolean = false,
|
topBarSharedHistoryIcon: SharedHistoryIcon = SharedHistoryIcon.NONE,
|
||||||
successorRoom: SuccessorRoom? = null,
|
successorRoom: SuccessorRoom? = null,
|
||||||
eventSink: (MessagesEvent) -> Unit = {},
|
eventSink: (MessagesEvent) -> Unit = {},
|
||||||
) = MessagesState(
|
) = MessagesState(
|
||||||
|
|
@ -148,7 +148,7 @@ fun aMessagesState(
|
||||||
pinnedMessagesBannerState = pinnedMessagesBannerState,
|
pinnedMessagesBannerState = pinnedMessagesBannerState,
|
||||||
dmUserVerificationState = dmUserVerificationState,
|
dmUserVerificationState = dmUserVerificationState,
|
||||||
roomMemberModerationState = roomMemberModerationState,
|
roomMemberModerationState = roomMemberModerationState,
|
||||||
showSharedHistoryIcon = showSharedHistoryIcon,
|
topBarSharedHistoryIcon = topBarSharedHistoryIcon,
|
||||||
successorRoom = successorRoom,
|
successorRoom = successorRoom,
|
||||||
eventSink = eventSink,
|
eventSink = eventSink,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ fun MessagesView(
|
||||||
heroes = state.heroes,
|
heroes = state.heroes,
|
||||||
roomCallState = state.roomCallState,
|
roomCallState = state.roomCallState,
|
||||||
dmUserIdentityState = state.dmUserVerificationState,
|
dmUserIdentityState = state.dmUserVerificationState,
|
||||||
showSharedHistoryIcon = state.showSharedHistoryIcon,
|
sharedHistoryIcon = state.topBarSharedHistoryIcon,
|
||||||
onBackClick = { hidingKeyboard { onBackClick() } },
|
onBackClick = { hidingKeyboard { onBackClick() } },
|
||||||
onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } },
|
onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } },
|
||||||
onJoinCallClick = onJoinCallClick,
|
onJoinCallClick = onJoinCallClick,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
|
import io.element.android.features.messages.impl.SharedHistoryIcon
|
||||||
import io.element.android.features.messages.impl.timeline.components.CallMenuItem
|
import io.element.android.features.messages.impl.timeline.components.CallMenuItem
|
||||||
import io.element.android.features.roomcall.api.RoomCallState
|
import io.element.android.features.roomcall.api.RoomCallState
|
||||||
import io.element.android.features.roomcall.api.aStandByCallState
|
import io.element.android.features.roomcall.api.aStandByCallState
|
||||||
|
|
@ -63,7 +64,7 @@ internal fun MessagesViewTopBar(
|
||||||
heroes: ImmutableList<AvatarData>,
|
heroes: ImmutableList<AvatarData>,
|
||||||
roomCallState: RoomCallState,
|
roomCallState: RoomCallState,
|
||||||
dmUserIdentityState: IdentityState?,
|
dmUserIdentityState: IdentityState?,
|
||||||
showSharedHistoryIcon: Boolean,
|
sharedHistoryIcon: SharedHistoryIcon,
|
||||||
onRoomDetailsClick: () -> Unit,
|
onRoomDetailsClick: () -> Unit,
|
||||||
onJoinCallClick: () -> Unit,
|
onJoinCallClick: () -> Unit,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
|
|
@ -110,12 +111,18 @@ internal fun MessagesViewTopBar(
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showSharedHistoryIcon) {
|
when (sharedHistoryIcon) {
|
||||||
Icon(
|
SharedHistoryIcon.NONE -> Unit
|
||||||
|
SharedHistoryIcon.SHARED -> Icon(
|
||||||
imageVector = CompoundIcons.History(),
|
imageVector = CompoundIcons.History(),
|
||||||
tint = ElementTheme.colors.iconInfoPrimary,
|
tint = ElementTheme.colors.iconInfoPrimary,
|
||||||
contentDescription = stringResource(CommonStrings.common_shared_history),
|
contentDescription = stringResource(CommonStrings.common_shared_history),
|
||||||
)
|
)
|
||||||
|
SharedHistoryIcon.WORLD_READABLE -> Icon(
|
||||||
|
imageVector = CompoundIcons.UserProfileSolid(),
|
||||||
|
tint = ElementTheme.colors.iconInfoPrimary,
|
||||||
|
contentDescription = stringResource(CommonStrings.common_world_readable_history),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -178,7 +185,7 @@ internal fun MessagesViewTopBarPreview() = ElementPreview {
|
||||||
heroes: ImmutableList<AvatarData> = persistentListOf(),
|
heroes: ImmutableList<AvatarData> = persistentListOf(),
|
||||||
roomCallState: RoomCallState = RoomCallState.Unavailable,
|
roomCallState: RoomCallState = RoomCallState.Unavailable,
|
||||||
dmUserIdentityState: IdentityState? = null,
|
dmUserIdentityState: IdentityState? = null,
|
||||||
showSharedHistoryIcon: Boolean = false,
|
sharedHistoryIcon: SharedHistoryIcon = SharedHistoryIcon.NONE,
|
||||||
) = MessagesViewTopBar(
|
) = MessagesViewTopBar(
|
||||||
roomName = roomName,
|
roomName = roomName,
|
||||||
roomAvatar = roomAvatar,
|
roomAvatar = roomAvatar,
|
||||||
|
|
@ -186,7 +193,7 @@ internal fun MessagesViewTopBarPreview() = ElementPreview {
|
||||||
heroes = heroes,
|
heroes = heroes,
|
||||||
roomCallState = roomCallState,
|
roomCallState = roomCallState,
|
||||||
dmUserIdentityState = dmUserIdentityState,
|
dmUserIdentityState = dmUserIdentityState,
|
||||||
showSharedHistoryIcon = showSharedHistoryIcon,
|
sharedHistoryIcon = sharedHistoryIcon,
|
||||||
onRoomDetailsClick = {},
|
onRoomDetailsClick = {},
|
||||||
onJoinCallClick = {},
|
onJoinCallClick = {},
|
||||||
onBackClick = {},
|
onBackClick = {},
|
||||||
|
|
@ -223,7 +230,12 @@ internal fun MessagesViewTopBarPreview() = ElementPreview {
|
||||||
AMessagesViewTopBar(
|
AMessagesViewTopBar(
|
||||||
roomName = "A DM with shared history",
|
roomName = "A DM with shared history",
|
||||||
dmUserIdentityState = IdentityState.Verified,
|
dmUserIdentityState = IdentityState.Verified,
|
||||||
showSharedHistoryIcon = true,
|
sharedHistoryIcon = SharedHistoryIcon.SHARED,
|
||||||
|
)
|
||||||
|
HorizontalDivider()
|
||||||
|
AMessagesViewTopBar(
|
||||||
|
roomName = "A room with world_readable history",
|
||||||
|
sharedHistoryIcon = SharedHistoryIcon.WORLD_READABLE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1233,7 +1233,28 @@ class MessagesPresenterTest {
|
||||||
awaitItem()
|
awaitItem()
|
||||||
runCurrent()
|
runCurrent()
|
||||||
val state = awaitItem()
|
val state = awaitItem()
|
||||||
assertThat(state.showSharedHistoryIcon).isTrue()
|
assertThat(state.topBarSharedHistoryIcon).isEqualTo(SharedHistoryIcon.SHARED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - shows a "world_readable" icon if the room is encrypted and history is world_readable`() = runTest {
|
||||||
|
val presenter = createMessagesPresenter(
|
||||||
|
joinedRoom = FakeJoinedRoom(
|
||||||
|
baseRoom = FakeBaseRoom(
|
||||||
|
roomPermissions = roomPermissions(),
|
||||||
|
initialRoomInfo = aRoomInfo(isEncrypted = true, historyVisibility = RoomHistoryVisibility.WorldReadable),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
featureFlagService = FakeFeatureFlagService(
|
||||||
|
initialState = mapOf(FeatureFlags.EnableKeyShareOnInvite.key to true)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
presenter.testWithLifecycleOwner {
|
||||||
|
awaitItem()
|
||||||
|
runCurrent()
|
||||||
|
val state = awaitItem()
|
||||||
|
assertThat(state.topBarSharedHistoryIcon).isEqualTo(SharedHistoryIcon.WORLD_READABLE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:2ca04a8092b40b50f3724bca9213ac2be4742c6b754ef949566fd23b052ab808
|
oid sha256:6e4d063c70dcfa2e882c7c1305b22975d1f91f9e1495b7cf75550277309dd6b7
|
||||||
size 46501
|
size 53365
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:cbca529b51092d41afbd772cb2ed207709423c5590588a128a7c48bfad64917b
|
oid sha256:3c9aea00c853d6f34988bd46b33275d6f6fe682c7e85c7ef3b87c4d4b45cbb63
|
||||||
size 45275
|
size 51969
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue