summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2015-07-28 18:27:28 -0700
committerDeepanshu Gupta <deepanshu@google.com>2015-07-28 18:30:48 -0700
commit6e8d8ad2b7cffed751b2a382ac7b761954767188 (patch)
tree5853b68323a8942cefec37dfe1e92fd525352646 /tools
parente3f9834ebd8a6e4ee155c8e4c9456dfc98e8b832 (diff)
downloadframeworks_base-6e8d8ad2b7cffed751b2a382ac7b761954767188.zip
frameworks_base-6e8d8ad2b7cffed751b2a382ac7b761954767188.tar.gz
frameworks_base-6e8d8ad2b7cffed751b2a382ac7b761954767188.tar.bz2
LayoutLib: fix layout when nav bar is absent.
Change-Id: I0d3ee6fd5a4656156a630d3b298533ea13eb8415
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
index 89d8319..d1c9f21 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
@@ -165,13 +165,13 @@ class Layout extends RelativeLayout {
FrameLayout contentRoot = new FrameLayout(getContext());
LayoutParams params = createLayoutParams(MATCH_PARENT, MATCH_PARENT);
int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE;
- if (mBuilder.solidBars()) {
+ if (mBuilder.hasNavBar() && mBuilder.solidBars()) {
params.addRule(rule, getId(ID_NAV_BAR));
}
int below = -1;
if (mBuilder.mActionBarSize <= 0 && mBuilder.mTitleBarSize > 0) {
below = getId(ID_TITLE_BAR);
- } else if (mBuilder.solidBars()) {
+ } else if (mBuilder.hasStatusBar() && mBuilder.solidBars()) {
below = getId(ID_STATUS_BAR);
}
if (below != -1) {
@@ -238,10 +238,10 @@ class Layout extends RelativeLayout {
}
LayoutParams layoutParams = createLayoutParams(MATCH_PARENT, MATCH_PARENT);
int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE;
- if (mBuilder.solidBars()) {
+ if (mBuilder.hasNavBar() && mBuilder.solidBars()) {
layoutParams.addRule(rule, getId(ID_NAV_BAR));
}
- if (mBuilder.solidBars()) {
+ if (mBuilder.hasStatusBar() && mBuilder.solidBars()) {
layoutParams.addRule(BELOW, getId(ID_STATUS_BAR));
}
actionBar.getRootView().setLayoutParams(layoutParams);
@@ -254,7 +254,7 @@ class Layout extends RelativeLayout {
int simulatedPlatformVersion) {
TitleBar titleBar = new TitleBar(context, title, simulatedPlatformVersion);
LayoutParams params = createLayoutParams(MATCH_PARENT, mBuilder.mTitleBarSize);
- if (mBuilder.solidBars()) {
+ if (mBuilder.hasStatusBar() && mBuilder.solidBars()) {
params.addRule(BELOW, getId(ID_STATUS_BAR));
}
if (mBuilder.isNavBarVertical() && mBuilder.solidBars()) {
@@ -333,10 +333,6 @@ class Layout extends RelativeLayout {
findNavBar();
}
- public boolean isNavBarVertical() {
- return mNavBarOrientation == VERTICAL;
- }
-
private void findBackground() {
if (!mParams.isBgColorOverridden()) {
mWindowBackground = mResources.findItemInTheme(ATTR_WINDOW_BACKGROUND, true);
@@ -444,16 +440,27 @@ class Layout extends RelativeLayout {
}
/**
- * Return if both status bar and nav bar are solid (content doesn't overlap with these
- * bars).
+ * Return true if the status bar or nav bar are present, they are not translucent (i.e
+ * content doesn't overlap with them).
*/
private boolean solidBars() {
- return hasNavBar() && !mTranslucentNav && !mTranslucentStatus && mStatusBarSize > 0;
+ return !(hasNavBar() && mTranslucentNav) && !(hasStatusBar() && mTranslucentStatus);
}
private boolean hasNavBar() {
return Config.showOnScreenNavBar(mParams.getSimulatedPlatformVersion()) &&
hasSoftwareButtons() && mNavBarSize > 0;
}
+
+ private boolean hasStatusBar() {
+ return mStatusBarSize > 0;
+ }
+
+ /**
+ * Return true if the nav bar is present and is vertical.
+ */
+ private boolean isNavBarVertical() {
+ return hasNavBar() && mNavBarOrientation == VERTICAL;
+ }
}
}