Skip to content

Commit

Permalink
Back gesture is recognized as drawing intent: https://app.asana.com/0…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuancoltech committed Nov 11, 2024
1 parent 1dc6f4b commit bcb614e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/dev/arkbuilders/arkmemo/ui/views/NotesCanvas.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.arkbuilders.arkmemo.ui.views

import android.content.Context
import android.content.res.Resources
import android.graphics.Canvas
import android.graphics.Path
import android.util.AttributeSet
Expand All @@ -18,6 +19,8 @@ class NotesCanvas(context: Context, attrs: AttributeSet) : View(context, attrs)
private lateinit var viewModel: GraphicNotesViewModel
private var path = Path()

private val screenWidth by lazy { Resources.getSystem().displayMetrics.widthPixels }

override fun onDraw(canvas: Canvas) {
val paths = viewModel.paths()
if (paths.isNotEmpty()) {
Expand All @@ -31,6 +34,14 @@ class NotesCanvas(context: Context, attrs: AttributeSet) : View(context, attrs)
val x = event.x
val y = event.y

val edgeThreshold = 50

// When touch point starts from either of the left or right side of the screen,
// that's probably a back gesture. Do not draw in this case
if (x < edgeThreshold || x > screenWidth - edgeThreshold) {
return false
}

var finishDrawing = false
when (event.action) {
MotionEvent.ACTION_DOWN -> {
Expand Down

0 comments on commit bcb614e

Please sign in to comment.