Fix scanner input and move keyboard toggle into admin dialog
All checks were successful
APK-BUILD/pipeline/head This commit looks good
All checks were successful
APK-BUILD/pipeline/head This commit looks good
onCheckIsTextEditor() returning false prevented the InputConnection from being established, breaking hardware key relay from the barcode scanner into HTML inputs. Always return true — the other suppression layers handle keyboard hiding. Move the keyboard toggle from the top-right corner gesture (which blocked a UI feature) into the admin dialog (7 taps top-left corner). The dialog now shows three options: exit, toggle keyboard, or cancel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
619fa4f048
commit
b03d4507c1
@ -27,9 +27,4 @@ object AppConfig {
|
||||
/** Time window (ms) for admin tap sequence. */
|
||||
const val ADMIN_TAP_WINDOW_MS = 3000L
|
||||
|
||||
/** Number of taps on the top-right corner to toggle the on-screen keyboard. */
|
||||
const val KEYBOARD_TOGGLE_TAP_COUNT = 5
|
||||
|
||||
/** Time window (ms) for keyboard toggle tap sequence. */
|
||||
const val KEYBOARD_TOGGLE_TAP_WINDOW_MS = 3000L
|
||||
}
|
||||
|
||||
@ -40,9 +40,6 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
// Admin exit: rapid taps in the top-left corner
|
||||
private var adminTapTimestamps = mutableListOf<Long>()
|
||||
|
||||
// Keyboard toggle: rapid taps in the top-right corner
|
||||
private var keyboardToggleTapTimestamps = mutableListOf<Long>()
|
||||
private var isKeyboardSuppressed = true
|
||||
|
||||
// Back-press exit: rapid presses when no WebView history
|
||||
@ -221,10 +218,6 @@ class MainActivity : AppCompatActivity() {
|
||||
if (ev.x < threshold && ev.y < threshold) {
|
||||
handleAdminTap()
|
||||
}
|
||||
val screenWidth = resources.displayMetrics.widthPixels
|
||||
if (ev.x > screenWidth - threshold && ev.y < threshold) {
|
||||
handleKeyboardToggleTap()
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
@ -236,34 +229,22 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
if (adminTapTimestamps.size >= AppConfig.ADMIN_TAP_COUNT) {
|
||||
adminTapTimestamps.clear()
|
||||
showAdminExitDialog()
|
||||
showAdminDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAdminExitDialog() {
|
||||
private fun showAdminDialog() {
|
||||
val keyboardLabel = if (isKeyboardSuppressed)
|
||||
getString(R.string.keyboard_show) else getString(R.string.keyboard_hide)
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Salir de la aplicación")
|
||||
.setMessage("¿Desea cerrar la aplicación del escáner?")
|
||||
.setPositiveButton("Salir") { _, _ -> finish() }
|
||||
.setNegativeButton("Cancelar", null)
|
||||
.setTitle(R.string.admin_title)
|
||||
.setMessage(R.string.admin_message)
|
||||
.setPositiveButton(R.string.admin_exit) { _, _ -> finish() }
|
||||
.setNeutralButton(keyboardLabel) { _, _ -> toggleKeyboard() }
|
||||
.setNegativeButton(R.string.admin_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
// ── Keyboard Toggle (hidden tap gesture, top-right corner) ──────────
|
||||
|
||||
private fun handleKeyboardToggleTap() {
|
||||
val now = System.currentTimeMillis()
|
||||
keyboardToggleTapTimestamps.add(now)
|
||||
keyboardToggleTapTimestamps.removeAll {
|
||||
now - it > AppConfig.KEYBOARD_TOGGLE_TAP_WINDOW_MS
|
||||
}
|
||||
|
||||
if (keyboardToggleTapTimestamps.size >= AppConfig.KEYBOARD_TOGGLE_TAP_COUNT) {
|
||||
keyboardToggleTapTimestamps.clear()
|
||||
toggleKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleKeyboard() {
|
||||
isKeyboardSuppressed = !isKeyboardSuppressed
|
||||
webView.keyboardSuppressed = isKeyboardSuppressed
|
||||
|
||||
@ -49,6 +49,6 @@ class NoSoftKeyboardWebView : WebView {
|
||||
}
|
||||
|
||||
override fun onCheckIsTextEditor(): Boolean {
|
||||
return !keyboardSuppressed
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
<string name="error_no_connection">No se puede conectar</string>
|
||||
<string name="error_check_wifi">Verifique la conexión Wi-Fi e intente de nuevo.</string>
|
||||
<string name="retry">Reintentar</string>
|
||||
<string name="admin_title">Administración</string>
|
||||
<string name="admin_message">¿Qué desea hacer?</string>
|
||||
<string name="admin_exit">Salir</string>
|
||||
<string name="admin_cancel">Cancelar</string>
|
||||
<string name="keyboard_show">Mostrar teclado</string>
|
||||
<string name="keyboard_hide">Ocultar teclado</string>
|
||||
<string name="keyboard_enabled">Teclado en pantalla activado</string>
|
||||
<string name="keyboard_disabled">Teclado en pantalla desactivado</string>
|
||||
</resources>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user