Skip to content

Commit b9e286d

Browse files
Add 'unencrypted room' badges and labels (#4445)
* Add 'unencrypted room' icon and label to composer * Modify colors for room details screen info labels * Add exception to Konsist's preview check * Update screenshots --------- Co-authored-by: ElementBot <[email protected]>
1 parent f969dcf commit b9e286d

File tree

113 files changed

+493
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+493
-196
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewPresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class AttachmentsPreviewPresenter @AssistedInject constructor(
7373

7474
val markdownTextEditorState = rememberMarkdownTextEditorState(initialText = null, initialFocus = false)
7575
val textEditorState by rememberUpdatedState(
76-
TextEditorState.Markdown(markdownTextEditorState)
76+
TextEditorState.Markdown(markdownTextEditorState, isRoomEncrypted = null)
7777
)
7878

7979
val ongoingSendAttachmentJob = remember { mutableStateOf<Job?>(null) }

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerPresenter.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class MessageComposerPresenter @AssistedInject constructor(
141141
override fun present(): MessageComposerState {
142142
val localCoroutineScope = rememberCoroutineScope()
143143

144+
val roomInfo by room.roomInfoFlow.collectAsState()
145+
144146
val richTextEditorState = richTextEditorStateFactory.remember()
145147
if (isTesting) {
146148
richTextEditorState.isReadyToProcessActions = true
@@ -242,9 +244,9 @@ class MessageComposerPresenter @AssistedInject constructor(
242244

243245
val textEditorState by rememberUpdatedState(
244246
if (showTextFormatting) {
245-
TextEditorState.Rich(richTextEditorState)
247+
TextEditorState.Rich(richTextEditorState, roomInfo.isEncrypted == true)
246248
} else {
247-
TextEditorState.Markdown(markdownTextEditorState)
249+
TextEditorState.Markdown(markdownTextEditorState, roomInfo.isEncrypted == true)
248250
}
249251
)
250252

features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,14 @@ private fun RoomBadge.toMatrixBadgeData(): MatrixBadgeAtom.MatrixBadgeData {
469469
MatrixBadgeAtom.MatrixBadgeData(
470470
text = stringResource(R.string.screen_room_details_badge_not_encrypted),
471471
icon = CompoundIcons.LockOff(),
472-
type = MatrixBadgeAtom.Type.Neutral,
472+
type = MatrixBadgeAtom.Type.Info,
473473
)
474474
}
475475
RoomBadge.PUBLIC -> {
476476
MatrixBadgeAtom.MatrixBadgeData(
477477
text = stringResource(R.string.screen_room_details_badge_public),
478478
icon = CompoundIcons.Public(),
479-
type = MatrixBadgeAtom.Type.Neutral,
479+
type = MatrixBadgeAtom.Type.Info,
480480
)
481481
}
482482
}

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/MatrixBadgeAtom.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import io.element.android.compound.tokens.generated.CompoundIcons
1414
import io.element.android.libraries.designsystem.components.Badge
1515
import io.element.android.libraries.designsystem.preview.ElementPreview
1616
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
17+
import io.element.android.libraries.designsystem.theme.badgeInfoBackgroundColor
18+
import io.element.android.libraries.designsystem.theme.badgeInfoContentColor
1719
import io.element.android.libraries.designsystem.theme.badgeNegativeBackgroundColor
1820
import io.element.android.libraries.designsystem.theme.badgeNegativeContentColor
1921
import io.element.android.libraries.designsystem.theme.badgeNeutralBackgroundColor
@@ -31,7 +33,8 @@ object MatrixBadgeAtom {
3133
enum class Type {
3234
Positive,
3335
Neutral,
34-
Negative
36+
Negative,
37+
Info,
3538
}
3639

3740
@Composable
@@ -42,16 +45,19 @@ object MatrixBadgeAtom {
4245
Type.Positive -> ElementTheme.colors.badgePositiveBackgroundColor
4346
Type.Neutral -> ElementTheme.colors.badgeNeutralBackgroundColor
4447
Type.Negative -> ElementTheme.colors.badgeNegativeBackgroundColor
48+
Type.Info -> ElementTheme.colors.badgeInfoBackgroundColor
4549
}
4650
val textColor = when (data.type) {
4751
Type.Positive -> ElementTheme.colors.badgePositiveContentColor
4852
Type.Neutral -> ElementTheme.colors.badgeNeutralContentColor
4953
Type.Negative -> ElementTheme.colors.badgeNegativeContentColor
54+
Type.Info -> ElementTheme.colors.badgeInfoContentColor
5055
}
5156
val iconColor = when (data.type) {
5257
Type.Positive -> ElementTheme.colors.iconSuccessPrimary
5358
Type.Neutral -> ElementTheme.colors.iconSecondary
5459
Type.Negative -> ElementTheme.colors.iconCriticalPrimary
60+
Type.Info -> ElementTheme.colors.iconInfoPrimary
5561
}
5662
Badge(
5763
text = data.text,
@@ -98,3 +104,15 @@ internal fun MatrixBadgeAtomNegativePreview() = ElementPreview {
98104
)
99105
)
100106
}
107+
108+
@PreviewsDayNight
109+
@Composable
110+
internal fun MatrixBadgeAtomInfoPreview() = ElementPreview {
111+
MatrixBadgeAtom.View(
112+
MatrixBadgeAtom.MatrixBadgeData(
113+
text = "Not encrypted",
114+
icon = CompoundIcons.LockOff(),
115+
type = MatrixBadgeAtom.Type.Info,
116+
)
117+
)
118+
}

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ val SemanticColors.badgeNegativeBackgroundColor
165165
val SemanticColors.badgeNegativeContentColor
166166
get() = if (isLight) LightColorTokens.colorRed1100 else DarkColorTokens.colorRed1100
167167

168+
@OptIn(CoreColorToken::class)
169+
val SemanticColors.badgeInfoBackgroundColor
170+
get() = if (isLight) LightColorTokens.colorAlphaBlue300 else DarkColorTokens.colorAlphaBlue300
171+
172+
@OptIn(CoreColorToken::class)
173+
val SemanticColors.badgeInfoContentColor
174+
get() = if (isLight) LightColorTokens.colorBlue1100 else DarkColorTokens.colorBlue1100
175+
168176
@OptIn(CoreColorToken::class)
169177
val SemanticColors.pinnedMessageBannerIndicator
170178
get() = if (isLight) LightColorTokens.colorAlphaGray600 else DarkColorTokens.colorAlphaGray600

0 commit comments

Comments
 (0)