summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-16 15:40:01 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-16 18:01:06 +0200
commit6789c11a7b44c221879b60e6b9397c9f8dd451d7 (patch)
treeb0b0fca9e1c5ec453d67fdbb0af8fe2b53b67d09 /ui/src/main/java
parentc56065fcfe9fb887cb7ccec23a7af22111f352bc (diff)
ConfigNamingDialogFragment: fix focus request for config naming dialog
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt20
1 files changed, 17 insertions, 3 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
index 03aad0f0..3c5d0ce9 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt
@@ -5,13 +5,16 @@
package com.wireguard.android.fragment
import android.app.Dialog
-import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
+import android.view.View
import android.view.inputmethod.InputMethodManager
+import androidx.annotation.IdRes
import androidx.appcompat.app.AlertDialog
+import androidx.core.content.getSystemService
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
+import com.google.android.material.textfield.TextInputEditText
import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.databinding.ConfigNamingDialogFragmentBinding
@@ -62,7 +65,7 @@ class ConfigNamingDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val activity = requireActivity()
- imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm = activity.getSystemService()
val alertDialogBuilder = AlertDialog.Builder(activity)
alertDialogBuilder.setTitle(R.string.import_from_qr_code)
binding = ConfigNamingDialogFragmentBinding.inflate(activity.layoutInflater, null, false)
@@ -72,7 +75,18 @@ class ConfigNamingDialogFragment : DialogFragment() {
}
alertDialogBuilder.setPositiveButton(R.string.create_tunnel, null)
alertDialogBuilder.setNegativeButton(R.string.cancel) { _, _ -> dismiss() }
- return alertDialogBuilder.create()
+ return alertDialogBuilder.create().apply {
+ setOnShowListener {
+ findViewById<TextInputEditText>(R.id.tunnel_name_text)?.apply {
+ setOnFocusChangeListener { v, _ ->
+ v.post {
+ imm?.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)
+ }
+ }
+ requestFocus()
+ }
+ }
+ }
}
override fun onResume() {