am b1f95c6a: (-s ours) am 331bb0c3: Setup ActionBars in layoutlib the same way the platform does it. do not merge.
* commit 'b1f95c6a938f6eaaa7a3fd28574a14647178059b':
Setup ActionBars in layoutlib the same way the platform does it. do not merge.
diff --git a/tools/layoutlib/bridge/resources/bars/action_bar.xml b/tools/layoutlib/bridge/resources/bars/action_bar.xml
index 7adc5af..51983f2 100644
--- a/tools/layoutlib/bridge/resources/bars/action_bar.xml
+++ b/tools/layoutlib/bridge/resources/bars/action_bar.xml
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <include layout="@android:layout/action_bar_home" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ <ImageView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
</merge>
diff --git a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
index 5df2a21..451edd2 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Matrix_Delegate.java
@@ -474,7 +474,7 @@
}
Matrix_Delegate other = sManager.getDelegate(other_matrix);
- if (other == null) {
+ if (d == null) {
return false;
}
@@ -570,7 +570,7 @@
}
Matrix_Delegate other = sManager.getDelegate(other_matrix);
- if (other == null) {
+ if (d == null) {
return false;
}
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 cd4fbfe..72ed351 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
@@ -145,14 +145,6 @@
}
}
- protected void loadIconById(int id, String iconReference) {
- ResourceValue value = getResourceValue(iconReference);
- if (value != null) {
- loadIconById(id, value);
- }
- }
-
-
protected Drawable loadIcon(int index, ResourceType type, String name) {
BridgeContext bridgeContext = (BridgeContext) mContext;
RenderResources res = bridgeContext.getRenderResources();
@@ -170,64 +162,34 @@
if (child instanceof ImageView) {
ImageView imageView = (ImageView) child;
- return loadIcon(imageView, value);
+ Drawable drawable = ResourceHelper.getDrawable(
+ value, (BridgeContext) mContext);
+ if (drawable != null) {
+ imageView.setBackgroundDrawable(drawable);
+ }
+
+ return drawable;
}
return null;
}
- private Drawable loadIconById(int id, ResourceValue value) {
- View child = findViewById(id);
- if (child instanceof ImageView) {
- ImageView imageView = (ImageView) child;
-
- return loadIcon(imageView, value);
- }
-
- return null;
- }
-
-
- private Drawable loadIcon(ImageView imageView, ResourceValue value) {
- Drawable drawable = ResourceHelper.getDrawable(value, (BridgeContext) mContext);
- if (drawable != null) {
- imageView.setImageDrawable(drawable);
- }
-
- return drawable;
- }
-
protected TextView setText(int index, String stringReference) {
View child = getChildAt(index);
if (child instanceof TextView) {
TextView textView = (TextView) child;
- setText(textView, stringReference);
+ ResourceValue value = getResourceValue(stringReference);
+ if (value != null) {
+ textView.setText(value.getValue());
+ } else {
+ textView.setText(stringReference);
+ }
return textView;
}
return null;
}
- protected TextView setTextById(int id, String stringReference) {
- View child = findViewById(id);
- if (child instanceof TextView) {
- TextView textView = (TextView) child;
- setText(textView, stringReference);
- return textView;
- }
-
- return null;
- }
-
- private void setText(TextView textView, String stringReference) {
- ResourceValue value = getResourceValue(stringReference);
- if (value != null) {
- textView.setText(value.getValue());
- } else {
- textView.setText(stringReference);
- }
- }
-
protected void setStyle(String themeEntryName) {
BridgeContext bridgeContext = (BridgeContext) mContext;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java
index 68f5aba..f6edea4 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java
@@ -34,7 +34,7 @@
// Cannot access the inside items through id because no R.id values have been
// created for them.
// We do know the order though.
- loadIconById(android.R.id.home, icon);
+ loadIcon(0, icon);
mTextView = setText(1, label);
setStyle("actionBarStyle");