Skip to content

feat/locked-view-controls#5

Merged
zac15987 merged 6 commits intomainfrom
dev
Jan 12, 2026
Merged

feat/locked-view-controls#5
zac15987 merged 6 commits intomainfrom
dev

Conversation

@zac15987
Copy link
Copy Markdown
Owner

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

  • Image Rotation: Two-finger rotation gesture for images with a dedicated toggle button
  • Locked Controls Setting: New preference to allow gestures (zoom, pan, rotate) even when the image is locked
  • Full i18n Support: English and Traditional Chinese translations for all new UI elements

Bug Fixes

  • Fixed pan gesture alignment when image is rotated - panning now moves in the correct direction relative to the rotated image
  • Fixed drag gesture rotation transformation by applying forward rotation instead of inverse rotation
  • Added 1.0° rotation threshold to reduce jitter during zoom gestures

Refactoring

  • Unified zoom and rotation into a single transform gesture handler (detectTransformGestures)
  • Renamed minScale to fitScale for clearer semantics - initial image scale now properly set to fit-to-screen
  • Created custom TransformGestureDetector for precise control over gesture detection

Changes

File Description
TransformGestureDetector.kt New custom gesture detector with rotation delta normalization
LockedControlsPreference.kt New enum for locked controls preference
LockedControlsRepository.kt New repository for locked controls persistence
ZoomableImage.kt Updated with rotation support and unified gesture handling
ImageViewerScreen.kt Added rotation toggle button and locked controls setting UI
ImageViewerState.kt Extended state model with rotation and locked controls
ImageViewerViewModel.kt Added rotation and locked controls business logic
SettingsViewModel.kt Added locked controls state management
SettingsViewModelFactory.kt Updated factory for new repository dependency
MainActivity.kt Minor updates for new features
strings.xml New localization strings (EN/ZH-TW)

Commits

  1. feat: add image rotation and locked controls settings

    • Add two-finger rotation gesture for images with toggle button
    • Introduce locked controls preference to allow gestures when locked
    • Full i18n support for English and Traditional Chinese
  2. refactor: unify zoom and rotation into single transform gesture handler

    • Replace separate detectZoom and detectRotation handlers with unified detectTransformGestures
    • Fix lockedControlsPreference state collection to use collectAsStateWithLifecycle
  3. fix: correct pan gesture alignment when image is rotated

    • Transform drag coordinates based on rotation angle
    • Replace detectTransformGestures with custom detectZoomAndRotation
  4. fix: correct drag gesture rotation transformation

    • Apply forward rotation instead of inverse rotation
    • Remove unnecessary scale multiplication
  5. add rotation threshold to reduce jitter during zoom gestures

    • Add 1.0° rotation threshold filter to prevent micro-movements
  6. refactor: rename minScale to fitScale and improve initial zoom behavior

    • Clarify zoom scale naming with fitScale as fit-to-screen scale
    • Update double-tap zoom logic to use fitScale as reference

Test Plan

  • Verify two-finger rotation works smoothly on images
  • Verify rotation toggle button enables/disables rotation
  • Verify locked controls setting allows gestures when image is locked
  • Verify panning direction is correct when image is rotated
  • Verify no rotation jitter occurs during pinch-zoom gestures
  • Verify double-tap zoom toggles between fit-to-screen and 2x zoom
  • Verify all new strings appear correctly in English and Traditional Chinese
  • Verify settings persist across app restarts

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.
@zac15987 zac15987 merged commit 07345cc into main Jan 12, 2026
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.

1 participant