summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2015-08-26 20:21:29 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-26 20:21:29 +0000
commit963cac18adefa1e60a827183b95b4e61a23929d3 (patch)
tree2d2bb6d6927e37bd8b1e4afd5166a5bb098f3e74
parent76111ecbbde11e0cdddbb76530cf865f8846603e (diff)
parent147c0506d5425633f0d45e1489262d4e27a35921 (diff)
downloadframeworks_base-963cac18adefa1e60a827183b95b4e61a23929d3.zip
frameworks_base-963cac18adefa1e60a827183b95b4e61a23929d3.tar.gz
frameworks_base-963cac18adefa1e60a827183b95b4e61a23929d3.tar.bz2
am 147c0506: am 55a36337: LayoutLib: Fix Status/Navigation Bar color. [DO NOT MERGE]
* commit '147c0506d5425633f0d45e1489262d4e27a35921': LayoutLib: Fix Status/Navigation Bar color. [DO NOT MERGE]
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
index 145a03a..b76ec17 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -16,6 +16,7 @@
package com.android.layoutlib.bridge.bars;
+import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.StyleResourceValue;
@@ -258,8 +259,21 @@ abstract class CustomBar extends LinearLayout {
ResourceValue resource = renderResources.findItemInTheme(attr, true);
// Form @color/bar to the #AARRGGBB
resource = renderResources.resolveResValue(resource);
- if (resource != null && ResourceType.COLOR.equals(resource.getResourceType())) {
- return ResourceHelper.getColor(resource.getValue());
+ if (resource != null) {
+ ResourceType type = resource.getResourceType();
+ if (type == null || type == ResourceType.COLOR) {
+ // if no type is specified, the value may have been specified directly in the style
+ // file, rather than referencing a color resource value.
+ try {
+ return ResourceHelper.getColor(resource.getValue());
+ } catch (NumberFormatException e) {
+ // Conversion failed.
+ Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT,
+ "Theme attribute @android:" + attr +
+ " does not reference a color, instead is '" +
+ resource.getValue() + "'.", resource);
+ }
+ }
}
return 0;
}