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

Commit 92db5193 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Make sure text selection always starts

When text can indeed be selected, we should always initiate
a text selection on long press. When the WordIterator fails
(for instance if the text is entirely made of punctuation
characters, maybe also with foreign languages), we select
one character.

Change-Id: I842507f7cbaed9a924d3176ea8ed6586f3548366
parent fa78fe0d
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -8920,14 +8920,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            wordIterator.setCharSequence(mText, minOffset, maxOffset);

            selectionStart = wordIterator.getBeginning(minOffset);
            if (selectionStart == BreakIterator.DONE) return false;

            selectionEnd = wordIterator.getEnd(maxOffset);
            if (selectionEnd == BreakIterator.DONE) return false;

            if (selectionStart == selectionEnd) {
            if (selectionStart == BreakIterator.DONE || selectionEnd == BreakIterator.DONE ||
                    selectionStart == selectionEnd) {
                // Possible when the word iterator does not properly handle the text's language
                long range = getCharRange(selectionStart);
                long range = getCharRange(minOffset);
                selectionStart = extractRangeStartFromLong(range);
                selectionEnd = extractRangeEndFromLong(range);
            }