# Lumen — The Last Light (Flutter 2.0.2) An illustrated island notebook about grandmother Mara, her grandchild, and restoring a lighthouse. The active app is now written in **Dart and Flutter**, with a thin Android Kotlin entry point. All puzzle generation, deductions, story navigation, progress, audio controls and advertising behavior live in `lib/`. Android is the tested target. iOS project scaffolding and test AdMob configuration are included, but iOS has not been built or tested on this Linux workstation. It still needs Apple signing, device testing, store icons and platform release configuration. ## Play - Sixteen cottage notebook leaves: the original dedication, cottage entry, folded note and repair note, plus separate entries, puzzles and illustrated memories for the match, lantern, key and compass, and a closing leaf toward the harbour. - Horizontal swipes across the writing or blank paper, plus corner arrows, turn leaves. Grid and control gestures never turn pages; vertical drags still scroll. Navigation stays fixed; overflow scrolling supports smaller screens and larger text. - Landscape pages rearrange themselves: a puzzle keeps its whole grid in one column, with the heading, area totals, hint and undo beside it, and the leaf navigation folds into a single row. The board stays fully visible without scrolling, even with larger text. - Saved reading position, puzzle marks, opened note, inspected repair and viewed pages. Android Back closes the current book and returns to the main page; previous/next leaf controls and swipes turn pages. - Twelve 7×7 picture puzzles across three chapters, with overlapping-area deductions on entries 3–12. Chapters II and III retain their briefing/puzzle/reveal structure, with swipes between those pages too. Chapter contents shows four entries at a time. Reading ahead keeps unfinished boards and completion awards separate. - Deterministic daily grids and generated Easy, Medium and Hard 5×5 practice. The grades measure deduction-chain depth, not expert-level difficulty. Every board has a unique solution and needs no guessing. - Undo and optional explained hints in every mode. Each hint, including the first, requires a voluntary rewarded ad and its AdMob reward callback. Declining, closing without a reward or unavailable ads leaves the grid unchanged; solving and reading remain available. - Expanded story passages connect the harbour key, crossing, bell signals and reunion with Mara. All added passages are narrated; original takes continue seamlessly into the new sections. - Solved patterns remain available when turning back from discoveries, including after restarting. Discoveries blend the exact pixel symbol into the watercolour, keep a small copy of the symbol visible, and offer a replay. - Local daily streaks, independent difficulty levels and exactly-once puzzle completion awards. - AdMob/UMP consent, optional rewarded hints, practice interstitials after every fourth completion and up to three automatic reading breaks per book (around one-third, two-thirds and the end). Each book remembers its used placements. Automatic ads do not interrupt opening notebook leaves or recorded readings; puzzle hints show ads only after confirmation. Progress starts fresh in Flutter, as requested. Old Java `lumen.xml` saves are **not imported or read**. Flutter keeps its own local preferences through `shared_preferences`; no account or game backend is required. Uninstalling loses local progress, and the daily date follows the device calendar. ## Artwork and readings All app-created text uses the bundled Dancing Script handwriting font, including grid clues and menus. Lit cells are shaded with pencil strokes, and dark cells use a drawn cross; neither depends on a symbol-font fallback. Original watercolour harbour, cloth cover, cottage, lantern and single-page art remain bundled for offline use. Native text sits directly on the page’s blank writing area. Art prompts and provenance are in [assets/artwork](assets/artwork/README.md); the font’s OFL license ships in the app’s open-source licenses. Campaign discoveries now support optional watercolour keepsakes declared in the campaign data. All twelve discoveries have illustrations, and the opening match memory uses the same match watercolour. Each object’s artwork appears only on its discovery leaf after its own pattern is solved. Entry pages, the earlier repair note and the closing leaf never display discovery art, even with completed progress. Pixel pictures are also hidden until solved and remain the fallback for missing artwork. Twenty-eight fixed, pre-rendered synthetic recordings play from bundled PCM16 WAV files. Twenty-four readings include the expanded story; the original PCM takes are preserved, followed by the added narrator passages. A single Play control covers the whole page and highlighting follows both parts. Mara’s five original British-English diary takes are preserved; twenty-three guiding passages use a distinct narrator voice, covering the cottage entries/memories/closing leaf and the later campaign introductions and discoveries. Readings start automatically 3 seconds after opening a narrated page, are labelled by speaker and support pause/resume, stop, replay, speed and passage highlighting. Page turns and backgrounding stop playback. WAV avoids the Huawei API 26 FLAC playback issue; archival FLACs stay out of the APK. There is no Android reader, runtime synthesis or audio download. See [narration provenance](assets/narration/README.md). Four bundled, original sound textures accompany the story: air around the cottage, harbour water, the stream under the bridge and wind around the lighthouse. They loop quietly, fade when locations change and duck beneath narration. Sound & atmosphere offers a saved mute switch and independent atmosphere volume. Leaving the story or backgrounding the app stops them; readings start after a 3-second pause on narrated pages. These are procedurally rendered soundscapes, not field recordings. See [soundscape provenance](assets/audio/AMBIENCE.md). ## Build and run Tested with Flutter 3.47.5 / Dart 3.13.4, JDK 21 and Android SDK 36. Flutter uses the standard `android/` platform project; the former root Gradle project is archived in `legacy/android/` and is not compiled into the Flutter app. ```sh flutter pub get flutter analyze flutter test flutter run --flavor prod -d YOUR_ANDROID_DEVICE ``` Use `JAVA_HOME=/path/to/jdk-21` if your default JDK is incompatible with Gradle. Use `flutter doctor -v` to inspect your setup. ```sh # Separate QA package: com.lumen.daily.qa flutter build apk --debug --flavor qa # QA permits SD-card installation on devices that support external apps. # Install explicitly with: adb install -r -s PATH_TO_QA_APK # The review Huawei rejects SD app installs; use adb install -r -f there. # Optimized development APK for the connected arm64 tablet flutter build apk --release --flavor prod --target-platform android-arm64 ``` The normal application ID remains `com.lumen.daily`; version 2.0.2 uses build number 11. The review APK is `artifacts/lumen-flutter-2.0.2-arm64.apk`. Build outputs, screenshots, local SDK paths, IDE state and private signing keys are ignored by Git. `pubspec.lock` is tracked for reproducible package resolution. The development release build currently uses the Android debug signing key so it can update the installed prototype. **Configure your private upload key before publishing.** No production signing material is included. ## Verification ```sh flutter analyze flutter test python3 scripts/check_narration_assets.py python3 scripts/check_soundscape_assets.py # Launch/playback/restart smoke test after installing the normal APK python3 scripts/check_flutter_install.py --serial YOUR_ANDROID_DEVICE # Real tablet integration, isolated from the normal app flutter drive --driver test_driver/integration_test.dart \ --target integration_test/notebook_test.dart --flavor qa \ --dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE ``` The forty-nine unit/widget tests cover 40 Java reference boards (including signed 64-bit seeds), 300 graded generated boards, solver counts against 300 exhaustive small systems, all twelve campaign solutions, bounded campaign comparison chains, solved-grid inspection after restart, discovery animation/replay, reward-gated hints in every mode, declined/unavailable ads and duplicate/stale reward callbacks, streaks, fresh progress, read-ahead, completion awards, campaign read-ahead restoration, gesture isolation, swipes over text and blank paper, cancelled drags, vertical scrolling, landscape and larger text; it also checks every cottage leaf with the real font at 1.5× text, all four hint controls, legacy route migration and exactly-once completion after restart. Reference parity protects the port’s rules; it is not used to migrate saves. The physical-device integration test uses a disposable in-memory game plus an isolated QA disk round-trip. It plays all five real WAV files, checks pause/resume, explores the six leaves, verifies bookmarks/discoveries, solves match and lantern puzzles and checks exactly-once awards. Screenshots are saved in `artifacts/flutter-check/`. The release smoke script requires an active, unmuted 24 kHz media track in the tablet’s audio mixer as well as exercising the actual play/pause/resume UI and restores the last page after process restart, without injecting puzzle fixtures. The release build includes a targeted R8 keep rule for the database constructor used reflectively by AdMob’s WorkManager dependency. Advertising is disabled for the automated story tests; real UMP startup is checked separately in the normal build. Reward delivery, cancellation and ad no-fill still need manual release testing with your final AdMob configuration. ## Puzzle thinking-depth tool `dart tool/analyze_puzzles.dart` reports hypothetical lookahead, successive deduction rounds, comparison steps and thin progress for every story puzzle. It also accepts daily/practice boards and custom visible constraints. Export Markdown and JSON traces with `--markdown PATH --json PATH --trace`. This is a defined reasoning-model estimate, not a validated human difficulty score. See [the tool guide](docs/THINKING_DEPTH.md). ## Source map | Location | Responsibility | | --- | --- | | `lib/main.dart` | Handwritten home, notebook, campaign, dialogs and lifecycle | | `lib/domain/puzzle.dart` | Seeded generation, uniqueness, constraint deductions, hints and difficulty | | `lib/domain/book.dart` | Stable story records and campaign asset loading | | `lib/domain/game.dart` | Routing, marks, undo, progress, streaks and completion | | `lib/ui/` | Page layout, margin gestures, native grid semantics and illustrated keepsakes | | `lib/services/` | Local storage, bundled playback and consent-gated AdMob | | `assets/campaign.json` | Authored twelve-picture campaign | | `assets/narration/scripts.json` | Canonical spoken diary text | | `assets/audio/` | Runtime WAV files, archival FLAC exports and passage timing manifest | | `legacy/` | Archived Java version 1.7, excluded from Flutter builds | For an agent-oriented architecture, dependency, screen-flow and persistence map, see [docs/CODE_MAP.md](docs/CODE_MAP.md). ## Before publishing Create your production Android AdMob app and ad units, configure Privacy & messaging, supply a public privacy policy and support contact, complete Play disclosures and ratings, and configure an upload key outside Git. The SDK still uses Google test IDs by default. For Android, supply the app ID using Gradle property `ADMOB_APP_ID`. Rewarded/interstitial unit IDs use Dart compile-time defines `ADMOB_REWARDED_ID` and `ADMOB_INTERSTITIAL_ID`. iOS needs its own app ID in `ios/Runner/Info.plist` and iOS-specific ad unit IDs. Verify consent refusal/revocation, reward completion/cancellation, offline/no-fill behavior, lifecycle interruptions, accessibility and release signing on physical devices before submitting an AAB. See [ROADMAP.md](ROADMAP.md) for the proposed 30–40-leaf campaign, page variety and further exploration ideas. Smaller follow-ups and asset tasks are tracked in [TODO.md](TODO.md). Chapter I page records live in `assets/notebook.json`. The original six IDs and `story_v1_0`–`story_v1_3` puzzle keys are preserved. Existing cottage briefing, puzzle and reveal saves reopen on their corresponding leaves. Reading ahead never awards a puzzle completion; leaving the cottage opens Chapter II even when patterns remain unfinished. All seven added prose leaves have narrator recordings; the original five diary takes are retained as PCM within the expanded recordings. To review the complete chapter on an isolated QA install, run `flutter drive --driver test_driver/integration_test.dart --target integration_test/cottage_test.dart --flavor qa --dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE`. This traverses all sixteen leaves, checks bookmarks/restart, rotates the compass puzzle at larger text, solves all four patterns and checks QA disk persistence. It saves eight screenshots in `artifacts/flutter-check/`. Device automation can use the `check` flavor (`com.lumen.daily.check`) to preserve the installed QA app and its progress. It has its own preferences and test data. Use `--flavor check` with the integration commands above for an isolated run alongside QA. ## Story library and languages The app opens on a bookshelf listing every installed story. Choosing a book resumes its own place, and Settings for language, sound, reading speed and privacy are reachable from both the shelf and the book's home page. Mara's original notebook remains available, and **The paper boat** is a short standard story in English and German. English and German app controls are bundled separately from story text; Mara currently falls back to its original English narrative. New stories are registered in `assets/library.json`; their pages, puzzles and translations live in independent asset packages. Chapter sizes are data-driven, and each story keeps its own progress. Switching language preserves reading position, bookmarks, marks and undo. Device-language selection, fallback text, optional localized narration and right-to-left layout are supported. See [Story packages and translations](docs/STORY_PACKAGES.md) for the schema, example package and validation commands. ### Halloween special: The Midnight Invitation Available in the story library in English: a complete three-chapter mystery with 38 leaves, twelve original picture puzzles, thirteen original watercolour illustrations, its own Gothic notebook background, and 26 cast diary recordings (about 32 minutes). Read postman Elias Ward’s first-person account of a delivery to a house with twelve missing guests and a thirteenth place waiting for him. Every puzzle is uniquely solvable without guessing; the opening two teach line totals and the remaining ten require overlapping-area comparisons. See the [story guide](assets/stories/midnight-invitation/README.md), [manuscript](assets/stories/midnight-invitation/STORY.md), and [artwork prompt set](assets/stories/midnight-invitation/artwork/prompts.json).