Skip to content

Conversation

@shubertm
Copy link
Member

@shubertm shubertm commented Sep 28, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Single taps now reliably leave a visible mark.
    • Strokes finalize correctly without extra actions.
    • Canvas updates consistently after touch events, reducing missed or laggy drawings.
  • Refactor
    • Drawing now begins immediately on touch-down and updates continuously, improving responsiveness and producing smoother curves.

Before

Screen_Recording_20250928_114125_251002125459.mp4

After

Screen_Recording_20250928_114453_251002125252.mp4

@coderabbitai
Copy link

coderabbitai bot commented Sep 28, 2025

Walkthrough

Touch handling in NotesCanvas was refactored: the finishDrawing flag and related branching were removed. A DrawPath is created and dispatched to the ViewModel on ACTION_DOWN; MOVE emits quadTo updates; UP/CANCEL may append a final lineTo, then reset the path. invalidate() is always called.

Changes

Cohort / File(s) Summary
Touch handling refactor
app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt
Removed finishDrawing state and conditional pathway; create and send DrawPath on ACTION_DOWN; continue quadTo updates on ACTION_MOVE; on ACTION_UP/ACTION_CANCEL optionally add final AbsLineTo then path.reset(); always call invalidate() after events; minor restructuring of draw timing.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Canvas as NotesCanvas
  participant VM as ViewModel

  User->>Canvas: Touch ACTION_DOWN (x,y)
  activate Canvas
  Canvas->>Canvas: create DrawPath(path, paint)
  Canvas->>VM: onDrawPath(DrawPath)
  Canvas->>Canvas: invalidate()
  deactivate Canvas

  User->>Canvas: Touch ACTION_MOVE (x,y)
  activate Canvas
  Canvas->>Canvas: path.quadTo(prev, mid)
  Canvas->>Canvas: emit AbsQuadTo command, update currentX/Y
  Canvas->>Canvas: invalidate()
  deactivate Canvas

  alt ACTION_UP or ACTION_CANCEL
    User->>Canvas: Touch end (x,y)
    activate Canvas
    opt if end == last point
      Canvas->>Canvas: append AbsLineTo(x,y)
    end
    Canvas->>Canvas: path.reset()
    Canvas->>Canvas: invalidate()
    deactivate Canvas
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I sketched a path with nimble paws,
No finish flag now, just simple laws—
Down I start, then curve and glide,
Move by move, the strokes abide.
Up I hop, the line set free—🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly identifies the two main changes—addressing drawing lag and supporting dot rendering on the canvas—and is concise, specific, and accurately represents the modifications summarized in the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch draw-lags

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 797085f and 2811af7.

📒 Files selected for processing (1)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt (2 hunks)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2811af7 and 36c661d.

📒 Files selected for processing (1)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt (1)
app/src/main/java/dev/arkbuilders/arkmemo/graphics/SVG.kt (1)
  • addCommand (34-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Comment on lines +79 to +88
if (x == currentX && y == currentY) {
path.lineTo(x, y)
viewModel.svg().apply {
addCommand(
SVGCommand.AbsLineTo(x, y).apply {
paintColor = viewModel.paint.color.getStrokeColor()
brushSizeId = viewModel.paint.strokeWidth.getBrushSizeId()
},
)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Dot detection needs touch-jitter tolerance.

ACTION_UP coordinates often drift by a few pixels even on a stationary tap, so this strict equality rarely fires. When it doesn’t, we skip the lineTo/SVG command and the dot still vanishes after reload—undercutting the PR goal. Please gate this branch with a small tolerance (e.g., a few px or scaledTouchSlop) instead of raw equality.

-                if (x == currentX && y == currentY) {
+                if (
+                    kotlin.math.abs(x - currentX) <= DOT_TOLERANCE_PX &&
+                    kotlin.math.abs(y - currentY) <= DOT_TOLERANCE_PX
+                ) {

Add an appropriate constant (tuned for density/touch slop) near the class definition, for example:

private companion object {
    private const val DOT_TOLERANCE_PX = 4f
}
🤖 Prompt for AI Agents
In app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt around
lines 79-88, the current dot-detection uses strict x == currentX && y ==
currentY which fails due to touch jitter; add a small tolerance constant near
the class definition (e.g., in a private companion object, either a fixed
DOT_TOLERANCE_PX or obtain ViewConfiguration.get(context).scaledTouchSlop
converted to pixels) and replace the equality check with a distance/tolerance
check (e.g., if (abs(x - currentX) <= DOT_TOLERANCE_PX && abs(y - currentY) <=
DOT_TOLERANCE_PX) or squared-distance comparison) so the touch-up branch fires
for near-identical coordinates and the SVG dot command is preserved.

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.

2 participants