Skip to content

Constraint for display resolution#2186

Open
keymapper-ai wants to merge 2 commits into
developfrom
claude/elegant-gates-ikjymp
Open

Constraint for display resolution#2186
keymapper-ai wants to merge 2 commits into
developfrom
claude/elegant-gates-ikjymp

Conversation

@keymapper-ai

Copy link
Copy Markdown
Collaborator

Closes #2184

Summary

Adds a new display resolution constraint. A key map with this constraint is only active when the device's real display resolution matches the chosen width and height.

Following the design discussed on the issue, the constraint is configured in a bottom sheet (like the other action/constraint sheets):

  • A row of selectable chips, one per resolution the display reports as supported (from Display.getSupportedModes()).
  • A trailing "Custom" chip that reveals two side-by-side text fields for typing an arbitrary width and height.
  • When the display reports one or zero supported modes, the custom text fields are shown immediately (no chips).

The real display size is read from DisplayAdapter.size (getRealSize), as requested. The comparison ignores orientation, so a resolution such as 1080 × 2400 satisfies the constraint in both portrait and landscape.

Changes

  • Model / persistence: new ConstraintId.DISPLAY_RESOLUTION, ConstraintData.DisplayResolution(width, height), entity type + width/height extras, and to/from entity mapping.
  • Evaluation: LazyConstraintSnapshot (and TestConstraintSnapshot) compare DisplayAdapter.size against the stored resolution, orientation-independent.
  • System: DisplayAdapter.getSupportedResolutions() implemented in AndroidDisplayAdapter from the default display's supported modes; exposed to the UI via CreateConstraintUseCase.
  • UI: new DisplayResolutionConstraintBottomSheet, wired into ChooseConstraintScreen/ChooseConstraintViewModel; category/icon/title in ConstraintUtils, description in ConstraintUiHelper, sort field in KeyMapConstraintsComparator, and new strings.
  • CHANGELOG.md updated.

Testing

  • ./gradlew ktlintFormat — clean.
  • ./gradlew :base:testDebugUnitTest — passing (compiles the new Compose UI, view model, and the constraint snapshot changes).

Notes / areas for human review

  • Supported resolutions come from Display.getSupportedModes(), whose dimensions are in the display's natural orientation, while DisplayAdapter.size reflects the current rotation — hence the orientation-independent comparison. Please sanity-check this matches the intended behaviour on real hardware.
  • The constraint is evaluated on demand when triggers fire (the snapshot reads size lazily), so no continuous observation of resolution changes was added. Let me know if you'd prefer an observable flow instead.
  • On devices that expose only a single mode, only the custom fields are shown, as specified.

🤖 Generated with Claude Code

https://claude.ai/code/session_011GqGRM7xSwYjxKYT6gp66F


Generated by Claude Code

Add a new constraint that is satisfied when the device's real display
resolution matches a chosen width and height.

The constraint is configured in a bottom sheet that shows a row of
selectable chips for each of the display's supported resolution modes,
plus a "Custom" chip that reveals side-by-side width and height text
fields. When the display reports one or zero supported modes, the text
fields are shown immediately.

The real display size is read from DisplayAdapter.size and compared
ignoring orientation so the constraint holds in both portrait and
landscape.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GqGRM7xSwYjxKYT6gp66F
@keymapper-ai keymapper-ai requested a review from sds100 July 10, 2026 09:21
Hoist the bottom sheet's selection/custom/width/height state and the
validity and resolved-resolution logic out of the composable and into
ChooseConstraintViewModel. The bottom sheet is now a stateless view that
renders DisplayResolutionSheetState and forwards user input through view
model callbacks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GqGRM7xSwYjxKYT6gp66F
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.

Constraint for display resolution

2 participants