diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index ba8822c3..bd127b89 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -1118,6 +1118,7 @@ class MainActivity : AppCompatActivity() { messageView.text = message } val input = layout.findViewById(R.id.password) as EditText + input.requestFocus() val checkBox = layout.findViewById(R.id.checkbox) as CheckBox checkBox.setOnCheckedChangeListener { _, isChecked -> if (isChecked) @@ -1126,9 +1127,11 @@ class MainActivity : AppCompatActivity() { input.transformationMethod = PasswordTransformationMethod() } val context = this - with(AlertDialog.Builder(this)) { + val builder = AlertDialog.Builder(this) + with(builder) { setView(layout) setPositiveButton(android.R.string.ok) { dialog, _ -> + imm.hideSoftInputFromWindow(input.windowToken, 0) dialog.dismiss() var password = input.text.toString().trim() if (!Account.checkAuthPass(password)) { @@ -1146,9 +1149,12 @@ class MainActivity : AppCompatActivity() { } } setNegativeButton(android.R.string.cancel) { dialog, _ -> + imm.hideSoftInputFromWindow(input.windowToken, 0) dialog.cancel() } - show() + val dialog = builder.create() + dialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + dialog.show() } } @@ -1168,6 +1174,7 @@ class MainActivity : AppCompatActivity() { val message = getString(R.string.account) + " " + Utils.plainAor(aor) messageView.text = message val input = layout.findViewById(R.id.password) as EditText + input.requestFocus() val checkBox = layout.findViewById(R.id.checkbox) as CheckBox checkBox.setOnCheckedChangeListener { _, isChecked -> if (isChecked) @@ -1176,9 +1183,11 @@ class MainActivity : AppCompatActivity() { input.transformationMethod = PasswordTransformationMethod() } val context = this - with(AlertDialog.Builder(this)) { + val builder = AlertDialog.Builder(this) + with(builder) { setView(layout) setPositiveButton(android.R.string.ok) { dialog, _ -> + imm.hideSoftInputFromWindow(input.windowToken, 0) dialog.dismiss() val password = input.text.toString().trim() if (!Account.checkAuthPass(password)) { @@ -1190,11 +1199,14 @@ class MainActivity : AppCompatActivity() { askPasswords(accounts) } setNegativeButton(android.R.string.cancel) { dialog, _ -> + imm.hideSoftInputFromWindow(input.windowToken, 0) dialog.cancel() aorPasswords.put(aor, "") askPasswords(accounts) } - show() + val dialog = builder.create() + dialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + dialog.show() } } else { askPasswords(accounts)