Update wordings for local room timeline

This commit is contained in:
Florian Renaud 2022-05-13 13:56:56 +02:00
parent e86f9193dd
commit b144bac578
5 changed files with 50 additions and 18 deletions

View file

@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.getRoomSummary
import org.matrix.android.sdk.api.session.room.model.localecho.RoomLocalEcho
import javax.inject.Inject
class EncryptionItemFactory @Inject constructor(
@ -55,12 +56,19 @@ class EncryptionItemFactory @Inject constructor(
val description: String
val shield: StatusTileTimelineItem.ShieldUIState
if (isSafeAlgorithm) {
val isDirect = session.getRoomSummary(event.root.roomId.orEmpty())?.isDirect.orFalse()
title = stringProvider.getString(R.string.encryption_enabled)
description = stringProvider.getString(
if (session.getRoomSummary(event.root.roomId ?: "")?.isDirect.orFalse()) {
R.string.direct_room_encryption_enabled_tile_description
} else {
R.string.encryption_enabled_tile_description
when {
isDirect && RoomLocalEcho.isLocalEchoId(event.root.roomId.orEmpty()) -> {
R.string.direct_room_encryption_enabled_tile_description_future
}
isDirect -> {
R.string.direct_room_encryption_enabled_tile_description
}
else -> {
R.string.encryption_enabled_tile_description
}
}
)
shield = StatusTileTimelineItem.ShieldUIState.BLACK

View file

@ -117,6 +117,7 @@ class MergedHeaderItemFactory @Inject constructor(
highlighted = true
}
val data = BasedMergedItem.Data(
roomId = mergedEvent.root.roomId,
userId = mergedEvent.root.senderId ?: "",
avatarUrl = mergedEvent.senderInfo.avatarUrl,
memberName = mergedEvent.senderInfo.disambiguatedDisplayName,
@ -199,6 +200,7 @@ class MergedHeaderItemFactory @Inject constructor(
highlighted = true
}
val data = BasedMergedItem.Data(
roomId = mergedEvent.root.roomId,
userId = mergedEvent.root.senderId ?: "",
avatarUrl = mergedEvent.senderInfo.avatarUrl,
memberName = mergedEvent.senderInfo.disambiguatedDisplayName,

View file

@ -54,6 +54,7 @@ abstract class BasedMergedItem<H : BasedMergedItem.Holder> : BaseEventItem<H>()
}
data class Data(
val roomId: String?,
val localId: Long,
val eventId: String,
val userId: String,

View file

@ -40,6 +40,7 @@ import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.tools.linkify
import me.gujun.android.span.span
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.localecho.RoomLocalEcho
import org.matrix.android.sdk.api.util.toMatrixItem
@EpoxyModelClass(layout = R.layout.item_timeline_event_base_noinfo)
@ -102,10 +103,16 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
}
if (attributes.isEncryptionAlgorithmSecure) {
holder.e2eTitleTextView.text = holder.expandView.resources.getString(R.string.encryption_enabled)
holder.e2eTitleDescriptionView.text = if (data?.isDirectRoom == true) {
holder.expandView.resources.getString(R.string.direct_room_encryption_enabled_tile_description)
} else {
holder.expandView.resources.getString(R.string.encryption_enabled_tile_description)
holder.e2eTitleDescriptionView.text = when {
data?.isDirectRoom == true && RoomLocalEcho.isLocalEchoId(data.roomId.orEmpty()) -> {
holder.expandView.resources.getString(R.string.direct_room_encryption_enabled_tile_description_future)
}
data?.isDirectRoom == true -> {
holder.expandView.resources.getString(R.string.direct_room_encryption_enabled_tile_description)
}
else -> {
holder.expandView.resources.getString(R.string.encryption_enabled_tile_description)
}
}
holder.e2eTitleDescriptionView.textAlignment = View.TEXT_ALIGNMENT_CENTER
holder.e2eTitleTextView.setCompoundDrawablesWithIntrinsicBounds(
@ -130,17 +137,29 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
val roomDisplayName = roomSummary?.displayName
holder.roomNameText.setTextOrHide(roomDisplayName)
val isDirect = roomSummary?.isDirect == true
val isLocalRoom = RoomLocalEcho.isLocalEchoId(roomSummary?.roomId.orEmpty())
val membersCount = roomSummary?.otherMemberIds?.size ?: 0
if (isDirect) {
holder.roomDescriptionText.text = holder.view.resources.getString(
R.string.this_is_the_beginning_of_dm,
roomSummary?.displayName ?: ""
)
} else if (roomDisplayName.isNullOrBlank() || roomSummary.name.isBlank()) {
holder.roomDescriptionText.text = holder.view.resources.getString(R.string.this_is_the_beginning_of_room_no_name)
} else {
holder.roomDescriptionText.text = holder.view.resources.getString(R.string.this_is_the_beginning_of_room, roomDisplayName)
when {
isDirect -> {
if (isLocalRoom) {
holder.roomDescriptionText.text = holder.view.resources.getString(
R.string.send_your_first_msg_to_invite,
roomSummary?.displayName.orEmpty()
)
} else {
holder.roomDescriptionText.text = holder.view.resources.getString(
R.string.this_is_the_beginning_of_dm,
roomSummary?.displayName.orEmpty()
)
}
}
roomDisplayName.isNullOrBlank() || roomSummary.name.isBlank() -> {
holder.roomDescriptionText.text = holder.view.resources.getString(R.string.this_is_the_beginning_of_room_no_name)
}
else -> {
holder.roomDescriptionText.text = holder.view.resources.getString(R.string.this_is_the_beginning_of_room, roomDisplayName)
}
}
val topic = roomSummary?.topic

View file

@ -2399,7 +2399,8 @@
<string name="encryption_enabled">Encryption enabled</string>
<string name="encryption_enabled_tile_description">Messages in this room are end-to-end encrypted. Learn more &amp; verify users in their profile.</string>
<string name="direct_room_encryption_enabled_tile_description">Messages in this room are end-to-end encrypted.</string>
<string name="direct_room_encryption_enabled_tile_description">Messages in this chat are end-to-end encrypted.</string>
<string name="direct_room_encryption_enabled_tile_description_future">Messages in this chat will be end-to-end encrypted.</string>
<string name="encryption_not_enabled">Encryption not enabled</string>
<string name="encryption_misconfigured">Encryption is misconfigured</string>
<string name="encryption_unknown_algorithm_tile_description">The encryption used by this room is not supported</string>
@ -2411,6 +2412,7 @@
<string name="this_is_the_beginning_of_room">This is the beginning of %s.</string>
<string name="this_is_the_beginning_of_room_no_name">This is the beginning of this conversation.</string>
<string name="this_is_the_beginning_of_dm">This is the beginning of your direct message history with %s.</string>
<string name="send_your_first_msg_to_invite">Send your first message to invite %s to chat</string>
<!-- First param will be replaced by the value of add_a_topic_link_text, that will be clickable-->
<string name="room_created_summary_no_topic_creation_text">%s to let people know what this room is about.</string>
<string name="add_a_topic_link_text">Add a topic</string>