fix: kiosk title center + location pref 2 uses + update confirm before download

app.js:
- _injectKioskOverlay: move kiosk-mode class assignment BEFORE the
  _kiosk_overlay existence guard — fixes race where Kotlin onPageFinished
  injects buttons during the await api() pause, then JS skips the class
- _PREF_LOC_NEEDED: 3 → 2 (remember use-location after 2 picks, not 3)

KioskActivity.kt:
- showNativeUpdateBanner: remove auto-start of triggerApkDownload;
  banner now shows with 'Scarica' button enabled, download only starts
  when user taps it (confirms before install)
This commit is contained in:
dadaloop82
2026-05-06 11:24:29 +00:00
parent 6d098a80a6
commit f04e227cc0
2 changed files with 9 additions and 6 deletions
+5 -3
View File
@@ -2025,12 +2025,14 @@ async function loadSettingsUI() {
// Only shown when _kioskBridge JS interface is available (Android WebView). // Only shown when _kioskBridge JS interface is available (Android WebView).
function _injectKioskOverlay() { function _injectKioskOverlay() {
if (typeof _kioskBridge === 'undefined') return; if (typeof _kioskBridge === 'undefined') return;
if (document.getElementById('_kiosk_overlay')) return;
// Mark header so CSS can center the title // Always mark header as kiosk-mode (idempotent) — must happen even if buttons
// were already injected by the native onPageFinished Kotlin callback.
const appHeader = document.querySelector('.app-header'); const appHeader = document.querySelector('.app-header');
if (appHeader) appHeader.classList.add('kiosk-mode'); if (appHeader) appHeader.classList.add('kiosk-mode');
if (document.getElementById('_kiosk_overlay')) return;
const headerLeft = document.getElementById('header-left'); const headerLeft = document.getElementById('header-left');
if (!headerLeft) return; if (!headerLeft) return;
@@ -6869,7 +6871,7 @@ function selectUseLocation(btn, loc) {
// After 3+ consistent choices from the same location for a product, // After 3+ consistent choices from the same location for a product,
// auto-selects it and hides the location picker (user can still tap "cambia"). // auto-selects it and hides the location picker (user can still tap "cambia").
const _PREF_LOC_KEY = '_prefUseLoc'; const _PREF_LOC_KEY = '_prefUseLoc';
const _PREF_LOC_NEEDED = 3; // choices needed to confirm a preference const _PREF_LOC_NEEDED = 2; // choices needed to confirm a preference
function _getPrefLocHistory(productId) { function _getPrefLocHistory(productId) {
try { try {
@@ -538,10 +538,11 @@ class KioskActivity : AppCompatActivity() {
private fun showNativeUpdateBanner(message: String, apkDownloadUrl: String) { private fun showNativeUpdateBanner(message: String, apkDownloadUrl: String) {
pendingApkDownloadUrl = apkDownloadUrl pendingApkDownloadUrl = apkDownloadUrl
tvUpdateMessage.text = "⬆️ Aggiornamento disponibile: $message" tvUpdateMessage.text = "⬆️ Aggiornamento disponibile: $message"
// Reset button to initial state so user can confirm before download starts
btnInstallUpdate.isEnabled = true
btnInstallUpdate.text = "⬇ Scarica"
updateBanner.visibility = View.VISIBLE updateBanner.visibility = View.VISIBLE
// Auto-start download immediately — no timer hide, stays until done or dismissed // Download starts only when the user taps btnInstallUpdate
activeInstallBtn = btnInstallUpdate
triggerApkDownload(apkDownloadUrl)
} }
// ── APK Download + Install ───────────────────────────────────────────── // ── APK Download + Install ─────────────────────────────────────────────