Fixes to title bar using top controls

- Do not differentiate between title bar in fixed vs auto-hide mode
  using different android layouts. Use top controls to always show
  titlebar for fixed titlebar.
- Always show the titlebar when page is being loaded even if the user
  scrolls during the page load.
- Fixes the jankiness seen in fixed titlebar mode when user navigates
  between webpages.
- Reaffirm top controls when user switches between fixed and auto-hide
  titlebar mode.

Change-Id: I2531695f34e725ae444f6159645c7557dec69fab
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index fbb5ad0..1ea1460 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -819,8 +819,8 @@
             } else {
                 mTitleBar.setEnabled(true);
             }
-
-            mTitleBar.setTranslationY(topControlsOffsetYPix);
+            if (!mTitleBar.isFixed() && !isLoading())
+                mTitleBar.setTranslationY(topControlsOffsetYPix);
         }
     }
 
@@ -898,10 +898,6 @@
 
     }
 
-    public void addFixedTitleBar(View view) {
-        mFixedTitlebarContainer.addView(view);
-    }
-
     public void setContentViewMarginTop(int margin) {
         LinearLayout.LayoutParams params =
                 (LinearLayout.LayoutParams) mContentView.getLayoutParams();
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 1ea4dad..5d5f1e3 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -102,13 +102,7 @@
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        if (mIsFixedTitleBar) {
-            int margin = getMeasuredHeight() - calculateEmbeddedHeight();
-            if (!isEditingUrl())
-                mBaseUi.setContentViewMarginTop(-margin);
-        } else {
-            mBaseUi.setContentViewMarginTop(0);
-        }
+        mBaseUi.setContentViewMarginTop(0);
     }
 
     private void setFixedTitleBar() {
@@ -125,12 +119,8 @@
         if (parent != null) {
             parent.removeView(this);
         }
-        if (mIsFixedTitleBar) {
-            mBaseUi.addFixedTitleBar(this);
-        } else {
-            mContentView.addView(this, makeLayoutParams());
-            mBaseUi.setContentViewMarginTop(0);
-        }
+        mContentView.addView(this, makeLayoutParams());
+        mBaseUi.setContentViewMarginTop(0);
     }
 
     public BaseUi getUi() {
@@ -168,7 +158,11 @@
         if (mSkipTitleBarAnimations) {
             this.setVisibility(View.VISIBLE);
             this.setTranslationY(0);
-            hideTopControls();
+            // reaffirm top-controls
+            if (isFixed() || isInLoad())
+                showTopControls();
+            else
+                enableTopControls();
         } else if (!bOldStyleAutoHideDisabled) {
             int visibleHeight = getVisibleTitleHeight();
             float startPos = (-getEmbeddedHeight() + visibleHeight);
@@ -283,7 +277,10 @@
             }
 
             //onPageFinished
-            enableTopControls();
+            if (isFixed())
+                showTopControls();
+            else
+                enableTopControls();
 
         } else {
             if (!mInLoad) {