Ensure no invisible displayName will be used
This commit is contained in:
parent
d47ba6bd11
commit
6ee6b0cad9
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.api.session.room.sender
|
package org.matrix.android.sdk.api.session.room.sender
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.internal.util.replaceSpaceChars
|
||||||
|
|
||||||
data class SenderInfo(
|
data class SenderInfo(
|
||||||
val userId: String,
|
val userId: String,
|
||||||
/**
|
/**
|
||||||
@ -27,7 +29,8 @@ data class SenderInfo(
|
|||||||
) {
|
) {
|
||||||
val disambiguatedDisplayName: String
|
val disambiguatedDisplayName: String
|
||||||
get() = when {
|
get() = when {
|
||||||
displayName.isNullOrBlank() -> userId
|
displayName == null -> userId
|
||||||
|
displayName.replaceSpaceChars().isBlank() -> "$displayName ($userId)"
|
||||||
isUniqueDisplayName -> displayName
|
isUniqueDisplayName -> displayName
|
||||||
else -> "$displayName ($userId)"
|
else -> "$displayName ($userId)"
|
||||||
}
|
}
|
||||||
|
@ -71,3 +71,10 @@ fun String.caseInsensitiveFind(subString: String): Boolean {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal val spaceChars = "[\u00A0\u2000-\u200B\u2800\u3000]".toRegex()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip all the UTF-8 chars which are actually spaces
|
||||||
|
*/
|
||||||
|
internal fun String.replaceSpaceChars() = replace(spaceChars, "")
|
||||||
|
@ -83,7 +83,7 @@ abstract class BaseAttachmentProvider<Type>(
|
|||||||
val dateString = dateFormatter.format(timelineEvent.root.originServerTs, DateFormatKind.DEFAULT_DATE_AND_TIME)
|
val dateString = dateFormatter.format(timelineEvent.root.originServerTs, DateFormatKind.DEFAULT_DATE_AND_TIME)
|
||||||
overlayView?.updateWith(
|
overlayView?.updateWith(
|
||||||
counter = stringProvider.getString(R.string.attachment_viewer_item_x_of_y, position + 1, getItemCount()),
|
counter = stringProvider.getString(R.string.attachment_viewer_item_x_of_y, position + 1, getItemCount()),
|
||||||
senderInfo = "${timelineEvent.senderInfo.displayName} $dateString"
|
senderInfo = "${timelineEvent.senderInfo.disambiguatedDisplayName} $dateString"
|
||||||
)
|
)
|
||||||
overlayView?.views?.overlayVideoControlsGroup?.isVisible = timelineEvent.root.isVideoMessage()
|
overlayView?.views?.overlayVideoControlsGroup?.isVisible = timelineEvent.root.isVideoMessage()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user