Conversation
Add two-finger rotation gesture for images with toggle button and introduce locked controls preference to allow gestures (zoom, pan, rotate) even when the image is locked. Includes full i18n support for English and Traditional Chinese.
- Replace separate detectZoom and detectRotation handlers with unified detectTransformGestures - Fix lockedControlsPreference state collection to use collectAsStateWithLifecycle for proper lifecycle awareness - Remove redundant pointerInput modifier for rotation detection
Transform drag coordinates based on rotation angle to align panning direction with the rotated image coordinate system. Previously, panning would move in screen coordinates regardless of rotation, causing counter-intuitive behavior. Also replaces detectTransformGestures with custom detectZoomAndRotation to provide more precise control over gesture detection and normalization of rotation deltas to -180 to 180 range.
Fixes the rotation transformation in the drag gesture handler by applying forward rotation instead of inverse rotation, and removing the unnecessary scale multiplication that was causing incorrect pan behavior when the image is rotated.
The change adds a 1.0° rotation threshold filter to prevent micro-movements and angle noise when users are pinch-zooming. While the current implementation uses the same threshold (1.0°) for both active scaling and non-scaling states, the infrastructure is in place to differentiate between them if needed. This reduces unwanted rotation jitter during zoom operations
This commit clarifies the zoom scale naming by introducing fitScale as the fit-to-screen scale, while minScale becomes 50% of fit-to-screen. The initial image scale is now properly set to fitScale when loading, and double-tap zoom logic is updated to use fitScale as the reference point instead of the old minScale.
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.
Summary
This PR introduces image rotation gesture support and a new "locked controls" feature that allows users to continue using zoom, pan, and rotate gestures even when the image is locked. It also includes several bug fixes and refactoring improvements for gesture handling.
New Features
Bug Fixes
Refactoring
detectTransformGestures)minScaletofitScalefor clearer semantics - initial image scale now properly set to fit-to-screenTransformGestureDetectorfor precise control over gesture detectionChanges
TransformGestureDetector.ktLockedControlsPreference.ktLockedControlsRepository.ktZoomableImage.ktImageViewerScreen.ktImageViewerState.ktImageViewerViewModel.ktSettingsViewModel.ktSettingsViewModelFactory.ktMainActivity.ktstrings.xmlCommits
feat: add image rotation and locked controls settings
refactor: unify zoom and rotation into single transform gesture handler
fix: correct pan gesture alignment when image is rotated
fix: correct drag gesture rotation transformation
add rotation threshold to reduce jitter during zoom gestures
refactor: rename minScale to fitScale and improve initial zoom behavior
Test Plan