Loading core/java/android/text/Selection.java +1 −1 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ public class Selection { * Remove the selection or cursor, if any, from the text. */ public static final void removeSelection(Spannable text) { text.removeSpan(SELECTION_START); text.removeSpan(SELECTION_START, Spanned.SPAN_INTERMEDIATE); text.removeSpan(SELECTION_END); removeMemory(text); } Loading core/java/android/text/Spannable.java +13 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,19 @@ extends Spanned */ public void removeSpan(Object what); /** * Remove the specified object from the range of text to which it * was attached, if any. It is OK to remove an object that was never * attached in the first place. * * See {@link Spanned} for an explanation of what the flags mean. * * @hide */ default void removeSpan(Object what, int flags) { removeSpan(what); } /** * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass * it to provide something other than {@link SpannableString}. Loading core/java/android/text/SpannableStringBuilder.java +15 −4 Original line number Diff line number Diff line Loading @@ -312,7 +312,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable // The following condition indicates that the span would become empty (textIsRemoved || mSpanStarts[i] > start || mSpanEnds[i] < mGapStart)) { mIndexOfSpan.remove(mSpans[i]); removeSpan(i); removeSpan(i, 0 /* flags */); return true; } return resolveGap(mSpanStarts[i]) <= end && (i & 1) != 0 && Loading Loading @@ -472,7 +472,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable } // Note: caller is responsible for removing the mIndexOfSpan entry. private void removeSpan(int i) { private void removeSpan(int i, int flags) { Object object = mSpans[i]; int start = mSpanStarts[i]; Loading @@ -496,8 +496,10 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable // Invariants must be restored before sending span removed notifications. restoreInvariants(); if ((flags & Spanned.SPAN_INTERMEDIATE) == 0) { sendSpanRemoved(object, start, end); } } // Documentation from interface public SpannableStringBuilder replace(int start, int end, CharSequence tb) { Loading Loading @@ -782,10 +784,19 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable * Remove the specified markup object from the buffer. */ public void removeSpan(Object what) { removeSpan(what, 0 /* flags */); } /** * Remove the specified markup object from the buffer. * * @hide */ public void removeSpan(Object what, int flags) { if (mIndexOfSpan == null) return; Integer i = mIndexOfSpan.remove(what); if (i != null) { removeSpan(i.intValue()); removeSpan(i.intValue(), flags); } } Loading core/java/android/text/SpannableStringInternal.java +11 −2 Original line number Diff line number Diff line Loading @@ -249,6 +249,13 @@ import java.lang.reflect.Array; } /* package */ void removeSpan(Object what) { removeSpan(what, 0 /* flags */); } /** * @hide */ public void removeSpan(Object what, int flags) { int count = mSpanCount; Object[] spans = mSpans; int[] data = mSpanData; Loading @@ -266,7 +273,9 @@ import java.lang.reflect.Array; mSpanCount--; if ((flags & Spanned.SPAN_INTERMEDIATE) == 0) { sendSpanRemoved(what, ostart, oend); } return; } } Loading core/java/android/view/inputmethod/BaseInputConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -522,7 +522,7 @@ public class BaseInputConnection implements InputConnection { b = tmp; } if (a == b) return null; if (a == b || a < 0) return null; if ((flags&GET_TEXT_WITH_STYLES) != 0) { return content.subSequence(a, b); Loading Loading
core/java/android/text/Selection.java +1 −1 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ public class Selection { * Remove the selection or cursor, if any, from the text. */ public static final void removeSelection(Spannable text) { text.removeSpan(SELECTION_START); text.removeSpan(SELECTION_START, Spanned.SPAN_INTERMEDIATE); text.removeSpan(SELECTION_END); removeMemory(text); } Loading
core/java/android/text/Spannable.java +13 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,19 @@ extends Spanned */ public void removeSpan(Object what); /** * Remove the specified object from the range of text to which it * was attached, if any. It is OK to remove an object that was never * attached in the first place. * * See {@link Spanned} for an explanation of what the flags mean. * * @hide */ default void removeSpan(Object what, int flags) { removeSpan(what); } /** * Factory used by TextView to create new {@link Spannable Spannables}. You can subclass * it to provide something other than {@link SpannableString}. Loading
core/java/android/text/SpannableStringBuilder.java +15 −4 Original line number Diff line number Diff line Loading @@ -312,7 +312,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable // The following condition indicates that the span would become empty (textIsRemoved || mSpanStarts[i] > start || mSpanEnds[i] < mGapStart)) { mIndexOfSpan.remove(mSpans[i]); removeSpan(i); removeSpan(i, 0 /* flags */); return true; } return resolveGap(mSpanStarts[i]) <= end && (i & 1) != 0 && Loading Loading @@ -472,7 +472,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable } // Note: caller is responsible for removing the mIndexOfSpan entry. private void removeSpan(int i) { private void removeSpan(int i, int flags) { Object object = mSpans[i]; int start = mSpanStarts[i]; Loading @@ -496,8 +496,10 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable // Invariants must be restored before sending span removed notifications. restoreInvariants(); if ((flags & Spanned.SPAN_INTERMEDIATE) == 0) { sendSpanRemoved(object, start, end); } } // Documentation from interface public SpannableStringBuilder replace(int start, int end, CharSequence tb) { Loading Loading @@ -782,10 +784,19 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable * Remove the specified markup object from the buffer. */ public void removeSpan(Object what) { removeSpan(what, 0 /* flags */); } /** * Remove the specified markup object from the buffer. * * @hide */ public void removeSpan(Object what, int flags) { if (mIndexOfSpan == null) return; Integer i = mIndexOfSpan.remove(what); if (i != null) { removeSpan(i.intValue()); removeSpan(i.intValue(), flags); } } Loading
core/java/android/text/SpannableStringInternal.java +11 −2 Original line number Diff line number Diff line Loading @@ -249,6 +249,13 @@ import java.lang.reflect.Array; } /* package */ void removeSpan(Object what) { removeSpan(what, 0 /* flags */); } /** * @hide */ public void removeSpan(Object what, int flags) { int count = mSpanCount; Object[] spans = mSpans; int[] data = mSpanData; Loading @@ -266,7 +273,9 @@ import java.lang.reflect.Array; mSpanCount--; if ((flags & Spanned.SPAN_INTERMEDIATE) == 0) { sendSpanRemoved(what, ostart, oend); } return; } } Loading
core/java/android/view/inputmethod/BaseInputConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -522,7 +522,7 @@ public class BaseInputConnection implements InputConnection { b = tmp; } if (a == b) return null; if (a == b || a < 0) return null; if ((flags&GET_TEXT_WITH_STYLES) != 0) { return content.subSequence(a, b); Loading