Merge "Make SuggestionRangeSpan public"
This commit is contained in:
@@ -45826,6 +45826,17 @@ package android.text.style {
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
}
|
||||
|
||||
public final class SuggestionRangeSpan extends android.text.style.CharacterStyle implements android.text.ParcelableSpan {
|
||||
ctor public SuggestionRangeSpan();
|
||||
method public int describeContents();
|
||||
method public int getBackgroundColor();
|
||||
method public int getSpanTypeId();
|
||||
method public void setBackgroundColor(int);
|
||||
method public void updateDrawState(@NonNull android.text.TextPaint);
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.text.style.SuggestionRangeSpan> CREATOR;
|
||||
}
|
||||
|
||||
public class SuggestionSpan extends android.text.style.CharacterStyle implements android.text.ParcelableSpan {
|
||||
ctor public SuggestionSpan(android.content.Context, String[], int);
|
||||
ctor public SuggestionSpan(java.util.Locale, String[], int);
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package android.text.style;
|
||||
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.ParcelableSpan;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
@@ -25,30 +26,40 @@ import android.text.TextUtils;
|
||||
/**
|
||||
* A SuggestionRangeSpan is used to show which part of an EditText is affected by a suggestion
|
||||
* popup window.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpan {
|
||||
public final class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpan {
|
||||
private int mBackgroundColor;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public SuggestionRangeSpan() {
|
||||
// 0 is a fully transparent black. Has to be set using #setBackgroundColor
|
||||
mBackgroundColor = 0;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public SuggestionRangeSpan(Parcel src) {
|
||||
/** @hide */
|
||||
public SuggestionRangeSpan(@NonNull Parcel src) {
|
||||
mBackgroundColor = src.readInt();
|
||||
}
|
||||
|
||||
public static final @NonNull Parcelable.Creator<SuggestionRangeSpan>
|
||||
CREATOR = new Parcelable.Creator<SuggestionRangeSpan>() {
|
||||
@Override
|
||||
public SuggestionRangeSpan createFromParcel(Parcel source) {
|
||||
return new SuggestionRangeSpan(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionRangeSpan[] newArray(int size) {
|
||||
return new SuggestionRangeSpan[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
writeToParcelInternal(dest, flags);
|
||||
}
|
||||
|
||||
@@ -67,13 +78,16 @@ public class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpa
|
||||
return TextUtils.SUGGESTION_RANGE_SPAN;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
mBackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
public void updateDrawState(@NonNull TextPaint tp) {
|
||||
tp.bgColor = mBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ import android.text.SpanWatcher;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.SpannedString;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.KeyListener;
|
||||
@@ -4120,8 +4121,15 @@ public class Editor {
|
||||
mSuggestionRangeSpan.setBackgroundColor(
|
||||
(underlineColor & 0x00FFFFFF) + (newAlpha << 24));
|
||||
}
|
||||
boolean sendAccessibilityEvent = mTextView.isVisibleToAccessibility();
|
||||
CharSequence beforeText = sendAccessibilityEvent
|
||||
? new SpannedString(spannable, true) : null;
|
||||
spannable.setSpan(mSuggestionRangeSpan, spanUnionStart, spanUnionEnd,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
if (sendAccessibilityEvent) {
|
||||
mTextView.sendAccessibilityEventTypeViewTextChanged(
|
||||
beforeText, spanUnionStart, spanUnionEnd);
|
||||
}
|
||||
|
||||
mSuggestionsAdapter.notifyDataSetChanged();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user