Merge "Scribe in View: disable cursor drag when handwriting is enabled" into tm-dev am: b3c1d1984e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17199134

Change-Id: Ia557d31b18b63bede3f322565b7aa265af9ebbc2
This commit is contained in:
Haoyu Zhang
2022-03-21 20:51:01 +00:00
committed by Automerger Merge Worker

View File

@@ -6309,7 +6309,8 @@ public class Editor {
}
switch (event.getActionMasked()) {
case MotionEvent.ACTION_MOVE:
if (event.isFromSource(InputDevice.SOURCE_MOUSE)) {
if (event.isFromSource(InputDevice.SOURCE_MOUSE)
|| (mTextView.isAutoHandwritingEnabled() && isFromStylus(event))) {
break;
}
if (mIsDraggingCursor) {
@@ -6332,6 +6333,11 @@ public class Editor {
}
}
private boolean isFromStylus(MotionEvent motionEvent) {
final int pointerIndex = motionEvent.getActionIndex();
return motionEvent.getToolType(pointerIndex) == MotionEvent.TOOL_TYPE_STYLUS;
}
private void positionCursorDuringDrag(MotionEvent event) {
mPrevLineDuringDrag = getLineDuringDrag(event);
int offset = mTextView.getOffsetAtCoordinate(mPrevLineDuringDrag, event.getX());