Skip to content

feat(design): Visual Island Template Composer with 10 official HyperOS templates, Design Hub Bento Grid & Design Manager (#272, #327, #383, #385) - #390

Merged
D4vidDf merged 4 commits into
dev/0_6_0from
feat/template-composer
Sep 26, 2026
Merged

D4vidDf merged 4 commits into
dev/0_6_0from
feat/template-composer

Conversation

@D4vidDf

@D4vidDf D4vidDf commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Overview

This PR delivers Phase 4 of the Custom Translators & Design Framework (#272) by introducing the Visual Island Template Composer. Built upon user feedback in #327, island templates are integrated directly into the custom translator pipeline as first-class PresentationMode.TEMPLATE presets rather than as a separate siloed subsystem.

In addition, this PR redesigns the Design Hub (DesignScreen) with a clean Material 3 Bento Grid layout, introduces the dedicated Design Manager Screen for comprehensive template & custom design management, and refines island previews to reflect authentic Xiaomi HyperOS Island visuals.


Key Highlights & Architectural Changes

1. 🏝️ The 10 Official Xiaomi HyperOS Island Templates (IslandTemplateCatalog)

  • Fully cataloged and implemented presets for the 10 official HyperOS Dynamic Island layouts:
    1. Standard Alert (tpl_standard_alert)
    2. Call Kit (tpl_call_kit)
    3. Media Player Compact (tpl_media_compact)
    4. Media Player Expanded (tpl_media_expanded)
    5. Ride Sharing / Progress (tpl_ride_sharing)
    6. Food & Package Delivery (tpl_delivery_status)
    7. Sports Score Live (tpl_sports_live)
    8. Timer / Stopwatch (tpl_timer_countdown)
    9. Boarding Pass / Flight Status (tpl_boarding_pass)
    10. Two-Factor OTP / Secure Code (tpl_otp_payment)
  • Seamless Integration with Custom Translators:
    • Picking a template produces a CustomTranslator with presentation.mode = TEMPLATE.
    • Templates inherit all matching conditions, priorities, regex extraction, token replacement, and .htrans import/export capabilities.
    • Templates materialize into concrete configurations when saved or edited so that per-field customizations (icons, texts, colors, action buttons) persist reliably.

2. 📱 Realistic HyperOS Island Previews (HyperOsIslandPreview, TemplateFocusCard)

  • Refactored HyperOsIslandPreview to look like the authentic hardware cutout / island:
    • Realistic camera pill cutout, accurate corner radiuses, and dynamic layout bounds matching system rendering.
    • Added template-specific preview samples (IslandPreviewSample) so each template previews with contextually appropriate demo content (e.g. flight numbers, OTP code, song titles).
    • Consolidated token replacement and variable maps (e.g. {smart_action.OTP.code}) for seamless preview rendering.

3. 🍱 Redesigned Design Hub (DesignScreen)

  • Bento Grid Layout: Replaced clunky carousels with a compact, structured Bento grid (DesignVariantBento) organizing Themes, Micro-Widgets, Designs, and Translators.
  • Featured Section & Guides: Added interactive featured highlight cards and documentation quick-links (GuidesSection, DocumentationUrls.kt).
  • Streamlined Add Flow (AddDesignFlow): Guided creation flow allowing users to choose an island template layout via visual gallery cards, select target notification types (in an intuitive 2-column grid with suggested badges), and immediately generate or edit a design.

4. 🗂️ Dedicated Design Manager (DesignManagerScreen)

  • Full lifecycle management for created island designs and template bindings.
  • Search, filter, enable/disable switches, edit triggers, and SAF (Storage Access Framework) import/export.
  • Interactive mode toggle to preview designs as real hardware islands or as icon cards.
  • Integrated with HomeScreen navigation back-stack tracking.

Changes by Module

File / Component Changes
IslandTemplateCatalog.kt Definitions, presets, token helpers, and preview samples for the 10 HyperOS templates
HyperOsIslandPreview.kt Realistic island rendering, camera hole positioning, and sample token resolution
TemplateFocusCard.kt Interactive focus preview cards for templates
AddDesignFlow.kt 2-step wizard for template selection and notification type binding
DesignScreen.kt Bento grid layout, status cards, featured carousel, and guides section
DesignManagerScreen.kt New dedicated manager screen for custom island designs
TranslatorEditorScreen.kt Template preset integration and slot customization
IslandTemplateCatalogTest.kt Comprehensive unit tests for template presets, variable mappings, and token resolution
strings.xml / strings.xml (es-rES) English and Spanish localization strings for templates, guides, and design manager

Testing & Verification

  • Unit Tests:
    • Added IslandTemplateCatalogTest testing all 10 templates, token resolution, and slot boundaries.
    • All existing unit tests pass: ./gradlew testDebugUnitTest
  • Build Verification:
    • Compiles without errors: ./gradlew compileDebugKotlin / ./gradlew assembleDebug
  • Manual Verification:
    • Verified Bento grid navigation from DesignScreen.
    • Walked through AddDesignFlow to create designs for various notification types.
    • Checked realistic island rendering in HyperOsIslandPreview.
    • Tested persistence, editing, and toggling in DesignManagerScreen.

Related Issues

noelpatata and others added 4 commits September 24, 2026 13:24
…aomi templates (#272, Phase 4) (#327)

* feat(composer): add island template model, Room persistence, matcher and translator

Phase 4 (#272) data layer: ComposerTemplate/IslandTemplateDefinition model
covering the 10 Xiaomi templates and their slots (left graphic, text,
progress, buttons, rule), a Room-backed repository with a hand-written
1->2 migration (avoids destructive fallback wiping settings), a pure
ComposerTemplateMatcher cloned from RulesEngine, and a ComposerTemplateTranslator
hooked into NotificationReaderService just before the built-in translator
dispatch. A matched template now wins over native Live Updates and the
built-in per-type translators for STANDARD/MESSAGE/PROGRESS/DOWNLOAD/MEDIA
notifications.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(composer): add matcher and repository unit tests

Covers package/title/text regex matching, priority ordering, disabled
templates, invalid-regex safety, and JSON round-tripping every field of
IslandTemplateDefinition through the Room repository (fake in-memory DAO,
matching this repo's existing testing conventions). ComposerTemplateMatcher
is kept free of android.util.Log so it stays plain-JUnit testable.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* feat(composer): add island template composer UI and DesignScreen entry point

Phase 4 (#272) Compose layer: a shared IslandTemplatePreview live pill
plus 10 default-definition catalog wrappers for the Xiaomi templates,
slot editors (left graphic, text/badge, progress, action buttons, rule
binder with an app picker + advanced regex toggle), IslandComposerScreen
(type switcher + live preview + gated editors + save), and
ComposerTemplateListScreen (list/enable/delete), wired into DesignScreen
and HomeScreen's hand-rolled route enum alongside the existing
Widgets/Themes flows.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(composer): make ComposerTemplateMatcher regex cache thread-safe

NotificationReaderService dispatches each notification onto
Dispatchers.Default (a real thread pool), so this singleton's regex
cache can be hit concurrently by multiple notifications. Switch the
plain mutableMapOf to a ConcurrentHashMap to avoid data races on the
24/7 service path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* feat(design): island templates as translator presentations (#272, Phase 4)

Rework of the Composer along the lines David asked for in #327: templates are
not a feature of their own any more, they are presets for the Phase 3
translator pipeline, and every preview goes through the component added for
TranslatorScreen.

- IslandTemplateCatalog: the ten official Xiaomi templates as named
  PresentationConfig presets. Reuses the ids the editor's picker already
  offered (so tpl_call_kit / tpl_media_compact keep the meaning
  DynamicTranslator gives them) and adds the two that were missing, boarding
  pass and courier tracking. Picking one produces an ordinary CustomTranslator
  with presentation.mode = TEMPLATE, so templates inherit matching, priority,
  theming and .htrans import/export instead of a parallel store.
- HyperOsIslandPreview gains an IslandPreviewSample (so each template previews
  with content that suits it), a showChrome flag for thumbnail use, and
  resolves TEMPLATE presets before rendering. The three copies of the token
  replacement chain collapse into one helper, which also fixes the compact
  pill showing a raw {notif.title}.
- Design tab: a Designs section listing the active designs, and Add design ->
  from a template (gallery of the ten, each previewed) or a custom design,
  which stays disabled until the Widget Studio lands. After picking a template
  the only question asked is the notification type.
- Translator editor: the template sheet is the same gallery, and picking a
  template now also opens the slot editors, so each element can be bound to
  notification data alongside the match conditions already there.
- DynamicTranslator fills the slots from the preset for a translator that only
  carries a templateId, so an imported .htrans renders as its template.

Tests: 12 new IslandTemplateCatalog cases; :app:testDebugUnitTest is 416 green
and :app:assembleDebug builds.

* fix(design): templates are materialized once, then rendered exactly as saved (#272)

effectivePresentation() merged the preset slot by slot, comparing each whole slot to the
class defaults, and refilled an empty action list from the preset. Two silent losses:
editing one text field of a translator that still carried a bare templateId dropped the
preset's other fields (the payment template's highlight / OTP text), and deleting a
preset's only action brought it back on every render.

A template is now either bare (only a templateId: rendered as the preset) or concrete
(rendered as saved). The editor materializes it when a translator is loaded, when the mode
is switched to TEMPLATE, and when a template is picked (applyTemplate), so every edit and
deletion sticks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(design): payment template highlights the OTP the translator actually extracts (#272)

The preset used {regex.1}, which nothing in DynamicTranslator's variable map ever fills,
so the payment island's highlight / pill text rendered blank. It now uses
{smart_action.OTP.code}, filled by the existing OTP extraction. A test pins every preset
to variables the translator provides.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: noelpatata2 <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: noelpatata <[email protected]>
…el, and Guides section (#383)

* feat: add dedicated Design Manager screen and update design dashboard layout

- Add `DesignManagerScreen` to allow browsing, searching, previewing, importing, exporting, and managing island designs.
- Replace `DesignsCarousel` on `DesignScreen` with a `DesignStatusCard` summary card that navigates to the new manager screen.
- Track previous route in `HomeScreen` to return to either the Design Manager or Translator Manager after design editing.
- Add vertical scrolling to notification type selection in `AddDesignFlow`.
- Add localized strings for design management features.

* feat: replace carousels with status cards on design screen

- Replace theme, widget, and translator carousels on `DesignScreen` with summary status cards and action buttons.
- Update notification type selection in `AddDesignFlow` to use a 2-column grid layout with type icons and suggested tags.
- Add required string resources for status cards and suggested badges.

* feat: update design screen layout to a bento grid

Replace status cards for themes, widgets, designs, and translators in `DesignScreen` with a compact bento grid layout (`DesignVariantBento`), and add string resources for layout variants.

* feat: add featured carousel and guides sections to design screen

- Add `FeaturedSection` and `GuidesSection` to `DesignScreen` for showcasing featured content and documentation links.
- Define documentation URL constants in `DocumentationUrls.kt`.
- Add localized string resources for new sections in English and Spanish.

* ui: refine template card layout and tag placement in AddDesignFlow

- Set a minimum height of 142.dp on design template cards.
- Restructure card layout with a fixed top slot for the "Suggested" tag to maintain consistent icon alignment.
- Adjust vertical spacing and padding within the template card.
…feedback) (#385)

Salvaged from #384 on top of #383: each official template gets a
TemplateCardLayout (style, progress, hint button, Xiaomi accent) and the
preview renders a TemplateFocusCard modelled on the HyperIsland ToolKit
demo instead of the generic expanded island. Used by the template
gallery, the translator editor and My Designs.

Co-authored-by: noelpatata2 <[email protected]>
…nize DesignManager UI (#389)

* feat: add per-app custom design management and package exclusion support

- Add `excludedPackages` field to `CustomTranslator` model and enforce exclusions in `TranslatorRegistry`.
- Add `getDesignsForApp` and `toggleDesignForApp` methods to `TranslatorViewModel` to toggle designs per package.
- Replace custom design placeholder in `AppConfigScreen` with `AppDesignsSectionCard` for managing app designs.
- Update `DesignPreviewCardItem` to support explicit checked state overrides.

* fix(design): show notification type designs on app config screen and wire add design flow

* feat(design): separate design items and add search & filter to app config design subscreen

* feat(design): add preview visibility toggle button on app config design subscreen

* feat(app-config): add filter bottom sheet for custom designs

* feat(design-manager): show AddDesignFlow bottom sheet on add fab and empty state

* feat(design): modernize add fab bottom sheet with m3 expressive design

* feat(design-manager): move explanation to help bottom sheet invoked by top bar info icon

* feat(app-config): add help info action to design subscreen top bar
@github-actions

Copy link
Copy Markdown

📱 Debug APK Ready for Testing

The debug APK for commit ef72b43 has been built and is ready:

📦 Android Installation Note: GitHub Actions artifacts are downloaded as a .zip archive. Extract the zip to access and install app-debug.apk.

@D4vidDf D4vidDf changed the title Feat/template composer feat(design): Visual Island Template Composer with 10 official HyperOS templates, Design Hub Bento Grid & Design Manager (#272, #327, #383, #385) Sep 25, 2026
@D4vidDf D4vidDf added enhancement New feature or request prio/critical breaking-changes help wanted Extra attention is needed labels Sep 25, 2026
@D4vidDf
D4vidDf marked this pull request as ready for review September 25, 2026 16:01
@D4vidDf

D4vidDf commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

Need users to test if all the templates works on their devices. I tested some combinations on my Xiaomi 13t and Xiaomi 15 Ultra

noelpatata added a commit to noelpatata/HyperBridge that referenced this pull request Sep 25, 2026
Takes David's D4vidDf#390/D4vidDf#391 versions of the composer, Design hub and 0.6 service code, and
re-applies only the Studio (D4vidDf#273) changes on top:
- Design Manager opens WIDGET-mode designs in the Studio instead of the translator editor
- dropped the leftover BridgeIslandGroup.scheduleRelease calls (the group was reverted in D4vidDf#380)
- Room stays v2 upstream + our v3 (source tables) / v4 (composer test builds) migrations

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@D4vidDf
D4vidDf merged commit eaffe4d into dev/0_6_0 Sep 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-changes enhancement New feature or request help wanted Extra attention is needed prio/critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Visual Island Template Composer with Official Xiaomi 10-Template Catalog (Phase 4)

2 participants