Constraint for display resolution#2186
Open
keymapper-ai wants to merge 2 commits into
Open
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
Display.getSupportedModes()).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
ConstraintId.DISPLAY_RESOLUTION,ConstraintData.DisplayResolution(width, height), entity type + width/height extras, and to/from entity mapping.LazyConstraintSnapshot(andTestConstraintSnapshot) compareDisplayAdapter.sizeagainst the stored resolution, orientation-independent.DisplayAdapter.getSupportedResolutions()implemented inAndroidDisplayAdapterfrom the default display's supported modes; exposed to the UI viaCreateConstraintUseCase.DisplayResolutionConstraintBottomSheet, wired intoChooseConstraintScreen/ChooseConstraintViewModel; category/icon/title inConstraintUtils, description inConstraintUiHelper, sort field inKeyMapConstraintsComparator, and new strings.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
Display.getSupportedModes(), whose dimensions are in the display's natural orientation, whileDisplayAdapter.sizereflects the current rotation — hence the orientation-independent comparison. Please sanity-check this matches the intended behaviour on real hardware.sizelazily), so no continuous observation of resolution changes was added. Let me know if you'd prefer an observable flow instead.🤖 Generated with Claude Code
https://claude.ai/code/session_011GqGRM7xSwYjxKYT6gp66F
Generated by Claude Code