[Android] Listen for key inputs in the PIN code activity
Nicolas Pomepuy
git at videolan.org
Wed Jul 12 08:30:36 UTC 2023
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jul 5 07:20:36 2023 +0200| [b6aa807daaaf857187ff8704ca919edb9ab10072] | committer: Duncan McNamara
Listen for key inputs in the PIN code activity
> https://code.videolan.org/videolan/vlc-android/commit/b6aa807daaaf857187ff8704ca919edb9ab10072
---
.../src/org/videolan/vlc/gui/PinCodeActivity.kt | 46 ++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PinCodeActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/PinCodeActivity.kt
index 5340fb1e06..87d2ac2fe1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PinCodeActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PinCodeActivity.kt
@@ -156,6 +156,52 @@ class PinCodeActivity : BaseActivity() {
}
+ override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
+ return when (keyCode) {
+ KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_NUMPAD_0 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "0")
+ true
+ }
+ KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_NUMPAD_1 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "1")
+ true
+ }
+ KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_NUMPAD_2 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "2")
+ true
+ }
+ KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_NUMPAD_3 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "3")
+ true
+ }
+ KeyEvent.KEYCODE_4, KeyEvent.KEYCODE_NUMPAD_4 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "4")
+ true
+ }
+ KeyEvent.KEYCODE_5, KeyEvent.KEYCODE_NUMPAD_5 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "5")
+ true
+ }
+ KeyEvent.KEYCODE_6, KeyEvent.KEYCODE_NUMPAD_6 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "6")
+ true
+ }
+ KeyEvent.KEYCODE_7, KeyEvent.KEYCODE_NUMPAD_7 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "7")
+ true
+ }
+ KeyEvent.KEYCODE_8, KeyEvent.KEYCODE_NUMPAD_8 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "8")
+ true
+ }
+ KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_NUMPAD_9 -> {
+ binding.pinCode.setText(binding.pinCode.text.toString() + "9")
+ true
+ }
+ else -> super.onKeyDown(keyCode, event)
+ }
+ }
+
private fun next() {
if (model.step.value == PinStep.RE_ENTER || model.step.value == PinStep.NO_MATCH) {
if (model.checkMatch(binding.pinCode.text.toString())) {
More information about the Android
mailing list