mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 12:19:55 +00:00
Show keyboard when EditText is focused for API < 27
This commit is contained in:
parent
07ff5691e2
commit
212c354072
1 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.philkes.notallyx.presentation.view.misc
|
package com.philkes.notallyx.presentation.view.misc
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.text.method.KeyListener
|
import android.text.method.KeyListener
|
||||||
|
@ -8,6 +9,7 @@ import android.util.AttributeSet
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.appcompat.widget.AppCompatEditText
|
import androidx.appcompat.widget.AppCompatEditText
|
||||||
import com.philkes.notallyx.presentation.clone
|
import com.philkes.notallyx.presentation.clone
|
||||||
|
import com.philkes.notallyx.presentation.showKeyboard
|
||||||
|
|
||||||
open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
|
open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
|
||||||
AppCompatEditText(context, attrs) {
|
AppCompatEditText(context, attrs) {
|
||||||
|
@ -42,6 +44,19 @@ open class EditTextWithWatcher(context: Context, attrs: AttributeSet) :
|
||||||
isFocusable = value
|
isFocusable = value
|
||||||
isFocusableInTouchMode = value
|
isFocusableInTouchMode = value
|
||||||
setTextIsSelectable(true)
|
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(
|
@Deprecated(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue