Loading api/current.txt +13 −0 Original line number Diff line number Diff line Loading @@ -22494,6 +22494,17 @@ package android.text.style { method public abstract void chooseHeight(java.lang.CharSequence, int, int, int, int, android.graphics.Paint.FontMetricsInt, android.text.TextPaint); } public class LocaleSpan extends android.text.style.MetricAffectingSpan implements android.text.ParcelableSpan { ctor public LocaleSpan(java.util.Locale); ctor public LocaleSpan(android.os.Parcel); method public int describeContents(); method public java.util.Locale getLocale(); method public int getSpanTypeId(); method public void updateDrawState(android.text.TextPaint); method public void updateMeasureState(android.text.TextPaint); method public void writeToParcel(android.os.Parcel, int); } public class MaskFilterSpan extends android.text.style.CharacterStyle implements android.text.style.UpdateAppearance { ctor public MaskFilterSpan(android.graphics.MaskFilter); method public android.graphics.MaskFilter getMaskFilter(); Loading Loading @@ -29294,6 +29305,7 @@ package android.widget { method public static int getTextColor(android.content.Context, android.content.res.TypedArray, int); method public final android.content.res.ColorStateList getTextColors(); method public static android.content.res.ColorStateList getTextColors(android.content.Context, android.content.res.TypedArray); method public java.util.Locale getTextLocale(); method public float getTextScaleX(); method public float getTextSize(); method public int getTotalPaddingBottom(); Loading Loading @@ -29396,6 +29408,7 @@ package android.widget { method public void setTextIsSelectable(boolean); method public final void setTextKeepState(java.lang.CharSequence); method public final void setTextKeepState(java.lang.CharSequence, android.widget.TextView.BufferType); method public void setTextLocale(java.util.Locale); method public void setTextScaleX(float); method public void setTextSize(float); method public void setTextSize(int, float); core/java/android/text/TextUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.text.style.CharacterStyle; import android.text.style.EasyEditSpan; import android.text.style.ForegroundColorSpan; import android.text.style.LeadingMarginSpan; import android.text.style.LocaleSpan; import android.text.style.MetricAffectingSpan; import android.text.style.QuoteSpan; import android.text.style.RelativeSizeSpan; Loading Loading @@ -587,6 +588,8 @@ public class TextUtils { public static final int SUGGESTION_RANGE_SPAN = 21; /** @hide */ public static final int EASY_EDIT_SPAN = 22; /** @hide */ public static final int LOCALE_SPAN = 23; /** * Flatten a CharSequence and whatever styles can be copied across processes Loading Loading @@ -754,6 +757,10 @@ public class TextUtils { readSpan(p, sp, new EasyEditSpan()); break; case LOCALE_SPAN: readSpan(p, sp, new LocaleSpan(p)); break; default: throw new RuntimeException("bogus span encoding " + kind); } Loading core/java/android/text/style/LocaleSpan.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.text.style; import android.graphics.Paint; import android.os.Parcel; import android.text.ParcelableSpan; import android.text.TextPaint; import android.text.TextUtils; import java.util.Locale; /** * Changes the {@link Locale} of the text to which the span is attached. */ public class LocaleSpan extends MetricAffectingSpan implements ParcelableSpan { private final Locale mLocale; /** * Creates a LocaleSpan. * @param locale The {@link Locale} of the text to which the span is * attached. */ public LocaleSpan(Locale locale) { mLocale = locale; } public LocaleSpan(Parcel src) { mLocale = new Locale(src.readString(), src.readString(), src.readString()); } @Override public int getSpanTypeId() { return TextUtils.LOCALE_SPAN; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mLocale.getLanguage()); dest.writeString(mLocale.getCountry()); dest.writeString(mLocale.getVariant()); } /** * Returns the {@link Locale}. * * @return The {@link Locale} for this span. */ public Locale getLocale() { return mLocale; } @Override public void updateDrawState(TextPaint ds) { apply(ds, mLocale); } @Override public void updateMeasureState(TextPaint paint) { apply(paint, mLocale); } private static void apply(Paint paint, Locale locale) { paint.setTextLocale(locale); } } core/java/android/widget/TextView.java +21 −0 Original line number Diff line number Diff line Loading @@ -2202,6 +2202,27 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener appearance.recycle(); } /** * Get the default {@link Locale} of the text in this TextView. * @return the default {@link Locale} of the text in this TextView. */ public Locale getTextLocale() { return mTextPaint.getTextLocale(); } /** * Set the default {@link Locale} of the text in this TextView to the given value. This value * is used to choose appropriate typefaces for ambiguous characters. Typically used for CJK * locales to disambiguate Hanzi/Kanji/Hanja characters. * * @param locale the {@link Locale} for drawing text, must not be null. * * @see Paint#setTextLocale */ public void setTextLocale(Locale locale) { mTextPaint.setTextLocale(locale); } /** * @return the size (in pixels) of the default text size in this TextView. */ Loading Loading
api/current.txt +13 −0 Original line number Diff line number Diff line Loading @@ -22494,6 +22494,17 @@ package android.text.style { method public abstract void chooseHeight(java.lang.CharSequence, int, int, int, int, android.graphics.Paint.FontMetricsInt, android.text.TextPaint); } public class LocaleSpan extends android.text.style.MetricAffectingSpan implements android.text.ParcelableSpan { ctor public LocaleSpan(java.util.Locale); ctor public LocaleSpan(android.os.Parcel); method public int describeContents(); method public java.util.Locale getLocale(); method public int getSpanTypeId(); method public void updateDrawState(android.text.TextPaint); method public void updateMeasureState(android.text.TextPaint); method public void writeToParcel(android.os.Parcel, int); } public class MaskFilterSpan extends android.text.style.CharacterStyle implements android.text.style.UpdateAppearance { ctor public MaskFilterSpan(android.graphics.MaskFilter); method public android.graphics.MaskFilter getMaskFilter(); Loading Loading @@ -29294,6 +29305,7 @@ package android.widget { method public static int getTextColor(android.content.Context, android.content.res.TypedArray, int); method public final android.content.res.ColorStateList getTextColors(); method public static android.content.res.ColorStateList getTextColors(android.content.Context, android.content.res.TypedArray); method public java.util.Locale getTextLocale(); method public float getTextScaleX(); method public float getTextSize(); method public int getTotalPaddingBottom(); Loading Loading @@ -29396,6 +29408,7 @@ package android.widget { method public void setTextIsSelectable(boolean); method public final void setTextKeepState(java.lang.CharSequence); method public final void setTextKeepState(java.lang.CharSequence, android.widget.TextView.BufferType); method public void setTextLocale(java.util.Locale); method public void setTextScaleX(float); method public void setTextSize(float); method public void setTextSize(int, float);
core/java/android/text/TextUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.text.style.CharacterStyle; import android.text.style.EasyEditSpan; import android.text.style.ForegroundColorSpan; import android.text.style.LeadingMarginSpan; import android.text.style.LocaleSpan; import android.text.style.MetricAffectingSpan; import android.text.style.QuoteSpan; import android.text.style.RelativeSizeSpan; Loading Loading @@ -587,6 +588,8 @@ public class TextUtils { public static final int SUGGESTION_RANGE_SPAN = 21; /** @hide */ public static final int EASY_EDIT_SPAN = 22; /** @hide */ public static final int LOCALE_SPAN = 23; /** * Flatten a CharSequence and whatever styles can be copied across processes Loading Loading @@ -754,6 +757,10 @@ public class TextUtils { readSpan(p, sp, new EasyEditSpan()); break; case LOCALE_SPAN: readSpan(p, sp, new LocaleSpan(p)); break; default: throw new RuntimeException("bogus span encoding " + kind); } Loading
core/java/android/text/style/LocaleSpan.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.text.style; import android.graphics.Paint; import android.os.Parcel; import android.text.ParcelableSpan; import android.text.TextPaint; import android.text.TextUtils; import java.util.Locale; /** * Changes the {@link Locale} of the text to which the span is attached. */ public class LocaleSpan extends MetricAffectingSpan implements ParcelableSpan { private final Locale mLocale; /** * Creates a LocaleSpan. * @param locale The {@link Locale} of the text to which the span is * attached. */ public LocaleSpan(Locale locale) { mLocale = locale; } public LocaleSpan(Parcel src) { mLocale = new Locale(src.readString(), src.readString(), src.readString()); } @Override public int getSpanTypeId() { return TextUtils.LOCALE_SPAN; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mLocale.getLanguage()); dest.writeString(mLocale.getCountry()); dest.writeString(mLocale.getVariant()); } /** * Returns the {@link Locale}. * * @return The {@link Locale} for this span. */ public Locale getLocale() { return mLocale; } @Override public void updateDrawState(TextPaint ds) { apply(ds, mLocale); } @Override public void updateMeasureState(TextPaint paint) { apply(paint, mLocale); } private static void apply(Paint paint, Locale locale) { paint.setTextLocale(locale); } }
core/java/android/widget/TextView.java +21 −0 Original line number Diff line number Diff line Loading @@ -2202,6 +2202,27 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener appearance.recycle(); } /** * Get the default {@link Locale} of the text in this TextView. * @return the default {@link Locale} of the text in this TextView. */ public Locale getTextLocale() { return mTextPaint.getTextLocale(); } /** * Set the default {@link Locale} of the text in this TextView to the given value. This value * is used to choose appropriate typefaces for ambiguous characters. Typically used for CJK * locales to disambiguate Hanzi/Kanji/Hanja characters. * * @param locale the {@link Locale} for drawing text, must not be null. * * @see Paint#setTextLocale */ public void setTextLocale(Locale locale) { mTextPaint.setTextLocale(locale); } /** * @return the size (in pixels) of the default text size in this TextView. */ Loading