Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 133dfc00 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Fix: Selection created by long tap and drag can be empty.

Bug: 21302473
Change-Id: Ia81729a402957d25b40d203af3ce69c166f8dc91
parent c67f9bc2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -5403,10 +5403,12 @@ public class Editor {
                // Expanding with start handle.
                offset = getWordStart(offset);
                startOffset = getWordEnd(mStartOffset);
                if (startOffset == offset) {
                    offset = getNextCursorOffset(offset, false);
                }
            }
            mLineSelectionIsOn = currLine;
            Selection.setSelection((Spannable) mTextView.getText(),
                    startOffset, offset);
            Selection.setSelection((Spannable) mTextView.getText(), startOffset, offset);
        }

        private void updateParagraphBasedSelection(MotionEvent event) {
+15 −0
Original line number Diff line number Diff line
@@ -169,6 +169,21 @@ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextV
        onView(withId(R.id.textview)).check(hasSelection("little handsome"));
    }

    @SmallTest
    public void testLongPressAndDragToSelect_emoji() throws Exception {
        final String text = "\uD83D\uDE00\uD83D\uDE01\uD83D\uDE02\uD83D\uDE03";
        onView(withId(R.id.textview)).perform(click());
        onView(withId(R.id.textview)).perform(replaceText(text));

        onView(withId(R.id.textview)).perform(longPressAndDragOnText(4, 6));
        onView(withId(R.id.textview)).check(hasSelection("\uD83D\uDE02"));

        onView(withId(R.id.textview)).perform(click());

        onView(withId(R.id.textview)).perform(longPressAndDragOnText(4, 2));
        onView(withId(R.id.textview)).check(hasSelection("\uD83D\uDE01"));
    }

    @SmallTest
    public void testDragAndDrop() throws Exception {
        final String text = "abc def ghi.";