mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Auto focus on PIN input and show keyboard
This commit is contained in:
parent
4644e523b0
commit
d1e46422df
1 changed files with 11 additions and 4 deletions
|
@ -6,11 +6,13 @@ import android.text.TextWatcher
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.LockPinDialogBinding
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
|
||||
object AccountDialog {
|
||||
// TODO add account creation dialog to allow creating accounts directly from AccountSelectActivity
|
||||
|
@ -30,8 +32,6 @@ object AccountDialog {
|
|||
|
||||
val binding = LockPinDialogBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
binding.pinEditTextError.visibility = View.GONE
|
||||
|
||||
val isPinSet = currentPin != null
|
||||
val isNewPin = editAccount && !isPinSet
|
||||
val isEditPin = editAccount && isPinSet
|
||||
|
@ -74,7 +74,7 @@ object AccountDialog {
|
|||
isPinValid = true
|
||||
|
||||
callback.invoke(enteredPin)
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe()
|
||||
}
|
||||
} else {
|
||||
binding.pinEditTextError.visibility = View.GONE
|
||||
|
@ -94,7 +94,7 @@ object AccountDialog {
|
|||
if (actionId == EditorInfo.IME_ACTION_DONE && isPinValid) {
|
||||
val enteredPin = binding.pinEditText.text.toString()
|
||||
callback.invoke(enteredPin)
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -104,5 +104,12 @@ object AccountDialog {
|
|||
dialog.setCanceledOnTouchOutside(false)
|
||||
|
||||
dialog.show()
|
||||
|
||||
// Auto focus on PIN input and show keyboard
|
||||
binding.pinEditText.requestFocus()
|
||||
binding.pinEditText.postDelayed({
|
||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(binding.pinEditText, InputMethodManager.SHOW_IMPLICIT)
|
||||
}, 200)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue