fix: openNativeSettings uses try/catch instead of fragile typeof check

This commit is contained in:
dadaloop82
2026-05-16 13:18:07 +00:00
parent c87d7d2cde
commit 8a596cb7d8
4 changed files with 13 additions and 10 deletions
+7 -7
View File
@@ -2362,13 +2362,13 @@ function _kioskReconfigureScale() {
// ── Kiosk: open native SettingsActivity (server URL, BLE, screensaver) ──
function _openKioskNativeSettings() {
if (typeof _kioskBridge === 'undefined') return;
if (typeof _kioskBridge.openNativeSettings === 'function') {
try { _kioskBridge.openNativeSettings(); } catch(e) {}
} else {
// Older APK without openNativeSettings — make the native gear button
// temporarily visible with a hint to tap it.
try { _kioskBridge.setNativeSettingsVisible(true); } catch(_) {}
showToast(t('settings.kiosk.native_tap_hint') || 'Tocca la rotella ⚙️ in alto a destra', 'info', 4000);
// Use try/catch directly: Android @JavascriptInterface methods are not always
// detected as 'function' by typeof, so we just call and catch if unavailable.
try {
_kioskBridge.openNativeSettings();
} catch(e) {
// Older APK without openNativeSettings bridge — inform user to update
showToast(t('settings.kiosk.native_update_hint') || 'Aggiorna l\'app kiosk per usare questa funzione', 'warning', 4000);
}
}
+2 -1
View File
@@ -681,7 +681,8 @@
"native_title": "Kiosk-Konfiguration",
"native_hint": "Server-URL, BLE-Waage, Bildschirmschoner und Einrichtungsassistent.",
"native_btn": "Kiosk-Konfiguration öffnen",
"native_tap_hint": "Zahnrad oben rechts antippen"
"native_tap_hint": "Zahnrad oben rechts antippen",
"native_update_hint": "Kiosk-App aktualisieren, um diese Funktion zu nutzen"
},
"saved": "✅ Konfiguration gespeichert!",
"saved_local": "✅ Konfiguration lokal gespeichert",
+2 -1
View File
@@ -681,7 +681,8 @@
"native_title": "Kiosk Configuration",
"native_hint": "Server URL, BLE scale, screensaver and setup wizard.",
"native_btn": "Open kiosk configuration",
"native_tap_hint": "Tap the gear button at the top right"
"native_tap_hint": "Tap the gear button at the top right",
"native_update_hint": "Update the kiosk app to use this feature"
},
"saved": "✅ Configuration saved!",
"saved_local": "✅ Configuration saved locally",
+2 -1
View File
@@ -681,7 +681,8 @@
"native_title": "Configurazione Kiosk",
"native_hint": "URL server, bilancia BLE, salvaschermo e setup wizard.",
"native_btn": "Apri configurazione kiosk",
"native_tap_hint": "Tocca la rotella in alto a destra"
"native_tap_hint": "Tocca la rotella in alto a destra",
"native_update_hint": "Aggiorna l'app kiosk per usare questa funzione"
},
"saved": "✅ Configurazione salvata!",
"saved_local": "✅ Configurazione salvata localmente",