Loading core/java/android/widget/Editor.java +1 −1 Original line number Diff line number Diff line Loading @@ -5737,7 +5737,7 @@ public class Editor { private boolean mIsDraggingCursor; public void onTouchEvent(MotionEvent event) { if (getSelectionController().isCursorBeingModified()) { if (hasSelectionController() && getSelectionController().isCursorBeingModified()) { return; } switch (event.getActionMasked()) { Loading core/tests/coretests/src/android/widget/EditorCursorDragTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class EditorCursorDragTest { mOriginalFlagValue = Editor.FLAG_ENABLE_CURSOR_DRAG; Editor.FLAG_ENABLE_CURSOR_DRAG = true; } @After public void after() throws Throwable { Editor.FLAG_ENABLE_CURSOR_DRAG = mOriginalFlagValue; Loading Loading @@ -356,6 +357,23 @@ public class EditorCursorDragTest { assertFalse(editor.getSelectionController().isCursorBeingModified()); } @Test // Reproduces b/147366705 public void testCursorDrag_nonSelectableTextView() throws Throwable { String text = "Hello world!"; TextView tv = mActivity.findViewById(R.id.nonselectable_textview); tv.setText(text); Editor editor = tv.getEditorForTesting(); // Simulate a tap. No error should be thrown. long event1Time = 1001; MotionEvent event1 = downEvent(event1Time, event1Time, 20f, 30f); mInstrumentation.runOnMainSync(() -> editor.onTouchEvent(event1)); // Swipe left to right. No error should be thrown. onView(withId(R.id.nonselectable_textview)).perform( dragOnText(text.indexOf("llo"), text.indexOf("!"))); } private static MotionEvent downEvent(long downTime, long eventTime, float x, float y) { return MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); } Loading Loading
core/java/android/widget/Editor.java +1 −1 Original line number Diff line number Diff line Loading @@ -5737,7 +5737,7 @@ public class Editor { private boolean mIsDraggingCursor; public void onTouchEvent(MotionEvent event) { if (getSelectionController().isCursorBeingModified()) { if (hasSelectionController() && getSelectionController().isCursorBeingModified()) { return; } switch (event.getActionMasked()) { Loading
core/tests/coretests/src/android/widget/EditorCursorDragTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class EditorCursorDragTest { mOriginalFlagValue = Editor.FLAG_ENABLE_CURSOR_DRAG; Editor.FLAG_ENABLE_CURSOR_DRAG = true; } @After public void after() throws Throwable { Editor.FLAG_ENABLE_CURSOR_DRAG = mOriginalFlagValue; Loading Loading @@ -356,6 +357,23 @@ public class EditorCursorDragTest { assertFalse(editor.getSelectionController().isCursorBeingModified()); } @Test // Reproduces b/147366705 public void testCursorDrag_nonSelectableTextView() throws Throwable { String text = "Hello world!"; TextView tv = mActivity.findViewById(R.id.nonselectable_textview); tv.setText(text); Editor editor = tv.getEditorForTesting(); // Simulate a tap. No error should be thrown. long event1Time = 1001; MotionEvent event1 = downEvent(event1Time, event1Time, 20f, 30f); mInstrumentation.runOnMainSync(() -> editor.onTouchEvent(event1)); // Swipe left to right. No error should be thrown. onView(withId(R.id.nonselectable_textview)).perform( dragOnText(text.indexOf("llo"), text.indexOf("!"))); } private static MotionEvent downEvent(long downTime, long eventTime, float x, float y) { return MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); } Loading