diff options
| author | Seigo Nonaka <nona@google.com> | 2017-03-09 15:11:41 -0800 |
|---|---|---|
| committer | Seigo Nonaka <nona@google.com> | 2017-03-15 14:05:37 -0700 |
| commit | 0763650a13dd1968f45e8e64950a32c6b508ce28 (patch) | |
| tree | 7fe700ab3e4a65ee666b3512b27f4a2f7d8e00f7 /core/java | |
| parent | aa0b3a8da1fd4d5c950b5886dabb8935cb34e964 (diff) | |
Notify caller if none of settings are effective.
Now setFontVariationSettings returns false if the given settings is not
effective.
Bug:35764323
Test: ran TextViewTest and PaintTest in cts
Change-Id: Ic31d9e47ec006c8e7bb2c907ff0ea2936bd71d01
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index d04f70febabb..b0c00f9503cb 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3802,23 +3802,28 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * @param fontVariationSettings font variation settings. You can pass null or empty string as * no variation settings. * + * @return true if the given settings is effective to at least one font file underlying this + * TextView. This function also returns true for empty settings string. Otherwise + * returns false. + * * @see #getFontVariationSettings() * @see Paint#getFontVariationSettings() Paint.getFontVariationSettings() */ - public void setFontVariationSettings(@Nullable String fontVariationSettings) { + public boolean setFontVariationSettings(@Nullable String fontVariationSettings) { final String existingSettings = mTextPaint.getFontVariationSettings(); if (fontVariationSettings == existingSettings || (fontVariationSettings != null && fontVariationSettings.equals(existingSettings))) { - return; + return true; } - mTextPaint.setFontVariationSettings(fontVariationSettings); + boolean effective = mTextPaint.setFontVariationSettings(fontVariationSettings); - if (mLayout != null) { + if (effective && mLayout != null) { nullLayouts(); requestLayout(); invalidate(); } + return effective; } /** |
