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

Commit 5073b912 authored by Siyamed Sinir's avatar Siyamed Sinir Committed by Android (Google) Code Review
Browse files

Merge "Don't copy NoCopySpans for assist and autofill" into oc-dev

parents f345a436 a8fce3b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1559,14 +1559,14 @@ public class AssistStructure implements Parcelable {
        @Override
        public void setText(CharSequence text) {
            ViewNodeText t = getNodeText();
            t.mText = text;
            t.mText = TextUtils.trimNoCopySpans(text);
            t.mTextSelectionStart = t.mTextSelectionEnd = -1;
        }

        @Override
        public void setText(CharSequence text, int selectionStart, int selectionEnd) {
            ViewNodeText t = getNodeText();
            t.mText = text;
            t.mText = TextUtils.trimNoCopySpans(text);
            t.mTextSelectionStart = selectionStart;
            t.mTextSelectionEnd = selectionEnd;
        }
+16 −0
Original line number Diff line number Diff line
@@ -1921,6 +1921,22 @@ public class TextUtils {
        return false;
    }

    /**
     * If the {@code charSequence} is instance of {@link Spanned}, creates a new copy and
     * {@link NoCopySpan}'s are removed from the copy. Otherwise the given {@code charSequence} is
     * returned as it is.
     *
     * @hide
     */
    @Nullable
    public static CharSequence trimNoCopySpans(@Nullable CharSequence charSequence) {
        if (charSequence != null && charSequence instanceof Spanned) {
            // SpannableStringBuilder copy constructor trims NoCopySpans.
            return new SpannableStringBuilder(charSequence);
        }
        return charSequence;
    }

    private static Object sLock = new Object();

    private static char[] sTemp = null;
+3 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.View;

import com.android.internal.util.Preconditions;
@@ -257,7 +258,8 @@ public final class AutofillValue implements Parcelable {
     * <p>See {@link View#AUTOFILL_TYPE_TEXT} for more info.
     */
    public static AutofillValue forText(@Nullable CharSequence value) {
        return value == null ? null : new AutofillValue(AUTOFILL_TYPE_TEXT, value);
        return value == null ? null : new AutofillValue(AUTOFILL_TYPE_TEXT,
                TextUtils.trimNoCopySpans(value));
    }

    /**