Commit Graph

237 Commits

Author SHA1 Message Date
dadaloop82 45040f250c fix: triple-tap exit, update banner auto-dismiss, .env overwrite bug
- Triple-tap exit zone now covers full header height (was 6px, untappable)
- Uses touchend event instead of click for reliable tablet interaction
- JS bridge registered once before loadUrl (not on every page load)
- Update banner auto-dismisses after 3 seconds
- CRITICAL: _finishSetup() no longer sends empty strings to save_settings
  → was overwriting .env values (Gemini key, Bring credentials) with blanks
  → now only sends non-empty values to the API
2026-04-16 17:36:48 +00:00
dadaloop82 e38a6cb7f6 feat(kiosk): true kiosk mode, gateway bg launch, update checks, wizard fix v1.2.0
- Screen pinning (startLockTask) blocks home/recent buttons
- Gateway launches in background, kiosk returns to front after 1.5s
- Injected thin green bar at top of WebView for triple-tap exit
- JavaScript bridge for kiosk exit from WebView context
- Update check via GitHub releases API (every 6h)
- Shows banner in WebView when kiosk/gateway updates available
- Setup wizard no longer re-appears after completion/skip (evershelf_setup_done flag)
- REORDER_TASKS permission for moveTaskToFront
- singleTask launch mode for proper kiosk behavior
- Version bumped to 1.2.0 (versionCode 3)
2026-04-16 17:25:47 +00:00
dadaloop82 5991e666ec fix(kiosk): connection test, gateway detection, splash, triple-tap exit
- Fix 404: test base URL directly instead of appending /api/
- Fix gateway not detected: add <queries> block for Android 11+ package visibility
- Add splash screen with icon + loading spinner (1.5s)
- Add triple-tap on wizard title to exit kiosk mode
- Accept 3xx redirects as valid responses
- New house/shelf vector icon for launcher
- Replace emoji icon with drawable on welcome screen
- Version 1.1.0
2026-04-16 17:04:25 +00:00
dadaloop82 9363bc147e refactor(kiosk): remove built-in scale, add SSL + gateway detection
- Remove BLE/scale code (BleScaleManager, ScaleProtocol, GatewayWebSocketServer, ScaleGatewayService)
- Kiosk is now a pure WebView wrapper — scale handled by standalone gateway app
- Fix SSL certificate error: accept self-signed certs for local servers (WebView + connection test)
- Add gateway APK detection: check if it.dadaloop.evershelf.scalegate is installed
- If gateway installed: show green status, auto-launch on finish
- If not installed: show download link to GitHub releases
- Remove BLE/foreground service permissions from manifest
- Remove java-websocket dependency
- Bump version to 1.1.0
2026-04-16 16:40:11 +00:00
dadaloop82 f8c8dfb990 fix(kiosk): match statusCallback signature (3 params) 2026-04-16 16:27:09 +00:00
dadaloop82 95b6258ad8 feat(kiosk): add setup wizard on first launch
- 3-step wizard: Welcome → Server URL → Scale Setup → Launch
- Connection test with live feedback
- BLE scale status during wizard
- Dark theme with modern UI (slate/purple palette)
- Settings page with URL edit, connection test, scale info, wizard reset
- Skip scale option for users without BLE scales
- Error page with retry button when server unreachable
- All UI in English
2026-04-16 16:23:13 +00:00
dadaloop82 d931b471f0 fix: add missing launcher icons for kiosk app
- Adaptive icon XMLs (API 26+) with vector foreground + green background
- PNG fallbacks for all density buckets (mdpi through xxxhdpi)
- Added ic_launcher_background color to colors.xml
2026-04-16 16:06:25 +00:00
dadaloop82 383ef1113d feat: kiosk APK download banner in settings page
- Green-themed banner between settings panels and Save button
- Direct download link to kiosk-latest release APK
- Auto-hidden when running inside Android WebView (kiosk mode)
- i18n: translations added for it/en/de
2026-04-16 16:00:40 +00:00
dadaloop82 1c792a4e4a ci: add GitHub Actions workflow for kiosk APK build 2026-04-16 14:47:35 +00:00
dadaloop82 3e25fcd5df feat: banner alerts, consumption predictions, scale improvements, kiosk app
- Banner notification system: suspicious quantities + consumption prediction alerts
- Consumption predictions API: tracks 90-day usage patterns, flags >30% deviations
- Scale stability timeout: 5s → 10s, auto-confirm remains 5s
- Scale integration in edit form: weigh button with inline live display
- Banner edit/weigh actions open edit form directly with scale activation
- Cooking mode: Italian aliases + stem-prefix matching for ingredients
- Recipe regeneration: tracks rejected ingredients for diversity
- Settings migration: localStorage → .env server-side storage
- Expiry priority: mandatory ≤3 days, recommended ≤7 days in recipes
- Scale bug fixes: clear stale weight, double-submit guard, cap deduction
- Android kiosk app (evershelf-kiosk): WebView + embedded BLE scale gateway
- Version bump to 1.4.0
2026-04-16 14:46:30 +00:00
dadaloop82 3ff91b3018 fix(scale): progress-bar restart loop + low-weight warning + gateway auto-reconnect cycle
- Fix progress-bar restarting continuously when weight is stable:
  add _cancelScaleTimersOnly() that stops timers/animations without
  _cancelScaleTimersOnly() so the same value resumes counting when
  stability returns instead of always restarting the 5-s wait.
  Add 'else if' branch in _scaleAutoFillUse / _scaleAutoFillRecipeUse
  to restart stability wait after brief instability for the same value.

- Show red blinking warning in scale-live-box when weight < 10 g:
  adds scale-low-weight CSS class with pulsing border/shadow animation,
  the label shows '< 10 g · inserisci manualmente' instead of the
  stability progress bar.  No auto-confirm fires below 10 g.

- Gateway Android app: scale auto-reconnect now retries indefinitely.
  isAutoReconnecting flag keeps the scan→wait→scan cycle running until
  the scale is found again; onScanStopped schedules a new scan after
  10 s whenever autoReconnect is active and scale is still offline.
2026-04-16 06:25:40 +00:00
dadaloop82 1c686fa842 feat(gateway): auto-reconnect to scale after disconnect (scale auto-off)
When the scale turns off by itself (auto-off after inactivity), onDisconnected()
now automatically restarts BLE scan after 5 s, with enableAutoConnect() set so
the saved scale is connected as soon as it starts advertising again.
The hint text shows '🔄 Reconnecting to saved scale in 5 s…' during the wait.
2026-04-15 21:17:34 +00:00
dadaloop82 951ef1d64f fix(scale): auto-fill broken for conf products (e.g. latte)
Two root causes:
1. _useNormalUnit was stale ('pz') for conf products because it's only
   updated in normal mode — fix: resolve effective unit from
   _useConfMode.packageUnit when in sub mode
2. Food scales in liquid mode send unit='ml' directly — was falling
   through to raw value, skipping density; fix: detect scaleAlreadyMl
   flag to use ml directly for ml target, or apply density for g target
Also: add scale pre-fill call after switchUseUnit('sub') in conf mode
2026-04-15 21:12:37 +00:00
dadaloop82 7144ec7386 feat(scale): g→ml density conversion for liquid products
- _scaleDensityForProduct(): returns g/ml density based on product name/category
  olio oliva 0.91, girasole 0.92, spirits 0.94, aceto/panna 1.01, latte 1.03,
  yogurt 1.05, succo 1.04, miele/sciroppo 1.40, default 1.00 (water)
- _scaleAutoFillUse(): normalises all scale units to grams first, then converts
  to target unit; when unit=ml applies density; never touches pz/conf
2026-04-15 21:08:41 +00:00
dadaloop82 d26229800c feat(scale): auto-fill use-quantity live from scale reading
- _scaleAutoFillUse(): converts and fills use-quantity on stable readings
- _scaleLatestWeight pre-fills when use page opens (after unit is known)
- oninput on use-quantity pauses auto-fill when user types manually
- showUseForm() resets paused flag so next opening resumes auto-fill
- Small 'live' hint text shown while auto-filling, hidden when overridden
2026-04-15 21:06:12 +00:00
dadaloop82 6f5bc15734 fix: use relative API paths (leading / broke /dispensa/ subdir routing) 2026-04-15 21:00:34 +00:00
dadaloop82 55c5b34381 feat(scale): auto-discover gateway on local network
- api/scale_discover.php: async TCP scan of whole /24 subnet on port 8765,
  confirms with WebSocket handshake, returns found ws:// URLs in ~1.5s
- index.html: '🔍 Auto' button next to gateway URL field
- app.js: discoverScaleGateway() — calls relay, fills URL field and
  auto-saves settings + reconnects on success
2026-04-15 20:56:54 +00:00
dadaloop82 099a6cc4e8 fix: HTTPS/WebSocket mixed-content — add PHP SSE relay for scale gateway
The browser (HTTPS) cannot connect to ws:// directly (mixed-content block).
Solution: PHP SSE relay bridges the gap server-side.

- api/scale_relay.php: GET ?url=ws://ip:port
  PHP opens WS connection to Android gateway, streams JSON frames as
  Server-Sent Events to the browser over existing HTTPS connection.
  Includes WS handshake, masked client frames, frame decoder, keep-alive.

- api/scale_ping.php: GET ?url=ws://ip:port
  One-shot connectivity test, returns {"ok":true} or {"ok":false,"error"}.

- app.js: WebSocket -> EventSource (SSE)
  _scaleWs -> _scaleEs, connects to /api/scale_relay.php
  testScaleConnection() -> fetch /api/scale_ping.php (no more direct ws://)
  readScaleWeight(): removed get_weight send (scale streams continuously)
2026-04-15 20:31:54 +00:00
dadaloop82 a146ba124a feat(gateway): fix QN-KS 0.1g resolution, unit passthrough, English UI
- ScaleProtocol: WeightReading now holds Float value + String unit
- parseQNFood: divide raw by 10 (0.1-unit resolution) so 170 raw -> 17.0g
- parseQNFood: detect unit from byte[4] (0x01=g, 0x02=oz, 0x03-04=ml)
- GatewayWebSocketServer: publishWeight(value: Float, unit: String, ...)
  WebSocket now sends {"value":17.0,"unit":"g"} with correct precision
- BleScaleManager: reading.grams -> reading.value (Float check > 0f)
- All Italian UI strings translated to English in all 4 Kotlin files + XML
2026-04-15 20:02:51 +00:00
dadaloop82 7be02c7174 chore(gateway): add .gitignore, remove build artifacts from git 2026-04-15 19:46:07 +00:00
dadaloop82 0a35e9e8b4 fix(gateway): add QN-KS food scale parser (QN/Yolanda FFF1 protocol)
The QN-KS sends 18-byte frames on FFF1 with opcode 0x10:
  [0x10][0x12=len][...][flags][weight_hi][weight_lo][...][crc]

Weight is u16BE at bytes 9-10 in grams (1g resolution).
Stable flag is bit 3 of byte[8] (0xF8=stable, 0xF0=settling).
Checksum = sum(bytes[0..16]) mod 256.

The generic parser was reading byte[1]=0x12=18 as '18 grams' (the
packet length field), which is why it always showed 18g.

Added parseQNFood() with CRC validation, detected before generic fallback.
Also added AE00/AE02 UUIDs (secondary notifiable service on QN-KS).
2026-04-15 19:45:48 +00:00
dadaloop82 690d5ecd18 fix(gateway): remove trailing junk from ScaleProtocol.kt causing build failure
The file had 6 lines of old code appended after the closing brace,
starting a second 'package' declaration that broke compilation.
2026-04-15 16:33:42 +00:00
dadaloop82 b606e2b361 feat(gateway): show app version in header + copy/share debug log
- Version label (e.g. v2.0.0 (6)) displayed in the app header
- Copy and Share buttons appear when debug panel is open
- Copy puts full log in clipboard, Share opens Android share sheet
2026-04-15 16:07:22 +00:00
dadaloop82 d839a7e267 feat(gateway): food scale only - remove all body scale code v2.0.0
BREAKING CHANGE: WeightReading now uses grams (Int) instead of weightKg (Float).
All body composition fields removed (fat%, BMI, muscle, water, bone, kcal, impedance).
WebSocket always sends {unit:'g', value:<grams>}.

- ScaleProtocol: removed QN, 1byone, Hesley, Renpho, Body Composition parsers
- ScaleProtocol: generic parser tries grams, 0.1g, 0.5g, cg, kg*100, oz*10 (1-15000g)
- BleScaleManager: food scale keyword scoring, demotes body scale devices
- BleScaleManager: simplified service discovery (SIG Weight, FFE0, FFF0, Acaia)
- MainActivity: always displays grams, no body composition UI
- GatewayWebSocketServer: publishWeight(grams: Int), always sends unit='g'
- Version bumped to 2.0.0 (versionCode=6)
2026-04-15 16:00:57 +00:00
dadaloop82 d03a4853b5 feat(gateway): food/kitchen scale support (arboleaf CK10G) v1.6.0
- Generic parser now supports food scale weight ranges (1g-15kg)
  with candidates for gram, 0.1g, and 0.5g divisors
- WebSocket sends grams (unit: 'g') for weights under 15kg
- MainActivity displays grams for food-scale readings
- Enhanced debug: raw byte dump on decode failure with index/decimal/hex
- versionCode=5, versionName=1.6.0
2026-04-15 15:49:12 +00:00
dadaloop82 71c49e2c82 fix(gateway): clean ScaleProtocol.kt - remove Unicode box-drawing chars and fix duplication
- Remove Unicode ─ characters from section comment dividers that caused
  Kotlin compiler parse error (line 191:83 Closing bracket expected)
- Use plain ASCII dashes in section comments
- Remove inline field comments from data class
- File was duplicated (672 lines), truncated to correct 316 lines
2026-04-15 15:27:06 +00:00
dadaloop82 d30e9e0aaa gateway v1.5.0: protocol-aware parsers, debug fix, auto-reconnect
BREAKING FIX: 'always 1.8 kg' — the old brute-force parseGeneric was
matching noise bytes. Replaced with protocol-specific parsers:

Protocol support (from openScale research):
  - Bluetooth SIG 0x2A9D/0x2A9C (standard weight/body composition)
  - QN/Yolanda/FITINDEX (opcode 0x10 weight, 0x12 scale info)
  - 1byone/Eufy (0xCF header, LE weight at bytes 3-4)
  - Hesley/YunChen (20-byte body composition frame)
  - Renpho proprietary (0x2E header on 0x2A9D)
  - Safe generic fallback (stricter: min 4 bytes, min 2kg, unstable)

Body composition fields: fat%, muscle%, water%, bone, BMR/kcal,
impedance — all displayed when available.

Debug panel fix: capped at 150 lines, UI updates throttled to 200ms
(was: unbounded StringBuilder updated on every BLE notification = freeze).

Auto-reconnect: saves last connected device MAC to SharedPreferences,
auto-starts scan on app launch and connects when saved device found.

GATT service discovery: now explicitly subscribes to QN (FFE0/FFE1)
and custom FFF0 (FFF4 or FFF1) characteristics in addition to
standard Weight Scale and Body Composition services.

ScaleProtocol state: resetState() called on new connection to reset
QN weight divisor (100 or 10, learned from 0x12 info frame).
2026-04-15 15:11:22 +00:00
dadaloop82 695ea19d5c gateway: UX improvements + debug mode v1.4.0
- Show device names from ScanRecord (fixes MAC-only display)
- Show 'Senza nome' for unnamed devices instead of hiding them
- Show proximity (Vicino/Medio/Lontano) instead of raw dBm
- Sort scan results: scale-likely devices first (keyword + UUID scoring)
- Add debug panel (toggle with 🐛 Debug button):
  shows GATT service map, raw hex bytes, parse attempts
- Expand parseGeneric: all 2-byte windows × 3 resolutions × LE+BE
  (adds 0.1f and big-endian candidates – common in cheap consumer scales)
- Log GATT services/characteristics after connection
- Log raw hex bytes on every characteristic notification
2026-04-15 13:15:44 +00:00
dadaloop82 4d972b824e fix: vacuum state in move-after-use modal + show all recipe ingredients in cooking mode
- showMoveAfterUseModal: add '🫙 Torna sotto vuoto' checkbox (default=previous state)
  only shown if item was vacuum sealed; confirmMoveAfterUse passes vacuum_sealed to API
- showRecipeMoveModal: same vacuum checkbox with wasVacuum default passed from ingredient
- confirmRecipeMove: passes vacuum_sealed to inventory_update
- PHP API: add vacuum_sealed to recipe ingredient enrichment
- renderCookingStep: remove step-text word filter; show ALL unused from_pantry
  ingredients at every cooking step (AI uses pronouns like 'tagliarla' instead of
  repeating the ingredient name, causing them to be invisible)
2026-04-15 11:05:23 +00:00
dadaloop82 0830b1b168 fix: remove BLE scan UUID filter to support non-standard scales (LePulse, etc)
Many consumer scales like LePulse FI2016LB don't advertise standard
Weight Scale (0x181D) or Body Composition (0x181B) service UUIDs.
Remove the scan filter so all BLE devices are discovered.
The GATT fallback already handles proprietary services.
2026-04-14 17:18:41 +00:00
dadaloop82 7ff7f56e0b fix: fix invalid XML in launcher foreground vector drawable latest 2026-04-14 16:54:11 +00:00
dadaloop82 2740be3bdf fix: add missing launcher icon resources (mipmap + adaptive icon) 2026-04-14 16:49:50 +00:00
dadaloop82 d1c46a0bcb fix: add gradle.properties with android.useAndroidX=true for APK build 2026-04-14 16:45:23 +00:00
dadaloop82 df9de2d257 ci: fix broken YAML - multiline notes had zero indentation breaking the literal block 2026-04-14 16:42:35 +00:00
dadaloop82 fb134128fe ci: trigger workflow with direct commit on main 2026-04-14 16:39:39 +00:00
dadaloop82 329eed5082 Merge branch 'develop' 2026-04-14 16:38:09 +00:00
dadaloop82 0a11214d3d ci: remove paths filter - run on every push to main to ensure APK is always built 2026-04-14 16:38:07 +00:00
dadaloop82 390221ed4c Merge branch 'develop' 2026-04-14 16:33:38 +00:00
dadaloop82 38d8fa7afe ci: fix workflow - use gradle directly instead of ./gradlew (wrapper jar not in repo) 2026-04-14 16:33:35 +00:00
dadaloop82 18af2e9ef4 Merge branch 'develop' 2026-04-14 16:31:59 +00:00
dadaloop82 3fcded1d9b ci: also trigger workflow on changes to the workflow file itself 2026-04-14 16:31:56 +00:00
dadaloop82 b7dd197944 Merge branch 'develop' 2026-04-14 16:29:12 +00:00
dadaloop82 9523b68fea ci: add GitHub Actions workflow to build & release Scale Gateway APK
- Add .github/workflows/build-scale-gateway.yml
  Triggers on push to main (evershelf-scale-gateway/** path filter)
  Builds debug APK with Gradle/JDK 17, renames to evershelf-scale-gateway.apk
  Creates/updates 'latest' GitHub Release so the direct download URL resolves
- Bump web app version v1.2.0 -> v1.3.0 (index.html)
- Bump Android versionCode 1->2, versionName 1.0.0->1.3.0 (app/build.gradle.kts)
2026-04-14 16:29:00 +00:00
dadaloop82 0893742f05 feat: add smart scale BLE gateway integration
- Add evershelf-scale-gateway/ Android app (Kotlin):
  - BLE scanning and GATT connection to smart scales
  - Supports BT SIG Weight Scale (0x181D), Body Composition (0x181B), and generic heuristic parser
  - WebSocket server on port 8765 (local LAN)
  - Real-time weight broadcasting to EverShelf browser client
- Add scale status indicator in header (green/orange/grey dot)
- Add Settings tab for scale configuration (URL, enable toggle, test, APK download link)
- Add 'Read from scale' button in Add/Use forms when unit is g or ml
- Add scale WebSocket client logic in app.js with auto-reconnect
- Fix recipe suggestion: expiry-prioritized ingredients now only injected into
  AI prompt when user explicitly selects 'Priorità Scadenze' or 'Zero Sprechi'
- Update README with smart scale section and website link
- Update all translations (it, en, de) with scale strings
2026-04-14 15:59:40 +00:00
dadaloop82 7fa8395e9e docs: move screenshots section to end of README, translate to English 2026-04-13 11:02:56 +00:00
dadaloop82 f2b518dd4b docs: move screenshots section to end of README, translate to English 2026-04-13 11:02:49 +00:00
dadaloop82 2f21be8829 docs: merge screenshots and README update from develop 2026-04-13 11:00:45 +00:00
dadaloop82 7e9ae24f88 docs: add 9 app screenshots to README and assets
- Add 9 curated screenshots to assets/img/screenshots/ covering all main features
- Update README with 3x3 screenshot table with Italian descriptions
- Anchor /screenshots/ gitignore rule so assets/img/screenshots/ is tracked
- Screenshots cover: dashboard, inventory, barcode scanner, recipe detail,
  recipes list, cooking mode, AI chat, shopping list, smart predictions
2026-04-13 11:00:25 +00:00
dadaloop82 0c6a07ee95 fix: preserve version badge during i18n translatePage
Move data-i18n to inner <span> so translatePage() with textContent
does not overwrite the sibling .header-version span.
2026-04-13 10:23:26 +00:00
dadaloop82 66b75b1537 Merge develop: v1.2.0 - EverShelf rebrand
Merging all changes from develop into main for v1.2.0 release:
- Project renamed from Dispensa Manager to EverShelf
- Contact email: evershelfproject@gmail.com
- All localStorage keys migrated: dispensa_* -> evershelf_*
- SQLite DB renamed: dispensa.db -> evershelf.db
- Docker/Apache resources renamed to evershelf
- Version badge added to app header
- App name updated in all translations (it, en, de)
- Asset version strings bumped to bust browser cache
- JS file truncation fix (safe Python-based replacements)
- CHANGELOG, manifest.json, OpenAPI spec updated for v1.2.0
v1.2.0
2026-04-13 10:21:28 +00:00