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

Commit 5b92a451 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Bug 5254884: suggestions are no logner copied in the clipboard"

parents 67ed574c cf68fee0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -9192,19 +9192,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                return true;

            case ID_CUT:
                setPrimaryClip(ClipData.newPlainText(null, mTransformed.subSequence(min, max)));
                setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
                ((Editable) mText).delete(min, max);
                stopSelectionActionMode();
                return true;

            case ID_COPY:
                setPrimaryClip(ClipData.newPlainText(null, mTransformed.subSequence(min, max)));
                setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
                stopSelectionActionMode();
                return true;
        }
        return false;
    }

    private CharSequence getTransformedText(int start, int end) {
        return removeSuggestionSpans(mTransformed.subSequence(start, end));
    }

    /**
     * Prepare text so that there are not zero or two spaces at beginning and end of region defined
     * by [min, max] when replacing this region by paste.
@@ -9321,7 +9325,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                // Start a drag
                final int start = getSelectionStart();
                final int end = getSelectionEnd();
                CharSequence selectedText = mTransformed.subSequence(start, end);
                CharSequence selectedText = getTransformedText(start, end);
                ClipData data = ClipData.newPlainText(null, selectedText);
                DragLocalState localState = new DragLocalState(this, start, end);
                startDrag(data, getTextThumbnailBuilder(selectedText), localState, 0);