mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
NumberPickerFactory: Show and hide keyboard using InputMethodManager
In about 1 every 10 attempts, the previous solution randomly failed to show the keyboard, although the text field was focused. This solution seems more reliable.
This commit is contained in:
@@ -20,12 +20,11 @@
|
||||
package org.isoron.uhabits.activities.common.dialogs
|
||||
|
||||
import android.content.*
|
||||
import androidx.appcompat.app.*
|
||||
import android.text.*
|
||||
import android.view.*
|
||||
import android.view.WindowManager.LayoutParams.*
|
||||
import android.view.inputmethod.*
|
||||
import android.widget.*
|
||||
import androidx.appcompat.app.*
|
||||
import org.isoron.androidbase.activities.*
|
||||
import org.isoron.androidbase.utils.*
|
||||
import org.isoron.uhabits.*
|
||||
@@ -70,14 +69,16 @@ class NumberPickerFactory
|
||||
val v = picker.value + 0.05 * picker2.value
|
||||
callback.onNumberPicked(v)
|
||||
}
|
||||
.setOnDismissListener{
|
||||
callback.onNumberPickerDismissed()
|
||||
}
|
||||
.create()
|
||||
|
||||
dialog.setOnShowListener {
|
||||
picker.getChildAt(0)?.requestFocus()
|
||||
dialog.window?.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
context.showKeyboard()
|
||||
}
|
||||
|
||||
dialog.setOnDismissListener {
|
||||
context.hideKeyboard()
|
||||
callback.onNumberPickerDismissed()
|
||||
}
|
||||
|
||||
InterfaceUtils.setupEditorAction(picker, TextView.OnEditorActionListener { _, actionId, _ ->
|
||||
|
||||
Reference in New Issue
Block a user