From e64a5bd2fb54d84d6fd2119ef831df1eba4185ff Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Mon, 29 Dec 2014 12:05:49 -0800 Subject: [PATCH] Fix DatePicker rendering. 1. Return AccessibilityManager service from context. 2. Don't throw an exception if no style specifited in obtainStyledAttributes. Specifying no style is valid and it's supposed to use the default theme in that case. Bug: http://b.android.com/82712 and http://b.android.com/79218 Change-Id: Iba7097f36996e4d6f1e9db778dc73294f2854c79 --- .../bridge/android/BridgeContext.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index c41ebb9206285..8523f1a95dab5 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -73,6 +73,7 @@ import android.view.DisplayAdjustments; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.accessibility.AccessibilityManager; import android.view.textservice.TextServicesManager; import java.io.File; @@ -476,6 +477,10 @@ public final class BridgeContext extends Context { return mDisplayManager; } + if (ACCESSIBILITY_SERVICE.equals(service)) { + return AccessibilityManager.getInstance(this); + } + throw new UnsupportedOperationException("Unsupported Service: " + service); } @@ -491,19 +496,22 @@ public final class BridgeContext extends Context { @Override public final BridgeTypedArray obtainStyledAttributes(int resid, int[] attrs) throws Resources.NotFoundException { + StyleResourceValue style = null; // get the StyleResourceValue based on the resId; - StyleResourceValue style = getStyleByDynamicId(resid); + if (resid != 0) { + style = getStyleByDynamicId(resid); - if (style == null) { - // In some cases, style may not be a dynamic id, so we do a full search. - ResourceReference ref = resolveId(resid); - if (ref != null) { - style = mRenderResources.getStyle(ref.getName(), ref.isFramework()); + if (style == null) { + // In some cases, style may not be a dynamic id, so we do a full search. + ResourceReference ref = resolveId(resid); + if (ref != null) { + style = mRenderResources.getStyle(ref.getName(), ref.isFramework()); + } } - } - if (style == null) { - throw new Resources.NotFoundException(); + if (style == null) { + throw new Resources.NotFoundException(); + } } if (mTypedArrayCache == null) {