Loading core/java/android/widget/EditorTouchState.java +3 −6 Original line number Diff line number Diff line Loading @@ -174,12 +174,9 @@ public class EditorTouchState { int touchSlop = config.getScaledTouchSlop(); mMovedEnoughForDrag = distanceSquared > touchSlop * touchSlop; if (mMovedEnoughForDrag) { // If the direction of the swipe motion is within 30 degrees of vertical, it is // considered a vertical drag. We don't actually have to compute the angle to // implement the check though. When the angle is exactly 30 degrees from // vertical, 2*deltaX = distance. When the angle is less than 30 degrees from // vertical, 2*deltaX < distance. mIsDragCloseToVertical = (4 * deltaXSquared) <= distanceSquared; // If the direction of the swipe motion is within 45 degrees of vertical, it is // considered a vertical drag. mIsDragCloseToVertical = Math.abs(deltaX) <= Math.abs(deltaY); } } } else if (action == MotionEvent.ACTION_CANCEL) { Loading core/tests/coretests/src/android/widget/EditorCursorDragTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public class EditorCursorDragTest { // Swipe along a diagonal path. This should drag the cursor. Because we snap the finger to // the handle as the touch moves downwards (and because we have some slop to avoid jumping // across lines), the cursor position will end up higher than the finger position. onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("3"))); onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("2"))); onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("1"))); // Swipe right-down along a very steep diagonal path. This should not drag the cursor. Loading Loading @@ -181,7 +181,7 @@ public class EditorCursorDragTest { // Swipe along a diagonal path. This should drag the cursor. Because we snap the finger to // the handle as the touch moves downwards (and because we have some slop to avoid jumping // across lines), the cursor position will end up higher than the finger position. onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("3"))); onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("2"))); onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("1"))); // Swipe right-down along a very steep diagonal path. This should not drag the cursor. Loading core/tests/coretests/src/android/widget/EditorTouchStateTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -326,9 +326,9 @@ public class EditorTouchStateTest { mTouchState.update(event1, mConfig); assertSingleTap(mTouchState, 0f, 0f, 0, 0); // Simulate an ACTION_MOVE event that is > 30 deg from vertical. // Simulate an ACTION_MOVE event that is > 45 deg from vertical. long event2Time = 1002; MotionEvent event2 = moveEvent(event1Time, event2Time, 100f, 173f); MotionEvent event2 = moveEvent(event1Time, event2Time, 100f, 90f); mTouchState.update(event2, mConfig); assertDrag(mTouchState, 0f, 0f, 0, 0, false); Loading Loading
core/java/android/widget/EditorTouchState.java +3 −6 Original line number Diff line number Diff line Loading @@ -174,12 +174,9 @@ public class EditorTouchState { int touchSlop = config.getScaledTouchSlop(); mMovedEnoughForDrag = distanceSquared > touchSlop * touchSlop; if (mMovedEnoughForDrag) { // If the direction of the swipe motion is within 30 degrees of vertical, it is // considered a vertical drag. We don't actually have to compute the angle to // implement the check though. When the angle is exactly 30 degrees from // vertical, 2*deltaX = distance. When the angle is less than 30 degrees from // vertical, 2*deltaX < distance. mIsDragCloseToVertical = (4 * deltaXSquared) <= distanceSquared; // If the direction of the swipe motion is within 45 degrees of vertical, it is // considered a vertical drag. mIsDragCloseToVertical = Math.abs(deltaX) <= Math.abs(deltaY); } } } else if (action == MotionEvent.ACTION_CANCEL) { Loading
core/tests/coretests/src/android/widget/EditorCursorDragTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public class EditorCursorDragTest { // Swipe along a diagonal path. This should drag the cursor. Because we snap the finger to // the handle as the touch moves downwards (and because we have some slop to avoid jumping // across lines), the cursor position will end up higher than the finger position. onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("3"))); onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("2"))); onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("1"))); // Swipe right-down along a very steep diagonal path. This should not drag the cursor. Loading Loading @@ -181,7 +181,7 @@ public class EditorCursorDragTest { // Swipe along a diagonal path. This should drag the cursor. Because we snap the finger to // the handle as the touch moves downwards (and because we have some slop to avoid jumping // across lines), the cursor position will end up higher than the finger position. onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("3"))); onView(withId(R.id.textview)).perform(dragOnText(text.indexOf("line1"), text.indexOf("2"))); onView(withId(R.id.textview)).check(hasInsertionPointerAtIndex(text.indexOf("1"))); // Swipe right-down along a very steep diagonal path. This should not drag the cursor. Loading
core/tests/coretests/src/android/widget/EditorTouchStateTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -326,9 +326,9 @@ public class EditorTouchStateTest { mTouchState.update(event1, mConfig); assertSingleTap(mTouchState, 0f, 0f, 0, 0); // Simulate an ACTION_MOVE event that is > 30 deg from vertical. // Simulate an ACTION_MOVE event that is > 45 deg from vertical. long event2Time = 1002; MotionEvent event2 = moveEvent(event1Time, event2Time, 100f, 173f); MotionEvent event2 = moveEvent(event1Time, event2Time, 100f, 90f); mTouchState.update(event2, mConfig); assertDrag(mTouchState, 0f, 0f, 0, 0, false); Loading