Unify normal and overlay action bar layouts.

Switch the action bar to always use the overlay layout, and
make it smarter to do the right thing depending on whether the
action bar is in overlay mode or not.

This allows apps to use the system UI magic flags without
having to worry about whether the action bar is configured
in overlay mode or note -- just select a stable layout and it
will automatically go into overlay mode.

In the future this should also allow us to simplify the action
bar code, since it is all sitting on one common implementation.
For example, much of the logic in ActionBarImpl can be moved
to the root action bar layout, and that layout can be optimized
to do custom layout with all of the known elements it has.

Also fixed a little bug in the performance tests.

Change-Id: Iec0c0c0699754f0d1ce37402d786b4966e052a56
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index f041f07..db20549 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -110,6 +110,7 @@
 
     private int mCurWindowVisibility = View.VISIBLE;
 
+    private boolean mContentAnimations = true;
     private boolean mHiddenByApp;
     private boolean mHiddenBySystem;
     private boolean mShowingForMode;
@@ -122,7 +123,7 @@
     final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
-            if (mContentView != null) {
+            if (mContentAnimations && mContentView != null) {
                 mContentView.setTranslationY(0);
                 mTopVisibilityView.setTranslationY(0);
             }
@@ -151,23 +152,24 @@
         mActivity = activity;
         Window window = activity.getWindow();
         View decor = window.getDecorView();
-        init(decor);
-        if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
+        boolean overlayMode = mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+        init(decor, overlayMode);
+        if (!overlayMode) {
             mContentView = decor.findViewById(android.R.id.content);
         }
     }
 
     public ActionBarImpl(Dialog dialog) {
         mDialog = dialog;
-        init(dialog.getWindow().getDecorView());
+        init(dialog.getWindow().getDecorView(), false);
     }
 
-    private void init(View decor) {
+    private void init(View decor, boolean overlayMode) {
         mContext = decor.getContext();
         mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(
                 com.android.internal.R.id.action_bar_overlay_layout);
         if (mOverlayLayout != null) {
-            mOverlayLayout.setActionBar(this);
+            mOverlayLayout.setActionBar(this, overlayMode);
         }
         mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
         mContextView = (ActionBarContextView) decor.findViewById(
@@ -586,6 +588,10 @@
         return mContainerView.getHeight();
     }
 
+    public void enableContentAnimations(boolean enabled) {
+        mContentAnimations = enabled;
+    }
+
     @Override
     public void show() {
         if (mHiddenByApp) {
@@ -684,7 +690,7 @@
             AnimatorSet anim = new AnimatorSet();
             AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView,
                     "translationY", 0));
-            if (mContentView != null) {
+            if (mContentAnimations && mContentView != null) {
                 b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
                         startingY, 0));
             }
@@ -709,7 +715,7 @@
         } else {
             mTopVisibilityView.setAlpha(1);
             mTopVisibilityView.setTranslationY(0);
-            if (mContentView != null) {
+            if (mContentAnimations && mContentView != null) {
                 mContentView.setTranslationY(0);
             }
             if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
@@ -742,7 +748,7 @@
             }
             AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView,
                     "translationY", endingY));
-            if (mContentView != null) {
+            if (mContentAnimations && mContentView != null) {
                 b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
                         0, endingY));
             }