From 115c9663229768c099722a92693e25b5034856c9 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Wed, 6 May 2026 13:44:50 +0000 Subject: [PATCH] fix: scale dot contrast + kiosk scale config panel + download banner in kiosk style.css: - Scale connected dot: bright #4ade80 fill + white border + double shadow so it pops on the dark green header (was white on green = invisible) index.html: - Scale settings tab: add kiosk panel with 'Riconfigura bilancia BLE' button (hidden in browser, shown in kiosk mode) - Wrap gateway download section and WebSocket URL section with IDs so JS can hide them in kiosk mode - CSS cache bust ?v=20260506b app.js: - syncSettingsFromDB: in kiosk mode hide scale gateway download section, WebSocket URL section and test button; show kiosk BLE panel instead; auto-set URL to ws://localhost:8765 - Add _kioskReconfigureScale() helper that calls _kioskBridge.reconfigureScale() KioskActivity.kt: - Add reconfigureScale() @JavascriptInterface: stops GatewayService, clears saved scale device prefs, launches SetupActivity at step 4 - Import GatewayService --- assets/css/style.css | 4 ++-- assets/js/app.js | 22 +++++++++++++++++++ .../dadaloop/evershelf/kiosk/KioskActivity.kt | 18 +++++++++++++++ index.html | 19 +++++++++++----- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 23ce07e..eafeb53 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -308,8 +308,8 @@ body { transition: background 0.4s, box-shadow 0.4s, border-color 0.4s; pointer-events: none; } -/* Connected: white dot with green glow — always visible regardless of header color */ -.scale-status-connected .scale-status-dot { background: #ffffff; border-color: #22c55e; box-shadow: 0 0 6px #22c55e; } +/* Connected: bright green fill + white border — visible on both dark and light backgrounds */ +.scale-status-connected .scale-status-dot { background: #4ade80; border-color: rgba(255,255,255,0.9); box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 0 6px #4ade80bb; } .scale-status-connected .scale-icon-emoji { filter: none; opacity: 1; } .scale-status-searching .scale-status-dot { background: #f59e0b; border-color: rgba(0,0,0,0.35); animation: scaleStatusPulse 1.4s infinite; } .scale-status-searching .scale-icon-emoji { filter: none; opacity: 0.85; } diff --git a/assets/js/app.js b/assets/js/app.js index 9f5e776..f4ae003 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2018,6 +2018,28 @@ async function loadSettingsUI() { if (kioskBanner && /; wv\)/.test(navigator.userAgent)) { kioskBanner.style.display = 'none'; } + // In kiosk mode: replace WebSocket scale config with native BLE reconfigure panel + const isKiosk = typeof _kioskBridge !== 'undefined'; + const scaleGwDl = document.getElementById('scale-gateway-download-section'); + const scaleWsEl = document.getElementById('scale-websocket-section'); + const scaleTestEl = document.getElementById('scale-test-section'); + const scaleKiosk = document.getElementById('scale-kiosk-panel'); + if (isKiosk) { + if (scaleGwDl) scaleGwDl.style.display = 'none'; + if (scaleWsEl) scaleWsEl.style.display = 'none'; + if (scaleTestEl) scaleTestEl.style.display = 'none'; + if (scaleKiosk) scaleKiosk.style.display = ''; + // Auto-set URL to localhost gateway (always port 8765 in kiosk) + if (scaleUrlUiEl && !scaleUrlUiEl.value) scaleUrlUiEl.value = 'ws://localhost:8765'; + } +} + +// ── Kiosk: trigger native BLE scale reconfiguration wizard ──────────── +function _kioskReconfigureScale() { + if (typeof _kioskBridge === 'undefined') return; + if (typeof _kioskBridge.reconfigureScale === 'function') { + _kioskBridge.reconfigureScale(); + } } // ── Kiosk overlay: X (close) + ↻ (refresh) buttons ─────────────────── diff --git a/evershelf-kiosk/app/src/main/kotlin/it/dadaloop/evershelf/kiosk/KioskActivity.kt b/evershelf-kiosk/app/src/main/kotlin/it/dadaloop/evershelf/kiosk/KioskActivity.kt index 52cee20..ed60bfd 100644 --- a/evershelf-kiosk/app/src/main/kotlin/it/dadaloop/evershelf/kiosk/KioskActivity.kt +++ b/evershelf-kiosk/app/src/main/kotlin/it/dadaloop/evershelf/kiosk/KioskActivity.kt @@ -42,6 +42,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import com.google.android.material.button.MaterialButton +import it.dadaloop.evershelf.kiosk.scale.GatewayService import org.json.JSONObject import java.net.URL import java.util.Locale @@ -418,6 +419,23 @@ class KioskActivity : AppCompatActivity() { fun stopSpeech() { tts?.stop() } @JavascriptInterface fun isTtsReady(): String = if (ttsReady) "true" else "false" + @JavascriptInterface + fun reconfigureScale() { + // Stop the BLE gateway service, clear saved scale device, + // and launch SetupActivity directly at step 4 (BLE scan) + runOnUiThread { + GatewayService.stop(this@KioskActivity) + prefs.edit() + .remove("scale_device_address") + .remove("scale_device_name") + .putBoolean("has_scale", false) + .putBoolean("setup_complete", false) + .apply() + val intent = Intent(this@KioskActivity, SetupActivity::class.java) + intent.putExtra("start_step", 4) + startActivity(intent) + } + } }, "_kioskBridge") val url = prefs.getString(KEY_URL, "http://evershelf.local") ?: "http://evershelf.local" diff --git a/index.html b/index.html index 0c531f3..2ef19fa 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ EverShelf - + @@ -1034,8 +1034,15 @@

⚖️ Bilancia Smart

Collega una bilancia Bluetooth tramite il gateway Android per leggere il peso automaticamente.

+ + + -
+

📱 EverShelf Scale Gateway

App Android che fa da ponte tra la bilancia BLE e questo sito.

📥 Scarica Gateway Android (APK) @@ -1054,7 +1061,7 @@
-
+
@@ -1065,8 +1072,10 @@
- - +
+ + +