Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
package com.ichi2.anki.ui.windows.reviewer.whiteboard

import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.view.animation.DecelerateInterpolator
import android.widget.LinearLayout
import androidx.core.view.ViewCompat
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.LinearLayoutManager
import com.ichi2.anki.databinding.ViewWhiteboardToolbarBinding
Expand Down Expand Up @@ -66,6 +68,28 @@ class WhiteboardToolbar : LinearLayout {
var onBrushLongClick: ((index: Int) -> Unit)? = null
var onToolbarVisibilityChanged: ((isShown: Boolean) -> Unit)? = null

/**
* Disables gesture swipe of docked whiteboard toolbar on the side on layout change
* While this code does attempt to set exclusion rect when ToolbarAlignment.BOTTOM,
* no effect occurs as bottom screen gestures cannot be opted out of
* https://developer.android.com/develop/ui/views/touch-and-input/gestures/gesturenav#kotlin
*/
private val boundingBox: Rect = Rect()
private val exclusions = listOf(boundingBox)

override fun onLayout(
changed: Boolean,
left: Int,
top: Int,
right: Int,
bottom: Int,
) {
super.onLayout(changed, left, top, right, bottom)
if (!changed) return
boundingBox.set(left, top, right, bottom)
ViewCompat.setSystemGestureExclusionRects(this, exclusions)
}

/**
* Updates the internal layout based on the toolbar alignment.
* Switches the RecyclerView orientation and the main layout orientation.
Expand Down
Loading