mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
check capabilities to use/ignore typing indicators
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
d3d8e2abef
commit
231cfef8c3
@ -323,20 +323,24 @@ class ChatActivity :
|
|||||||
|
|
||||||
private val conversationMessageListener = object : SignalingMessageReceiver.ConversationMessageListener {
|
private val conversationMessageListener = object : SignalingMessageReceiver.ConversationMessageListener {
|
||||||
override fun onStartTyping(session: String) {
|
override fun onStartTyping(session: String) {
|
||||||
var name = webSocketInstance?.getDisplayNameForSession(session)
|
if (!CapabilitiesUtilNew.isTypingStatusPrivate(conversationUser!!)) {
|
||||||
|
var name = webSocketInstance?.getDisplayNameForSession(session)
|
||||||
|
|
||||||
if (name != null && !typingParticipants.contains(session)) {
|
if (name != null && !typingParticipants.contains(session)) {
|
||||||
if (name == "") {
|
if (name == "") {
|
||||||
name = context.resources?.getString(R.string.nc_guest)!!
|
name = context.resources?.getString(R.string.nc_guest)!!
|
||||||
|
}
|
||||||
|
typingParticipants[session] = name
|
||||||
|
updateTypingIndicator()
|
||||||
}
|
}
|
||||||
typingParticipants[session] = name
|
|
||||||
updateTypingIndicator()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStopTyping(session: String) {
|
override fun onStopTyping(session: String) {
|
||||||
typingParticipants.remove(session)
|
if (!CapabilitiesUtilNew.isTypingStatusPrivate(conversationUser!!)) {
|
||||||
updateTypingIndicator()
|
typingParticipants.remove(session)
|
||||||
|
updateTypingIndicator()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,8 +352,8 @@ class ChatActivity :
|
|||||||
0 -> typingString = SpannableStringBuilder().append(binding.typingIndicator.text)
|
0 -> typingString = SpannableStringBuilder().append(binding.typingIndicator.text)
|
||||||
|
|
||||||
1 -> typingString = SpannableStringBuilder()
|
1 -> typingString = SpannableStringBuilder()
|
||||||
.bold { append(participantNames[0]) }
|
.bold { append(participantNames[0]) }
|
||||||
.append(WHITESPACE + context.resources?.getString(R.string.typing_is_typing))
|
.append(WHITESPACE + context.resources?.getString(R.string.typing_is_typing))
|
||||||
|
|
||||||
2 -> typingString = SpannableStringBuilder()
|
2 -> typingString = SpannableStringBuilder()
|
||||||
.bold { append(participantNames[0]) }
|
.bold { append(participantNames[0]) }
|
||||||
@ -388,7 +392,7 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val typingIndicatorHeight = DisplayUtils.convertDpToPixel(20f,context)
|
val typingIndicatorHeight = DisplayUtils.convertDpToPixel(20f, context)
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (participantNames.size > 0) {
|
if (participantNames.size > 0) {
|
||||||
@ -396,7 +400,6 @@ class ChatActivity :
|
|||||||
.translationY(binding.messageInputView.y - typingIndicatorHeight)
|
.translationY(binding.messageInputView.y - typingIndicatorHeight)
|
||||||
.setInterpolator(AccelerateDecelerateInterpolator())
|
.setInterpolator(AccelerateDecelerateInterpolator())
|
||||||
.duration = TYPING_INDICATOR_ANIMATION_DURATION
|
.duration = TYPING_INDICATOR_ANIMATION_DURATION
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binding.typingIndicatorWrapper.animate()
|
binding.typingIndicatorWrapper.animate()
|
||||||
.translationY(binding.messageInputView.y)
|
.translationY(binding.messageInputView.y)
|
||||||
@ -733,26 +736,28 @@ class ChatActivity :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typingTimer == null) {
|
if (!CapabilitiesUtilNew.isTypingStatusPrivate(conversationUser!!)) {
|
||||||
for ((sessionId, participant) in webSocketInstance?.getUserMap()!!) {
|
if (typingTimer == null) {
|
||||||
val ncSignalingMessage = NCSignalingMessage()
|
for ((sessionId, participant) in webSocketInstance?.getUserMap()!!) {
|
||||||
ncSignalingMessage.to = sessionId
|
val ncSignalingMessage = NCSignalingMessage()
|
||||||
ncSignalingMessage.type = "startedTyping"
|
ncSignalingMessage.to = sessionId
|
||||||
signalingMessageSender!!.send(ncSignalingMessage)
|
ncSignalingMessage.type = "startedTyping"
|
||||||
|
signalingMessageSender!!.send(ncSignalingMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
typingTimer = object : CountDownTimer(4000, 1000) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
sendStopTypingMessage()
|
||||||
|
typingTimer = null
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
} else {
|
||||||
|
typingTimer?.cancel()
|
||||||
|
typingTimer?.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
typingTimer = object : CountDownTimer(4000, 1000) {
|
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFinish() {
|
|
||||||
sendStopTypingMessage()
|
|
||||||
typingTimer = null
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
} else {
|
|
||||||
typingTimer?.cancel()
|
|
||||||
typingTimer?.start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ object CapabilitiesUtilNew {
|
|||||||
|
|
||||||
fun isTypingStatusAvailable(user: User): Boolean {
|
fun isTypingStatusAvailable(user: User): Boolean {
|
||||||
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
if (user.capabilities?.spreedCapability?.config?.containsKey("chat") == true) {
|
||||||
val map: Map<String, Any>? = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
val map = user.capabilities!!.spreedCapability!!.config!!["chat"]
|
||||||
return map != null && map.containsKey("typing-privacy")
|
return map != null && map.containsKey("typing-privacy")
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user