Merge pull request #4524 from nextcloud/backport/4519/stable-20.1

[stable-20.1] Improve detekt score
This commit is contained in:
Andy Scherzinger 2024-12-06 19:42:16 +01:00 committed by GitHub
commit 4f22aa99d6
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)
binding!!.microphoneButton.setOnTouchListener(MicrophoneButtonTouchListener())
pulseAnimation = PulseAnimation.create().with(binding!!.microphoneButton)
.setDuration(310)
.setDuration(PULSE_ANIMATION_DURATION)
.setRepeatCount(PulseAnimation.INFINITE)
.setRepeatMode(PulseAnimation.REVERSE)
basicInitialization()
@ -745,6 +745,7 @@ class CallActivity : CallBaseActivity() {
binding!!.endCallPopupMenu.text = context.getString(R.string.leave_call)
}
@Suppress("Detekt.TooGenericExceptionCaught")
private fun createCameraEnumerator() {
var camera2EnumeratorIsSupported = false
try {
@ -931,17 +932,17 @@ class CallActivity : CallBaseActivity() {
resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
) {
if (participantsInGrid > 2) {
2
GRID_MAX_COLUMN_COUNT_PORTRAIT
} else {
1
GRID_MIN_COLUMN_COUNT_PORTRAIT
}
} else {
if (participantsInGrid > 2) {
3
GRID_MAX_COLUMN_COUNT_LANDSCAPE
} else if (participantsInGrid > 1) {
2
GRID_MIN_GROUP_COLUMN_COUNT_LANDSCAPE
} else {
1
GRID_MIN_COLUMN_COUNT_LANDSCAPE
}
}
binding!!.gridview.numColumns = columns
@ -1264,18 +1265,18 @@ class CallActivity : CallBaseActivity() {
private fun getSpotlightView(): SpotlightView? {
val builder = SpotlightView.Builder(this)
.introAnimationDuration(300)
.introAnimationDuration(INTRO_ANIMATION_DURATION)
.enableRevealAnimation(true)
.performClick(false)
.fadeinTextDuration(400)
.headingTvSize(20)
.fadeinTextDuration(FADE_IN_ANIMATION_DURATION)
.headingTvSize(SPOTLIGHT_HEADING_SIZE)
.headingTvText(resources.getString(R.string.nc_push_to_talk))
.subHeadingTvColor(resources.getColor(R.color.bg_default, null))
.subHeadingTvSize(16)
.subHeadingTvSize(SPOTLIGHT_SUBHEADING_SIZE)
.subHeadingTvText(resources.getString(R.string.nc_push_to_talk_desc))
.maskColor(Color.parseColor("#dc000000"))
.target(binding!!.microphoneButton)
.lineAnimDuration(400)
.lineAnimDuration(FADE_IN_ANIMATION_DURATION)
.enableDismissAfterShown(true)
.dismissOnBackPress(true)
.usageId("pushToTalk")
@ -1396,7 +1397,7 @@ class CallActivity : CallBaseActivity() {
callInfosHandler.removeCallbacksAndMessages(null)
cameraSwitchHandler.removeCallbacksAndMessages(null)
alpha = OPACITY_ENABLED
duration = SECOND_IN_MILLIES
duration = SECOND_IN_MILLIS
if (binding!!.callControls.visibility != View.VISIBLE) {
binding!!.callControls.alpha = OPACITY_INVISIBLE
binding!!.callControls.visibility = View.VISIBLE
@ -1407,12 +1408,12 @@ class CallActivity : CallBaseActivity() {
binding!!.switchSelfVideoButton.visibility = View.VISIBLE
}
} else {
callControlHandler.postDelayed({ animateCallControls(false, 0) }, 5000)
callControlHandler.postDelayed({ animateCallControls(false, 0) }, FIVE_SECONDS)
return
}
} else {
alpha = OPACITY_INVISIBLE
duration = SECOND_IN_MILLIES
duration = SECOND_IN_MILLIS
}
binding!!.callControls.isEnabled = false
binding!!.callControls.animate()
@ -1433,7 +1434,7 @@ class CallActivity : CallBaseActivity() {
if (!isPushToTalkActive) {
animateCallControls(false, 0)
}
}, 7500)
}, CALL_CONTROLLS_ANIMATION_DELAY)
}
binding!!.callControls.isEnabled = true
}
@ -1454,7 +1455,7 @@ class CallActivity : CallBaseActivity() {
if (!isPushToTalkActive) {
animateCallControls(false, 0)
}
}, 7500)
}, CALL_CONTROLLS_ANIMATION_DELAY)
}
binding!!.callInfosLinearLayout.isEnabled = true
}
@ -1799,7 +1800,7 @@ class CallActivity : CallBaseActivity() {
)
) {
binding!!.callDuration.visibility = View.VISIBLE
val currentTimeInSec = System.currentTimeMillis() / SECOND_IN_MILLIES
val currentTimeInSec = System.currentTimeMillis() / SECOND_IN_MILLIS
elapsedSeconds = currentTimeInSec - callStartTime
val callTimeTask: Runnable = object : Runnable {
@ -1857,7 +1858,7 @@ class CallActivity : CallBaseActivity() {
}
if (delayOnError.get() == 0) {
delayOnError.set(1)
} else if (delayOnError.get() < 16) {
} else if (delayOnError.get() < DELAY_ON_ERROR_STOP_THRESHOLD) {
delayOnError.set(delayOnError.get() * 2)
}
Observable.timer(delayOnError.get().toLong(), TimeUnit.SECONDS)
@ -2157,7 +2158,7 @@ class CallActivity : CallBaseActivity() {
Log.d(
TAG,
" inCallFlag of participant " +
participant.sessionId!!.substring(0, 4) +
participant.sessionId!!.substring(0, SESSION_ID_PREFFIX_END) +
" : " +
inCallFlag
)
@ -2494,20 +2495,26 @@ class CallActivity : CallBaseActivity() {
val screenWidthDp = DisplayUtils.convertPixelToDp(screenWidthPx.toFloat(), applicationContext).toInt()
var newXafterRotate = 0f
val newYafterRotate: Float = if (binding!!.callInfosLinearLayout.visibility == View.VISIBLE) {
250f
Y_POS_CALL_INFO
} else {
20f
Y_POS_NO_CALL_INFO
}
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
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()
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) {
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()
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
val newXafterRotatePx = DisplayUtils.convertDpToPixel(newXafterRotate, applicationContext).toInt()
@ -2674,7 +2681,7 @@ class CallActivity : CallBaseActivity() {
}
CallStatus.JOINED -> {
handler!!.postDelayed({ setCallState(CallStatus.CALLING_TIMEOUT) }, 45000)
handler!!.postDelayed({ setCallState(CallStatus.CALLING_TIMEOUT) }, CALLING_TIMEOUT)
handler!!.post {
binding!!.callModeTextView.text = descriptionForCallType
if (isIncomingCallFromNotification) {
@ -2704,7 +2711,7 @@ class CallActivity : CallBaseActivity() {
binding!!.callInfosLinearLayout.visibility = View.GONE
}
if (!isPushToTalkActive) {
animateCallControls(false, 5000)
animateCallControls(false, FIVE_SECONDS)
}
if (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)
pulseAnimation!!.stop()
toggleMedia(false, false)
animateCallControls(false, 5000)
animateCallControls(false, FIVE_SECONDS)
}
return true
}
@ -3198,7 +3205,7 @@ class CallActivity : CallBaseActivity() {
const val OPACITY_DISABLED = 0.7f
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_ONE_HOUR = 3600
const val CALL_DURATION_EMPTY = "--:--"
@ -3214,6 +3221,32 @@ class CallActivity : CallBaseActivity() {
private const val WIDTH: Int = 1280
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_STOPPED = "stoppedSpeaking"
private const val SIGNALING_MESSAGE_VIDEO_ON = "videoOn"

View File

@ -97,7 +97,7 @@ class ContactItem(
null
)
)
holder?.binding?.avatarView?.alpha = 0.38f
holder?.binding?.avatarView?.alpha = SEMI_TRANSPARENT
} else {
holder?.binding?.nameText?.setTextColor(
ResourcesCompat.getColor(
@ -106,7 +106,7 @@ class ContactItem(
null
)
)
holder?.binding?.avatarView?.alpha = 1.0f
holder?.binding?.avatarView?.alpha = FULLY_OPAQUE
}
holder?.binding?.nameText?.text = model.displayName
@ -188,4 +188,9 @@ class ContactItem(
var binding: RvItemContactBinding =
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)
} else {
holder.binding.conversationInfoStatusMessage.text = ""
alignUsernameVertical(holder, 10f)
alignUsernameVertical(holder, NO_USER_STATUS_DP_FROM_TOP)
}
if (!statusIcon.isNullOrEmpty()) {
holder.binding.participantStatusEmoji.setText(statusIcon)
@ -228,6 +228,7 @@ class MentionAutocompleteItem(
companion object {
private const val STATUS_SIZE_IN_DP = 9f
private const val NO_ICON = ""
private const val NO_USER_STATUS_DP_FROM_TOP: Float = 10f
const val SOURCE_CALLS = "calls"
const val SOURCE_GUESTS = "guests"
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)
}
@Suppress("Detekt.TooGenericExceptionCaught")
private fun setParentMessageDataOnMessageItem(message: ChatMessage) {
if (message.parentMessageId != null && !message.isDeleted) {
CoroutineScope(Dispatchers.Main).launch {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -555,9 +555,9 @@ class ChatActivity :
messageInputViewModel.messageQueueFlow.observe(this) { list ->
list.forEachIndexed { _, qMsg ->
val temporaryChatMessage = ChatMessage()
temporaryChatMessage.jsonMessageId = -3
temporaryChatMessage.jsonMessageId = TEMPORARY_MESSAGE_ID_INT
temporaryChatMessage.actorId = "-3"
temporaryChatMessage.timestamp = System.currentTimeMillis() / 1000
temporaryChatMessage.timestamp = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
temporaryChatMessage.message = qMsg.message.toString()
temporaryChatMessage.tempMessageId = qMsg.id
temporaryChatMessage.isTempMessage = true
@ -571,11 +571,11 @@ class ChatActivity :
messageInputViewModel.messageQueueSizeFlow.observe(this) { size ->
if (size == 0) {
var i = 0
var pos = adapter?.getMessagePositionById("-3")
var pos = adapter?.getMessagePositionById(TEMPORARY_MESSAGE_ID_STRING)
while (pos != null && pos > -1) {
adapter?.items?.removeAt(pos)
i++
pos = adapter?.getMessagePositionById("-3")
pos = adapter?.getMessagePositionById(TEMPORARY_MESSAGE_ID_STRING)
}
adapter?.notifyDataSetChanged()
}
@ -1618,7 +1618,7 @@ class ChatActivity :
}
}
}
mediaPlayerHandler?.postDelayed(this, MILISEC_15)
mediaPlayerHandler?.postDelayed(this, MILLISEC_15)
}
})
@ -2817,7 +2817,7 @@ class ChatActivity :
currentlyPlayedVoiceMessage = pair?.first
val voiceMessagePosition = pair?.second!!
lastRecordMediaPosition = voiceMessageToRestoreAudioPosition * 1000
lastRecordMediaPosition = voiceMessageToRestoreAudioPosition * ONE_SECOND_IN_MILLIS
Log.d(RESUME_AUDIO_TAG, "trying to resume audio")
binding.messagesListView.scrollToPosition(voiceMessagePosition)
// WORKAROUND TO FETCH FILE INFO:
@ -3799,13 +3799,15 @@ class ChatActivity :
private const val TYPING_INDICATOR_MAX_NAME_LENGTH = 14
private const val TYPING_INDICATOR_POSITION_VISIBLE = -18f
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_POSITION_KEY = "CURRENT_AUDIO_POSITION"
private const val CURRENT_AUDIO_WAS_PLAYING_KEY = "CURRENT_AUDIO_PLAYING"
private const val RESUME_AUDIO_TAG = "RESUME_AUDIO_TAG"
private const val DELAY_TO_SHOW_PROGRESS_BAR = 1000L
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 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 INCREMENT = 8f
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
@ -256,8 +259,8 @@ class MessageInputFragment : Fragment() {
private fun handleUI(isOnline: Boolean, connectionGained: Boolean) {
if (isOnline) {
if (connectionGained) {
val animation: Animation = AlphaAnimation(1.0f, 0.0f)
animation.duration = 3000
val animation: Animation = AlphaAnimation(FULLY_OPAQUE, FULLY_TRANSPARENT)
animation.duration = CONNECTION_ESTABLISHED_ANIM_DURATION
animation.interpolator = LinearInterpolator()
binding.fragmentConnectionLost.setBackgroundColor(resources.getColor(R.color.hwSecurityGreen))
binding.fragmentConnectionLost.text = getString(R.string.connection_established)
@ -649,7 +652,7 @@ class MessageInputFragment : Fragment() {
private fun showRecordAudioUi(show: Boolean) {
if (show) {
val animation: Animation = AlphaAnimation(1.0f, 0.0f)
val animation: Animation = AlphaAnimation(FULLY_OPAQUE, FULLY_TRANSPARENT)
animation.duration = ANIMATION_DURATION
animation.interpolator = LinearInterpolator()
animation.repeatCount = Animation.INFINITE

View File

@ -399,7 +399,7 @@ class OfflineFirstChatRepository @Inject constructor(
.map(ChatMessageEntity::asModel)
}
@Suppress("UNCHECKED_CAST", "MagicNumber")
@Suppress("UNCHECKED_CAST", "MagicNumber", "Detekt.TooGenericExceptionCaught")
private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? {
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
}
@Suppress("Detekt.TooGenericExceptionCaught")
fun getContactsFromSearchParams() {
_contactsViewState.value = ContactsUiState.Loading
viewModelScope.launch {
@ -84,6 +85,8 @@ class ContactsViewModel @Inject constructor(
}
}
}
@Suppress("Detekt.TooGenericExceptionCaught")
fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?) {
viewModelScope.launch {
try {

View File

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

View File

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

View File

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

View File

@ -1042,7 +1042,7 @@ class ConversationsListActivity :
val layoutManager = binding.recyclerView.layoutManager as SmoothScrollLinearLayoutManager?
layoutManager?.scrollToPositionWithOffset(
nextUnreadConversationScrollPosition,
binding.recyclerView.height / 3
binding.recyclerView.height / OFFSET_HEIGHT_DIVIDER
)
}
binding.newMentionPopupBubble.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it) }
@ -1960,5 +1960,6 @@ class ConversationsListActivity :
const val BADGE_OFFSET = 35
const val DAYS_FOR_NOTIFICATION_WARNING = 5L
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>? {
var conversationsFromSync: List<ConversationEntity>? = null

View File

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

View File

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

View File

@ -36,6 +36,7 @@ import java.net.URLConnection
class SaveFileToStorageWorker(val context: Context, workerParameters: WorkerParameters) :
Worker(context, workerParameters) {
@Suppress("Detekt.TooGenericExceptionCaught")
override fun doWork(): Result {
try {
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) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
@ -1349,6 +1350,7 @@ class SettingsActivity :
})
}
@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeReadPrivacy() {
lifecycleScope.launch {
var state = appPreferences.readPrivacy
@ -1384,6 +1386,7 @@ class SettingsActivity :
}
}
@Suppress("Detekt.TooGenericExceptionCaught")
private fun observeTypingStatus() {
lifecycleScope.launch {
var state = appPreferences.typingStatus

View File

@ -202,6 +202,7 @@ class ConversationsListBottomDialog(
}
}
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun addConversationToFavorites() {
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
@ -228,6 +229,7 @@ class ConversationsListBottomDialog(
}
}
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun removeConversationFromFavorites() {
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 {
private val TAG = DisplayUtils::class.java.getSimpleName()
private const val INDEX_LUMINATION = 2
private const val HSL_SIZE = 3
private const val MAX_LIGHTNESS = 0.92
private const val TWITTER_HANDLE_PREFIX = "@"
private const val HTTP_PROTOCOL = "http://"
@ -80,6 +81,7 @@ object DisplayUtils {
private const val HTTPS_MIN_LENGTH: Int = 7
private const val DATE_TIME_PARTS_SIZE = 2
private const val ONE_MINUTE_IN_MILLIS: Int = 60000
private const val ROUND_UP_BUMP: Float = 0.5f
fun isDarkModeOn(context: Context): Boolean {
val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return currentNightMode == Configuration.UI_MODE_NIGHT_YES
@ -126,7 +128,7 @@ object DisplayUtils {
TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dp,
context.resources.displayMetrics
) + 0.5f
) + ROUND_UP_BUMP
).toFloat()
}
@ -195,7 +197,9 @@ object DisplayUtils {
.crossfade(true)
.transformations(CircleCropTransformation())
.target(object : Target {
override fun onStart(placeholder: Drawable?) {}
override fun onStart(placeholder: Drawable?) {
// unused atm
}
override fun onError(error: Drawable?) {
chip.chipIcon = error
}
@ -374,7 +378,7 @@ object DisplayUtils {
}
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)
return hsl
}

View File

@ -150,7 +150,8 @@ class PushUtils {
val result = StringBuilder()
for (individualByte in bytes) {
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)
)
}
@ -403,6 +404,9 @@ class PushUtils {
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_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_PUSH_PROXY: String = "LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY"
}

View File

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

View File

@ -8,7 +8,6 @@
*/
package com.nextcloud.talk.utils.preferences.preferencestorage
import android.annotation.SuppressLint
import android.text.TextUtils
import android.util.Log
import autodagger.AutoInjector
@ -64,10 +63,10 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
this.conversationToken = conversationToken
}
@SuppressLint("TooGenericExceptionCaught")
@Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveBoolean(key: String, value: Boolean) {
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 credentials = getCredentials(conversationUser.username, conversationUser.token)
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) {
when (key) {
"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
class FakeRepositoryError : ContactsRepository {
@Suppress("Detekt.TooGenericExceptionThrown")
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
throw Exception("unable to fetch contacts")
}
@Suppress("Detekt.TooGenericExceptionThrown")
override suspend fun createRoom(
roomType: String,
sourceType: String,

View File

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