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/res/layout/title_bar_bg.xml b/res/layout/title_bar_bg.xml
new file mode 100644
index 0000000..c4213b0
--- /dev/null
+++ b/res/layout/title_bar_bg.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+   Copyright 2009, The Android Open Source Project
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_height="wrap_content"
+    android:layout_width="wrap_content"
+    android:foreground="?android:attr/windowContentOverlay"
+    android:background="@color/white"
+    />
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;
     }