mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +03:00
Merge pull request #4034 from vector-im/feature/bma/displayNameFallback
Add a fallback for user displayName when this one is null or empty
This commit is contained in:
commit
eceb341986
48 changed files with 200 additions and 32 deletions
1
changelog.d/3732.feature
Normal file
1
changelog.d/3732.feature
Normal file
|
@ -0,0 +1 @@
|
|||
Add a fallback for user displayName when this one is null or empty
|
|
@ -25,6 +25,9 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
|
||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
||||
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
|
||||
|
||||
|
@ -48,7 +51,14 @@ class MarkdownParserTest : InstrumentedTest {
|
|||
private val markdownParser = MarkdownParser(
|
||||
Parser.builder().build(),
|
||||
HtmlRenderer.builder().softbreak("<br />").build(),
|
||||
TextPillsUtils(MentionLinkSpecComparator())
|
||||
TextPillsUtils(
|
||||
MentionLinkSpecComparator(),
|
||||
DisplayNameResolver(
|
||||
MatrixConfiguration(
|
||||
applicationFlavor = "TestFlavor",
|
||||
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
@Test
|
||||
|
|
|
@ -48,6 +48,10 @@ data class MatrixConfiguration(
|
|||
* True to advertise support for call transfers to other parties on Matrix calls.
|
||||
*/
|
||||
val supportsCallTransfer: Boolean = false,
|
||||
/**
|
||||
* MatrixItemDisplayNameFallbackProvider to provide default display name for MatrixItem. By default, the id will be used
|
||||
*/
|
||||
val matrixItemDisplayNameFallbackProvider: MatrixItemDisplayNameFallbackProvider? = null,
|
||||
/**
|
||||
* RoomDisplayNameFallbackProvider to provide default room display name.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.api
|
||||
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
interface MatrixItemDisplayNameFallbackProvider {
|
||||
fun getDefaultName(matrixItem: MatrixItem): String
|
||||
}
|
|
@ -23,13 +23,8 @@ package org.matrix.android.sdk.api.session.user.model
|
|||
data class User(
|
||||
val userId: String,
|
||||
/**
|
||||
* For usage in UI, consider using [getBestName]
|
||||
* For usage in UI, consider converting to MatrixItem and call getBestName()
|
||||
*/
|
||||
val displayName: String? = null,
|
||||
val avatarUrl: String? = null
|
||||
) {
|
||||
/**
|
||||
* Return the display name or the user id
|
||||
*/
|
||||
fun getBestName() = displayName?.takeIf { it.isNotEmpty() } ?: userId
|
||||
}
|
||||
)
|
||||
|
|
|
@ -84,9 +84,6 @@ sealed class MatrixItem(
|
|||
if (BuildConfig.DEBUG) checkId()
|
||||
}
|
||||
|
||||
// Best name is the id, and we keep the displayName of the room for the case we need the first letter
|
||||
override fun getBestName() = id
|
||||
|
||||
override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar)
|
||||
}
|
||||
|
||||
|
@ -98,16 +95,9 @@ sealed class MatrixItem(
|
|||
if (BuildConfig.DEBUG) checkId()
|
||||
}
|
||||
|
||||
// Best name is the id, and we keep the displayName of the room for the case we need the first letter
|
||||
override fun getBestName() = id
|
||||
|
||||
override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar)
|
||||
}
|
||||
|
||||
open fun getBestName(): String {
|
||||
return displayName?.takeIf { it.isNotBlank() } ?: id
|
||||
}
|
||||
|
||||
protected fun checkId() {
|
||||
if (!id.startsWith(getIdPrefix())) {
|
||||
error("Wrong usage of MatrixItem: check the id $id should start with ${getIdPrefix()}")
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.realm.RealmObject
|
|||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String = "",
|
||||
@Index var userId: String = "",
|
||||
|
@ -39,7 +40,7 @@ internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String =
|
|||
membershipStr = value.name
|
||||
}
|
||||
|
||||
fun getBestName() = displayName?.takeIf { it.isNotBlank() } ?: userId
|
||||
fun toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl)
|
||||
|
||||
companion object
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.session.displayname
|
||||
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class DisplayNameResolver @Inject constructor(
|
||||
private val matrixConfiguration: MatrixConfiguration
|
||||
) {
|
||||
fun getBestName(matrixItem: MatrixItem): String {
|
||||
return if (matrixItem is MatrixItem.GroupItem || matrixItem is MatrixItem.RoomAliasItem) {
|
||||
// Best name is the id, and we keep the displayName of the room for the case we need the first letter
|
||||
matrixItem.id
|
||||
} else {
|
||||
matrixItem.displayName?.takeIf { it.isNotBlank() }
|
||||
?: matrixConfiguration.matrixItemDisplayNameFallbackProvider?.getDefaultName(matrixItem)
|
||||
?: matrixItem.id
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
|||
import org.matrix.android.sdk.internal.database.query.getOrNull
|
||||
import org.matrix.android.sdk.internal.database.query.where
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -40,6 +41,7 @@ import javax.inject.Inject
|
|||
*/
|
||||
internal class RoomDisplayNameResolver @Inject constructor(
|
||||
matrixConfiguration: MatrixConfiguration,
|
||||
private val displayNameResolver: DisplayNameResolver,
|
||||
@UserId private val userId: String
|
||||
) {
|
||||
|
||||
|
@ -83,7 +85,8 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
|||
activeMembers.where()
|
||||
.equalTo(RoomMemberSummaryEntityFields.USER_ID, it)
|
||||
.findFirst()
|
||||
?.getBestName()
|
||||
?.toMatrixItem()
|
||||
?.let { matrixItem -> displayNameResolver.getBestName(matrixItem) }
|
||||
}
|
||||
?: roomDisplayNameFallbackProvider.getNameForRoomInvite()
|
||||
} else if (roomEntity?.membership == Membership.JOIN) {
|
||||
|
@ -109,7 +112,7 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
|||
// Get left members if any
|
||||
val leftMembersNames = roomMembers.queryLeftRoomMembersEvent()
|
||||
.findAll()
|
||||
.map { it.getBestName() }
|
||||
.map { displayNameResolver.getBestName(it.toMatrixItem()) }
|
||||
roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames)
|
||||
}
|
||||
1 -> {
|
||||
|
@ -157,7 +160,7 @@ internal class RoomDisplayNameResolver @Inject constructor(
|
|||
roomMemberHelper: RoomMemberHelper): String {
|
||||
val isUnique = roomMemberHelper.isUniqueDisplayName(roomMemberSummary.displayName)
|
||||
return if (isUnique) {
|
||||
roomMemberSummary.getBestName()
|
||||
displayNameResolver.getBestName(roomMemberSummary.toMatrixItem())
|
||||
} else {
|
||||
"${roomMemberSummary.displayName} (${roomMemberSummary.userId})"
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.matrix.android.sdk.internal.session.room.send.pills
|
|||
|
||||
import android.text.SpannableString
|
||||
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||
import java.util.Collections
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -25,7 +26,8 @@ import javax.inject.Inject
|
|||
* formatted text to send them as a Matrix messages.
|
||||
*/
|
||||
internal class TextPillsUtils @Inject constructor(
|
||||
private val mentionLinkSpecComparator: MentionLinkSpecComparator
|
||||
private val mentionLinkSpecComparator: MentionLinkSpecComparator,
|
||||
private val displayNameResolver: DisplayNameResolver
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -63,7 +65,7 @@ internal class TextPillsUtils @Inject constructor(
|
|||
// append text before pill
|
||||
append(text, currIndex, start)
|
||||
// append the pill
|
||||
append(String.format(template, urlSpan.matrixItem.id, urlSpan.matrixItem.getBestName()))
|
||||
append(String.format(template, urlSpan.matrixItem.id, displayNameResolver.getBestName(urlSpan.matrixItem)))
|
||||
currIndex = end
|
||||
}
|
||||
// append text after the last pill
|
||||
|
|
|
@ -20,11 +20,14 @@ import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
|||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
||||
import org.matrix.android.sdk.api.session.user.model.User
|
||||
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
||||
import org.matrix.android.sdk.api.session.widgets.model.WidgetContent
|
||||
import org.matrix.android.sdk.api.session.widgets.model.WidgetType
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.internal.database.RealmSessionProvider
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
|
||||
import org.matrix.android.sdk.internal.session.user.UserDataSource
|
||||
import java.net.URLEncoder
|
||||
|
@ -32,6 +35,7 @@ import javax.inject.Inject
|
|||
|
||||
internal class WidgetFactory @Inject constructor(private val userDataSource: UserDataSource,
|
||||
private val realmSessionProvider: RealmSessionProvider,
|
||||
private val displayNameResolver: DisplayNameResolver,
|
||||
private val urlResolver: ContentUrlResolver,
|
||||
@UserId private val userId: String) {
|
||||
|
||||
|
@ -68,13 +72,13 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
|||
// Ref: https://github.com/matrix-org/matrix-widget-api/blob/master/src/templating/url-template.ts#L29-L33
|
||||
fun computeURL(widget: Widget, isLightTheme: Boolean): String? {
|
||||
var computedUrl = widget.widgetContent.url ?: return null
|
||||
val myUser = userDataSource.getUser(userId)
|
||||
val myUser = userDataSource.getUser(userId) ?: User(userId)
|
||||
|
||||
val keyValue = widget.widgetContent.data.mapKeys { "\$${it.key}" }.toMutableMap()
|
||||
|
||||
keyValue[WIDGET_PATTERN_MATRIX_USER_ID] = userId
|
||||
keyValue[WIDGET_PATTERN_MATRIX_DISPLAY_NAME] = myUser?.getBestName() ?: userId
|
||||
keyValue[WIDGET_PATTERN_MATRIX_AVATAR_URL] = urlResolver.resolveFullSize(myUser?.avatarUrl) ?: ""
|
||||
keyValue[WIDGET_PATTERN_MATRIX_DISPLAY_NAME] = displayNameResolver.getBestName(myUser.toMatrixItem())
|
||||
keyValue[WIDGET_PATTERN_MATRIX_AVATAR_URL] = urlResolver.resolveFullSize(myUser.avatarUrl) ?: ""
|
||||
keyValue[WIDGET_PATTERN_MATRIX_WIDGET_ID] = widget.widgetId
|
||||
keyValue[WIDGET_PATTERN_MATRIX_ROOM_ID] = widget.event.roomId ?: ""
|
||||
keyValue[WIDGET_PATTERN_THEME] = getTheme(isLightTheme)
|
||||
|
|
|
@ -23,6 +23,7 @@ import im.vector.app.core.epoxy.ClickListener
|
|||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
|
|
@ -33,6 +33,7 @@ import im.vector.app.features.call.telecom.CallConnection
|
|||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.call.webrtc.getOpponentAsMatrixItem
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.notifications.NotificationUtils
|
||||
import im.vector.app.features.popup.IncomingCallAlert
|
||||
|
|
|
@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
|||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ import im.vector.app.features.call.dialpad.DialPadFragment
|
|||
import im.vector.app.features.call.utils.EglUtils
|
||||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.RoomDetailActivity
|
||||
import im.vector.app.features.home.room.detail.RoomDetailArgs
|
||||
|
|
|
@ -22,6 +22,7 @@ import im.vector.app.core.resources.StringProvider
|
|||
import im.vector.app.core.utils.ensureProtocol
|
||||
import im.vector.app.core.utils.toBase32String
|
||||
import im.vector.app.features.call.conference.jwt.JitsiJWTFactory
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.raw.wellknown.getElementWellknown
|
||||
import im.vector.app.features.settings.VectorLocale
|
||||
import im.vector.app.features.themes.ThemeProvider
|
||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.features.crypto.verification
|
|||
import android.content.Context
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.RoomDetailActivity
|
||||
import im.vector.app.features.home.room.detail.RoomDetailArgs
|
||||
|
@ -63,7 +64,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
|||
is VerificationTxState.OnStarted -> {
|
||||
// Add a notification for every incoming request
|
||||
val user = session?.getUser(tx.otherUserId)
|
||||
val name = user?.getBestName() ?: tx.otherUserId
|
||||
val name = user?.toMatrixItem()?.getBestName() ?: tx.otherUserId
|
||||
val alert = VerificationVectorAlert(
|
||||
uid,
|
||||
context.getString(R.string.sas_incoming_request_notif_title),
|
||||
|
|
|
@ -45,6 +45,7 @@ import im.vector.app.features.crypto.verification.emoji.VerificationEmojiCodeFra
|
|||
import im.vector.app.features.crypto.verification.qrconfirmation.VerificationQRWaitingFragment
|
||||
import im.vector.app.features.crypto.verification.qrconfirmation.VerificationQrScannedByOtherFragment
|
||||
import im.vector.app.features.crypto.verification.request.VerificationRequestFragment
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
|
|
@ -30,6 +30,7 @@ import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationD
|
|||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationEmojisItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationWaitingItem
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import javax.inject.Inject
|
||||
|
||||
class VerificationEmojiCodeController @Inject constructor(
|
||||
|
|
|
@ -25,6 +25,7 @@ import im.vector.app.features.crypto.verification.VerificationBottomSheetViewSta
|
|||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationBigImageItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import im.vector.app.features.crypto.verification.epoxy.bottomSheetSelfWaitItem
|
|||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationWaitingItem
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import javax.inject.Inject
|
||||
|
||||
class VerificationRequestController @Inject constructor(
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.displayname
|
||||
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
fun MatrixItem.getBestName(): String {
|
||||
// Note: this code is copied from [DisplayNameResolver] in the SDK
|
||||
return if (this is MatrixItem.GroupItem || this is MatrixItem.RoomAliasItem) {
|
||||
// Best name is the id, and we keep the displayName of the room for the case we need the first letter
|
||||
id
|
||||
} else {
|
||||
displayName
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?: VectorMatrixItemDisplayNameFallbackProvider.getDefaultName(this)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.displayname
|
||||
|
||||
import org.matrix.android.sdk.api.MatrixItemDisplayNameFallbackProvider
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
// Used to provide the fallback to the MatrixSDK, in the MatrixConfiguration
|
||||
object VectorMatrixItemDisplayNameFallbackProvider : MatrixItemDisplayNameFallbackProvider {
|
||||
override fun getDefaultName(matrixItem: MatrixItem): String {
|
||||
// Can customize something from the id if necessary here
|
||||
return matrixItem.id
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import im.vector.app.core.epoxy.ClickListener
|
|||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
|
|
@ -36,6 +36,7 @@ import im.vector.app.features.autocomplete.group.AutocompleteGroupPresenter
|
|||
import im.vector.app.features.autocomplete.member.AutocompleteMemberPresenter
|
||||
import im.vector.app.features.autocomplete.room.AutocompleteRoomPresenter
|
||||
import im.vector.app.features.command.Command
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.html.PillImageSpan
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
|
|
@ -26,6 +26,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
|||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setLeftDrawable
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.RoomDetailAction
|
||||
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
||||
|
|
|
@ -28,6 +28,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
|
|||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.ButtonStateView
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.invite.InviteButtonStateBinder
|
||||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||
|
|
|
@ -30,6 +30,7 @@ import im.vector.app.RoomGroupingMethod
|
|||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -41,6 +42,7 @@ import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
|
|||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
|
||||
import org.matrix.android.sdk.api.session.room.state.isPublic
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -95,7 +97,7 @@ class RoomListViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
session.rx().liveUser(session.myUserId)
|
||||
.map { it.getOrNull()?.getBestName() }
|
||||
.map { it.getOrNull()?.toMatrixItem()?.getBestName() }
|
||||
.distinctUntilChanged()
|
||||
.execute {
|
||||
copy(
|
||||
|
|
|
@ -33,6 +33,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
|
|||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.ui.views.ShieldImageView
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.bumptech.glide.request.transition.Transition
|
|||
import com.google.android.material.chip.ChipDrawable
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.glide.GlideRequests
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
|
|
@ -33,6 +33,7 @@ import im.vector.app.core.intent.getFilenameFromUri
|
|||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.databinding.DialogBaseEditTextBinding
|
||||
import im.vector.app.databinding.FragmentLoginAccountCreatedBinding
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||
import im.vector.app.features.login2.AbstractLoginFragment2
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.view.View
|
|||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.core.util.Pair
|
||||
import im.vector.app.features.crypto.recover.SetupMode
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.login.LoginConfig
|
||||
import im.vector.app.features.media.AttachmentData
|
||||
import im.vector.app.features.pin.PinMode
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.core.app.NotificationCompat
|
|||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter
|
||||
import im.vector.app.features.home.room.detail.timeline.format.NoticeEventFormatter
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
|
@ -34,6 +35,7 @@ import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
|||
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getEditedEventId
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
||||
import timber.log.Timber
|
||||
import java.util.UUID
|
||||
|
@ -107,7 +109,7 @@ class NotifiableEventResolver @Inject constructor(
|
|||
displayIndex = 0,
|
||||
senderInfo = SenderInfo(
|
||||
userId = user.userId,
|
||||
displayName = user.getBestName(),
|
||||
displayName = user.toMatrixItem().getBestName(),
|
||||
isUniqueDisplayName = true,
|
||||
avatarUrl = user.avatarUrl
|
||||
)
|
||||
|
|
|
@ -27,11 +27,13 @@ import im.vector.app.BuildConfig
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.utils.FirstThrottler
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
@ -228,7 +230,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
|||
|
||||
val user = session.getUser(session.myUserId)
|
||||
// myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash
|
||||
val myUserDisplayName = user?.getBestName() ?: session.myUserId
|
||||
val myUserDisplayName = user?.toMatrixItem()?.getBestName() ?: session.myUserId
|
||||
val myUserAvatarUrl = session.contentUrlResolver().resolveThumbnail(user?.avatarUrl, avatarSize, avatarSize, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
synchronized(eventList) {
|
||||
Timber.v("%%%%%%%% REFRESH NOTIFICATION DRAWER ")
|
||||
|
|
|
@ -53,6 +53,7 @@ import im.vector.app.core.utils.startNotificationChannelSettingsIntent
|
|||
import im.vector.app.features.call.VectorCallActivity
|
||||
import im.vector.app.features.call.service.CallHeadsUpActionReceiver
|
||||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.HomeActivity
|
||||
import im.vector.app.features.home.room.detail.RoomDetailActivity
|
||||
import im.vector.app.features.home.room.detail.RoomDetailArgs
|
||||
|
|
|
@ -22,6 +22,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.extensions.setLeftDrawable
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
import im.vector.app.databinding.AlerterIncomingCallLayoutBinding
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.View
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
import im.vector.app.databinding.AlerterJitsiCallLayoutBinding
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import im.vector.app.databinding.DialogShareQrCodeBinding
|
|||
import im.vector.app.databinding.FragmentMatrixProfileBinding
|
||||
import im.vector.app.databinding.ViewStubRoomMemberProfileHeaderBinding
|
||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.RoomDetailPendingAction
|
||||
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
|
||||
|
|
|
@ -32,6 +32,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.mvrx.runCatchingToAsync
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.powerlevel.PowerLevelsObservableFactory
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.functions.BiFunction
|
||||
|
|
|
@ -35,6 +35,7 @@ import im.vector.app.core.extensions.exhaustive
|
|||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.utils.styleMatchingText
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.roomprofile.settings.joinrule.toOption
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
|
@ -41,6 +41,7 @@ import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
|||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.utils.styleMatchingText
|
||||
import im.vector.app.databinding.BottomSheetLeaveSpaceBinding
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.spaces.leave.SpaceLeaveAdvancedActivity
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
|
|
@ -36,6 +36,7 @@ import im.vector.app.core.platform.ButtonStateView
|
|||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.core.utils.toast
|
||||
import im.vector.app.databinding.BottomSheetInvitedToSpaceBinding
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.matrixto.SpaceCardRenderer
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
|
|
@ -27,6 +27,7 @@ import im.vector.app.core.epoxy.ClickListener
|
|||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.ClickListener
|
|||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package im.vector.app.features.userdirectory
|
||||
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.user.model.User
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
|
||||
sealed class PendingSelection {
|
||||
data class UserPendingSelection(val user: User) : PendingSelection()
|
||||
|
@ -25,7 +27,7 @@ sealed class PendingSelection {
|
|||
|
||||
fun getBestName(): String {
|
||||
return when (this) {
|
||||
is UserPendingSelection -> user.getBestName()
|
||||
is UserPendingSelection -> user.toMatrixItem().getBestName()
|
||||
is ThreePidPendingSelection -> threePid.value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import im.vector.app.core.error.ErrorFormatter
|
|||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.ui.list.genericPillItem
|
||||
import im.vector.app.features.displayname.getBestName
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
|
Loading…
Reference in a new issue