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

This commit is contained in:
Haoyu Zhang
2022-03-21 20:11:46 +00:00
committed by Android (Google) Code Review

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());