summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2015-01-10 02:10:55 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-10 02:10:55 +0000
commit74147527357b9abd9d30b3a2dbd72a5172a35625 (patch)
treeecdcfcd12b61d65140a17b14f88c7a9c79774c80
parentdf878bd3fc63f26e91b055e39ba63c53c14b31a0 (diff)
parent8505c3870a17f41d23329344fe381cd9ff324bd2 (diff)
downloadframeworks_base-74147527357b9abd9d30b3a2dbd72a5172a35625.zip
frameworks_base-74147527357b9abd9d30b3a2dbd72a5172a35625.tar.gz
frameworks_base-74147527357b9abd9d30b3a2dbd72a5172a35625.tar.bz2
am 8505c387: Special case AppCompat to show action bar.
* commit '8505c3870a17f41d23329344fe381cd9ff324bd2': Special case AppCompat to show action bar.
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index bd42ca4..ed17b9c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -36,6 +36,7 @@ import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.Result.Status;
import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
+import com.android.ide.common.rendering.api.StyleResourceValue;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.ViewType;
import com.android.internal.util.XmlUtils;
@@ -132,6 +133,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
private int mMeasuredScreenHeight = -1;
private boolean mIsAlphaChannelImage;
private boolean mWindowIsFloating;
+ private Boolean mIsThemeAppCompat;
private int mStatusBarSize;
private int mNavigationBarSize;
@@ -192,11 +194,9 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
DisplayMetrics metrics = getContext().getMetrics();
// use default of true in case it's not found to use alpha by default
- mIsAlphaChannelImage = getBooleanThemeValue(resources,
- "windowIsFloating", true /*defaultValue*/);
-
- mWindowIsFloating = getBooleanThemeValue(resources, "windowIsFloating",
- true /*defaultValue*/);
+ mIsAlphaChannelImage = getBooleanThemeValue(resources, "windowIsFloating", true, true);
+ // FIXME: Find out why both variables are taking the same value.
+ mWindowIsFloating = getBooleanThemeValue(resources, "windowIsFloating", true, true);
findBackground(resources);
findStatusBar(resources, metrics);
@@ -1043,7 +1043,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
boolean windowFullscreen = getBooleanThemeValue(resources,
- "windowFullscreen", false /*defaultValue*/);
+ "windowFullscreen", false, !isThemeAppCompat(resources));
if (!windowFullscreen && !mWindowIsFloating) {
// default value
@@ -1070,7 +1070,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
boolean windowActionBar = getBooleanThemeValue(resources,
- "windowActionBar", true /*defaultValue*/);
+ "windowActionBar", true, !isThemeAppCompat(resources));
// if there's a value and it's false (default is true)
if (windowActionBar) {
@@ -1097,7 +1097,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
} else {
// action bar overrides title bar so only look for this one if action bar is hidden
boolean windowNoTitle = getBooleanThemeValue(resources,
- "windowNoTitle", false /*defaultValue*/);
+ "windowNoTitle", false, !isThemeAppCompat(resources));
if (!windowNoTitle) {
@@ -1169,20 +1169,30 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
}
+ private boolean isThemeAppCompat(RenderResources resources) {
+ // Ideally, we should check if the corresponding activity extends
+ // android.support.v7.app.ActionBarActivity, and not care about the theme name at all.
+ if (mIsThemeAppCompat == null) {
+ StyleResourceValue defaultTheme = resources.getDefaultTheme();
+ StyleResourceValue val = resources.getStyle("Theme.AppCompat", false);
+ mIsThemeAppCompat = defaultTheme == val || resources.themeIsParentOf(val, defaultTheme);
+ }
+ return mIsThemeAppCompat;
+ }
+
/**
- * Looks for a attribute in the current theme. The attribute is in the android
- * namespace.
+ * Looks for an attribute in the current theme.
*
* @param resources the render resources
* @param name the name of the attribute
* @param defaultValue the default value.
+ * @param isFrameworkAttr if the attribute is in android namespace
* @return the value of the attribute or the default one if not found.
*/
private boolean getBooleanThemeValue(RenderResources resources,
- String name, boolean defaultValue) {
+ String name, boolean defaultValue, boolean isFrameworkAttr) {
- // get the title bar flag from the current theme.
- ResourceValue value = resources.findItemInTheme(name, true /*isFrameworkAttr*/);
+ ResourceValue value = resources.findItemInTheme(name, isFrameworkAttr);
// because it may reference something else, we resolve it.
value = resources.resolveResValue(value);