Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager

Expand All @@ -41,7 +42,7 @@ import java.io.PrintWriter
* This class ensure that all dialogs opened from a service will have the same behaviour. It provides basic lifecycle
* alike methods to ease the view initialization/cleaning.
*/
abstract class OverlayDialog(@StyleRes theme: Int? = null) : BaseOverlay(theme, recreateOnRotation = true, useWindowContext = true) {
abstract class OverlayDialog(@StyleRes theme: Int? = null) : BaseOverlay(theme, recreateOnRotation = true) {

/** The Android InputMethodManger, for ensuring the keyboard dismiss on dialog dismiss. */
private lateinit var inputMethodManager: InputMethodManager
Expand Down Expand Up @@ -105,7 +106,7 @@ abstract class OverlayDialog(@StyleRes theme: Int? = null) : BaseOverlay(theme,

window?.apply {
setType(OverlayManager.OVERLAY_WINDOW_TYPE)
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
applySoftInputMode(this)
decorView.setOnTouchListener(hideSoftInputTouchListener)
}

Expand All @@ -120,6 +121,14 @@ abstract class OverlayDialog(@StyleRes theme: Int? = null) : BaseOverlay(theme,
onDialogCreated(dialog!!)
}

/** Soft keyboard: resize dialog so input fields stay visible (accessibility overlay). */
protected open fun applySoftInputMode(window: Window) {
window.setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN,
)
}

@CallSuper
override fun onStart() {
if (isShown) return
Expand Down
Loading