Fix: EditText with textMultiLine & IME_ACTION_SEND

This commit is contained in:
andrekir 2021-09-05 15:10:02 -03:00
parent 615f202583
commit 15161862f3
2 changed files with 5 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package com.geeksville.mesh.ui
import android.os.Bundle
import android.text.InputType
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -28,6 +29,8 @@ import java.util.*
// Allows usage like email.on(EditorInfo.IME_ACTION_NEXT, { confirm() })
fun EditText.on(actionId: Int, func: () -> Unit) {
setImeOptions(EditorInfo.IME_ACTION_SEND) // Force "SEND" IME Action
setRawInputType(InputType.TYPE_CLASS_TEXT) // Suppress ENTER but allow textMultiLine
setOnEditorActionListener { _, receivedActionId, _ ->
if (actionId == receivedActionId) {
@ -239,7 +242,7 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
// requireActivity().hideKeyboard()
}
binding.messageInputText.on(EditorInfo.IME_ACTION_DONE) {
binding.messageInputText.on(EditorInfo.IME_ACTION_SEND) {
debug("did IME action")
val str = binding.messageInputText.text.toString().trim()