Move the find dialog to the top of the screen.

Adjust the animations for the new location, and remove
the browser bar when Find is showing.

Bug 2667046

Change-Id: I565106b6c7e02200ed45ae145033447a8931af62
diff --git a/res/anim/find_dialog_enter.xml b/res/anim/find_dialog_enter.xml
index 5e597a4..6fbcb9e 100644
--- a/res/anim/find_dialog_enter.xml
+++ b/res/anim/find_dialog_enter.xml
@@ -16,6 +16,6 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@android:anim/decelerate_interpolator">
-	<translate android:fromYDelta="25%" android:toYDelta="0" android:duration="75"/>
-	<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="75" />
+    <translate android:fromYDelta="-25%" android:toYDelta="0" android:duration="75"/>
+    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="75" />
 </set>
diff --git a/res/anim/find_dialog_exit.xml b/res/anim/find_dialog_exit.xml
index 854abd0..9845849 100644
--- a/res/anim/find_dialog_exit.xml
+++ b/res/anim/find_dialog_exit.xml
@@ -16,7 +16,7 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@android:anim/accelerate_interpolator">
-	<translate android:fromYDelta="0" android:toYDelta="50%" android:duration="50"/>
-	<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="50" />
+    <translate android:fromYDelta="0" android:toYDelta="-50%" android:duration="50"/>
+    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="50" />
 </set>
 
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 4209a28..bee06b5 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -834,6 +834,13 @@
             if (mainView == null) {
                 return;
             }
+            // Do not need to check for null, since the current tab will have
+            // at least a main WebView, or we would have returned above.
+            if (getTopWindow().getFindIsUp()) {
+                // Do not show the fake title bar, which would cover up the
+                // FindDialog.
+                return;
+            }
 
             WindowManager manager
                     = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
@@ -1368,7 +1375,17 @@
                     mFindDialog = new FindDialog(this);
                 }
                 // Need to do something special for Tablet
-                mTabControl.getCurrentTab().showFind(mFindDialog);
+                Tab tab = mTabControl.getCurrentTab();
+                if (tab.getSubWebView() == null) {
+                    // If the Find is being performed on the main webview,
+                    // remove the embedded title bar.
+                    WebView mainView = tab.getWebView();
+                    if (mainView != null) {
+                        mainView.setEmbeddedTitleBar(null);
+                    }
+                }
+                hideFakeTitleBar();
+                tab.showFind(mFindDialog);
                 mMenuState = EMPTY_MENU;
                 break;
 
@@ -1453,11 +1470,26 @@
      * Remove the FindDialog.
      */
     public void closeFind() {
+        Tab currentTab = mTabControl.getCurrentTab();
         if (mFindDialog != null) {
-            mTabControl.getCurrentTab().closeFind(mFindDialog);
+            currentTab.closeFind(mFindDialog);
             mFindDialog.dismiss();
         }
+        // If the Find was being performed in the main WebView, replace the
+        // embedded title bar.
+        if (currentTab.getSubWebView() == null) {
+            WebView mainView = currentTab.getWebView();
+            if (mainView != null) {
+                mainView.setEmbeddedTitleBar(mTitleBar);
+            }
+        }
         mMenuState = R.id.MAIN_MENU;
+        if (mInLoad) {
+            // The title bar was hidden, because otherwise it would cover up the
+            // find dialog.  Now that the dialog has been removed, show the fake
+            // title bar once again.
+            showFakeTitleBar();
+        }
     }
 
     @Override
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 12f0cf6..921ecb3 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1963,7 +1963,7 @@
             container = mContainer;
         }
         dialog.show();
-        container.addView(dialog, new LinearLayout.LayoutParams(
+        container.addView(dialog, 0, new LinearLayout.LayoutParams(
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 ViewGroup.LayoutParams.WRAP_CONTENT));
         dialog.setWebView(view);