mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-18 22:52:04 +03:00
style(detekt): Replace MagicNumbers with constants
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
7221d8cc56
commit
eb890cfbd3
10 changed files with 96 additions and 46 deletions
|
@ -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()
|
||||||
|
@ -931,17 +931,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 +1264,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 +1396,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 +1407,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 +1433,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 +1454,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 +1799,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 +1857,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 +2157,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 +2494,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 +2680,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 +2710,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 +3038,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 +3204,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 +3220,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"
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +376,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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
|
||||||
@SuppressLint("TooGenericExceptionCaught")
|
@SuppressLint("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
|
||||||
|
|
|
@ -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: 169
|
||||||
weights:
|
weights:
|
||||||
# complexity: 2
|
# complexity: 2
|
||||||
# LongParameterList: 1
|
# LongParameterList: 1
|
||||||
|
|
Loading…
Reference in a new issue