Use AppCompatEditText instead of EditText
This commit is contained in:
parent
6d55c15761
commit
dbc17ae515
|
@ -421,7 +421,7 @@ class RoomDetailFragment :
|
||||||
if (text != composerLayout.composerEditText.text.toString()) {
|
if (text != composerLayout.composerEditText.text.toString()) {
|
||||||
// Ignore update to avoid saving a draft
|
// Ignore update to avoid saving a draft
|
||||||
composerLayout.composerEditText.setText(text)
|
composerLayout.composerEditText.setText(text)
|
||||||
composerLayout.composerEditText.setSelection(composerLayout.composerEditText.text.length)
|
composerLayout.composerEditText.setSelection(composerLayout.composerEditText.text?.length ?: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,21 +1135,21 @@ class RoomDetailFragment :
|
||||||
val myDisplayName = session.getUser(session.myUserId)?.displayName
|
val myDisplayName = session.getUser(session.myUserId)?.displayName
|
||||||
if (myDisplayName == text) {
|
if (myDisplayName == text) {
|
||||||
// current user
|
// current user
|
||||||
if (composerLayout.composerEditText.text.isBlank()) {
|
if (composerLayout.composerEditText.text.isNullOrBlank()) {
|
||||||
composerLayout.composerEditText.append(Command.EMOTE.command + " ")
|
composerLayout.composerEditText.append(Command.EMOTE.command + " ")
|
||||||
composerLayout.composerEditText.setSelection(composerLayout.composerEditText.text.length)
|
composerLayout.composerEditText.setSelection(composerLayout.composerEditText.text?.length ?: 0)
|
||||||
// vibrate = true
|
// vibrate = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// another user
|
// another user
|
||||||
if (composerLayout.composerEditText.text.isBlank()) {
|
if (composerLayout.composerEditText.text.isNullOrBlank()) {
|
||||||
// Ensure displayName will not be interpreted as a Slash command
|
// Ensure displayName will not be interpreted as a Slash command
|
||||||
if (text.startsWith("/")) {
|
if (text.startsWith("/")) {
|
||||||
composerLayout.composerEditText.append("\\")
|
composerLayout.composerEditText.append("\\")
|
||||||
}
|
}
|
||||||
composerLayout.composerEditText.append(sanitizeDisplayName(text) + ": ")
|
composerLayout.composerEditText.append(sanitizeDisplayName(text) + ": ")
|
||||||
} else {
|
} else {
|
||||||
composerLayout.composerEditText.text.insert(composerLayout.composerEditText.selectionStart, sanitizeDisplayName(text) + " ")
|
composerLayout.composerEditText.text?.insert(composerLayout.composerEditText.selectionStart, sanitizeDisplayName(text) + " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// vibrate = true
|
// vibrate = true
|
||||||
|
|
|
@ -23,12 +23,12 @@ import android.os.Build
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.InputConnection
|
import android.view.inputmethod.InputConnection
|
||||||
import android.widget.EditText
|
import androidx.appcompat.widget.AppCompatEditText
|
||||||
import androidx.core.view.inputmethod.EditorInfoCompat
|
import androidx.core.view.inputmethod.EditorInfoCompat
|
||||||
import androidx.core.view.inputmethod.InputConnectionCompat
|
import androidx.core.view.inputmethod.InputConnectionCompat
|
||||||
|
|
||||||
class ComposerEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = android.R.attr.editTextStyle)
|
class ComposerEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = android.R.attr.editTextStyle)
|
||||||
: EditText(context, attrs, defStyleAttr) {
|
: AppCompatEditText(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
interface Callback {
|
interface Callback {
|
||||||
fun onRichContentSelected(contentUri: Uri): Boolean
|
fun onRichContentSelected(contentUri: Uri): Boolean
|
||||||
|
|
Loading…
Reference in New Issue