mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 22:04:24 +01:00
Merge pull request #3823 from nextcloud/bugfix/noid/fixClickOnFederatedUser
avoid error when clicking on federated user
This commit is contained in:
commit
4c96f511c8
@ -132,7 +132,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -118,7 +118,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -140,7 +140,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -140,7 +140,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -234,7 +234,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -172,7 +172,7 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
|
||||
userAvatar.setOnClickListener { v: View ->
|
||||
if (payload is MessagePayload) {
|
||||
(payload as MessagePayload).profileBottomSheet.showFor(
|
||||
message.actorId!!,
|
||||
message,
|
||||
v.context
|
||||
)
|
||||
}
|
||||
|
@ -21,9 +21,11 @@ import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage
|
||||
import com.nextcloud.talk.bottomsheet.items.listItemsWithImage
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.models.json.hovercard.HoverCardAction
|
||||
import com.nextcloud.talk.models.json.hovercard.HoverCardOverall
|
||||
import com.nextcloud.talk.models.json.participants.Participant
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.EMAIL
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.PROFILE
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.SPREED
|
||||
@ -41,10 +43,15 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
|
||||
|
||||
private val allowedAppIds = listOf(SPREED.stringValue, PROFILE.stringValue, EMAIL.stringValue)
|
||||
|
||||
fun showFor(user: String, context: Context) {
|
||||
fun showFor(message: ChatMessage, context: Context) {
|
||||
if (message.actorType == Participant.ActorType.FEDERATED.toString()) {
|
||||
Log.d(TAG, "no actions for federated users are shown")
|
||||
return
|
||||
}
|
||||
|
||||
ncApi.hoverCard(
|
||||
ApiUtils.getCredentials(userModel.username, userModel.token),
|
||||
ApiUtils.getUrlForHoverCard(userModel.baseUrl!!, user)
|
||||
ApiUtils.getUrlForHoverCard(userModel.baseUrl!!, message.actorId!!)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<HoverCardOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
@ -55,13 +62,13 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
|
||||
bottomSheet(
|
||||
hoverCardOverall.ocs!!.data!!.actions!!,
|
||||
hoverCardOverall.ocs!!.data!!.displayName!!,
|
||||
user,
|
||||
message.actorId!!,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Failed to get hover card for user $user", e)
|
||||
Log.e(TAG, "Failed to get hover card for user " + message.actorId, e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
|
@ -271,7 +271,7 @@ object DisplayUtils {
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
}
|
||||
if ("user" == type && conversationUser.userId != id) {
|
||||
if ("user" == type && conversationUser.userId != id && !isFederated) {
|
||||
spannableString.setSpan(clickableSpan, start, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user