diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt index 7d713ca27e..347d80587b 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt @@ -7,6 +7,7 @@ import android.text.Editable import android.view.LayoutInflater import android.view.MotionEvent import android.view.View +import android.view.ViewConfiguration import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import androidx.lifecycle.Lifecycle @@ -910,7 +911,9 @@ class BlockAdapter( if (holder !is SupportCustomTouchProcessor) { when (holder) { is RelationBlockViewHolder -> { + val touchSlop = ViewConfiguration.get(holder.itemView.context).scaledTouchSlop val processor = EditorTouchProcessor( + touchSlop = touchSlop, fallback = { holder.itemView.onTouchEvent(it) }, onLongClick = { val pos = holder.bindingAdapterPosition diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/EditorTouchProcessor.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/EditorTouchProcessor.kt index 4a41ed8e6f..0fca2900b9 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/EditorTouchProcessor.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/EditorTouchProcessor.kt @@ -9,140 +9,128 @@ import android.text.style.ClickableSpan import android.view.HapticFeedbackConstants import android.view.MotionEvent import android.view.View -import android.view.ViewConfiguration import com.anytypeio.anytype.core_ui.extensions.disable import com.anytypeio.anytype.core_ui.widgets.text.TextInputWidget import timber.log.Timber import kotlin.math.abs /** - * @property [fallback] fallback method for processing touch event. - * @property [onLongClick] long click event (replacement for [View.OnLongClickListener]) - * @property [onDragAndDropTrigger] drag-and-drop triggering event + * Handles touch gestures for editor interactions. + * + * @property touchSlop threshold for detecting drag motion. + * @property fallback fallback method for processing touch event. + * @property onLongClick long click event (replacement for [View.OnLongClickListener]) + * @property onDragAndDropTrigger drag-and-drop triggering event */ class EditorTouchProcessor( + private val touchSlop: Int, val fallback: (event: MotionEvent?) -> Boolean, var onLongClick: () -> Unit = {}, var onDragAndDropTrigger: (event: MotionEvent?) -> Unit = { } ) { - val moves = mutableListOf() - + private val moves = mutableListOf() private val actionHandler = Handler(Looper.getMainLooper()) + private var actionUpStartInMillis: Long = 0 + private var lastEvent: MotionEvent? = null + private var isDragging: Boolean = false private val dragAndDropTimeoutRunnable = Runnable { - Timber.d("Runnable triggered") - if (moves.size > 1) { - val first = moves.first() - val last = moves.last() - val delta = abs(first - last) - if (delta == 0f) { - Timber.d("Runnable dispatched 1") - onDragAndDropTrigger(lastEvent) - } else { - Timber.d("Runnable ignored 1") - } - } else { - Timber.d("Runnable dispatched 2") + val delta = if (moves.size > 1) abs(moves.last() - moves.first()) else 0f + + if (!isDragging && delta <= touchSlop) { + Timber.d("Triggering drag due to long press without movement") onDragAndDropTrigger(lastEvent) + } else if (isDragging) { + Timber.d("Triggering drag due to long press with movement") + onDragAndDropTrigger(lastEvent) + } else { + Timber.d("Skipping drag trigger") } + moves.clear() } - private var actionUpStartInMillis: Long = 0 - - private var lastEvent: MotionEvent? = null - fun process(v: View, event: MotionEvent?): Boolean { - if (event != null) { - lastEvent = event - when (event.action) { - MotionEvent.ACTION_DOWN -> { - Timber.d("ACTION DOWN") - actionUpStartInMillis = SystemClock.elapsedRealtime() - actionHandler.postDelayed( - dragAndDropTimeoutRunnable, - DND_TIMEOUT - ) - moves.clear() - } - MotionEvent.ACTION_MOVE -> { - Timber.d("ACTION MOVE: $event") - moves.add(event.getY(0)) - if (moves.size > 1) { - val first = moves.first() - val last = moves.last() - Timber.d("ACTION MOVE DELTA: ${abs(last - first)}") - } - } - MotionEvent.ACTION_CANCEL -> { - if (moves.isEmpty() && event.elapsed() > DND_TIMEOUT) { - v.emulateHapticFeedback() - } - Timber.d("ACTION CANCEL") - actionHandler.removeCallbacksAndMessages(null) - moves.clear() - } - MotionEvent.ACTION_UP -> { - moves.clear() - Timber.d("ACTION UP") - actionHandler.removeCallbacksAndMessages(null) + event ?: return fallback(null) + lastEvent = event - /** - * When clicking on mention text, the code contains two separate logics - * that handle clicks on this text: the EditorTouchProcessor, - * which is responsible for triggering drag-and-drop or long-click mode, - * and the ClickableSpan, which is applied to the mention text. - * Since it is impossible to predict which listener will execute first, - * the click on the mention is handled in two different places. - * @see fun Editable.setClickableSpan(click: ((String) -> Unit)?, mark: Markup.Mark.Mention) - */ - if (v is TextInputWidget) { - val x = (event.x - v.totalPaddingLeft + v.scrollX).toInt() - val y = (event.y - v.totalPaddingTop + v.scrollY).toInt() + when (event.action) { + MotionEvent.ACTION_DOWN -> { + Timber.d("ACTION DOWN") + actionUpStartInMillis = SystemClock.elapsedRealtime() + isDragging = false + moves.clear() + actionHandler.postDelayed(dragAndDropTimeoutRunnable, DND_TIMEOUT) + } - val layout: Layout = v.layout - val line = layout.getLineForVertical(y) - val offset = layout.getOffsetForHorizontal(line, x.toFloat()) - - val link = - v.editableText.getSpans(offset, offset, ClickableSpan::class.java) - if (link.isNotEmpty()) { - v.disable() - link[0].onClick(v) - return true - } + MotionEvent.ACTION_MOVE -> { + Timber.d("ACTION MOVE: $event") + val y = event.getY(0) + moves.add(y) + if (moves.size > 1) { + val delta = abs(moves.last() - moves.first()) + Timber.d("ACTION MOVE DELTA: $delta") + if (delta > touchSlop) { + isDragging = true } - - return when (actionUpStartInMillis.untilNow()) { - in LONG_PRESS_TIMEOUT..DND_TIMEOUT -> { - onLongClick() - v.performLongClickWithHaptic() - true - } - else -> { - return fallback(event) - } - } - } - else -> { - Timber.d("Ignored motion event: $event") } } + + MotionEvent.ACTION_CANCEL -> { + Timber.d("ACTION CANCEL") + if (!isDragging && event.elapsed() > DND_TIMEOUT) { + v.emulateHapticFeedback() + } + actionHandler.removeCallbacksAndMessages(null) + moves.clear() + } + + MotionEvent.ACTION_UP -> { + Timber.d("ACTION UP") + actionHandler.removeCallbacksAndMessages(null) + moves.clear() + + if (v is TextInputWidget) { + val x = (event.x - v.totalPaddingLeft + v.scrollX).toInt() + val y = (event.y - v.totalPaddingTop + v.scrollY).toInt() + val layout: Layout = v.layout + val line = layout.getLineForVertical(y) + val offset = layout.getOffsetForHorizontal(line, x.toFloat()) + val link = v.editableText.getSpans(offset, offset, ClickableSpan::class.java) + if (link.isNotEmpty()) { + v.disable() + link[0].onClick(v) + return true + } + } + + return when { + !isDragging && actionUpStartInMillis.untilNow() >= LONG_PRESS_TIMEOUT -> { + onLongClick() + v.performLongClickWithHaptic() + true + } + else -> fallback(event) + } + } + + else -> { + Timber.d("Ignored motion event: $event") + } } + return fallback(event) } companion object { - val LONG_PRESS_TIMEOUT: Long = ViewConfiguration.getLongPressTimeout().toLong() + val LONG_PRESS_TIMEOUT: Long = android.view.ViewConfiguration.getLongPressTimeout().toLong() val DND_TIMEOUT: Long = 2 * LONG_PRESS_TIMEOUT } private fun View.emulateHapticFeedback() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (this !is TextInputWidget) { - performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && this !is TextInputWidget) { + performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) } } } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/dataview/DataViewBlockViewHolder.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/dataview/DataViewBlockViewHolder.kt index 3a1b503f13..aa36ae0bd5 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/dataview/DataViewBlockViewHolder.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/dataview/DataViewBlockViewHolder.kt @@ -3,6 +3,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.dataview import android.text.Spannable import android.text.SpannableString import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.TextView import androidx.cardview.widget.CardView @@ -204,6 +205,7 @@ sealed class DataViewBlockViewHolder( abstract override val decoratableCard: CardView override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/error/MediaError.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/error/MediaError.kt index 16e75acd29..9034de6d65 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/error/MediaError.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/error/MediaError.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.error import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import androidx.core.view.marginEnd import androidx.core.view.marginStart @@ -28,6 +29,7 @@ abstract class MediaError( abstract fun errorClick(item: BlockView.Error, clicked: (ListenerType) -> Unit) override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Bookmark.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Bookmark.kt index a5951d92f2..aaa5aa01f0 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Bookmark.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Bookmark.kt @@ -3,6 +3,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.media import android.graphics.drawable.Drawable import android.text.Spannable import android.view.View +import android.view.ViewConfiguration import android.widget.TextView import com.anytypeio.anytype.core_ui.common.SearchHighlightSpan import com.anytypeio.anytype.core_ui.common.SearchTargetHighlightSpan @@ -24,6 +25,7 @@ import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target +import kotlin.text.get import timber.log.Timber class Bookmark(val binding: ItemBlockBookmarkBinding) : Media(binding.root), DecoratableCardViewHolder { @@ -43,6 +45,7 @@ class Bookmark(val binding: ItemBlockBookmarkBinding) : Media(binding.root), Dec override val decoratableCard: View = binding.bookmarkRoot override val editorTouchProcessor: EditorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> clickContainer.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Media.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Media.kt index c7930873c8..2e82f39f2f 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Media.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/media/Media.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.media import android.annotation.SuppressLint import android.view.View +import android.view.ViewConfiguration import com.anytypeio.anytype.core_ui.extensions.setBlockBackgroundColor import com.anytypeio.anytype.core_ui.features.editor.BlockViewDiffUtil import com.anytypeio.anytype.core_ui.features.editor.BlockViewHolder @@ -25,6 +26,7 @@ abstract class Media(view: View) : BlockViewHolder(view), abstract fun select(isSelected: Boolean) override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> clickContainer.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt index c86706e669..3fb3f1f137 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt @@ -6,6 +6,7 @@ import android.os.Build.VERSION_CODES.N import android.os.Build.VERSION_CODES.N_MR1 import android.text.Editable import android.view.View +import android.view.ViewConfiguration import android.view.inputmethod.InputMethodManager import android.widget.FrameLayout import android.widget.TextView @@ -43,6 +44,7 @@ class Code( get() = binding.snippet val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Divider.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Divider.kt index 66979ed34e..acd3cb4d84 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Divider.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Divider.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding @@ -26,6 +27,7 @@ abstract class Divider(view: View) : BlockViewHolder(view), abstract val container: View override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObject.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObject.kt index ca9c8231cd..d028db9c38 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObject.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObject.kt @@ -3,6 +3,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other import android.text.Spannable import android.text.SpannableString import android.text.style.LeadingMarginSpan +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.TextView import androidx.core.view.updateLayoutParams @@ -42,6 +43,7 @@ class LinkToObject( private val objectType = binding.tvObjectType override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectArchive.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectArchive.kt index fce9b2f527..f2b5a8cdd7 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectArchive.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectArchive.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other import android.text.Spannable +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.TextView import androidx.core.view.updateLayoutParams @@ -38,6 +39,7 @@ class LinkToObjectArchive( val title = binding.pageTitle override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectCard.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectCard.kt index cd5349aef5..483e389ecb 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectCard.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectCard.kt @@ -3,6 +3,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other import android.text.Spannable import android.text.SpannableString import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView @@ -62,6 +63,7 @@ abstract class LinkToObjectCard( abstract override val decoratableCard: CardView override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectDelete.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectDelete.kt index 18d0f59c18..e7f485abb4 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectDelete.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/LinkToObjectDelete.kt @@ -1,5 +1,6 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other +import android.view.ViewConfiguration import android.widget.FrameLayout import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding @@ -32,6 +33,7 @@ class LinkToObjectDelete( get() = binding.decorationContainer override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/TableOfContents.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/TableOfContents.kt index 4adb8a86e9..72ea8a09df 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/TableOfContents.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/TableOfContents.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.other import android.view.MotionEvent import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.LinearLayout import androidx.core.view.ViewCompat.generateViewId @@ -36,6 +37,7 @@ class TableOfContents( private val defPadding = root.resources.getDimension(R.dimen.def_toc_item_padding_start).toInt() override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> root.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/placeholders/MediaPlaceholder.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/placeholders/MediaPlaceholder.kt index fab893e227..c8ecde850c 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/placeholders/MediaPlaceholder.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/placeholders/MediaPlaceholder.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.placeholders import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import android.widget.TextView import com.anytypeio.anytype.core_ui.databinding.ItemBlockMediaPlaceholderBinding @@ -39,6 +40,7 @@ abstract class MediaPlaceholder( abstract fun setup() override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/upload/MediaUpload.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/upload/MediaUpload.kt index 6f23d572da..fe468aa931 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/upload/MediaUpload.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/upload/MediaUpload.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.upload import android.view.View +import android.view.ViewConfiguration import android.widget.FrameLayout import com.anytypeio.anytype.core_ui.databinding.ItemBlockMediaPlaceholderBinding import com.anytypeio.anytype.core_ui.features.editor.BlockViewDiffUtil @@ -24,6 +25,7 @@ abstract class MediaUpload( abstract fun uploadClick(target: String, clicked: (ListenerType) -> Unit) override val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(itemView.context).scaledTouchSlop, fallback = { e -> itemView.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt index 0ff0fc906a..c36233f132 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt @@ -10,6 +10,7 @@ import android.text.TextWatcher import android.util.AttributeSet import android.view.DragEvent import android.view.MotionEvent +import android.view.ViewConfiguration import androidx.appcompat.widget.AppCompatEditText import com.anytypeio.anytype.core_ui.features.editor.EditorTouchProcessor import com.anytypeio.anytype.core_ui.tools.TextInputTextWatcher @@ -34,6 +35,7 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter { val editorTouchProcessor by lazy { EditorTouchProcessor( + touchSlop = ViewConfiguration.get(context).scaledTouchSlop, fallback = { e -> super.onTouchEvent(e) } ) } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TableOfContentsItemWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TableOfContentsItemWidget.kt index fdd2de660f..15a3535bd1 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TableOfContentsItemWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TableOfContentsItemWidget.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.Paint import android.util.AttributeSet import android.view.LayoutInflater +import android.view.ViewConfiguration import android.widget.FrameLayout import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.databinding.TvTableOfContentsBinding @@ -19,6 +20,7 @@ class TableOfContentsItemWidget @JvmOverloads constructor( val textView = binding.text val editorTouchProcessor = EditorTouchProcessor( + touchSlop = ViewConfiguration.get(context).scaledTouchSlop, fallback = { e -> this.onTouchEvent(e) } ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TextInputWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TextInputWidget.kt index 95f2845ef0..20f18a6ac6 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TextInputWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/TextInputWidget.kt @@ -13,6 +13,7 @@ import android.util.AttributeSet import android.view.DragEvent import android.view.KeyEvent import android.view.MotionEvent +import android.view.ViewConfiguration import androidx.appcompat.widget.AppCompatEditText import androidx.core.graphics.withTranslation import com.anytypeio.anytype.core_ui.R @@ -66,6 +67,7 @@ class TextInputWidget : AppCompatEditText { val editorTouchProcessor by lazy { EditorTouchProcessor( + touchSlop = ViewConfiguration.get(context).scaledTouchSlop, fallback = { e -> super.onTouchEvent(e) } ) }