diff options
| author | Seigo Nonaka <nona@google.com> | 2018-03-19 19:02:39 -0700 |
|---|---|---|
| committer | Seigo Nonaka <nona@google.com> | 2018-03-20 14:33:35 -0700 |
| commit | 3483bc7d648ad96916eb68203103dc9668dd0be7 (patch) | |
| tree | 1b38610a72d6a6e905fa030b4551d6abdb411fda /core/java/android/text/SpannedString.java | |
| parent | 1817c1329fcb7b4601da5e7bca9e914a69defa42 (diff) | |
Introduce new constructor for not copying NoCopySpan
To hold the original text in PrecomputedText, need to create
SpannableString, but copying NoCopySpan causes some side effect.
This CL introduces a way of copying SpannableString/SpannedString
with all spans other than NoCopySpan.
Bug: 72998298
Bug: 35638900
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I20dea2114ccaa54b16ff679c97682a5003f9a4c1
Diffstat (limited to 'core/java/android/text/SpannedString.java')
| -rw-r--r-- | core/java/android/text/SpannedString.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/java/android/text/SpannedString.java b/core/java/android/text/SpannedString.java index afed221f4152..acee3c5f1a41 100644 --- a/core/java/android/text/SpannedString.java +++ b/core/java/android/text/SpannedString.java @@ -26,12 +26,27 @@ public final class SpannedString extends SpannableStringInternal implements CharSequence, GetChars, Spanned { + /** + * @param source source object to copy from + * @param ignoreNoCopySpan whether to copy NoCopySpans in the {@code source} + * @hide + */ + public SpannedString(CharSequence source, boolean ignoreNoCopySpan) { + super(source, 0, source.length(), ignoreNoCopySpan); + } + + /** + * For the backward compatibility reasons, this constructor copies all spans including {@link + * android.text.NoCopySpan}. + * @param source source text + */ public SpannedString(CharSequence source) { - super(source, 0, source.length()); + this(source, false /* ignoreNoCopySpan */); // preserve existing NoCopySpan behavior } private SpannedString(CharSequence source, int start, int end) { - super(source, start, end); + // preserve existing NoCopySpan behavior + super(source, start, end, false /* ignoreNoCopySpan */); } public CharSequence subSequence(int start, int end) { |
