Skip to content

Add delay before resuming drawing in OnyxInputHandler#247

Open
Ethran wants to merge 5 commits intomainfrom
dev
Open

Add delay before resuming drawing in OnyxInputHandler#247
Ethran wants to merge 5 commits intomainfrom
dev

Conversation

@Ethran
Copy link
Copy Markdown
Owner

@Ethran Ethran commented Apr 18, 2026

  • Call DeviceCompat.delayBeforeResumingDrawing() before enabling raw drawing in OnyxInputHandler.

Ethran added 5 commits April 18, 2026 15:52
- Call `DeviceCompat.delayBeforeResumingDrawing()` before enabling raw drawing in `OnyxInputHandler`.
### Core Logic
- **einkHelper.kt**:
    - Updated `resetScreenFreeze` to perform the `isRawDrawingRenderEnabled` toggle within a `CoroutineScope` using `Dispatchers.Default`.
    - Integrated `DeviceCompat.delayBeforeResumingDrawing()` between the toggle states to ensure the Android UI settles before resuming raw drawing.
    - Enhanced logging in `DeviceCompat.delayBeforeResumingDrawing` for better traceability.
- **OnyxInputHandler.kt**:
    - Commented out the blocking `DeviceCompat.delayBeforeResumingDrawing()` call in the drawing state update, favoring the new asynchronous approach in the helper.
Fix ToolbarMenu.kt to close reliably on pen action.
Rename UpdateMenuOpenTo → ToggleEraserManu

### Core Logic & State
- **EditorViewModel**:
    - Renamed `UpdateMenuOpenTo` to `ToggleEraserManu` for clarity.
    - Updated `ToolbarAction` handlers to defer `updateDrawingState` calls to focus change events.
    - Modified `updateDrawingState` to include a device-specific delay before resuming drawing via `DeviceCompat`.
    - Removed `onFocusChanged` in favor of centralized handling in `CanvasObserverRegistry`.
- **CanvasObserverRegistry**: Now explicitly triggers `viewModel.updateDrawingState()` when the canvas gains focus.
- **MainActivity**: Added an `onResume` override to ensure full-screen mode is enabled and focus change events are emitted to the `CanvasEventBus`.

### UI & Components
- **Toolbar**: Updated eraser menu open change callback to use the renamed `ToggleEraserManu` action.
- **PenToolbarButton**: Commented out `onStrokeMenuOpenChange` logic and associated effects.
- **PageView**: Temporarily changed logical rect redraw color to `GREEN` for debugging.
- **ToolbarMenu**: Simplified `onDismissRequest` logic for the popup menu.
- **EditorView**: Cleaned up redundant focus change collectors.
…ns for preview/thumbnail storage.

### Editor & Canvas
- **Rendering Threading**: Changed coroutine dispatchers from `Dispatchers.Main.immediate` to `Dispatchers.Main` in `PageView` and `CanvasObserverRegistry` to prevent race conditions during UI updates and canvas refreshes.
- **Diagnostics**: Added detailed logging for canvas and bitmap memory addresses (`hashCode`) across `PageView`, `CanvasRefreshManager`, and `pageDrawing` to assist in tracking drawing state inconsistencies.
- **State Management**: Refactored `updateDrawingState` in `EditorViewModel` for clearer logging and better handling of canvas creation cycles.

### Storage & Persistence
- **Atomic Writes**: Updated `saveHQPagePreview` and `savePageThumbnail` to write to temporary files (`.tmp`) before renaming them to their final destination. This prevents corrupted or empty cache files if a write is interrupted.
- **Error Recovery**: Enhanced `decodeBitmapFromFile` to automatically delete invalid or zero-byte files that fail to decode, forcing a clean redraw in subsequent sessions.
- **Resource Management**: Improved bitmap recycling logic in thumbnail generation to prevent memory leaks during optimization.

### UI Components
- **SnackBar**: Added a manual dismiss button ("x") to the snackbar notification component.
- **Code Cleanup**: Removed redundant logging and added thread-safety warnings regarding dispatcher selection in `CanvasObserverRegistry`.
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