Show/Dismiss keyboard when editing report name

dev
Laurent 7 years ago
parent e621c3cda8
commit 8c953e6c65
  1. 13
      app/src/main/java/net/pokeranalytics/android/ui/fragment/report/AbstractReportFragment.kt

@ -2,9 +2,10 @@ package net.pokeranalytics.android.ui.fragment.report
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.WindowManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.fragment_progress_report.* import kotlinx.android.synthetic.main.fragment_progress_report.*
import net.pokeranalytics.android.calculus.Report import net.pokeranalytics.android.calculus.Report
import net.pokeranalytics.android.model.CustomFieldCriteria import net.pokeranalytics.android.model.CustomFieldCriteria
@ -78,12 +79,16 @@ abstract class AbstractReportFragment : DataManagerFragment() {
val dialog = builder.create() val dialog = builder.create()
dialog.setOnShowListener { dialog.setOnShowListener {
nameEditText.requestFocus() nameEditText.requestFocus()
dialog.getWindow()?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) val s = ContextCompat.getSystemService(requireContext(), InputMethodManager::class.java)
s?.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)
} }
dialog.show() dialog.setOnDismissListener {
// dialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) val s = ContextCompat.getSystemService(requireContext(), InputMethodManager::class.java)
s?.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
}
dialog.show()
} ?: throw IllegalStateException("Activity cannot be null") } ?: throw IllegalStateException("Activity cannot be null")

Loading…
Cancel
Save