Skip to content

Fix reader scrolling and soften predictive back - #12

Merged
bjcdeshu merged 2 commits into
mainfrom
codex/fix-reader-scroll-back-motion
Jul 25, 2026
Merged

Fix reader scrolling and soften predictive back#12
bjcdeshu merged 2 commits into
mainfrom
codex/fix-reader-scroll-back-motion

Conversation

@bjcdeshu

@bjcdeshu bjcdeshu commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • remove the full-document pointer consumer that intercepted Reader WebView swipes
  • keep predictive-Back progress reads in graphics-layer scope instead of recomposing the document tree for every frame
  • replace the large custom transition with a restrained, finger-linked reveal:
    • maximum translation reduced from 45% to 8% of window width
    • outgoing document scale reduced from 0.90 to 0.96
    • Home remains visually stable underneath
    • document fade is spread smoothly across the final 35%
    • cancellation uses a distance-aware 80–180 ms ease-out
  • update focused predictive-motion unit coverage

Root cause

The document Surface consumed every pointer change at PointerEventPass.Final.
That prevented the embedded AndroidView/WebView from receiving a usable
vertical gesture. On the exact blocked v0.3.0 Draft, a controlled 1000 px center
swipe left visible Section 9/10/11 bounds unchanged.

The old predictive transition also combined 45% window translation, a
1.10→1.00 Home zoom, 0.90 outgoing scale, and a fade concentrated into the final
20%. Current-run capture reproduced the maintainer's report: large spatial
movement and dense document/Home text overlap.

Behavior after the fix

  • the same center swipe advances the long test document by roughly the expected
    gesture distance and hides the toolbar
  • the right-edge thumb still drags directly from approximately Section 5 to
    Section 40
  • left- and right-edge predictive Back complete without the thumb intercepting
    the gesture outside its local hit target
  • the destination remains real Home, but spatial movement and background zoom are
    no longer visually dominant

The motion direction follows current Android Compose guidance for custom in-app
predictive Back: keep the destination stable and use a restrained outgoing
transform driven by gesture progress.

Validation

  • .\gradlew.bat --no-daemon --no-build-cache --rerun-tasks testDebugUnitTest lintDebug assembleDebug
  • API 36 emulator: long-document center swipe, toolbar hide, position persistence,
    right-edge progress drag, left/right predictive Back completion
  • git diff --check

Release boundary

The immutable v0.3.0 tag and hidden Draft remain blocked and will not be moved,
republished, or have assets replaced. This PR intentionally does not change
version metadata. After merge and green main CI, release finalization will move
the stable target to a new patch version and repeat the complete signed
exact-asset gates.

Summary by CodeRabbit

  • New Features

    • Improved predictive back gestures with smoother cancellation animations and more responsive motion.
    • Refined document scaling, translation, corner radius, and fade behavior during navigation.
    • Kept the destination screen stable while swiping back.
    • Preserved touch interaction with embedded document content during back gestures.
  • Bug Fixes

    • Improved handling of invalid or incomplete gesture progress values.
    • Adjusted cancellation timing to better match the distance remaining in the gesture.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bjcdeshu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b78145e-3911-425d-b18a-8133079d1181

📥 Commits

Reviewing files that changed from the base of the PR and between 3057b5f and 1d80eff.

📒 Files selected for processing (1)
  • app/src/main/java/de/unbow/mora/ui/MoraApp.kt
📝 Walkthrough

Walkthrough

Predictive-back animation calculations now use direct gesture progress, smoothed fading, revised document transforms, identity home frames, and progress-based cancellation durations. Compose applies these frames inline, and the document container no longer consumes pointer events needed by the embedded WebView.

Changes

Predictive-back behavior

Layer / File(s) Summary
Revise predictive-back frame and cancellation calculations
app/src/main/java/de/unbow/mora/ui/PredictiveDocumentBack.kt
Motion constants, document scaling and translation, polynomial fade smoothing, identity home transforms, and clamped cancellation-duration interpolation are updated.
Apply frames during Compose predictive-back transitions
app/src/main/java/de/unbow/mora/ui/MoraApp.kt
Cancellation animations use computed durations and slow-out easing; home and document transforms are calculated inline, and full-screen pointer consumption is removed from the document surface.
Update predictive-back behavior tests
app/src/test/java/de/unbow/mora/ui/PredictiveDocumentBackTest.kt
Assertions cover revised motion, fade timing, identity home frames, invalid progress, spatial tracking, and cancellation durations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PredictiveBackGesture
  participant HomeScreen
  participant DocumentSurface
  participant WebView
  PredictiveBackGesture->>HomeScreen: Update home frame from gesture progress
  PredictiveBackGesture->>DocumentSurface: Update document frame from gesture progress
  DocumentSurface->>WebView: Pass unconsumed motion events
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Accurately summarizes the main user-facing changes: Reader scrolling and a toned-down predictive-back animation.
Description check ✅ Passed Covers what changed, why, and how it was validated; only the screenshot/recording section from the template is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-reader-scroll-back-motion

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bjcdeshu
bjcdeshu marked this pull request as ready for review July 25, 2026 02:04
@bjcdeshu

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/src/main/java/de/unbow/mora/ui/MoraApp.kt (1)

326-342: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Home's predictive-back frame is always Identity — drop the redundant computation.

calculatePredictiveDocumentBackFrame(...).home is unconditionally PredictiveDocumentBackTransform.Identity, same as PredictiveDocumentBackFrame.Idle.home. Both branches here yield an identical, constant result, so the full frame calculation (fade smoothing, scale/translation/cornerRadius math) runs every frame purely to read a constant.

♻️ Proposed simplification
                 .graphicsLayer {
-                    val frame = if (predictiveBackVisualActive) {
-                        calculatePredictiveDocumentBackFrame(
-                            progress = predictiveBackProgress,
-                            swipeEdge = predictiveBackSwipeEdge,
-                            maximumTranslation = maximumBackTranslation,
-                            maximumCornerRadius = maximumBackCornerRadius,
-                        )
-                    } else {
-                        PredictiveDocumentBackFrame.Idle
-                    }
-                    scaleX = frame.home.scale
-                    scaleY = frame.home.scale
-                    alpha = frame.home.alpha
+                    scaleX = 1f
+                    scaleY = 1f
+                    alpha = 1f
                 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/de/unbow/mora/ui/MoraApp.kt` around lines 326 - 342, Remove
the predictiveBackVisualActive conditional and
calculatePredictiveDocumentBackFrame call from HomeScreen’s graphicsLayer; use
the constant PredictiveDocumentBackTransform.Identity values for home scale and
alpha directly, preserving Home’s existing non-animated appearance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/src/main/java/de/unbow/mora/ui/MoraApp.kt`:
- Around line 326-342: Remove the predictiveBackVisualActive conditional and
calculatePredictiveDocumentBackFrame call from HomeScreen’s graphicsLayer; use
the constant PredictiveDocumentBackTransform.Identity values for home scale and
alpha directly, preserving Home’s existing non-animated appearance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7af92e93-ec4e-46d5-9519-5244837e5661

📥 Commits

Reviewing files that changed from the base of the PR and between 03fbe8c and 3057b5f.

📒 Files selected for processing (3)
  • app/src/main/java/de/unbow/mora/ui/MoraApp.kt
  • app/src/main/java/de/unbow/mora/ui/PredictiveDocumentBack.kt
  • app/src/test/java/de/unbow/mora/ui/PredictiveDocumentBackTest.kt

@bjcdeshu
bjcdeshu merged commit 9cdc6be into main Jul 25, 2026
2 checks passed
@bjcdeshu
bjcdeshu deleted the codex/fix-reader-scroll-back-motion branch July 25, 2026 02:15
bjcdeshu added a commit that referenced this pull request Jul 25, 2026
## Summary

- bump Mora to `versionName 0.3.1` / `versionCode 5`
- record the v0.3.0 tag and hidden Draft as a permanently blocked,
unpublished exact-asset candidate
- align the English and Chinese READMEs, roadmap, project status,
changelog, and release guide with the v0.3.1 stable path

## Why

Real-device testing of the exact v0.3.0 Draft found Reader touch
interception and an overly forceful predictive-Back transition. PR #12
fixes those regressions on `main`; a distributed replacement must use a
new version name and version code rather than moving or republishing the
failed tag.

## Validation

- `.\gradlew.bat --no-daemon --no-build-cache --rerun-tasks
testDebugUnitTest lintDebug assembleDebug`
- Debug APK badging: `de.unbow.mora`, `versionName 0.3.1`, `versionCode
5`, `minSdk 26`, `targetSdk 36`
- verified the live v0.3.0 annotated tag target, hidden Draft status,
and Draft APK SHA-256 before recording the blocked audit entry
- `git diff --check`

## Release boundary

This PR does not create a tag, build a signed candidate, alter the
v0.3.0 tag or Draft, or publish a Release. After merge and green `main`
CI, the protected signed v0.3.1 candidate still requires the complete
exact-asset real-device gate and explicit maintainer approval before
tagging.

Co-authored-by: bjcdeshu <186153588+bjcdeshu@users.noreply.github.com>
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