Make the fake title bar look more like the regular title bar.
Place the fake title bar in FrameLayout with a shadow overlay and
a white background so it will look like the embedded title bar.
Fixes http://b/issue?id=2123300 and part of http://b/issue?id=2118813
Change-Id: I079cd5100dbc344867a75e3593471bc0c1e3d8eb
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index d4cd7eb..74103f2 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -881,6 +881,19 @@
private TitleBar mFakeTitleBar;
/**
+ * Holder for the fake title bar. It will have a foreground shadow, as well
+ * as a white background, so the fake title bar looks like the real one.
+ */
+ private ViewGroup mFakeTitleBarHolder;
+
+ /**
+ * Layout parameters for the fake title bar within mFakeTitleBarHolder
+ */
+ private FrameLayout.LayoutParams mFakeTitleBarParams
+ = new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ /**
* Keeps track of whether the options menu is open. This is important in
* determining whether to show or hide the title bar overlay.
*/
@@ -967,7 +980,16 @@
Rect rectangle = new Rect();
mBrowserFrameLayout.getGlobalVisibleRect(rectangle);
params.y = rectangle.top;
- manager.addView(mFakeTitleBar, params);
+ // Add a holder for the title bar. It is a FrameLayout, which
+ // allows it to have an overlay shadow. It also has a white
+ // background, which is the same as the background when it is
+ // placed in a WebView.
+ if (mFakeTitleBarHolder == null) {
+ mFakeTitleBarHolder = (ViewGroup) LayoutInflater.from(this)
+ .inflate(R.layout.title_bar_bg, null);
+ }
+ mFakeTitleBarHolder.addView(mFakeTitleBar, mFakeTitleBarParams);
+ manager.addView(mFakeTitleBarHolder, params);
}
}
@@ -987,7 +1009,8 @@
if (mFakeTitleBar == null) return;
WindowManager manager
= (WindowManager) getSystemService(Context.WINDOW_SERVICE);
- manager.removeView(mFakeTitleBar);
+ mFakeTitleBarHolder.removeView(mFakeTitleBar);
+ manager.removeView(mFakeTitleBarHolder);
mFakeTitleBar = null;
}