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

Commit 4b823b94 authored by Richard Ledley's avatar Richard Ledley
Browse files

Set selection bounds when we try to copy, so it will work with nonselectable text.

Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Bug: b/67629726
Change-Id: I685ae3527685665eb3b50aaea90a570ebec47fd7
parent 2647c5f2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10942,6 +10942,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                return true;

            case ID_COPY:
                // For link action mode in a non-selectable/non-focusable TextView,
                // make sure that we set the appropriate min/max.
                final int selStart = getSelectionStart();
                final int selEnd = getSelectionEnd();
                min = Math.max(0, Math.min(selStart, selEnd));
                max = Math.max(0, Math.max(selStart, selEnd));
                final ClipData copyData = ClipData.newPlainText(null, getTransformedText(min, max));
                if (setPrimaryClip(copyData)) {
                    stopTextActionMode();