Conversation
…n. Now the event will first handled by DrawCanvas.kt, which passes down the touch gestures. Removed old workaround. --AI-- - **`DrawCanvas` now handles stylus events directly:** `onTouchEvent` is overridden in `DrawCanvas` to specifically capture and process `TOOL_TYPE_STYLUS` and `TOOL_TYPE_ERASER` motion events. All other touch events (like finger gestures) are passed down to the standard view handling. - **Gesture Receiver handles non-stylus input:** The `EditorGestureReceiver` is now responsible only for touch gestures, with the temporary stylus handling logic removed. - **Composables layering order corrected:** The `EditorGestureReceiver` is now placed before the `EditorSurface` in the composable tree. This ensures that it can intercept touch gestures without blocking stylus events from reaching the `DrawCanvas` underneath. - **Removed obsolete code:** The temporary `eraserTouchPoint` flow and related logic for handling stylus events within the `EditorGestureReceiver` have been removed.
There was a problem hiding this comment.
Pull request overview
Reorders Compose layers so DrawCanvas receives pointer events before EditorGestureReceiver, and removes the old stylus workaround path.
Changes:
- Reordered
EditorGestureReceiverandEditorSurfaceinEditorViewcomposition. - Moved stylus/eraser handling into
DrawCanvas.onTouchEvent()and removed the SharedFlow-based workaround. - Cleaned up a misleading comment in
OpenGLRenderer.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/java/com/ethran/notable/editor/ui/EditorSurface.kt | Removes the sizing Box wrapper around AndroidView (now only AndroidView remains). |
| app/src/main/java/com/ethran/notable/editor/ui/EditorGestureReceiver.kt | Removes stylus workaround and adds a runtime assertion about stylus events. |
| app/src/main/java/com/ethran/notable/editor/drawing/OpenGLRenderer.kt | Removes outdated comment about event delivery. |
| app/src/main/java/com/ethran/notable/editor/EditorView.kt | Reorders composables so DrawCanvas is layered above the gesture receiver. |
| app/src/main/java/com/ethran/notable/editor/DrawCanvas.kt | Adds onTouchEvent to capture stylus/eraser and deletes the old eraser SharedFlow collector. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/com/ethran/notable/editor/ui/EditorSurface.kt
Outdated
Show resolved
Hide resolved
| // We should not get any stylus events | ||
| require(down.type != PointerType.Stylus || | ||
| down.type == PointerType.Eraser) |
There was a problem hiding this comment.
require(...) will crash the app if a stylus event reaches this receiver (which can still happen under edge cases like event routing changes or OEM behaviors). Also, the condition is confusing and effectively reduces to down.type != PointerType.Stylus, since PointerType.Eraser already satisfies down.type != PointerType.Stylus. Prefer handling this gracefully (e.g., early-return/ignore stylus+eraser here, or log and skip), and use an explicit condition that matches the intended policy (ignore stylus and eraser vs. ignore only stylus).
Now the event will first handled by DrawCanvas.kt, which passes down the touch gestures. Removed old workaround.
PR will fix issue #171