Merge pull request #4519 from nextcloud/style/noid/improveDetektScore

Improve detekt score
This commit is contained in:
Marcel Hibbe 2024-12-06 12:04:25 +01:00 committed by GitHub
commit 4c5287105d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 143 additions and 51 deletions

View File

@ -476,7 +476,7 @@ class CallActivity : CallBaseActivity() {
initClickListeners(isModerator, isOneToOneConversation) initClickListeners(isModerator, isOneToOneConversation)
binding!!.microphoneButton.setOnTouchListener(MicrophoneButtonTouchListener()) binding!!.microphoneButton.setOnTouchListener(MicrophoneButtonTouchListener())
pulseAnimation = PulseAnimation.create().with(binding!!.microphoneButton) pulseAnimation = PulseAnimation.create().with(binding!!.microphoneButton)
.setDuration(310) .setDuration(PULSE_ANIMATION_DURATION)
.setRepeatCount(PulseAnimation.INFINITE) .setRepeatCount(PulseAnimation.INFINITE)
.setRepeatMode(PulseAnimation.REVERSE) .setRepeatMode(PulseAnimation.REVERSE)
basicInitialization() basicInitialization()
@ -745,6 +745,7 @@ class CallActivity : CallBaseActivity() {
binding!!.endCallPopupMenu.text = context.getString(R.string.leave_call) binding!!.endCallPopupMenu.text = context.getString(R.string.leave_call)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun createCameraEnumerator() { private fun createCameraEnumerator() {
var camera2EnumeratorIsSupported = false var camera2EnumeratorIsSupported = false
try { try {
@ -931,17 +932,17 @@ class CallActivity : CallBaseActivity() {
resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
) { ) {
if (participantsInGrid > 2) { if (participantsInGrid > 2) {
2 GRID_MAX_COLUMN_COUNT_PORTRAIT
} else { } else {
1 GRID_MIN_COLUMN_COUNT_PORTRAIT
} }
} else { } else {
if (participantsInGrid > 2) { if (participantsInGrid > 2) {
3 GRID_MAX_COLUMN_COUNT_LANDSCAPE
} else if (participantsInGrid > 1) { } else if (participantsInGrid > 1) {
2 GRID_MIN_GROUP_COLUMN_COUNT_LANDSCAPE
} else { } else {
1 GRID_MIN_COLUMN_COUNT_LANDSCAPE
} }
} }
binding!!.gridview.numColumns = columns binding!!.gridview.numColumns = columns
@ -1264,18 +1265,18 @@ class CallActivity : CallBaseActivity() {
private fun getSpotlightView(): SpotlightView? { private fun getSpotlightView(): SpotlightView? {
val builder = SpotlightView.Builder(this) val builder = SpotlightView.Builder(this)
.introAnimationDuration(300) .introAnimationDuration(INTRO_ANIMATION_DURATION)
.enableRevealAnimation(true) .enableRevealAnimation(true)
.performClick(false) .performClick(false)
.fadeinTextDuration(400) .fadeinTextDuration(FADE_IN_ANIMATION_DURATION)
.headingTvSize(20) .headingTvSize(SPOTLIGHT_HEADING_SIZE)
.headingTvText(resources.getString(R.string.nc_push_to_talk)) .headingTvText(resources.getString(R.string.nc_push_to_talk))
.subHeadingTvColor(resources.getColor(R.color.bg_default, null)) .subHeadingTvColor(resources.getColor(R.color.bg_default, null))
.subHeadingTvSize(16) .subHeadingTvSize(SPOTLIGHT_SUBHEADING_SIZE)
.subHeadingTvText(resources.getString(R.string.nc_push_to_talk_desc)) .subHeadingTvText(resources.getString(R.string.nc_push_to_talk_desc))
.maskColor(Color.parseColor("#dc000000")) .maskColor(Color.parseColor("#dc000000"))
.target(binding!!.microphoneButton) .target(binding!!.microphoneButton)
.lineAnimDuration(400) .lineAnimDuration(FADE_IN_ANIMATION_DURATION)
.enableDismissAfterShown(true) .enableDismissAfterShown(true)
.dismissOnBackPress(true) .dismissOnBackPress(true)
.usageId("pushToTalk") .usageId("pushToTalk")
@ -1396,7 +1397,7 @@ class CallActivity : CallBaseActivity() {
callInfosHandler.removeCallbacksAndMessages(null) callInfosHandler.removeCallbacksAndMessages(null)
cameraSwitchHandler.removeCallbacksAndMessages(null) cameraSwitchHandler.removeCallbacksAndMessages(null)
alpha = OPACITY_ENABLED alpha = OPACITY_ENABLED
duration = SECOND_IN_MILLIES duration = SECOND_IN_MILLIS
if (binding!!.callControls.visibility != View.VISIBLE) { if (binding!!.callControls.visibility != View.VISIBLE) {
binding!!.callControls.alpha = OPACITY_INVISIBLE binding!!.callControls.alpha = OPACITY_INVISIBLE
binding!!.callControls.visibility = View.VISIBLE binding!!.callControls.visibility = View.VISIBLE
@ -1407,12 +1408,12 @@ class CallActivity : CallBaseActivity() {
binding!!.switchSelfVideoButton.visibility = View.VISIBLE binding!!.switchSelfVideoButton.visibility = View.VISIBLE
} }
} else { } else {
callControlHandler.postDelayed({ animateCallControls(false, 0) }, 5000) callControlHandler.postDelayed({ animateCallControls(false, 0) }, FIVE_SECONDS)
return return
} }
} else { } else {
alpha = OPACITY_INVISIBLE alpha = OPACITY_INVISIBLE
duration = SECOND_IN_MILLIES duration = SECOND_IN_MILLIS
} }
binding!!.callControls.isEnabled = false binding!!.callControls.isEnabled = false
binding!!.callControls.animate() binding!!.callControls.animate()
@ -1433,7 +1434,7 @@ class CallActivity : CallBaseActivity() {
if (!isPushToTalkActive) { if (!isPushToTalkActive) {
animateCallControls(false, 0) animateCallControls(false, 0)
} }
}, 7500) }, CALL_CONTROLLS_ANIMATION_DELAY)
} }
binding!!.callControls.isEnabled = true binding!!.callControls.isEnabled = true
} }
@ -1454,7 +1455,7 @@ class CallActivity : CallBaseActivity() {
if (!isPushToTalkActive) { if (!isPushToTalkActive) {
animateCallControls(false, 0) animateCallControls(false, 0)
} }
}, 7500) }, CALL_CONTROLLS_ANIMATION_DELAY)
} }
binding!!.callInfosLinearLayout.isEnabled = true binding!!.callInfosLinearLayout.isEnabled = true
} }
@ -1799,7 +1800,7 @@ class CallActivity : CallBaseActivity() {
) )
) { ) {
binding!!.callDuration.visibility = View.VISIBLE binding!!.callDuration.visibility = View.VISIBLE
val currentTimeInSec = System.currentTimeMillis() / SECOND_IN_MILLIES val currentTimeInSec = System.currentTimeMillis() / SECOND_IN_MILLIS
elapsedSeconds = currentTimeInSec - callStartTime elapsedSeconds = currentTimeInSec - callStartTime
val callTimeTask: Runnable = object : Runnable { val callTimeTask: Runnable = object : Runnable {
@ -1857,7 +1858,7 @@ class CallActivity : CallBaseActivity() {
} }
if (delayOnError.get() == 0) { if (delayOnError.get() == 0) {
delayOnError.set(1) delayOnError.set(1)
} else if (delayOnError.get() < 16) { } else if (delayOnError.get() < DELAY_ON_ERROR_STOP_THRESHOLD) {
delayOnError.set(delayOnError.get() * 2) delayOnError.set(delayOnError.get() * 2)
} }
Observable.timer(delayOnError.get().toLong(), TimeUnit.SECONDS) Observable.timer(delayOnError.get().toLong(), TimeUnit.SECONDS)
@ -2157,7 +2158,7 @@ class CallActivity : CallBaseActivity() {
Log.d( Log.d(
TAG, TAG,
" inCallFlag of participant " + " inCallFlag of participant " +
participant.sessionId!!.substring(0, 4) + participant.sessionId!!.substring(0, SESSION_ID_PREFFIX_END) +
" : " + " : " +
inCallFlag inCallFlag
) )
@ -2494,20 +2495,26 @@ class CallActivity : CallBaseActivity() {
val screenWidthDp = DisplayUtils.convertPixelToDp(screenWidthPx.toFloat(), applicationContext).toInt() val screenWidthDp = DisplayUtils.convertPixelToDp(screenWidthPx.toFloat(), applicationContext).toInt()
var newXafterRotate = 0f var newXafterRotate = 0f
val newYafterRotate: Float = if (binding!!.callInfosLinearLayout.visibility == View.VISIBLE) { val newYafterRotate: Float = if (binding!!.callInfosLinearLayout.visibility == View.VISIBLE) {
250f Y_POS_CALL_INFO
} else { } else {
20f Y_POS_NO_CALL_INFO
} }
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
layoutParams.height = resources.getDimension(R.dimen.call_self_video_short_side_length).toInt() layoutParams.height = resources.getDimension(R.dimen.call_self_video_short_side_length).toInt()
layoutParams.width = resources.getDimension(R.dimen.call_self_video_long_side_length).toInt() layoutParams.width = resources.getDimension(R.dimen.call_self_video_long_side_length).toInt()
newXafterRotate = newXafterRotate =
(screenWidthDp - resources.getDimension(R.dimen.call_self_video_short_side_length) * 0.8).toFloat() (
screenWidthDp - resources.getDimension(R.dimen.call_self_video_short_side_length) *
BY_80_PERCENT
).toFloat()
} else if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { } else if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
layoutParams.height = resources.getDimension(R.dimen.call_self_video_long_side_length).toInt() layoutParams.height = resources.getDimension(R.dimen.call_self_video_long_side_length).toInt()
layoutParams.width = resources.getDimension(R.dimen.call_self_video_short_side_length).toInt() layoutParams.width = resources.getDimension(R.dimen.call_self_video_short_side_length).toInt()
newXafterRotate = newXafterRotate =
(screenWidthDp - resources.getDimension(R.dimen.call_self_video_short_side_length) * 0.5).toFloat() (
screenWidthDp - resources.getDimension(R.dimen.call_self_video_short_side_length) *
BY_50_PERCENT
).toFloat()
} }
binding!!.selfVideoRenderer.layoutParams = layoutParams binding!!.selfVideoRenderer.layoutParams = layoutParams
val newXafterRotatePx = DisplayUtils.convertDpToPixel(newXafterRotate, applicationContext).toInt() val newXafterRotatePx = DisplayUtils.convertDpToPixel(newXafterRotate, applicationContext).toInt()
@ -2674,7 +2681,7 @@ class CallActivity : CallBaseActivity() {
} }
CallStatus.JOINED -> { CallStatus.JOINED -> {
handler!!.postDelayed({ setCallState(CallStatus.CALLING_TIMEOUT) }, 45000) handler!!.postDelayed({ setCallState(CallStatus.CALLING_TIMEOUT) }, CALLING_TIMEOUT)
handler!!.post { handler!!.post {
binding!!.callModeTextView.text = descriptionForCallType binding!!.callModeTextView.text = descriptionForCallType
if (isIncomingCallFromNotification) { if (isIncomingCallFromNotification) {
@ -2704,7 +2711,7 @@ class CallActivity : CallBaseActivity() {
binding!!.callInfosLinearLayout.visibility = View.GONE binding!!.callInfosLinearLayout.visibility = View.GONE
} }
if (!isPushToTalkActive) { if (!isPushToTalkActive) {
animateCallControls(false, 5000) animateCallControls(false, FIVE_SECONDS)
} }
if (binding!!.callStates.callStateRelativeLayout.visibility != View.INVISIBLE) { if (binding!!.callStates.callStateRelativeLayout.visibility != View.INVISIBLE) {
binding!!.callStates.callStateRelativeLayout.visibility = View.INVISIBLE binding!!.callStates.callStateRelativeLayout.visibility = View.INVISIBLE
@ -3032,7 +3039,7 @@ class CallActivity : CallBaseActivity() {
binding!!.microphoneButton.setImageResource(R.drawable.ic_mic_off_white_24px) binding!!.microphoneButton.setImageResource(R.drawable.ic_mic_off_white_24px)
pulseAnimation!!.stop() pulseAnimation!!.stop()
toggleMedia(false, false) toggleMedia(false, false)
animateCallControls(false, 5000) animateCallControls(false, FIVE_SECONDS)
} }
return true return true
} }
@ -3198,7 +3205,7 @@ class CallActivity : CallBaseActivity() {
const val OPACITY_DISABLED = 0.7f const val OPACITY_DISABLED = 0.7f
const val OPACITY_INVISIBLE = 0.0f const val OPACITY_INVISIBLE = 0.0f
const val SECOND_IN_MILLIES: Long = 1000 const val SECOND_IN_MILLIS: Long = 1000
const val CALL_TIME_COUNTER_DELAY: Long = 1000 const val CALL_TIME_COUNTER_DELAY: Long = 1000
const val CALL_TIME_ONE_HOUR = 3600 const val CALL_TIME_ONE_HOUR = 3600
const val CALL_DURATION_EMPTY = "--:--" const val CALL_DURATION_EMPTY = "--:--"
@ -3214,6 +3221,32 @@ class CallActivity : CallBaseActivity() {
private const val WIDTH: Int = 1280 private const val WIDTH: Int = 1280
private const val HEIGHT: Int = 720 private const val HEIGHT: Int = 720
private const val FIVE_SECONDS: Long = 5000
private const val CALLING_TIMEOUT: Long = 45000
private const val INTRO_ANIMATION_DURATION: Long = 300
private const val FADE_IN_ANIMATION_DURATION: Long = 400
private const val PULSE_ANIMATION_DURATION: Int = 310
private const val CALL_CONTROLLS_ANIMATION_DELAY: Long = 7500
private const val SPOTLIGHT_HEADING_SIZE: Int = 20
private const val SPOTLIGHT_SUBHEADING_SIZE: Int = 16
private const val GRID_MAX_COLUMN_COUNT_PORTRAIT: Int = 2
private const val GRID_MIN_COLUMN_COUNT_PORTRAIT: Int = 1
private const val GRID_MAX_COLUMN_COUNT_LANDSCAPE: Int = 3
private const val GRID_MIN_GROUP_COLUMN_COUNT_LANDSCAPE: Int = 2
private const val GRID_MIN_COLUMN_COUNT_LANDSCAPE: Int = 1
private const val DELAY_ON_ERROR_STOP_THRESHOLD: Int = 16
private const val BY_50_PERCENT = 0.5
private const val BY_80_PERCENT = 0.8
private const val Y_POS_CALL_INFO: Float = 250f
private const val Y_POS_NO_CALL_INFO: Float = 20f
private const val SESSION_ID_PREFFIX_END: Int = 4
private const val SIGNALING_MESSAGE_SPEAKING_STARTED = "speaking" private const val SIGNALING_MESSAGE_SPEAKING_STARTED = "speaking"
private const val SIGNALING_MESSAGE_SPEAKING_STOPPED = "stoppedSpeaking" private const val SIGNALING_MESSAGE_SPEAKING_STOPPED = "stoppedSpeaking"
private const val SIGNALING_MESSAGE_VIDEO_ON = "videoOn" private const val SIGNALING_MESSAGE_VIDEO_ON = "videoOn"

View File

@ -97,7 +97,7 @@ class ContactItem(
null null
) )
) )
holder?.binding?.avatarView?.alpha = 0.38f holder?.binding?.avatarView?.alpha = SEMI_TRANSPARENT
} else { } else {
holder?.binding?.nameText?.setTextColor( holder?.binding?.nameText?.setTextColor(
ResourcesCompat.getColor( ResourcesCompat.getColor(
@ -106,7 +106,7 @@ class ContactItem(
null null
) )
) )
holder?.binding?.avatarView?.alpha = 1.0f holder?.binding?.avatarView?.alpha = FULLY_OPAQUE
} }
holder?.binding?.nameText?.text = model.displayName holder?.binding?.nameText?.text = model.displayName
@ -188,4 +188,9 @@ class ContactItem(
var binding: RvItemContactBinding = var binding: RvItemContactBinding =
RvItemContactBinding.bind(view!!) RvItemContactBinding.bind(view!!)
} }
companion object {
private const val FULLY_OPAQUE: Float = 1.0f
private const val SEMI_TRANSPARENT: Float = 0.38f
}
} }

View File

@ -188,7 +188,7 @@ class MentionAutocompleteItem(
alignUsernameVertical(holder, 0f) alignUsernameVertical(holder, 0f)
} else { } else {
holder.binding.conversationInfoStatusMessage.text = "" holder.binding.conversationInfoStatusMessage.text = ""
alignUsernameVertical(holder, 10f) alignUsernameVertical(holder, NO_USER_STATUS_DP_FROM_TOP)
} }
if (!statusIcon.isNullOrEmpty()) { if (!statusIcon.isNullOrEmpty()) {
holder.binding.participantStatusEmoji.setText(statusIcon) holder.binding.participantStatusEmoji.setText(statusIcon)
@ -228,6 +228,7 @@ class MentionAutocompleteItem(
companion object { companion object {
private const val STATUS_SIZE_IN_DP = 9f private const val STATUS_SIZE_IN_DP = 9f
private const val NO_ICON = "" private const val NO_ICON = ""
private const val NO_USER_STATUS_DP_FROM_TOP: Float = 10f
const val SOURCE_CALLS = "calls" const val SOURCE_CALLS = "calls"
const val SOURCE_GUESTS = "guests" const val SOURCE_GUESTS = "guests"
const val SOURCE_GROUPS = "groups" const val SOURCE_GROUPS = "groups"

View File

@ -180,6 +180,7 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -158,6 +158,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -143,6 +143,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -165,6 +165,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -165,6 +165,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) { private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -278,6 +278,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -171,6 +171,7 @@ class OutcomingDeckCardViewHolder(
commonMessageInterface.onClickReaction(chatMessage, emoji) commonMessageInterface.onClickReaction(chatMessage, emoji)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -146,6 +146,7 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
commonMessageInterface.onClickReaction(chatMessage, emoji) commonMessageInterface.onClickReaction(chatMessage, emoji)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -198,6 +198,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
}) })
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -158,6 +158,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -157,6 +157,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
commonMessageInterface.onClickReaction(chatMessage, emoji) commonMessageInterface.onClickReaction(chatMessage, emoji)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) { private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -283,6 +283,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
binding.progressBar.visibility = View.VISIBLE binding.progressBar.visibility = View.VISIBLE
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) { private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -112,6 +112,7 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
ViewCompat.setBackground(bubble, bubbleDrawable) ViewCompat.setBackground(bubble, bubbleDrawable)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun processParentMessage(message: ChatMessage) { private fun processParentMessage(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) { if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {

View File

@ -576,9 +576,9 @@ class ChatActivity :
messageInputViewModel.messageQueueFlow.observe(this) { list -> messageInputViewModel.messageQueueFlow.observe(this) { list ->
list.forEachIndexed { _, qMsg -> list.forEachIndexed { _, qMsg ->
val temporaryChatMessage = ChatMessage() val temporaryChatMessage = ChatMessage()
temporaryChatMessage.jsonMessageId = -3 temporaryChatMessage.jsonMessageId = TEMPORARY_MESSAGE_ID_INT
temporaryChatMessage.actorId = "-3" temporaryChatMessage.actorId = "-3"
temporaryChatMessage.timestamp = System.currentTimeMillis() / 1000 temporaryChatMessage.timestamp = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
temporaryChatMessage.message = qMsg.message.toString() temporaryChatMessage.message = qMsg.message.toString()
temporaryChatMessage.tempMessageId = qMsg.id temporaryChatMessage.tempMessageId = qMsg.id
temporaryChatMessage.isTempMessage = true temporaryChatMessage.isTempMessage = true
@ -592,11 +592,11 @@ class ChatActivity :
messageInputViewModel.messageQueueSizeFlow.observe(this) { size -> messageInputViewModel.messageQueueSizeFlow.observe(this) { size ->
if (size == 0) { if (size == 0) {
var i = 0 var i = 0
var pos = adapter?.getMessagePositionById("-3") var pos = adapter?.getMessagePositionById(TEMPORARY_MESSAGE_ID_STRING)
while (pos != null && pos > -1) { while (pos != null && pos > -1) {
adapter?.items?.removeAt(pos) adapter?.items?.removeAt(pos)
i++ i++
pos = adapter?.getMessagePositionById("-3") pos = adapter?.getMessagePositionById(TEMPORARY_MESSAGE_ID_STRING)
} }
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} }
@ -1654,7 +1654,7 @@ class ChatActivity :
} }
} }
} }
mediaPlayerHandler?.postDelayed(this, MILISEC_15) mediaPlayerHandler?.postDelayed(this, MILLISEC_15)
} }
}) })
@ -2869,7 +2869,7 @@ class ChatActivity :
currentlyPlayedVoiceMessage = pair?.first currentlyPlayedVoiceMessage = pair?.first
val voiceMessagePosition = pair?.second!! val voiceMessagePosition = pair?.second!!
lastRecordMediaPosition = voiceMessageToRestoreAudioPosition * 1000 lastRecordMediaPosition = voiceMessageToRestoreAudioPosition * ONE_SECOND_IN_MILLIS
Log.d(RESUME_AUDIO_TAG, "trying to resume audio") Log.d(RESUME_AUDIO_TAG, "trying to resume audio")
binding.messagesListView.scrollToPosition(voiceMessagePosition) binding.messagesListView.scrollToPosition(voiceMessagePosition)
// WORKAROUND TO FETCH FILE INFO: // WORKAROUND TO FETCH FILE INFO:
@ -3851,13 +3851,15 @@ class ChatActivity :
private const val TYPING_INDICATOR_MAX_NAME_LENGTH = 14 private const val TYPING_INDICATOR_MAX_NAME_LENGTH = 14
private const val TYPING_INDICATOR_POSITION_VISIBLE = -18f private const val TYPING_INDICATOR_POSITION_VISIBLE = -18f
private const val TYPING_INDICATOR_POSITION_HIDDEN = -1f private const val TYPING_INDICATOR_POSITION_HIDDEN = -1f
private const val MILISEC_15: Long = 15 private const val MILLISEC_15: Long = 15
private const val CURRENT_AUDIO_MESSAGE_KEY = "CURRENT_AUDIO_MESSAGE" private const val CURRENT_AUDIO_MESSAGE_KEY = "CURRENT_AUDIO_MESSAGE"
private const val CURRENT_AUDIO_POSITION_KEY = "CURRENT_AUDIO_POSITION" private const val CURRENT_AUDIO_POSITION_KEY = "CURRENT_AUDIO_POSITION"
private const val CURRENT_AUDIO_WAS_PLAYING_KEY = "CURRENT_AUDIO_PLAYING" private const val CURRENT_AUDIO_WAS_PLAYING_KEY = "CURRENT_AUDIO_PLAYING"
private const val RESUME_AUDIO_TAG = "RESUME_AUDIO_TAG" private const val RESUME_AUDIO_TAG = "RESUME_AUDIO_TAG"
private const val DELAY_TO_SHOW_PROGRESS_BAR = 1000L private const val DELAY_TO_SHOW_PROGRESS_BAR = 1000L
private const val FIVE_MINUTES_IN_SECONDS: Long = 300 private const val FIVE_MINUTES_IN_SECONDS: Long = 300
private const val TEMPORARY_MESSAGE_ID_INT: Int = -3
private const val TEMPORARY_MESSAGE_ID_STRING: String = "-3"
const val CONVERSATION_INTERNAL_ID = "CONVERSATION_INTERNAL_ID" const val CONVERSATION_INTERNAL_ID = "CONVERSATION_INTERNAL_ID"
const val NO_OFFLINE_MESSAGES_FOUND = "NO_OFFLINE_MESSAGES_FOUND" const val NO_OFFLINE_MESSAGES_FOUND = "NO_OFFLINE_MESSAGES_FOUND"
} }

View File

@ -105,6 +105,9 @@ class MessageInputFragment : Fragment() {
private const val VOICE_RECORD_LOCK_THRESHOLD: Float = 100f private const val VOICE_RECORD_LOCK_THRESHOLD: Float = 100f
private const val INCREMENT = 8f private const val INCREMENT = 8f
private const val CURSOR_KEY = "_cursor" private const val CURSOR_KEY = "_cursor"
private const val CONNECTION_ESTABLISHED_ANIM_DURATION: Long = 3000
private const val FULLY_OPAQUE: Float = 1.0f
private const val FULLY_TRANSPARENT: Float = 0.0f
} }
@Inject @Inject
@ -256,8 +259,8 @@ class MessageInputFragment : Fragment() {
private fun handleUI(isOnline: Boolean, connectionGained: Boolean) { private fun handleUI(isOnline: Boolean, connectionGained: Boolean) {
if (isOnline) { if (isOnline) {
if (connectionGained) { if (connectionGained) {
val animation: Animation = AlphaAnimation(1.0f, 0.0f) val animation: Animation = AlphaAnimation(FULLY_OPAQUE, FULLY_TRANSPARENT)
animation.duration = 3000 animation.duration = CONNECTION_ESTABLISHED_ANIM_DURATION
animation.interpolator = LinearInterpolator() animation.interpolator = LinearInterpolator()
binding.fragmentConnectionLost.setBackgroundColor(resources.getColor(R.color.hwSecurityGreen)) binding.fragmentConnectionLost.setBackgroundColor(resources.getColor(R.color.hwSecurityGreen))
binding.fragmentConnectionLost.text = getString(R.string.connection_established) binding.fragmentConnectionLost.text = getString(R.string.connection_established)
@ -649,7 +652,7 @@ class MessageInputFragment : Fragment() {
private fun showRecordAudioUi(show: Boolean) { private fun showRecordAudioUi(show: Boolean) {
if (show) { if (show) {
val animation: Animation = AlphaAnimation(1.0f, 0.0f) val animation: Animation = AlphaAnimation(FULLY_OPAQUE, FULLY_TRANSPARENT)
animation.duration = ANIMATION_DURATION animation.duration = ANIMATION_DURATION
animation.interpolator = LinearInterpolator() animation.interpolator = LinearInterpolator()
animation.repeatCount = Animation.INFINITE animation.repeatCount = Animation.INFINITE

View File

@ -399,7 +399,7 @@ class OfflineFirstChatRepository @Inject constructor(
.map(ChatMessageEntity::asModel) .map(ChatMessageEntity::asModel)
} }
@Suppress("UNCHECKED_CAST", "MagicNumber") @Suppress("UNCHECKED_CAST", "MagicNumber", "Detekt.TooGenericExceptionCaught")
private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? { private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? {
val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int> val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int>

View File

@ -69,6 +69,7 @@ class ContactsViewModel @Inject constructor(
_isAddParticipantsView.value = value _isAddParticipantsView.value = value
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun getContactsFromSearchParams() { fun getContactsFromSearchParams() {
_contactsViewState.value = ContactsUiState.Loading _contactsViewState.value = ContactsUiState.Loading
viewModelScope.launch { viewModelScope.launch {
@ -84,6 +85,8 @@ class ContactsViewModel @Inject constructor(
} }
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?) { fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?) {
viewModelScope.launch { viewModelScope.launch {
try { try {

View File

@ -75,6 +75,7 @@ class ConversationCreationViewModel @Inject constructor(
_conversationDescription.value = conversationDescription _conversationDescription.value = conversationDescription
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoomAndAddParticipants( fun createRoomAndAddParticipants(
roomType: String, roomType: String,
conversationName: String, conversationName: String,
@ -142,6 +143,7 @@ class ConversationCreationViewModel @Inject constructor(
return repository.getImageUri(avatarId, requestBigSize) return repository.getImageUri(avatarId, requestBigSize)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoom(roomType: String, conversationName: String?) { fun createRoom(roomType: String, conversationName: String?) {
viewModelScope.launch { viewModelScope.launch {
try { try {

View File

@ -150,6 +150,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun listBans(user: User, token: String) { fun listBans(user: User, token: String) {
val url = ApiUtils.getUrlForBans(user.baseUrl!!, token) val url = ApiUtils.getUrlForBans(user.baseUrl!!, token)
viewModelScope.launch { viewModelScope.launch {
@ -163,6 +164,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun banActor(user: User, token: String, actorType: String, actorId: String, internalNote: String) { fun banActor(user: User, token: String, actorType: String, actorId: String, internalNote: String) {
val url = ApiUtils.getUrlForBans(user.baseUrl!!, token) val url = ApiUtils.getUrlForBans(user.baseUrl!!, token)
viewModelScope.launch { viewModelScope.launch {
@ -182,6 +184,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun setConversationReadOnly(roomToken: String, state: Int) { fun setConversationReadOnly(roomToken: String, state: Int) {
viewModelScope.launch { viewModelScope.launch {
try { try {
@ -193,6 +196,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun unbanActor(user: User, token: String, banId: Int) { fun unbanActor(user: User, token: String, banId: Int) {
val url = ApiUtils.getUrlForUnban(user.baseUrl!!, token, banId) val url = ApiUtils.getUrlForUnban(user.baseUrl!!, token, banId)
viewModelScope.launch { viewModelScope.launch {
@ -206,6 +210,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun allowGuests(token: String, allow: Boolean) { fun allowGuests(token: String, allow: Boolean) {
viewModelScope.launch { viewModelScope.launch {
try { try {
@ -217,6 +222,7 @@ class ConversationInfoViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("SuspiciousIndentation") @SuppressLint("SuspiciousIndentation")
fun setPassword(password: String, token: String) { fun setPassword(password: String, token: String) {
viewModelScope.launch { viewModelScope.launch {
@ -241,6 +247,7 @@ class ConversationInfoViewModel @Inject constructor(
conversationsRepository.unarchiveConversation(user.getCredentials(), url) conversationsRepository.unarchiveConversation(user.getCredentials(), url)
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun clearChatHistory(apiVersion: Int, roomToken: String) { fun clearChatHistory(apiVersion: Int, roomToken: String) {
viewModelScope.launch { viewModelScope.launch {
try { try {

View File

@ -75,6 +75,7 @@ class ConversationInfoEditViewModel @Inject constructor(
?.subscribe(DeleteConversationAvatarObserver()) ?.subscribe(DeleteConversationAvatarObserver())
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun renameRoom(roomToken: String, newRoomName: String) { fun renameRoom(roomToken: String, newRoomName: String) {
viewModelScope.launch { viewModelScope.launch {
try { try {
@ -86,6 +87,7 @@ class ConversationInfoEditViewModel @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
fun setConversationDescription(roomToken: String, conversationDescription: String?) { fun setConversationDescription(roomToken: String, conversationDescription: String?) {
viewModelScope.launch { viewModelScope.launch {
try { try {

View File

@ -1042,7 +1042,7 @@ class ConversationsListActivity :
val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager? val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager?
layoutManager?.scrollToPositionWithOffset( layoutManager?.scrollToPositionWithOffset(
nextUnreadConversationScrollPosition, nextUnreadConversationScrollPosition,
binding.recyclerView.height / 3 binding.recyclerView.height / OFFSET_HEIGHT_DIVIDER
) )
} }
binding.newMentionPopupBubble.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it) } binding.newMentionPopupBubble.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it) }
@ -1960,5 +1960,6 @@ class ConversationsListActivity :
const val BADGE_OFFSET = 35 const val BADGE_OFFSET = 35
const val DAYS_FOR_NOTIFICATION_WARNING = 5L const val DAYS_FOR_NOTIFICATION_WARNING = 5L
const val NOTIFICATION_WARNING_DATE_NOT_SET = 0L const val NOTIFICATION_WARNING_DATE_NOT_SET = 0L
const val OFFSET_HEIGHT_DIVIDER: Int = 3
} }
} }

View File

@ -102,6 +102,7 @@ class OfflineFirstConversationsRepository @Inject constructor(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private suspend fun getRoomsFromServer(): List<ConversationEntity>? { private suspend fun getRoomsFromServer(): List<ConversationEntity>? {
var conversationsFromSync: List<ConversationEntity>? = null var conversationsFromSync: List<ConversationEntity>? = null

View File

@ -13,6 +13,7 @@ import com.bluelinelabs.logansquare.LoganSquare
class ArrayListConverter { class ArrayListConverter {
@Suppress("Detekt.TooGenericExceptionCaught")
@TypeConverter @TypeConverter
fun arrayListToString(list: ArrayList<String>?): String? { fun arrayListToString(list: ArrayList<String>?): String? {
return if (list == null) { return if (list == null) {

View File

@ -62,9 +62,11 @@ class LeaveConversationWorker(context: Context, workerParams: WorkerParameters)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<GenericOverall?> { .subscribe(object : Observer<GenericOverall?> {
override fun onSubscribe(d: Disposable) { override fun onSubscribe(d: Disposable) {
// unused atm
} }
override fun onNext(p0: GenericOverall) { override fun onNext(p0: GenericOverall) {
// unused atm
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {

View File

@ -36,6 +36,7 @@ import java.net.URLConnection
class SaveFileToStorageWorker(val context: Context, workerParameters: WorkerParameters) : class SaveFileToStorageWorker(val context: Context, workerParameters: WorkerParameters) :
Worker(context, workerParameters) { Worker(context, workerParameters) {
@Suppress("Detekt.TooGenericExceptionCaught")
override fun doWork(): Result { override fun doWork(): Result {
try { try {
val sourceFilePath = inputData.getString(KEY_SOURCE_FILE_PATH) val sourceFilePath = inputData.getString(KEY_SOURCE_FILE_PATH)

View File

@ -1130,6 +1130,7 @@ class SettingsActivity :
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) { override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults) super.onRequestPermissionsResult(requestCode, permissions, grantResults)
@ -1349,6 +1350,7 @@ class SettingsActivity :
}) })
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeReadPrivacy() { private fun observeReadPrivacy() {
lifecycleScope.launch { lifecycleScope.launch {
var state = appPreferences.readPrivacy var state = appPreferences.readPrivacy
@ -1384,6 +1386,7 @@ class SettingsActivity :
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeTypingStatus() { private fun observeTypingStatus() {
lifecycleScope.launch { lifecycleScope.launch {
var state = appPreferences.typingStatus var state = appPreferences.typingStatus

View File

@ -202,6 +202,7 @@ class ConversationsListBottomDialog(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught") @SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun addConversationToFavorites() { private fun addConversationToFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
@ -228,6 +229,7 @@ class ConversationsListBottomDialog(
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught") @SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun removeConversationFromFavorites() { private fun removeConversationFromFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))

View File

@ -72,6 +72,7 @@ import java.util.regex.Pattern
object DisplayUtils { object DisplayUtils {
private val TAG = DisplayUtils::class.java.getSimpleName() private val TAG = DisplayUtils::class.java.getSimpleName()
private const val INDEX_LUMINATION = 2 private const val INDEX_LUMINATION = 2
private const val HSL_SIZE = 3
private const val MAX_LIGHTNESS = 0.92 private const val MAX_LIGHTNESS = 0.92
private const val TWITTER_HANDLE_PREFIX = "@" private const val TWITTER_HANDLE_PREFIX = "@"
private const val HTTP_PROTOCOL = "http://" private const val HTTP_PROTOCOL = "http://"
@ -80,6 +81,7 @@ object DisplayUtils {
private const val HTTPS_MIN_LENGTH: Int = 7 private const val HTTPS_MIN_LENGTH: Int = 7
private const val DATE_TIME_PARTS_SIZE = 2 private const val DATE_TIME_PARTS_SIZE = 2
private const val ONE_MINUTE_IN_MILLIS: Int = 60000 private const val ONE_MINUTE_IN_MILLIS: Int = 60000
private const val ROUND_UP_BUMP: Float = 0.5f
fun isDarkModeOn(context: Context): Boolean { fun isDarkModeOn(context: Context): Boolean {
val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return currentNightMode == Configuration.UI_MODE_NIGHT_YES return currentNightMode == Configuration.UI_MODE_NIGHT_YES
@ -126,7 +128,7 @@ object DisplayUtils {
TypedValue.applyDimension( TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dp, TypedValue.COMPLEX_UNIT_DIP, dp,
context.resources.displayMetrics context.resources.displayMetrics
) + 0.5f ) + ROUND_UP_BUMP
).toFloat() ).toFloat()
} }
@ -195,7 +197,9 @@ object DisplayUtils {
.crossfade(true) .crossfade(true)
.transformations(CircleCropTransformation()) .transformations(CircleCropTransformation())
.target(object : Target { .target(object : Target {
override fun onStart(placeholder: Drawable?) {} override fun onStart(placeholder: Drawable?) {
// unused atm
}
override fun onError(error: Drawable?) { override fun onError(error: Drawable?) {
chip.chipIcon = error chip.chipIcon = error
} }
@ -374,7 +378,7 @@ object DisplayUtils {
} }
private fun colorToHSL(color: Int): FloatArray { private fun colorToHSL(color: Int): FloatArray {
val hsl = FloatArray(3) val hsl = FloatArray(HSL_SIZE)
ColorUtils.RGBToHSL(Color.red(color), Color.green(color), Color.blue(color), hsl) ColorUtils.RGBToHSL(Color.red(color), Color.green(color), Color.blue(color), hsl)
return hsl return hsl
} }

View File

@ -150,7 +150,8 @@ class PushUtils {
val result = StringBuilder() val result = StringBuilder()
for (individualByte in bytes) { for (individualByte in bytes) {
result.append( result.append(
Integer.toString((individualByte.toInt() and 0xff) + 0x100, 16) ((individualByte.toInt() and BYTES_TO_HEX_SUFFIX) + BYTES_TO_HEX_SUFFIX_SUFFIX)
.toString(BYTES_TO_HEX_RADIX)
.substring(1) .substring(1)
) )
} }
@ -403,6 +404,9 @@ class PushUtils {
private const val RETURN_CODE_KEY_GENERATION_SUCCESSFUL: Int = 0 private const val RETURN_CODE_KEY_GENERATION_SUCCESSFUL: Int = 0
private const val RETURN_CODE_KEY_ALREADY_EXISTS: Int = -1 private const val RETURN_CODE_KEY_ALREADY_EXISTS: Int = -1
private const val RETURN_CODE_KEY_GENERATION_FAILED: Int = -2 private const val RETURN_CODE_KEY_GENERATION_FAILED: Int = -2
private const val BYTES_TO_HEX_RADIX: Int = 16
private const val BYTES_TO_HEX_SUFFIX = 0xff
private const val BYTES_TO_HEX_SUFFIX_SUFFIX = 0x100
const val LATEST_PUSH_REGISTRATION_AT_SERVER: String = "LATEST_PUSH_REGISTRATION_AT_SERVER" const val LATEST_PUSH_REGISTRATION_AT_SERVER: String = "LATEST_PUSH_REGISTRATION_AT_SERVER"
const val LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY: String = "LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY" const val LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY: String = "LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY"
} }

View File

@ -522,6 +522,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
} }
} }
@Suppress("Detekt.TooGenericExceptionCaught")
override fun getMessageQueue(internalConversationId: String): MutableList<MessageInputViewModel.QueuedMessage> { override fun getMessageQueue(internalConversationId: String): MutableList<MessageInputViewModel.QueuedMessage> {
val queueStr = val queueStr =
runBlocking { async { readString(internalConversationId + MESSAGE_QUEUE).first() } }.getCompleted() runBlocking { async { readString(internalConversationId + MESSAGE_QUEUE).first() } }.getCompleted()

View File

@ -8,7 +8,6 @@
*/ */
package com.nextcloud.talk.utils.preferences.preferencestorage package com.nextcloud.talk.utils.preferences.preferencestorage
import android.annotation.SuppressLint
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import autodagger.AutoInjector import autodagger.AutoInjector
@ -64,10 +63,10 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
this.conversationToken = conversationToken this.conversationToken = conversationToken
} }
@SuppressLint("TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveBoolean(key: String, value: Boolean) { suspend fun saveBoolean(key: String, value: Boolean) {
if ("call_notifications_switch" == key) { if ("call_notifications_switch" == key) {
val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(4)) val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4))
val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken) val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken)
val credentials = getCredentials(conversationUser.username, conversationUser.token) val credentials = getCredentials(conversationUser.username, conversationUser.token)
val notificationLevel = if (value) 1 else 0 val notificationLevel = if (value) 1 else 0
@ -92,7 +91,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
} }
} }
@SuppressLint("TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveString(key: String, value: String) { suspend fun saveString(key: String, value: String) {
when (key) { when (key) {
"conversation_settings_dropdown" -> { "conversation_settings_dropdown" -> {

View File

@ -12,10 +12,12 @@ import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
import com.nextcloud.talk.models.json.conversations.RoomOverall import com.nextcloud.talk.models.json.conversations.RoomOverall
class FakeRepositoryError : ContactsRepository { class FakeRepositoryError : ContactsRepository {
@Suppress("Detekt.TooGenericExceptionThrown")
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall { override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
throw Exception("unable to fetch contacts") throw Exception("unable to fetch contacts")
} }
@Suppress("Detekt.TooGenericExceptionThrown")
override suspend fun createRoom( override suspend fun createRoom(
roomType: String, roomType: String,
sourceType: String, sourceType: String,

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
build: build:
maxIssues: 202 maxIssues: 122
weights: weights:
# complexity: 2 # complexity: 2
# LongParameterList: 1 # LongParameterList: 1