Merge "Make ActionBar scroll together with other lists"
diff --git a/res/layout/lists_fragment.xml b/res/layout/lists_fragment.xml
index f97b336..d75095a 100644
--- a/res/layout/lists_fragment.xml
+++ b/res/layout/lists_fragment.xml
@@ -18,13 +18,13 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:paddingTop="?android:attr/actionBarSize"
     android:animateLayoutChanges="true"
     android:id="@+id/lists_frame">
     <ListView
         android:id="@+id/shortcut_card_list"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:paddingTop="?android:attr/actionBarSize"
         android:background="@color/actionbar_background_color"
         android:clipToPadding="false"
         android:fadingEdge="none"
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index 88e5ce0..4a26d42 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -1,6 +1,7 @@
 package com.android.dialer.list;
 
 import android.animation.LayoutTransition;
+import android.app.ActionBar;
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.LoaderManager;
@@ -71,9 +72,11 @@
         public void showCallHistory();
     }
 
+    private ActionBar mActionBar;
     private ViewPager mViewPager;
     private ViewPagerTabs mViewPagerTabs;
     private ViewPagerAdapter mViewPagerAdapter;
+    private ListView mShortcutCardsListView;
     private SpeedDialFragment mSpeedDialFragment;
     private CallLogFragment mRecentsFragment;
     private AllContactsFragment mAllContactsFragment;
@@ -118,6 +121,40 @@
         }
     }
 
+    private PanelSlideListener mPanelSlideListener = new PanelSlideListener() {
+        @Override
+        public void onPanelSlide(View panel, float slideOffset) {
+            // For every 2 percent that the panel is slid upwards, clip 3 percent from each edge
+            // of the shortcut card, to achieve the animated effect of the shortcut card
+            // rapidly shrinking and disappearing from view when the panel is slid upwards.
+            // slideOffset is 1 when the shortcut card is fully exposed, and 0 when completely
+            // hidden.
+            float ratioCardHidden = (1 - slideOffset) * 1.5f;
+            if (mShortcutCardsListView.getCount() > 0) {
+                SwipeableShortcutCard v =
+                        (SwipeableShortcutCard) mShortcutCardsListView.getChildAt(0);
+                v.clipCard(ratioCardHidden);
+            }
+
+            if (mActionBar != null) {
+                // Amount of available space that is not being hidden by the bottom pane
+                final int topPaneHeight = (int) (slideOffset * mShortcutCardsListView.getHeight());
+
+                final int availableActionBarHeight =
+                        Math.min(mActionBar.getHeight(), topPaneHeight);
+                mActionBar.setHideOffset(mActionBar.getHeight() - availableActionBarHeight);
+            }
+        }
+
+        @Override
+        public void onPanelOpened(View panel) {
+        }
+
+        @Override
+        public void onPanelClosed(View panel) {
+        }
+    };
+
     public class ViewPagerAdapter extends FragmentPagerAdapter {
         public ViewPagerAdapter(FragmentManager fm) {
             super(fm);
@@ -194,7 +231,7 @@
         final SharedPreferences prefs = getActivity().getSharedPreferences(
                 DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE);
         mLastCallShortcutDate = prefs.getLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, 0);
-
+        mActionBar = getActivity().getActionBar();
         fetchCalls();
         mCallLogAdapter.setLoading(true);
     }
@@ -204,6 +241,7 @@
         // Wipe the cache to refresh the call shortcut item. This is not that expensive because
         // it only contains one item.
         mCallLogAdapter.invalidateCache();
+        mActionBar = null;
         super.onPause();
     }
 
@@ -226,11 +264,10 @@
         mViewPagerTabs.setViewPager(mViewPager);
         addOnPageChangeListener(mViewPagerTabs);
 
-        final ListView shortcutCardsListView =
-                (ListView) parentView.findViewById(R.id.shortcut_card_list);
-        shortcutCardsListView.setAdapter(mMergedAdapter);
+        mShortcutCardsListView = (ListView) parentView.findViewById(R.id.shortcut_card_list);
+        mShortcutCardsListView.setAdapter(mMergedAdapter);
 
-        setupPaneLayout((OverlappingPaneLayout) parentView, shortcutCardsListView);
+        setupPaneLayout((OverlappingPaneLayout) parentView);
 
         return parentView;
     }
@@ -298,34 +335,12 @@
         }
     }
 
-    private void setupPaneLayout(OverlappingPaneLayout paneLayout,
-            final ListView shortcutCardsListView) {
+    private void setupPaneLayout(OverlappingPaneLayout paneLayout) {
         // TODO: Remove the notion of a capturable view. The entire view be slideable, once
         // the framework better supports nested scrolling.
         paneLayout.setCapturableView(mViewPagerTabs);
         paneLayout.openPane();
-        paneLayout.setPanelSlideListener(new PanelSlideListener() {
-            @Override
-            public void onPanelSlide(View panel, float slideOffset) {
-                // For every 2 percent that the panel is slid upwards, clip 3 percent from each edge
-                // of the shortcut card, to achieve the animated effect of the shortcut card
-                // rapidly shrinking and disappearing from view when the panel is slid upwards.
-                float ratioCardHidden = (1 - slideOffset) * 1.5f;
-                if (shortcutCardsListView.getCount() > 0) {
-                    SwipeableShortcutCard v =
-                            (SwipeableShortcutCard) shortcutCardsListView.getChildAt(0);
-                    v.clipCard(ratioCardHidden);
-                }
-            }
-
-            @Override
-            public void onPanelOpened(View panel) {
-            }
-
-            @Override
-            public void onPanelClosed(View panel) {
-            }
-        });
+        paneLayout.setPanelSlideListener(mPanelSlideListener);
 
         LayoutTransition transition = paneLayout.getLayoutTransition();
         // Turns on animations for all types of layout changes so that they occur for