Skip to content

feat/optimize-global-ifw-rule-screen - #1519

Open
juliewww wants to merge 30 commits into
mainfrom
feat/optimize-global-ifw-rule-screen
Open

feat/optimize-global-ifw-rule-screen#1519
juliewww wants to merge 30 commits into
mainfrom
feat/optimize-global-ifw-rule-screen

Conversation

@juliewww

@juliewww juliewww commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

name: Pull request
about: Create a pull request
label: 'triage me'

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way
    we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter
    pass (./gradlew --init-script gradle/init.gradle.kts spotlessApply to automatically apply
    formatting)
  • Appropriate docs were updated (if necessary)

Is this your first Pull Request?

  • Run ./tools/setup.sh
  • Import the code formatting style as explained in the setup script.

Fixes #<issue_number_goes_here> 🦕

juliewww and others added 22 commits March 30, 2026 09:26
- Move IFW rule models, filters, and string matchers from `feature/globalifwrule` and `core/ifw-api` to `core/model` for better architectural separation
- Relocate IFW rule editor models and mappers to `core/model`
- Update `core/ifw-api` to use `api` dependency on `core/model`
- Add UI preview parameter providers and states for global IFW rules in `core/ui`
- Implement Compose previews for `AddRuleScreen`, `SimpleGlobalIfwRuleScreen`, and `GlobalIfwRuleScreen`
- Refactor `GlobalIfwRuleScreen` to improve delete dialog handling and clean up unused parameters
- Extract `IfwComponentType` resource labels into a dedicated `GlobalIfwRuleResources.kt` file
- Replace local `ErrorContent` and `EmptyContent` with centralized `ErrorScreen` and `EmptyScreen` in `GlobalIfwRuleScreen`
- Update `EmptyScreen` to support an optional content description/subtext field
- Add preview for `EmptyScreen` with description support
- Improve `GlobalIfwRuleScreen` empty state with specific title and description resources
- Redesign the Global IFW Rule screen with a card-based layout, grouping rules by package using `Surface` containers with elevated backgrounds and borders
- Add `PackageAvatar` component to display app icons or letter placeholders in rule group headers
- Introduce `RuleItemPresentationUiState` and `GlobalIfwRuleMapper` logic to extract more readable titles, target paths, and supporting text from rule filters
- Replace `AssistChip` badges in rule items with custom `RuleMetaBadge` components for better status visualization (block, log, component type)
- Refactor rule editor components by splitting `GlobalIfwRuleEditorComponents.kt` and `SimpleGlobalIfwRuleEditorComponents.kt` into dedicated files
- Update preview providers with the new presentation model and refined summary formats
- Redesign the Global IFW Rule screen with a card-based layout, grouping rules by package using `Surface` containers with elevated backgrounds and borders
- Add `PackageAvatar` component to display app icons or letter placeholders in rule group headers
- Introduce `RuleItemPresentationUiState` and `GlobalIfwRuleMapper` logic to extract more readable titles, target paths, and supporting text from rule filters
- Replace `AssistChip` badges in rule items with custom `RuleMetaBadge` components for better status visualization (block, log, component type)
- Refactor rule editor components by splitting `GlobalIfwRuleEditorComponents.kt` and `SimpleGlobalIfwRuleEditorComponents.kt` into dedicated files
- Update preview providers with the new presentation model and refined summary formats
- Update `optional_action` and `optional_category` string resources to use "Intent action" and "Intent category" (and their respective translations) across all supported languages
- Reformat `GlobalIfwRuleScreen.kt` for consistent indentation
- Move shared UI components (`RuleMetaBadge`, `RulePrimaryMetadataText`, `RuleSecondaryMetadataText`, `DeleteConfirmationDialog`) from `GlobalIfwRuleScreen.kt` to a new `GlobalIfwRuleUiComponents.kt` file
- Extract `AdvancedGlobalIfwRuleDetailScreen` into its own file for better maintainability
- Update `GlobalIfwRuleScreen` to use the new common text components and refined spacing (from 8dp/12dp to 10dp) for metadata sections
- Standardize typography and colors across IFW rule displays using the new shared components
- Move shared UI components (`RuleMetaBadge`, `RulePrimaryMetadataText`, `RuleSecondaryMetadataText`, `DeleteConfirmationDialog`) from `GlobalIfwRuleScreen.kt` to a new `GlobalIfwRuleUiComponents.kt` file
- Extract `AdvancedGlobalIfwRuleDetailScreen` into its own file for better maintainability
- Update `GlobalIfwRuleScreen` to use the new common text components and refined spacing (from 8dp/12dp to 10dp) for metadata sections
- Standardize typography and colors across IFW rule displays using the new shared components
- Relocate `GlobalIfwRuleEditorComponents.kt`, `GlobalIfwRuleUiComponents.kt`, `GlobalIfwRuleMapper.kt`, `SimpleGlobalIfwRuleEditorComponents.kt`, and `GlobalIfwRuleResources.kt` to the `com.merxury.blocker.feature.globalifwrule.impl.components` package
- Update package declarations and import statements across the module to reflect the new structure
- Update copyright year to 2026 in `GlobalIfwRuleEditorComponents.kt`
- Minor formatting adjustment in `GlobalIfwRuleViewModel.kt`
…preview provider

- Replace `AdvancedGlobalIfwRuleScreenPreviewParameterProvider` with explicit `@Preview` functions for different states (Add, Edit, and Missing Selector)
- Remove `AdvancedGlobalIfwRuleScreenPreviewState` data class
- Update `AdvancedGlobalIfwRuleScreenPreview` to accept direct parameters instead of a state object
- Improve preview coverage by adding specific test cases for different IFW rule configurations
- Update `BlockerOutlinedCard` to support optional `onClick` and customizable `outerPadding`
- Improve accessibility for toggles and radio buttons by using `Modifier.toggleable` and `Modifier.selectable` with appropriate `Role` and larger touch targets
- Refactor `GroupModeSelector` to use `FlowRow` for better layout of logic options
- Refactor `AddRuleScreen` to use `Scaffold` for better top bar and padding management
- Move IFW validation messages into `GroupEditorCard` for better visual grouping
- Add `contentDescription` to the back button in `BlockerTopAppBar`
- Fix UI issues such as missing single-line constraints in dropdowns and spacing in row layouts
- **UI Enhancements**:
    - Update colors and typography for `IntentFilterBanner` and `SectionLabel`.
    - Replace the save icon button with a `BlockerTextButton` in the top app bar.
    - Organize "Target" and "Behavior" sections in `AddRuleScreen` using labels and grouped surfaces.
    - Reduce horizontal padding/indentation for nested rules (from 12dp to 8dp).
- **IFW Rule Editor**:
    - Implement expandable/collapsible groups in `GroupEditorCard` with an animated transition and a summary view for collapsed nodes.
    - Simplify the `ConditionEditorCard` layout by moving the delete button and making the condition kind dropdown full-width.
    - Use `Surface` with semi-transparent variant colors instead of `BlockerOutlinedCard` for nested group/condition containers.
    - Update "Add" action styling: root groups use full-width outlined buttons, while nested groups use a combination of outlined and text buttons.
- **Preview**: Add validation and valid state previews for `IfwRuleTreeEditor`.
…h translations

- Reorder `modifier` parameter in `GroupEditorCard` and `BlockerOutlinedCard` to follow standard Compose conventions (placed before optional trailing parameters)
- Escape apostrophes in `feature/globalifwrule/api` French string resources to ensure proper XML parsing
- Wrap `SimpleGlobalIfwRuleScreen` in a `Scaffold` and use `innerPadding` for correct layout
- Replace `BlockerSwitch` with context-aware `RadioButton` (for single selection) and `Checkbox` (for multiple selection) in component lists
- Update `TargetModeRow` and component items to use `selectable` and `toggleable` modifiers with appropriate semantic roles for better accessibility
- Redesign section layouts using `Surface` containers with `surfaceVariant` backgrounds to group related fields
- Replace `SectionTitle` with `SectionLabel` using `labelMedium` typography and `onSurfaceVariant` color
- Improve spacing and alignment across the rule editor screen
- Add unsaved changes confirmation logic when navigating back (referenced in `handleBack`)
- Delete `SimpleGlobalIfwRuleScreenPreviewParameterProvider` and its associated state data class `SimpleGlobalIfwRuleScreenPreviewState` from `GlobalIfwRulePreviewParameterProvider.kt`.
- Remove unused `SimpleTargetMode` import.
- Extract UI sections into focused `@Composable` functions: `TargetSection`, `TargetModeSection`, `TargetComponentSection`, `BehaviorSection`, and `OptionalConditionsSection`
- Create `SimpleGlobalIfwRuleContent` to manage the high-level layout of the screen
- Improve code readability and maintainability by reducing the nesting level and complexity of the main screen function
- Pass specific state and callbacks to sub-components to reduce parameter overhead in nested calls
- Move `SectionLabel` and `BehaviorSection` to `GlobalIfwRuleEditorComponents.kt` for reuse
- Update `AddRuleScreen` and `SimpleGlobalIfwRuleScreen` to use the shared components
- Remove duplicate component definitions from individual screen files
- Extract content into `AdvancedGlobalIfwRuleContent`
- Extract target package and component type logic into `AdvancedTargetSection`
- Extract IFW condition tree logic into `ConditionsSection`
- Improve code readability and structure in `AddRuleScreen.kt`
- Add `GlobalIfwRuleScreenScreenshotTests` covering list, simple editor, advanced editor, and detail screens
- Support light/dark mode and multi-device screenshot testing for IFW features
- Update `feature/globalifwrule/impl/build.gradle.kts` with Roborazzi and screenshot testing dependencies
- Add `waitForIdle()` calls in `ScreenshotHelper.kt` to ensure UI stability before capturing images
Migrate `createAndroidComposeRule` and `createComposeRule` imports from `androidx.compose.ui.test.junit4` to `androidx.compose.ui.test.junit4.v2` across all screenshot and UI tests.
- Refactor `componentSelectionModifier` into an extension function on `Modifier`
- Simplify the `Modifier` chain in `SimpleGlobalIfwRuleEditorComponents.kt` by removing the `.then()` call site usage
Comment thread core/ifw-api/build.gradle.kts Outdated
juliewww and others added 2 commits March 31, 2026 14:27
…e module

- Relocate `GlobalIfwRuleModels.kt` from `core:model` to `feature:globalifwrule:impl` as `GlobalIfwRuleUiModels.kt`
- Move `GlobalIfwRulePreviewParameterProvider.kt` from `core:ui` to `feature:globalifwrule:impl`
- Update all internal references and imports to point to the new package structure in the `feature` module
- Change `core:model` dependency in `core:ifw-api` from `api` to `implementation`
- Update `IfwRuleTreeEditor` preview to use explicit node definitions instead of the moved preview data
- Update copyright years to 2026 in touched files
juliewww and others added 4 commits March 31, 2026 14:36
- Replace `DefaultTestDevices.PHONE.spec` with a local `PHONE_DEVICE_SPEC` constant
- Remove helper `capturePhoneDark` method in favor of direct `composeTestRule.captureForDevice` calls
- Inline screenshot capture logic within individual test methods
- Move helper Composable functions outside of the test class scope
…reen' into feat/optimize-global-ifw-rule-screen
- Move `IfwFilter.toSummary()` from `core:ifw-api` to `feature:globalifwrule`
- Rename the imported extension to `toIntentFilterSummary` in `GlobalIfwRuleMapper` to avoid name collisions
- Update internal visibility for the relocated summary utility functions
These data classes (IfwFilter, IfwRule, IfwRules, IfwComponentType,
IfwIntentFilter, StringMatcher, IfwRuleEditorMapper, IfwRuleEditorModel)
are IFW implementation details and should stay scoped to core:ifw-api
rather than being exposed via core:model to 13+ unrelated modules.

Both core:ui and feature:globalifwrule:impl already depend on
core:ifw-api, so no dependency problem exists.

Change-Id: I206dfa2c09a81304e3c1bdbb298ee0d0dfe25ebc
@lihenggui
lihenggui force-pushed the feat/optimize-global-ifw-rule-screen branch from f743540 to 418adcc Compare April 9, 2026 18:34
- Deduplicate SwitchRow: remove duplicate from feature/globalifwrule,
  reuse core/ui version with textStyle/contentPadding parameters
- Replace duplicate AdvancedRuleReadOnlyNotice with IntentFilterBanner
- Fix fully-qualified IfwEditorConditionKind references in GroupEditorCard
- Fix BlockerOutlinedCard non-clickable variant using inconsistent colors
- Rename misleading contentDescriptionRes to descriptionRes in EmptyScreen

Change-Id: Ib782508b54a450d2ded8bd35878f4032d622a009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants