Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ sealed class MatrixItem(
is RoomAliasItem -> roomDisplayName ?: displayName
else -> displayName
}
return (displayName?.takeIf { it.isNotBlank() } ?: id)
return (displayName?.takeIf { it.isNotBlank() }?.replace("\\[TG] ".toRegex(), "")?.replace("\\$".toRegex(), "") ?: id)
.let { dn ->
var startIndex = 0
val initial = dn[startIndex]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,26 @@ fun MatrixItem.getBestName(): String {
// Best name is the id, and we keep the displayName of the room for the case we need the first letter
id
} else {
displayName
// displayName
// ?.takeIf { it.isNotBlank() }?.replace("[TG] ","")?.replace("$","")
// ?: VectorMatrixItemDisplayNameFallbackProvider.getDefaultName(this).replace("[TG] ","").replace("$","")
val modifiedDisplayName = displayName
?.takeIf { it.isNotBlank() }
?: VectorMatrixItemDisplayNameFallbackProvider.getDefaultName(this)
?.let {
when {
it.startsWith("[TG] ") -> {
it.replaceFirst("[TG] ", "") // Remove [TG] from the beginning
}
it.startsWith("$") -> {
it.replace("$", "") // Remove $ from the string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess all these replacements should only change the first occurance as the name may contain multiple '$$$'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that block change is redundant anyway, there is another "replacement" again on the resulting string below

}
else -> it
}
}
?: VectorMatrixItemDisplayNameFallbackProvider.getDefaultName(this).replace("[TG] ","").replace("$","")

modifiedDisplayName.replace("[TG] ", "").replace("$","")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[TG] name$ would lead to name instead of name$


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AvatarRenderer @Inject constructor(
val matrixItem = MatrixItem.UserItem(
// Need an id starting with @
id = profileInfo.matrixId,
displayName = profileInfo.displayName,
displayName = profileInfo.displayName?.replace("[TG] ","")?.replace("$",""),
)

val placeholder = getPlaceholderDrawable(matrixItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,27 @@ class TimelineFragment :
views.includeRoomToolbar.roomToolbarContentView.isClickable = false
} else {
views.includeRoomToolbar.roomToolbarContentView.isClickable = roomSummary.membership == Membership.JOIN
views.includeRoomToolbar.roomToolbarTitleView.text = roomSummary.displayName
// views.includeRoomToolbar.roomToolbarTitleView.text = roomSummary.displayName.replace("[TG] ","").replace("$","")
if (roomSummary.displayName.startsWith("[TG]") && roomSummary.displayName.startsWith("$")) {
// Remove [TG] from the beginning
val modifiedString = roomSummary.displayName.replace("[TG] ", "")
// Update the roomToolbarTitleView.text with the modified string
views.includeRoomToolbar.roomToolbarTitleView.text = modifiedString
} else if (roomSummary.displayName.startsWith("$") && roomSummary.displayName.startsWith("[TG]")) {
// Remove $ from the beginning
val modifiedString = roomSummary.displayName.replace("$", "")
// Update the roomToolbarTitleView.text with the modified string
views.includeRoomToolbar.roomToolbarTitleView.text = modifiedString
} else if (roomSummary.displayName.startsWith("[TG] ")){
val modifiedString = roomSummary.displayName.replace("[TG] ","")
views.includeRoomToolbar.roomToolbarTitleView.text = modifiedString
} else if (roomSummary.displayName.startsWith("$")) {
val modifiedString = roomSummary.displayName.replace("$","")
views.includeRoomToolbar.roomToolbarTitleView.text = modifiedString
} else {
views.includeRoomToolbar.roomToolbarTitleView.text = roomSummary.displayName
}

avatarRenderer.render(roomSummary.toMatrixItem(), views.includeRoomToolbar.roomToolbarAvatarImageView)
val showPresence = roomSummary.isDirect
views.includeRoomToolbar.roomToolbarPresenceImageView.render(showPresence, roomSummary.directUserPresence)
Expand All @@ -1265,6 +1285,7 @@ class TimelineFragment :
}
}


private fun displayE2eError(withHeldCode: WithHeldCode?) {
val msgId = when (withHeldCode) {
WithHeldCode.BLACKLISTED -> R.string.crypto_error_withheld_blacklisted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,23 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
}

private fun bindCreationSummaryTile(holder: Holder) {
val roomDisplayName = roomSummary?.displayName
val roomDisplayName = roomSummary?.displayName?.replace("[TG] ","")?.replace("$","")
val membersCount = roomSummary?.otherMemberIds?.size ?: 0

holder.roomNameText.setTextOrHide(roomDisplayName)
if (roomSummary?.displayName!!.startsWith("[TG]")) {
holder.roomNameText.setTextOrHide(roomDisplayName!!.replace("[TG] ",""))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roomDisplayName is already sanitized on line 176

holder.roomNameText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.chatimg, 0,0,0)
holder.roomNameText.setCompoundDrawablePadding(10)
}
if (roomSummary?.displayName!!.startsWith("$")) {
holder.roomNameText.setTextOrHide(roomDisplayName!!.replace("$",""))
holder.roomNameText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.dollar, 0,0,0)
holder.roomNameText.setCompoundDrawablePadding(10)
} else {
holder.roomNameText.setTextOrHide(roomDisplayName)
}


renderRoomDescription(holder)
renderRoomTopic(holder)

Expand Down Expand Up @@ -229,7 +242,7 @@ abstract class MergedRoomCreationItem : BasedMergedItem<MergedRoomCreationItem.H
holder.view.resources.getString(R.string.this_is_the_beginning_of_room_no_name)
}
else -> {
holder.view.resources.getString(R.string.this_is_the_beginning_of_room, roomDisplayName)
holder.view.resources.getString(R.string.this_is_the_beginning_of_room, roomDisplayName.replace("[TG] ","").replace("$",""))
}
}
holder.roomDescriptionText.text = description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ abstract class RoomSummaryCenteredItem : VectorEpoxyModel<RoomSummaryCenteredIte
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
itemLongClickListener?.onLongClick(it) ?: false
}
if (matrixItem.displayName!!.startsWith("[TG] ")){
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.chatimg, 0,0,0)
} else if (matrixItem.displayName!!.startsWith("$")) {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.dollar,0,0,0)
} else {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0)
}

holder.titleView.invalidate()
holder.titleView.text = matrixItem.getBestName()
avatarRenderer.render(matrixItem, holder.avatarImageView)
holder.roomAvatarDecorationImageView.render(encryptionTrustLevel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package im.vector.app.features.home.room.list

import android.util.Log
import android.view.HapticFeedbackConstants
import android.view.View
import android.widget.ImageView
Expand Down Expand Up @@ -115,6 +116,18 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>(R.layo
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
itemLongClickListener?.onLongClick(it) ?: false
}
if (matrixItem.displayName!!.startsWith("[TG] ")) {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.chatimg, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(10)
} else if (matrixItem.displayName!!.startsWith("$")) {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.dollar, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(10)
} else {
// Reset compound drawables if none of the conditions are met
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(0)
}
holder.titleView.invalidate()
holder.titleView.text = matrixItem.getBestName()
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State.Count(unreadNotificationCount, showHighlighted))
holder.unreadIndentIndicator.isVisible = hasUnreadMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ abstract class SpaceChildInfoItem : VectorEpoxyModel<SpaceChildInfoItem.Holder>(
itemLongClickListener?.onLongClick(it) ?: false
}
holder.titleView.text = matrixItem.displayName ?: holder.rootView.context.getString(R.string.unnamed_room)
if (matrixItem.displayName!!.startsWith("[TG] ")) {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.chatimg, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(10)
} else if (matrixItem.displayName!!.startsWith("$")) {
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.dollar, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(10)
} else {
// Reset compound drawables if none of the conditions are met
holder.titleView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
holder.titleView.setCompoundDrawablePadding(0)
}
holder.titleView.invalidate()
avatarRenderer.render(matrixItem, holder.avatarImageView)

holder.descriptionText.text = span {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>(R.layout
holder.rootView.onClick(globalListener)

avatarRenderer.render(matrixItem, holder.avatarView)
holder.nameView.text = matrixItem.displayName
holder.nameView.text = matrixItem.displayName?.replace("[TG] ", "")?.replace("$","")
if (matrixItem.displayName!!.startsWith("[TG] ")) {
holder.nameView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.chatimg,0,0,0)
holder.nameView.setCompoundDrawablePadding(10)
} else if (matrixItem.displayName!!.startsWith("$")) {
holder.nameView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.dollar, 0,0,0)
holder.nameView.setCompoundDrawablePadding(10)
} else {
holder.nameView.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0)
holder.nameView.setCompoundDrawablePadding(0)
}

holder.aliasView.setTextOrHide(roomAlias)
holder.topicView.setTextOrHide(roomTopic)
// TODO Use formatter for big numbers?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,28 @@ class RoomPreviewNoPreviewFragment :
views.roomPreviewNoPreviewToolbarAvatar.isVisible = false
views.roomPreviewNoPreviewAvatar.isVisible = false
}
views.roomPreviewNoPreviewToolbarTitle.text = roomName
if (roomName.startsWith("[TG] ")) {
views.roomPreviewNoPreviewToolbarTitle.text = roomName.replace("[TG] ","")
} else if (roomName.startsWith("$")) {
views.roomPreviewNoPreviewToolbarTitle.text = roomName.replace("$","")
} else {
views.roomPreviewNoPreviewToolbarTitle.text = roomName
}


// Screen
views.roomPreviewNoPreviewName.text = roomName
if (roomName.startsWith("[TG] ")) {
views.roomPreviewNoPreviewName.text = roomName.replace("[TG]","")
views.roomPreviewNoPreviewName.setCompoundDrawablesWithIntrinsicBounds(R.drawable.chatimg,0,0,0)
views.roomPreviewNoPreviewName.setCompoundDrawablePadding(10)
} else if (roomName.startsWith("$")) {
views.roomPreviewNoPreviewName.text = roomName.replace("$","")
views.roomPreviewNoPreviewName.setCompoundDrawablesWithIntrinsicBounds(R.drawable.dollar,0,0,0)
views.roomPreviewNoPreviewName.setCompoundDrawablePadding(10)
} else {
views.roomPreviewNoPreviewName.text = roomName
}

views.roomPreviewNoPreviewTopic.setTextOrHide(topic)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,25 @@ class RoomProfileFragment :
Timber.w("The room has been left")
activity?.finish()
} else {
headerViews.roomProfileNameView.text = it.displayName
// headerViews.roomProfileNameView.text = it.displayName.replace("[TG] ","").replace("$","")
if (it.displayName.startsWith("[TG]")) {
val modifiedString = it.displayName.replace("[TG] ","").replace("$","$")
headerViews.roomProfileNameView.text = modifiedString
} else if (it.displayName.startsWith("$")) {
val modifiedString = it.displayName.replace("$","").replace("[TG]","[TG]")
headerViews.roomProfileNameView.text = modifiedString
} else {
headerViews.roomProfileNameView.text = it.displayName
}
if (it.displayName.startsWith("[TG]")) {
headerViews.roomProfileNameView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.chatimg,0,0,0)
headerViews.roomProfileNameView.setCompoundDrawablePadding(10);
}

if (it.displayName.startsWith("$")) {
headerViews.roomProfileNameView.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.dollar, 0,0,0)
headerViews.roomProfileNameView.setCompoundDrawablePadding(10);
}
views.matrixProfileToolbarTitleView.text = it.displayName
headerViews.roomProfileAliasView.setTextOrHide(it.canonicalAlias)
val matrixItem = it.toMatrixItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ class SpacePreviewFragment :
val spaceAvatarUrl = spacePreviewState.spaceInfo.invoke()?.avatarUrl ?: spacePreviewState.avatarUrl
val mxItem = MatrixItem.SpaceItem(spacePreviewState.idOrAlias, spaceName, spaceAvatarUrl)
avatarRenderer.render(mxItem, views.spacePreviewToolbarAvatar)
views.roomPreviewNoPreviewToolbarTitle.text = spaceName
if (spaceName.startsWith("[TG] ")) {
views.roomPreviewNoPreviewToolbarTitle.text = spaceName.replace("[TG]","")
} else if (spaceName.startsWith("$")) {
views.roomPreviewNoPreviewToolbarTitle.text = spaceName.replace("$","")
} else {
views.roomPreviewNoPreviewToolbarTitle.text = spaceName
}
// }
// is SpacePeekResult.SpacePeekError,
// null -> {
Expand Down
Binary file added vector/src/main/res/drawable/chatimg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vector/src/main/res/drawable/dollar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.