Merge "ActionBar overlay mode, height fetching, show/hide"
diff --git a/api/current.xml b/api/current.xml
index 64ac66f..dbbdb7b 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -10580,6 +10580,17 @@
  visibility="public"
 >
 </field>
+<field name="windowActionBarOverlay"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843558"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="windowActionBarStyle"
  type="int"
  transient="false"
@@ -20936,6 +20947,17 @@
  visibility="public"
 >
 </method>
+<method name="getHeight"
+ return="int"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getNavigationMode"
  return="int"
  abstract="true"
@@ -20980,6 +21002,17 @@
  visibility="public"
 >
 </method>
+<method name="hide"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="insertTab"
  return="void"
  abstract="true"
@@ -20995,6 +21028,17 @@
 <parameter name="position" type="int">
 </parameter>
 </method>
+<method name="isShowing"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="newTab"
  return="android.app.ActionBar.Tab"
  abstract="true"
@@ -21287,6 +21331,17 @@
 <parameter name="resId" type="int">
 </parameter>
 </method>
+<method name="show"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <field name="DISPLAY_HIDE_HOME"
  type="int"
  transient="false"
@@ -201148,7 +201203,7 @@
  visibility="public"
 >
 </field>
-<field name="FEATURE_ACTION_MODE_OVERLAY"
+<field name="FEATURE_ACTION_BAR_OVERLAY"
  type="int"
  transient="false"
  volatile="false"
@@ -201159,6 +201214,17 @@
  visibility="public"
 >
 </field>
+<field name="FEATURE_ACTION_MODE_OVERLAY"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="10"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FEATURE_CONTEXT_MENU"
  type="int"
  transient="false"
@@ -201185,7 +201251,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="10"
+ value="11"
  static="true"
  final="true"
  deprecated="not deprecated"
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index d33494b..38086f0 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -18,6 +18,7 @@
 
 import android.graphics.drawable.Drawable;
 import android.view.View;
+import android.view.Window;
 import android.widget.SpinnerAdapter;
 
 /**
@@ -383,6 +384,34 @@
     public abstract void selectTab(Tab tab);
 
     /**
+     * Retrieve the current height of the ActionBar.
+     *
+     * @return The ActionBar's height
+     */
+    public abstract int getHeight();
+
+    /**
+     * Show the ActionBar if it is not currently showing.
+     * If the window hosting the ActionBar does not have the feature
+     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
+     * content to fit the new space available.
+     */
+    public abstract void show();
+
+    /**
+     * Hide the ActionBar if it is not currently showing.
+     * If the window hosting the ActionBar does not have the feature
+     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
+     * content to fit the new space available.
+     */
+    public abstract void hide();
+
+    /**
+     * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
+     */
+    public abstract boolean isShowing();
+
+    /**
      * Callback interface for ActionBar navigation events. 
      */
     public interface NavigationCallback {
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index f32ff77..36f6bb2 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -64,14 +64,24 @@
      */
     public static final int FEATURE_ACTION_BAR = 8;
     /**
+     * Flag for requesting an Action Bar that overlays window content.
+     * Normally an Action Bar will sit in the space above window content, but if this
+     * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
+     * the window content itself. This is useful if you would like your app to have more control
+     * over how the Action Bar is displayed, such as letting application content scroll beneath
+     * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
+     * Action Bar over application content.
+     */
+    public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
+    /**
      * Flag for specifying the behavior of action modes when an Action Bar is not present.
      * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
      */
-    public static final int FEATURE_ACTION_MODE_OVERLAY = 9;
+    public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
     /**
      * Flag for requesting this window to be hardware accelerated, if possible. 
      */
-    public static final int FEATURE_HARDWARE_ACCELERATED = 10;
+    public static final int FEATURE_HARDWARE_ACCELERATED = 11;
     /** Flag for setting the progress bar's visibility to VISIBLE */
     public static final int PROGRESS_VISIBILITY_ON = -1;
     /** Flag for setting the progress bar's visibility to GONE */
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 6b52409..0be42d6 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -397,6 +397,27 @@
         trans.commit();
     }
 
+    @Override
+    public int getHeight() {
+        return mActionView.getHeight();
+    }
+
+    @Override
+    public void show() {
+        // TODO animate!
+        mAnimatorView.setVisibility(View.VISIBLE);
+    }
+
+    @Override
+    public void hide() {
+        // TODO animate!
+        mAnimatorView.setVisibility(View.GONE);
+    }
+
+    public boolean isShowing() {
+        return mAnimatorView.getVisibility() == View.VISIBLE;
+    }
+
     /**
      * @hide 
      */
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index 1357251..d00a99e 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -20,6 +20,7 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
+import android.view.Gravity;
 import android.view.ViewGroup;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
@@ -82,6 +83,7 @@
         if (p instanceof LayoutParams) {
             LayoutParams lp = (LayoutParams) p;
             return lp.leftMargin == mItemMargin && lp.rightMargin == mItemMargin &&
+                    lp.gravity == Gravity.CENTER_VERTICAL &&
                     lp.width == LayoutParams.WRAP_CONTENT && lp.height == LayoutParams.WRAP_CONTENT;
         }
         return false;
@@ -93,6 +95,7 @@
                 LayoutParams.WRAP_CONTENT);
         params.leftMargin = mItemMargin;
         params.rightMargin = mItemMargin;
+        params.gravity = Gravity.CENTER_VERTICAL;
         return params;
     }
     
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index c641441..3c40bb0 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -118,7 +118,6 @@
         super(context, attrs);
 
         final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
-        mContentHeight = (int) (CONTENT_HEIGHT_DIP * metrics.density + 0.5f);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar);
 
@@ -157,14 +156,18 @@
             LayoutInflater inflater = LayoutInflater.from(context);
             mCustomNavView = (View) inflater.inflate(customNavId, null);
             mNavigationMode = ActionBar.NAVIGATION_MODE_CUSTOM;
+            addView(mCustomNavView);
         }
 
+        final int padding = a.getDimensionPixelSize(R.styleable.ActionBar_padding,
+                (int) (CONTENT_PADDING_DIP * metrics.density + 0.5f));
+        setPadding(padding, padding, padding, padding);
+        mContentHeight = a.getDimensionPixelSize(R.styleable.ActionBar_height,
+                (int) (CONTENT_PADDING_DIP * metrics.density + 0.5f)) - padding * 2;
+
         a.recycle();
 
         // TODO: Set this in the theme
-        int padding = (int) (CONTENT_PADDING_DIP * metrics.density + 0.5f);
-        setPadding(padding, padding, padding, padding);
-
         mSpacing = (int) (CONTENT_SPACING_DIP * metrics.density + 0.5f);
         mActionSpacing = (int) (CONTENT_ACTION_SPACING_DIP * metrics.density + 0.5f);
         
diff --git a/core/res/res/layout-xlarge/screen_action_bar_overlay.xml b/core/res/res/layout-xlarge/screen_action_bar_overlay.xml
new file mode 100644
index 0000000..d0277f0
--- /dev/null
+++ b/core/res/res/layout-xlarge/screen_action_bar_overlay.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<!--
+This is an optimized layout for a screen with
+the Action Bar enabled overlaying application content.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fitsSystemWindows="true">
+    <FrameLayout android:id="@android:id/content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+    <ViewAnimator android:id="@+id/action_bar_animator"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="top"
+        android:inAnimation="@anim/push_down_in"
+        android:outAnimation="@anim/push_down_out">
+        <com.android.internal.widget.ActionBarView
+            android:id="@+id/action_bar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            style="?android:attr/windowActionBarStyle" />
+        <com.android.internal.widget.ActionBarContextView
+            android:id="@+id/action_context_bar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+    </ViewAnimator>
+    <ImageView android:src="?android:attr/windowContentOverlay"
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
+               android:layout_below="@id/action_bar_animator" />
+</RelativeLayout>
diff --git a/core/res/res/layout/screen_action_bar_overlay.xml b/core/res/res/layout/screen_action_bar_overlay.xml
new file mode 100644
index 0000000..cb1ffc5
--- /dev/null
+++ b/core/res/res/layout/screen_action_bar_overlay.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<!--
+This is an optimized layout for a screen with
+the Action Bar enabled overlaying application content.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fitsSystemWindows="true">
+    <FrameLayout android:id="@android:id/content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+    <ViewAnimator android:id="@+id/action_bar_animator"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="top"
+        android:inAnimation="@anim/push_down_in"
+        android:outAnimation="@anim/push_down_out">
+        <com.android.internal.widget.ActionBarView
+            android:id="@+id/action_bar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            style="?android:attr/windowActionBarStyle" />
+        <com.android.internal.widget.ActionBarContextView
+            android:id="@+id/action_context_bar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+    </ViewAnimator>
+    <ImageView android:src="?android:attr/windowContentOverlay"
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
+               android:layout_below="@id/action_bar_animator" />
+    <LinearLayout android:id="@+id/lower_action_context_bar"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_gravity="bottom"
+                  style="?android:attr/windowActionBarStyle"
+                  android:visibility="gone" />
+</RelativeLayout>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 97c5822..a8c7842 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -248,6 +248,11 @@
              in place of the usual title bar. -->
         <attr name="windowActionBar" format="boolean" />
 
+        <!-- Flag indicating whether this window's Action Bar should overlay
+             application content. Does nothing if the window would not
+             have an Action Bar. -->
+        <attr name="windowActionBarOverlay" format="boolean" />
+
         <!-- Reference to a style for the Action Bar -->
         <attr name="windowActionBarStyle" format="reference" />
 
@@ -999,6 +1004,7 @@
         <attr name="windowActionBar" />
         <attr name="windowActionBarStyle" />
         <attr name="windowActionModeOverlay" />
+        <attr name="windowActionBarOverlay" />
     </declare-styleable>
 
     <!-- The set of attributes that describe a AlertDialog's theme. -->
@@ -3987,6 +3993,10 @@
         <attr name="background" />
         <!-- Specifies a layout for custom navigation. Overrides navigationMode. -->
         <attr name="customNavigationLayout" format="reference" />
+        <!-- Specifies a fixed height. -->
+        <attr name="height" />
+        <!-- Specifies padding around all sides. -->
+        <attr name="padding" />
     </declare-styleable>
 
 </resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 99263d7..dee1cbc 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1315,6 +1315,7 @@
   <public type="attr" name="propertyName" />
   <public type="attr" name="ordering" />
   <public type="attr" name="fragment" />
+  <public type="attr" name="windowActionBarOverlay" />
 
   <public type="id" name="home" />
   <!-- Context menu ID for the "Select text..." menu item to switch to text
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index e0dc3a9..0e7509e 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -889,6 +889,8 @@
         <item name="android:background">@android:drawable/action_bar_background</item>
         <item name="android:displayOptions">useLogo</item>
         <item name="android:divider">@android:drawable/action_bar_divider</item>
+        <item name="android:height">56dip</item>
+        <item name="android:padding">3dip</item>
     </style>
 
     <style name="Widget.ActionButton">
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 8a6428b..9e4015b 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -2247,6 +2247,10 @@
             requestFeature(FEATURE_ACTION_BAR);
         }
 
+        if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionBarOverlay, false)) {
+            requestFeature(FEATURE_ACTION_BAR_OVERLAY);
+        }
+
         if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionModeOverlay, false)) {
             requestFeature(FEATURE_ACTION_MODE_OVERLAY);
         }
@@ -2333,7 +2337,11 @@
             if (mIsFloating) {
                 layoutResource = com.android.internal.R.layout.dialog_title;
             } else if ((features & (1 << FEATURE_ACTION_BAR)) != 0) {
-                layoutResource = com.android.internal.R.layout.screen_action_bar;
+                if ((features & (1 << FEATURE_ACTION_BAR_OVERLAY)) != 0) {
+                    layoutResource = com.android.internal.R.layout.screen_action_bar_overlay;
+                } else {
+                    layoutResource = com.android.internal.R.layout.screen_action_bar;
+                }
             } else {
                 layoutResource = com.android.internal.R.layout.screen_title;
             }