diff options
| author | 2017-04-30 06:50:36 +0000 | |
|---|---|---|
| committer | 2017-04-30 06:50:43 +0000 | |
| commit | 7f90a9fdb0e655a3c804442c045a0589df0ba80e (patch) | |
| tree | 87df1f8853d13ddcc6506b9a520c4c40b2bf8a96 | |
| parent | 4c60abc9ae3d0351b39e3d13f661e4033c883942 (diff) | |
| parent | b7df9d0d6bd490c5db0085bc37ceafb9fd5b5e42 (diff) | |
Merge "Restricted Context layout font loading in TextView" into oc-dev
| -rw-r--r-- | core/java/android/widget/TextView.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index eee70e047dfd..629216e32fa9 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -912,10 +912,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; case com.android.internal.R.styleable.TextAppearance_fontFamily: - try { - fontTypeface = appearance.getFont(attr); - } catch (UnsupportedOperationException | Resources.NotFoundException e) { - // Expected if it is not a font resource. + if (!context.isRestricted()) { + try { + fontTypeface = appearance.getFont(attr); + } catch (UnsupportedOperationException + | Resources.NotFoundException e) { + // Expected if it is not a font resource. + } } if (fontTypeface == null) { fontFamily = appearance.getString(attr); @@ -1229,11 +1232,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; case com.android.internal.R.styleable.TextView_fontFamily: - try { - fontTypeface = a.getFont(attr); - } catch (UnsupportedOperationException | Resources.NotFoundException e) { - // Expected if it is not a resource reference or if it is a reference to - // another resource type. + if (!context.isRestricted()) { + try { + fontTypeface = a.getFont(attr); + } catch (UnsupportedOperationException | Resources.NotFoundException e) { + // Expected if it is not a resource reference or if it is a reference to + // another resource type. + } } if (fontTypeface == null) { fontFamily = a.getString(attr); @@ -3380,10 +3385,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Typeface fontTypeface = null; String fontFamily = null; - try { - fontTypeface = ta.getFont(R.styleable.TextAppearance_fontFamily); - } catch (UnsupportedOperationException | Resources.NotFoundException e) { - // Expected if it is not a font resource. + if (!context.isRestricted()) { + try { + fontTypeface = ta.getFont(R.styleable.TextAppearance_fontFamily); + } catch (UnsupportedOperationException | Resources.NotFoundException e) { + // Expected if it is not a font resource. + } } if (fontTypeface == null) { fontFamily = ta.getString(R.styleable.TextAppearance_fontFamily); |