Loading core/java/android/text/flags/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -96,3 +96,10 @@ flag { description: "A feature flag for fixing the crash while delete text in insert mode." bug: "314254153" } flag { name: "insert_mode_not_update_selection" namespace: "text" description: "Fix that InputService#onUpdateSelection is not called when insert mode gesture is performed." bug: "300850862" } core/java/android/widget/TextView.java +33 −2 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FastMath; import com.android.internal.util.Preconditions; import com.android.text.flags.Flags; import libcore.util.EmptyArray; Loading Loading @@ -539,7 +540,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // System wide time for last cut, copy or text changed action. static long sLastCutCopyOrTextChangedTime; private ColorStateList mTextColor; private ColorStateList mHintTextColor; private ColorStateList mLinkTextColor; Loading Loading @@ -2857,8 +2857,39 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } if (updateText) { if (Flags.insertModeNotUpdateSelection()) { // Update the transformation text. if (mTransformation == null) { mTransformed = mText; } else { mTransformed = mTransformation.getTransformation(mText, this); } if (mTransformed == null) { // Should not happen if the transformation method follows the non-null // postcondition. mTransformed = ""; } final boolean isOffsetMapping = mTransformed instanceof OffsetMapping; // If the mText is a Spannable and the new TransformationMethod needs to listen to // its updates, apply the watcher on it. if (mTransformation != null && mText instanceof Spannable && (!mAllowTransformationLengthChange || isOffsetMapping)) { Spannable sp = (Spannable) mText; final int priority = isOffsetMapping ? OFFSET_MAPPING_SPAN_PRIORITY : 0; sp.setSpan(mTransformation, 0, mText.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE | (priority << Spanned.SPAN_PRIORITY_SHIFT)); } if (mLayout != null) { nullLayouts(); requestLayout(); invalidate(); } } else { setText(mText); } } if (hasPasswordTransformationMethod()) { notifyViewAccessibilityStateChangedIfNeeded( Loading Loading
core/java/android/text/flags/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -96,3 +96,10 @@ flag { description: "A feature flag for fixing the crash while delete text in insert mode." bug: "314254153" } flag { name: "insert_mode_not_update_selection" namespace: "text" description: "Fix that InputService#onUpdateSelection is not called when insert mode gesture is performed." bug: "300850862" }
core/java/android/widget/TextView.java +33 −2 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FastMath; import com.android.internal.util.Preconditions; import com.android.text.flags.Flags; import libcore.util.EmptyArray; Loading Loading @@ -539,7 +540,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // System wide time for last cut, copy or text changed action. static long sLastCutCopyOrTextChangedTime; private ColorStateList mTextColor; private ColorStateList mHintTextColor; private ColorStateList mLinkTextColor; Loading Loading @@ -2857,8 +2857,39 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } if (updateText) { if (Flags.insertModeNotUpdateSelection()) { // Update the transformation text. if (mTransformation == null) { mTransformed = mText; } else { mTransformed = mTransformation.getTransformation(mText, this); } if (mTransformed == null) { // Should not happen if the transformation method follows the non-null // postcondition. mTransformed = ""; } final boolean isOffsetMapping = mTransformed instanceof OffsetMapping; // If the mText is a Spannable and the new TransformationMethod needs to listen to // its updates, apply the watcher on it. if (mTransformation != null && mText instanceof Spannable && (!mAllowTransformationLengthChange || isOffsetMapping)) { Spannable sp = (Spannable) mText; final int priority = isOffsetMapping ? OFFSET_MAPPING_SPAN_PRIORITY : 0; sp.setSpan(mTransformation, 0, mText.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE | (priority << Spanned.SPAN_PRIORITY_SHIFT)); } if (mLayout != null) { nullLayouts(); requestLayout(); invalidate(); } } else { setText(mText); } } if (hasPasswordTransformationMethod()) { notifyViewAccessibilityStateChangedIfNeeded( Loading