mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 12:19:55 +00:00
Merge pull request #549 from PhilKes/fix/keyboard-api-24
Show keyboard when EditText is focused for API < 27
This commit is contained in:
commit
0407f2bdc4
1 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.philkes.notallyx.presentation.view.misc
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.text.method.KeyListener
|
||||
|
@ -8,6 +9,7 @@ import android.util.AttributeSet
|
|||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.philkes.notallyx.presentation.clone
|
||||
import com.philkes.notallyx.presentation.showKeyboard
|
||||
|
||||
open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
|
||||
AppCompatEditText(context, attrs) {
|
||||
|
@ -42,6 +44,19 @@ open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
|
|||
isFocusable = value
|
||||
isFocusableInTouchMode = value
|
||||
setTextIsSelectable(true)
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
|
||||
setOnClickListener {
|
||||
if (value) {
|
||||
context.showKeyboard(this)
|
||||
}
|
||||
}
|
||||
setOnFocusChangeListener { v, hasFocus ->
|
||||
if (hasFocus && value) {
|
||||
context.showKeyboard(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue