Apply imeOptions to ComposerEditText without overriding previously set options
This commit is contained in:
parent
d2f9ca4cbc
commit
e5cf431cc7
@ -1537,12 +1537,7 @@ class TimelineFragment :
|
|||||||
observerUserTyping()
|
observerUserTyping()
|
||||||
|
|
||||||
composerEditText.setUseIncognitoKeyboard(vectorPreferences.useIncognitoKeyboard())
|
composerEditText.setUseIncognitoKeyboard(vectorPreferences.useIncognitoKeyboard())
|
||||||
|
composerEditText.setSendMessageWithEnter(vectorPreferences.sendMessageWithEnter())
|
||||||
if (vectorPreferences.sendMessageWithEnter()) {
|
|
||||||
// imeOptions="actionSend" only works with single line, so we remove multiline inputType
|
|
||||||
composerEditText.inputType = composerEditText.inputType and EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE.inv()
|
|
||||||
composerEditText.imeOptions = EditorInfo.IME_ACTION_SEND
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -81,7 +81,22 @@ class ComposerEditText @JvmOverloads constructor(
|
|||||||
|
|
||||||
/** Set whether the keyboard should disable personalized learning. */
|
/** Set whether the keyboard should disable personalized learning. */
|
||||||
fun setUseIncognitoKeyboard(useIncognitoKeyboard: Boolean) {
|
fun setUseIncognitoKeyboard(useIncognitoKeyboard: Boolean) {
|
||||||
imeOptions = if (useIncognitoKeyboard) imeOptions or INCOGNITO_KEYBOARD_IME else imeOptions and INCOGNITO_KEYBOARD_IME.inv()
|
imeOptions = if (useIncognitoKeyboard) {
|
||||||
|
imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||||
|
} else {
|
||||||
|
imeOptions and EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING.inv()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set whether enter should send the message or add a new line. */
|
||||||
|
fun setSendMessageWithEnter(sendMessageWithEnter: Boolean) {
|
||||||
|
if (sendMessageWithEnter) {
|
||||||
|
inputType = inputType and EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE.inv()
|
||||||
|
imeOptions = imeOptions or EditorInfo.IME_ACTION_SEND
|
||||||
|
} else {
|
||||||
|
inputType = inputType or EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
|
||||||
|
imeOptions = imeOptions and EditorInfo.IME_ACTION_SEND.inv()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -121,8 +136,4 @@ class ComposerEditText @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val INCOGNITO_KEYBOARD_IME = EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user