Fix lint issues

This commit is contained in:
Jorge Martín 2022-10-04 13:39:14 +02:00
parent 321fddf5f6
commit e1cad01d54
3 changed files with 41 additions and 50 deletions

View File

@ -71,9 +71,7 @@ import im.vector.app.core.extensions.ensureEndsLeftToRight
import im.vector.app.core.extensions.filterDirectionOverrides import im.vector.app.core.extensions.filterDirectionOverrides
import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.extensions.registerStartForActivityResult
import im.vector.app.core.extensions.replaceChildFragment
import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.extensions.setTextOrHide
import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.core.extensions.trackItemsVisibilityChange import im.vector.app.core.extensions.trackItemsVisibilityChange
import im.vector.app.core.glide.GlideApp import im.vector.app.core.glide.GlideApp
import im.vector.app.core.glide.GlideRequests import im.vector.app.core.glide.GlideRequests

View File

@ -16,6 +16,7 @@
package im.vector.app.features.home.room.detail.composer package im.vector.app.features.home.room.detail.composer
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
@ -249,15 +250,13 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
composerEditText.setOnEditorActionListener { v, actionId, keyEvent -> composerEditText.setOnEditorActionListener { v, actionId, keyEvent ->
val imeActionId = actionId and EditorInfo.IME_MASK_ACTION val imeActionId = actionId and EditorInfo.IME_MASK_ACTION
if (EditorInfo.IME_ACTION_DONE == imeActionId || EditorInfo.IME_ACTION_SEND == imeActionId) { val isSendAction = EditorInfo.IME_ACTION_DONE == imeActionId || EditorInfo.IME_ACTION_SEND == imeActionId
sendTextMessage(v.text)
true
}
// Add external keyboard functionality (to send messages) // Add external keyboard functionality (to send messages)
else if (null != keyEvent && val externalKeyboardPressedEnter = null != keyEvent &&
!keyEvent.isShiftPressed && !keyEvent.isShiftPressed &&
keyEvent.keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.keyCode == KeyEvent.KEYCODE_ENTER &&
resources.configuration.keyboard != Configuration.KEYBOARD_NOKEYS) { resources.configuration.keyboard != Configuration.KEYBOARD_NOKEYS
if (isSendAction || externalKeyboardPressedEnter) {
sendTextMessage(v.text) sendTextMessage(v.text)
true true
} else false } else false
@ -716,6 +715,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
} }
} }
@SuppressLint("SetTextI18n")
private fun insertUserDisplayNameInTextEditor(userId: String) { private fun insertUserDisplayNameInTextEditor(userId: String) {
val startToCompose = views.composerLayout.text.isNullOrBlank() val startToCompose = views.composerLayout.text.isNullOrBlank()
@ -726,10 +726,8 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
views.composerLayout.views.composerEditText.setSelection(Command.EMOTE.command.length + 1) views.composerLayout.views.composerEditText.setSelection(Command.EMOTE.command.length + 1)
} else { } else {
val roomMember = timelineViewModel.getMember(userId) val roomMember = timelineViewModel.getMember(userId)
// TODO move logic outside of fragment val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
sanitizeDisplayName(roomMember?.displayName ?: userId) val pill = buildSpannedString {
.let { displayName ->
buildSpannedString {
append(displayName) append(displayName)
setSpan( setSpan(
PillImageSpan( PillImageSpan(
@ -744,7 +742,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
) )
append(if (startToCompose) ": " else " ") append(if (startToCompose) ": " else " ")
}.let { pill -> }
if (startToCompose) { if (startToCompose) {
if (displayName.startsWith("/")) { if (displayName.startsWith("/")) {
// Ensure displayName will not be interpreted as a Slash command // Ensure displayName will not be interpreted as a Slash command
@ -755,8 +753,6 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
views.composerLayout.views.composerEditText.text?.insert(views.composerLayout.views.composerEditText.selectionStart, pill) views.composerLayout.views.composerEditText.text?.insert(views.composerLayout.views.composerEditText.selectionStart, pill)
} }
} }
}
}
focusComposerAndShowKeyboard() focusComposerAndShowKeyboard()
} }

View File

@ -151,19 +151,9 @@ class VoiceRecorderFragment : VectorBaseFragment<FragmentVoiceRecorderBinding>()
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Idle) updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Idle)
} }
override fun onRecordingLimitReached() { override fun onRecordingLimitReached() = pauseRecording()
messageComposerViewModel.handle(
MessageComposerAction.PauseRecordingVoiceMessage
)
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
}
override fun onRecordingWaveformClicked() { override fun onRecordingWaveformClicked() = pauseRecording()
messageComposerViewModel.handle(
MessageComposerAction.PauseRecordingVoiceMessage
)
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
}
override fun onVoiceWaveformTouchedUp(percentage: Float, duration: Int) { override fun onVoiceWaveformTouchedUp(percentage: Float, duration: Int) {
messageComposerViewModel.handle( messageComposerViewModel.handle(
@ -182,6 +172,13 @@ class VoiceRecorderFragment : VectorBaseFragment<FragmentVoiceRecorderBinding>()
MessageComposerAction.OnVoiceRecordingUiStateChanged(state) MessageComposerAction.OnVoiceRecordingUiStateChanged(state)
) )
} }
private fun pauseRecording() {
messageComposerViewModel.handle(
MessageComposerAction.PauseRecordingVoiceMessage
)
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
}
} }
} }