From 5a97e90a82d38e6b06f1dc9e9b4a82be604d0e75 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 23 May 2023 11:31:55 +0200 Subject: [PATCH] improve detekt score: avoid magicNumbers... Signed-off-by: Marcel Hibbe --- .../java/com/nextcloud/talk/chat/ChatActivity.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index d0f62eff7..a3a4ce232 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -908,6 +908,7 @@ class ChatActivity : } } + @Suppress("MagicNumber") private fun updateTypingIndicator() { fun ellipsize(text: String): String { return DisplayUtils.ellipsize(text, TYPING_INDICATOR_MAX_NAME_LENGTH) @@ -999,12 +1000,16 @@ class ChatActivity : for ((sessionId, participant) in webSocketInstance?.getUserMap()!!) { val ncSignalingMessage = NCSignalingMessage() ncSignalingMessage.to = sessionId - ncSignalingMessage.type = "startedTyping" + ncSignalingMessage.type = TYPING_STARTED_SIGNALING_MESSAGE_TYPE signalingMessageSender!!.send(ncSignalingMessage) } - typingTimer = object : CountDownTimer(4000, 1000) { + typingTimer = object : CountDownTimer( + TYPING_DURATION_BEFORE_SENDING_STOP, + TYPING_DURATION_BEFORE_SENDING_STOP + ) { override fun onTick(millisUntilFinished: Long) { + // unused atm } override fun onFinish() { @@ -1025,7 +1030,7 @@ class ChatActivity : for ((sessionId, participant) in webSocketInstance?.getUserMap()!!) { val ncSignalingMessage = NCSignalingMessage() ncSignalingMessage.to = sessionId - ncSignalingMessage.type = "stoppedTyping" + ncSignalingMessage.type = TYPING_STOPPED_SIGNALING_MESSAGE_TYPE signalingMessageSender!!.send(ncSignalingMessage) } } @@ -3795,5 +3800,8 @@ class ChatActivity : private const val COMMA = ", " private const val TYPING_INDICATOR_ANIMATION_DURATION = 200L private const val TYPING_INDICATOR_MAX_NAME_LENGTH = 14 + private const val TYPING_DURATION_BEFORE_SENDING_STOP = 4000L + private const val TYPING_STARTED_SIGNALING_MESSAGE_TYPE = "startedTyping" + private const val TYPING_STOPPED_SIGNALING_MESSAGE_TYPE = "stoppedTyping" } }