Fix lint issues
This commit is contained in:
parent
321fddf5f6
commit
e1cad01d54
|
@ -71,9 +71,7 @@ import im.vector.app.core.extensions.ensureEndsLeftToRight
|
|||
import im.vector.app.core.extensions.filterDirectionOverrides
|
||||
import im.vector.app.core.extensions.hideKeyboard
|
||||
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.toMvRxBundle
|
||||
import im.vector.app.core.extensions.trackItemsVisibilityChange
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
import im.vector.app.core.glide.GlideRequests
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.home.room.detail.composer
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
|
@ -249,15 +250,13 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||
|
||||
composerEditText.setOnEditorActionListener { v, actionId, keyEvent ->
|
||||
val imeActionId = actionId and EditorInfo.IME_MASK_ACTION
|
||||
if (EditorInfo.IME_ACTION_DONE == imeActionId || EditorInfo.IME_ACTION_SEND == imeActionId) {
|
||||
sendTextMessage(v.text)
|
||||
true
|
||||
}
|
||||
val isSendAction = EditorInfo.IME_ACTION_DONE == imeActionId || EditorInfo.IME_ACTION_SEND == imeActionId
|
||||
// Add external keyboard functionality (to send messages)
|
||||
else if (null != keyEvent &&
|
||||
val externalKeyboardPressedEnter = null != keyEvent &&
|
||||
!keyEvent.isShiftPressed &&
|
||||
keyEvent.keyCode == KeyEvent.KEYCODE_ENTER &&
|
||||
resources.configuration.keyboard != Configuration.KEYBOARD_NOKEYS) {
|
||||
resources.configuration.keyboard != Configuration.KEYBOARD_NOKEYS
|
||||
if (isSendAction || externalKeyboardPressedEnter) {
|
||||
sendTextMessage(v.text)
|
||||
true
|
||||
} else false
|
||||
|
@ -716,6 +715,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun insertUserDisplayNameInTextEditor(userId: String) {
|
||||
val startToCompose = views.composerLayout.text.isNullOrBlank()
|
||||
|
||||
|
@ -726,36 +726,32 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||
views.composerLayout.views.composerEditText.setSelection(Command.EMOTE.command.length + 1)
|
||||
} else {
|
||||
val roomMember = timelineViewModel.getMember(userId)
|
||||
// TODO move logic outside of fragment
|
||||
sanitizeDisplayName(roomMember?.displayName ?: userId)
|
||||
.let { displayName ->
|
||||
buildSpannedString {
|
||||
append(displayName)
|
||||
setSpan(
|
||||
PillImageSpan(
|
||||
glideRequests,
|
||||
avatarRenderer,
|
||||
requireContext(),
|
||||
MatrixItem.UserItem(userId, displayName, roomMember?.avatarUrl)
|
||||
)
|
||||
.also { it.bind(views.composerLayout.views.composerEditText) },
|
||||
0,
|
||||
displayName.length,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
append(if (startToCompose) ": " else " ")
|
||||
}.let { pill ->
|
||||
if (startToCompose) {
|
||||
if (displayName.startsWith("/")) {
|
||||
// Ensure displayName will not be interpreted as a Slash command
|
||||
views.composerLayout.views.composerEditText.append("\\")
|
||||
}
|
||||
views.composerLayout.views.composerEditText.append(pill)
|
||||
} else {
|
||||
views.composerLayout.views.composerEditText.text?.insert(views.composerLayout.views.composerEditText.selectionStart, pill)
|
||||
}
|
||||
}
|
||||
}
|
||||
val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
|
||||
val pill = buildSpannedString {
|
||||
append(displayName)
|
||||
setSpan(
|
||||
PillImageSpan(
|
||||
glideRequests,
|
||||
avatarRenderer,
|
||||
requireContext(),
|
||||
MatrixItem.UserItem(userId, displayName, roomMember?.avatarUrl)
|
||||
)
|
||||
.also { it.bind(views.composerLayout.views.composerEditText) },
|
||||
0,
|
||||
displayName.length,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
append(if (startToCompose) ": " else " ")
|
||||
}
|
||||
if (startToCompose) {
|
||||
if (displayName.startsWith("/")) {
|
||||
// Ensure displayName will not be interpreted as a Slash command
|
||||
views.composerLayout.views.composerEditText.append("\\")
|
||||
}
|
||||
views.composerLayout.views.composerEditText.append(pill)
|
||||
} else {
|
||||
views.composerLayout.views.composerEditText.text?.insert(views.composerLayout.views.composerEditText.selectionStart, pill)
|
||||
}
|
||||
}
|
||||
focusComposerAndShowKeyboard()
|
||||
}
|
||||
|
|
|
@ -151,19 +151,9 @@ class VoiceRecorderFragment : VectorBaseFragment<FragmentVoiceRecorderBinding>()
|
|||
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Idle)
|
||||
}
|
||||
|
||||
override fun onRecordingLimitReached() {
|
||||
messageComposerViewModel.handle(
|
||||
MessageComposerAction.PauseRecordingVoiceMessage
|
||||
)
|
||||
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
|
||||
}
|
||||
override fun onRecordingLimitReached() = pauseRecording()
|
||||
|
||||
override fun onRecordingWaveformClicked() {
|
||||
messageComposerViewModel.handle(
|
||||
MessageComposerAction.PauseRecordingVoiceMessage
|
||||
)
|
||||
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
|
||||
}
|
||||
override fun onRecordingWaveformClicked() = pauseRecording()
|
||||
|
||||
override fun onVoiceWaveformTouchedUp(percentage: Float, duration: Int) {
|
||||
messageComposerViewModel.handle(
|
||||
|
@ -182,6 +172,13 @@ class VoiceRecorderFragment : VectorBaseFragment<FragmentVoiceRecorderBinding>()
|
|||
MessageComposerAction.OnVoiceRecordingUiStateChanged(state)
|
||||
)
|
||||
}
|
||||
|
||||
private fun pauseRecording() {
|
||||
messageComposerViewModel.handle(
|
||||
MessageComposerAction.PauseRecordingVoiceMessage
|
||||
)
|
||||
updateRecordingUiState(VoiceMessageRecorderView.RecordingUiState.Draft)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue