mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Revert "NumberPickerFactory: Show and hide keyboard using InputMethodManager"
This reverts commit 6967def950. InputMethodManager method
does not work reliably on widgets. It also cannot reliably hide the keyboard.
This commit is contained in:
@@ -22,7 +22,6 @@ import android.content.*
|
||||
import android.graphics.*
|
||||
import android.util.*
|
||||
import android.view.*
|
||||
import android.view.inputmethod.*
|
||||
import android.widget.*
|
||||
import android.widget.TextView.*
|
||||
import androidx.core.view.*
|
||||
@@ -83,16 +82,4 @@ object InterfaceUtils {
|
||||
return ViewCompat.getLayoutDirection(view!!) ==
|
||||
ViewCompat.LAYOUT_DIRECTION_RTL
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getInputManager() =
|
||||
this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
||||
fun Context.showKeyboard() {
|
||||
this.getInputManager().toggleSoftInput(InputMethodManager.SHOW_FORCED,
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY)
|
||||
}
|
||||
|
||||
fun Context.hideKeyboard() {
|
||||
this.getInputManager().toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
|
||||
}
|
||||
@@ -20,11 +20,12 @@
|
||||
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.*
|
||||
@@ -69,16 +70,14 @@ class NumberPickerFactory
|
||||
val v = picker.value + 0.05 * picker2.value
|
||||
callback.onNumberPicked(v)
|
||||
}
|
||||
.setOnDismissListener{
|
||||
callback.onNumberPickerDismissed()
|
||||
}
|
||||
.create()
|
||||
|
||||
dialog.setOnShowListener {
|
||||
picker.getChildAt(0)?.requestFocus()
|
||||
context.showKeyboard()
|
||||
}
|
||||
|
||||
dialog.setOnDismissListener {
|
||||
context.hideKeyboard()
|
||||
callback.onNumberPickerDismissed()
|
||||
dialog.window?.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
}
|
||||
|
||||
InterfaceUtils.setupEditorAction(picker, TextView.OnEditorActionListener { _, actionId, _ ->
|
||||
|
||||
Reference in New Issue
Block a user