Titlebar cleanup

- Removed timer based Titlebar animation
- Always show Titlebar when keyboard is up
- Block webpage scroll when Titlebar is focused
- Added command line switch to disable top controls
- Fix rendering issue seen when user exits fullscreen video

Change-Id: I9d0afe7be907522b3678746c04049c2904118a4b
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 3a05724..2d53daa 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -72,9 +72,6 @@
         ViewGroup.LayoutParams.MATCH_PARENT,
         Gravity.CENTER);
 
-    private static final int MSG_HIDE_TITLEBAR = 1;
-    public static final int HIDE_TITLEBAR_DELAY = 1500; // in ms
-
     Activity mActivity;
     UiController mUiController;
     TabControl mTabControl;
@@ -90,8 +87,6 @@
     private CustomViewCallback mCustomViewCallback;
     private int mOriginalOrientation;
 
-    private UrlBarAutoShowManager mUrlBarAutoShowManager;
-
     private Toast mStopToast;
 
     // the default <video> poster
@@ -131,7 +126,6 @@
                 mContentView);
         mTitleBar.setProgress(100);
         mNavigationBar = mTitleBar.getNavigationBar();
-        mUrlBarAutoShowManager = new UrlBarAutoShowManager(this);
 
         // install system ui visibility listeners
         mDecorView = mActivity.getWindow().getDecorView();
@@ -219,6 +213,12 @@
         return false;
     }
 
+    public boolean isFullScreen() {
+        if (mTabControl.getCurrentTab() != null)
+            return mTabControl.getCurrentTab().isTabFullScreen();
+        return false;
+    }
+
     @Override
     public boolean onMenuKey() {
         return false;
@@ -281,7 +281,6 @@
 
         // block unnecessary focus change animations during tab switch
         mBlockFocusAnimations = true;
-        mHandler.removeMessages(MSG_HIDE_TITLEBAR);
         if ((tab != mActiveTab) && (mActiveTab != null)) {
             tabToRemove = mActiveTab;
             WebView web = mActiveTab.getWebView();
@@ -292,7 +291,6 @@
         mActiveTab = tab;
 
         BrowserWebView web = (BrowserWebView) mActiveTab.getWebView();
-        updateUrlBarAutoShowManagerTarget();
         attachTabToContentView(tab);
         if (web != null) {
             // Request focus on the top window.
@@ -310,7 +308,6 @@
         scheduleRemoveTab(tabToRemove, tabToWaitFor);
 
         updateTabSecurityState(tab);
-        mTitleBar.setSkipTitleBarAnimations(false);
     }
 
     Tab mTabToRemove = null;
@@ -378,13 +375,6 @@
         mTabToWaitFor = null;
     }
 
-    protected void updateUrlBarAutoShowManagerTarget() {
-        WebView web = mActiveTab != null ? mActiveTab.getWebView() : null;
-        if (web instanceof BrowserWebView) {
-            mUrlBarAutoShowManager.setTarget((BrowserWebView) web);
-        }
-    }
-
     Tab getActiveTab() {
         return mActiveTab;
     }
@@ -598,15 +588,14 @@
     }
 
     protected void showTitleBar() {
-        mHandler.removeMessages(MSG_HIDE_TITLEBAR);
         if (canShowTitleBar()) {
-            mTitleBar.show();
+            mTitleBar.showTopControls(false);
         }
     }
 
     protected void hideTitleBar() {
         if (mTitleBar.isShowing()) {
-            mTitleBar.hide();
+            mTitleBar.enableTopControls(false);
         }
     }
 
@@ -871,36 +860,34 @@
         if (getWebView() != null) {
             BrowserWebView bwv = (BrowserWebView) getWebView();
             if (fullScreen) {
-                //hide topbar
-                bwv.enableTopControls(false);
+                // hide titlebar
                 mTitleBar.hideTopControls(true);
             } else {
-                bwv.enableTopControls(true);
-                //show the topbar
-                mTitleBar.showTopControls(true);
-                //enable for auto-hide
+                // show titlebar
+                mTitleBar.showTopControls(false);
+                // enable auto hide titlebar
                 if (!mTitleBar.isFixed())
-                    mTitleBar.enableTopControls(true);
+                    mTitleBar.enableTopControls(false);
             }
         }
     }
 
     public void translateTitleBar(float topControlsOffsetYPix) {
-        if (mTitleBar != null && !mInActionMode) {
+        if (mTitleBar == null || mTitleBar.isFixed())
+            return;
+        if (!mInActionMode) {
             if (topControlsOffsetYPix != 0.0) {
                 mTitleBar.setEnabled(false);
             } else {
                 mTitleBar.setEnabled(true);
             }
-            if (!mTitleBar.isFixed()) {
-                float currentY = mTitleBar.getTranslationY();
-                float height = mNavigationBar.getHeight();
-                if ((height + currentY) <= 0 && (height + topControlsOffsetYPix) > 0) {
-                    mTitleBar.requestLayout();
-                } else if ((height + topControlsOffsetYPix) <= 0) {
-                    topControlsOffsetYPix -= 1;
-                    mTitleBar.getParent().requestTransparentRegion(mTitleBar);
-                }
+            float currentY = mTitleBar.getTranslationY();
+            float height = mNavigationBar.getHeight();
+            if ((height + currentY) <= 0 && (height + topControlsOffsetYPix) > 0) {
+                mTitleBar.requestLayout();
+            } else if ((height + topControlsOffsetYPix) <= 0) {
+                topControlsOffsetYPix -= 1;
+                mTitleBar.getParent().requestTransparentRegion(mTitleBar);
             }
             // This was done to get HTML5 fullscreen API to work with fixed mode since
             // topcontrols are used to implement HTML5 fullscreen
@@ -931,28 +918,6 @@
         return mActiveTab != null ? mActiveTab.inPageLoad() : false;
     }
 
-    /**
-     * Suggest to the UI that the title bar can be hidden. The UI will then
-     * decide whether or not to hide based off a number of factors, such
-     * as if the user is editing the URL bar or if the page is loading
-     */
-    public void suggestHideTitleBar() {
-        if (!isLoading() && !isEditingUrl() && !mTitleBar.wantsToBeVisible()
-                && !mNavigationBar.isMenuShowing()) {
-            hideTitleBar();
-        }
-    }
-
-    protected final void showTitleBarForDuration() {
-        showTitleBarForDuration(HIDE_TITLEBAR_DELAY);
-    }
-
-    protected final void showTitleBarForDuration(long duration) {
-        showTitleBar();
-        Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR);
-        mHandler.sendMessageDelayed(msg, duration);
-    }
-
     protected void setMenuItemVisibility(Menu menu, int id,
                                          boolean visibility) {
         MenuItem item = menu.findItem(id);
@@ -965,9 +930,6 @@
 
         @Override
         public void handleMessage(Message msg) {
-            if (msg.what == MSG_HIDE_TITLEBAR) {
-                suggestHideTitleBar();
-            }
             BaseUi.this.handleMessage(msg);
         }
     };