From 8a596cb7d82b55382827a1833912e53020ae45c4 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Sat, 16 May 2026 13:18:07 +0000 Subject: [PATCH] fix: openNativeSettings uses try/catch instead of fragile typeof check --- assets/js/app.js | 14 +++++++------- translations/de.json | 3 ++- translations/en.json | 3 ++- translations/it.json | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index f42facd..0ef85b3 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -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); } } diff --git a/translations/de.json b/translations/de.json index 4458264..6a5abf4 100644 --- a/translations/de.json +++ b/translations/de.json @@ -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", diff --git a/translations/en.json b/translations/en.json index 251d637..3e3afb3 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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", diff --git a/translations/it.json b/translations/it.json index 469c1b0..db8d4f8 100644 --- a/translations/it.json +++ b/translations/it.json @@ -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",