Commit Graph

3 Commits

Author SHA1 Message Date
nstefanelli
9ca16127c8 Fix kiosk screensaver idle timer not resetting on touch (#4434)
## Summary
- Kiosk screensaver idle timer was not resetting on user interaction —
`recordKioskActivity()` was defined but never called
- WKWebView consumes touch events before UIKit idle detection, so the
timer counted down from kiosk activation rather than last touch
- Added a tap gesture recognizer on the WebView (`cancelsTouchesInView =
false`) to detect taps without interfering with normal interaction
- Added `scrollViewWillBeginDragging` delegate hook to detect
scroll/drag interactions

## Test plan
- [ ] Enable kiosk mode with 30s screensaver timeout
- [ ] Tap on the WebView dashboard — idle timer should reset
- [ ] Scroll on the dashboard — idle timer should reset
- [ ] Stop interacting — screensaver should appear after configured
timeout
- [ ] Verify normal WebView interaction (taps, links, scrolling) still
works normally

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Nick Stefanelli <nstefanelli@users.noreply.github.com>
2026-03-23 09:28:44 +01:00
nstefanelli
31b2db4853 Add kiosk mode core infrastructure (PR 1/5) (#4422)
## Summary

Reopening kiosk mode PR (previously #4218) after addressing all review
feedback from @bgoncal. Apologies for the delay — some family matters
pulled me away, but I'm excited to get this implemented and am fully
committed to seeing it through.

This PR adds the foundational infrastructure for **kiosk mode** — a
feature designed for wall-mounted iPad displays running Home Assistant
dashboards.

### What's included:
- **KioskModeManager** — Central coordinator singleton with
KioskModeObserver protocol (no NotificationCenter)
- **KioskSettings** — Comprehensive settings model with GRDB persistence
(camelCase columns, Codable)
- **Screensaver system** — Clock screensaver with 4 styles, pixel shift
for OLED burn-in prevention
- **Secret exit gesture** — Configurable corner tap to access settings
when locked down
- **Status bar hiding** — StatusBarForwardingNavigationController for
proper UIKit integration
- **Settings UI** — SwiftUI settings accessible via Settings menu and
secret gesture
- **28 unit tests** — Covering settings serialization, time logic,
orientations, enums

### Changes since #4218 (all review feedback addressed):
-  Fixed settings modal dismissal on iOS 15 (UINavigationController +
explicit onDismiss closure)
-  Fixed status bar hiding (StatusBarForwardingNavigationController +
statusBarView integration)
-  Removed non-functional settings (navigationLockdown,
TouchFeedbackManager, IconMapper)
-  Replaced `Date()` with `Current.date()` for testability
-  GRDB persistence follows CarPlayConfig/WatchConfig pattern with
DatabaseTableProtocol
-  All strings localized via L10n (SwiftGen)
-  SFSafeSymbols used throughout (no string-based systemName)
-  KioskModeObserver protocol (no NotificationCenter)
-  Kiosk files prefixed with `Kiosk`
-  UIKit screensaver container (required for status bar/home indicator
control)
-  macCatalyst filtered out
-  Merged with latest upstream/main (adapted to Frontend/ directory
restructure)
-  Idle timer pauses when settings view is open
-  TODO comments (no PR-specific comments)

### Testing Instructions
1. **Settings → Companion App → Kiosk Mode** → Enable "Enable Kiosk
Mode"
2. Set screensaver timeout to **30 seconds** for quick testing
3. Wait for screensaver → tap to wake
4. Use secret gesture (default: 3 taps in top-left corner) to access
settings

### Previous review context
All feedback from @bgoncal in #4218 has been addressed. See that PR for
full discussion history.

## Test plan
- [ ] Enable/disable kiosk mode from Settings
- [ ] Screensaver activates after timeout
- [ ] Tap to wake from screensaver
- [ ] Secret gesture opens settings
- [ ] Status bar hides when kiosk mode active (full-screen iPad only)
- [ ] Device authentication toggle works
- [ ] Settings persist across app restart
- [ ] Clock screensaver styles (large, minimal, digital, analog)
- [ ] Pixel shift moves clock position periodically
- [ ] Kiosk entry hidden on macCatalyst

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Nick Stefanelli <nstefanelli@users.noreply.github.com>
2026-03-13 13:03:54 +00:00
Bruno Pantaleão Gonçalves
e17f81f64b Organize webview folder (#4324)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2026-02-08 15:18:43 +01:00