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.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.databinding.LockPinDialogBinding
|
import com.lagradost.cloudstream3.databinding.LockPinDialogBinding
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
|
|
||||||
object AccountDialog {
|
object AccountDialog {
|
||||||
// TODO add account creation dialog to allow creating accounts directly from AccountSelectActivity
|
// 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))
|
val binding = LockPinDialogBinding.inflate(LayoutInflater.from(context))
|
||||||
|
|
||||||
binding.pinEditTextError.visibility = View.GONE
|
|
||||||
|
|
||||||
val isPinSet = currentPin != null
|
val isPinSet = currentPin != null
|
||||||
val isNewPin = editAccount && !isPinSet
|
val isNewPin = editAccount && !isPinSet
|
||||||
val isEditPin = editAccount && isPinSet
|
val isEditPin = editAccount && isPinSet
|
||||||
|
@ -74,7 +74,7 @@ object AccountDialog {
|
||||||
isPinValid = true
|
isPinValid = true
|
||||||
|
|
||||||
callback.invoke(enteredPin)
|
callback.invoke(enteredPin)
|
||||||
dialog.dismiss()
|
dialog.dismissSafe()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.pinEditTextError.visibility = View.GONE
|
binding.pinEditTextError.visibility = View.GONE
|
||||||
|
@ -94,7 +94,7 @@ object AccountDialog {
|
||||||
if (actionId == EditorInfo.IME_ACTION_DONE && isPinValid) {
|
if (actionId == EditorInfo.IME_ACTION_DONE && isPinValid) {
|
||||||
val enteredPin = binding.pinEditText.text.toString()
|
val enteredPin = binding.pinEditText.text.toString()
|
||||||
callback.invoke(enteredPin)
|
callback.invoke(enteredPin)
|
||||||
dialog.dismiss()
|
dialog.dismissSafe()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -104,5 +104,12 @@ object AccountDialog {
|
||||||
dialog.setCanceledOnTouchOutside(false)
|
dialog.setCanceledOnTouchOutside(false)
|
||||||
|
|
||||||
dialog.show()
|
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