Merge "Use new nested scrolling APIs"
diff --git a/res/drawable/shadow_fade_up.xml b/res/drawable/shadow_fade_up.xml
index e2d9934..e961c86 100644
--- a/res/drawable/shadow_fade_up.xml
+++ b/res/drawable/shadow_fade_up.xml
@@ -18,7 +18,7 @@
     android:shape="rectangle" >
     <gradient
         android:type="linear"
-        android:startColor="#66999999"
-        android:endColor="#00ffffff"
+        android:startColor="#1a000000"
+        android:endColor="@null"
         android:angle="90"/>
 </shape>
\ No newline at end of file
diff --git a/res/layout/dialpad_fragment.xml b/res/layout/dialpad_fragment.xml
index 33324d1..b2312ad 100644
--- a/res/layout/dialpad_fragment.xml
+++ b/res/layout/dialpad_fragment.xml
@@ -28,7 +28,7 @@
     <!-- Dialpad shadow -->
     <View
         android:layout_width="match_parent"
-        android:layout_height="3dp"
+        android:layout_height="10dp"
         android:background="@drawable/shadow_fade_up" />
     <include layout="@layout/dialpad_view" />
     <!-- "Dialpad chooser" UI, shown only when the user brings up the
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 38b8dae..70adb36 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -21,6 +21,7 @@
     <color name="dialtacts_secondary_text_color">#888888</color>
     <color name="dialer_accent_color">#eeff41</color>
 
+    <color name="contact_list_background_color">#f2f2f2</color>
 
     <!-- Color of the text describing an unconsumed missed call. -->
     <color name="call_log_missed_call_highlight_color">#FF0000</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a45d1e7..e541b0b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -57,7 +57,7 @@
         <item name="list_item_label_width_weight">3</item>
         <item name="contact_browser_list_padding_left">8dip</item>
         <item name="contact_browser_list_padding_right">0dip</item>
-        <item name="contact_browser_background">@android:color/transparent</item>
+        <item name="contact_browser_background">@color/contact_list_background_color</item>
         <item name="list_item_text_indent">@dimen/contact_browser_list_item_text_indent</item>
         <!-- CallLog -->
         <item name="call_log_primary_text_color">#000000</item>
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 7aaa897..7f9200e 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -16,10 +16,7 @@
 
 package com.android.dialer;
 
-import android.animation.Animator;
 import android.animation.LayoutTransition;
-import android.animation.Animator.AnimatorListener;
-import android.animation.AnimatorListenerAdapter;
 import android.app.ActionBar;
 import android.app.Activity;
 import android.app.Fragment;
@@ -133,6 +130,8 @@
 
     private static final int ANIMATION_DURATION = 250;
 
+    private RelativeLayout parentLayout;
+
     /**
      * Fragment containing the dialpad that slides into view
      */
@@ -154,7 +153,6 @@
     private ListsFragment mListsFragment;
 
     private View mFloatingActionButton;
-    private View mMenuButton;
     private View mDialpadButton;
     private View mDialButton;
 
@@ -203,6 +201,9 @@
     private DialerDatabaseHelper mDialerDatabaseHelper;
     private DragDropController mDragDropController;
 
+    private int mDialerBackgroundColor;
+    private int mContactListBackgroundColor;
+
     private class OverflowPopupMenu extends PopupMenu {
         public OverflowPopupMenu(Context context, View anchor) {
             super(context, anchor);
@@ -364,8 +365,13 @@
             mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
         }
 
-        RelativeLayout parent = (RelativeLayout) findViewById(R.id.dialtacts_mainlayout);
-        parent.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
+        parentLayout = (RelativeLayout) findViewById(R.id.dialtacts_mainlayout);
+        parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
+        parentLayout.setOnDragListener(new LayoutOnDragListener());
+
+        mDialerBackgroundColor = getResources().getColor(R.color.background_dialer_light);
+        mContactListBackgroundColor =
+                getResources().getColor(R.color.contact_list_background_color);
 
         mFragmentsFrame = findViewById(R.id.dialtacts_frame);
 
@@ -381,8 +387,6 @@
 
         mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
         SmartDialPrefix.initializeNanpSettings(this);
-
-        findViewById(R.id.dialtacts_mainlayout).setOnDragListener(new LayoutOnDragListener());
     }
 
     @Override
@@ -625,6 +629,7 @@
         if (mListsFragment != null && mListsFragment.isResumed() && mListsFragment.isVisible()) {
             // If the favorites fragment is showing, fade to blank.
             mFragmentsFrame.animate().alpha(0.0f);
+            parentLayout.setBackgroundColor(mContactListBackgroundColor);
         }
         getActionBar().hide();
         alignFloatingActionButtonMiddle();
@@ -650,6 +655,8 @@
 
         if (mListsFragment != null && mListsFragment.isVisible()) {
             mFragmentsFrame.animate().alpha(1.0f);
+            parentLayout.setBackgroundColor(mDialerBackgroundColor);
+
         }
         getActionBar().show();
         alignFloatingActionButtonByTab(mCurrentTabPosition);
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 407ba75..77e6d00 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -245,7 +245,14 @@
     private final View.OnClickListener mExpandCollapseListener = new View.OnClickListener() {
         @Override
         public void onClick(View v) {
-            expandOrCollapseActions((View) v.getParent().getParent());
+            final View callLogItem = (View) v.getParent().getParent();
+            final CallLogListItemViews views = (CallLogListItemViews) callLogItem.getTag();
+
+            // Hide or show the actions view.
+            boolean expanded = toggleExpansion(views.rowId);
+
+            // Trigger loading of the viewstub and visual expand or collapse.
+            expandOrCollapseActions(callLogItem, expanded);
             notifyDataSetChanged();
         }
     };
@@ -616,13 +623,7 @@
 
         // Restore expansion state of the row on rebind.  Inflate the actions ViewStub if required,
         // and set its visibility state accordingly.
-        if (isExpanded(rowId)) {
-            // Inflate the view stub if necessary, and wire up the event handlers.
-            inflateActionViewStub(view);
-            views.actionsView.setVisibility(View.VISIBLE);
-        } else if (views.actionsView != null) {
-            views.actionsView.setVisibility(View.GONE);
-        }
+        expandOrCollapseActions(view, isExpanded(rowId));
 
         // Lookup contacts with this number
         NumberWithCountryIso numberCountryIso = new NumberWithCountryIso(number, countryIso);
@@ -751,17 +752,15 @@
      * Expands or collapses the view containing the CALLBACK, VOICEMAIL and DELETE action buttons.
      *
      * @param callLogItem The call log entry parent view.
+     * @param isExpanded The new expansion state of the view.
      */
-    private void expandOrCollapseActions(View callLogItem) {
+    private void expandOrCollapseActions(View callLogItem, boolean isExpanded) {
         final CallLogListItemViews views = (CallLogListItemViews)callLogItem.getTag();
 
-        // Hide or show the actions view.
-        boolean expanded = toggleExpansion(views.rowId);
+        if (isExpanded) {
+            // Inflate the view stub if necessary, and wire up the event handlers.
+            inflateActionViewStub(callLogItem);
 
-        // Inflate the view stub if necessary, and wire up the event handlers.
-        inflateActionViewStub(callLogItem);
-
-        if (expanded) {
             views.actionsView.setVisibility(View.VISIBLE);
             callLogItem.setBackgroundColor(
                     callLogItem.getResources().getColor(R.color.background_dialer_light));
@@ -777,7 +776,12 @@
                     views.voicemailButtonView.requestAccessibilityFocus() ||
                     views.deleteButtonView.requestAccessibilityFocus();
         } else {
-            views.actionsView.setVisibility(View.GONE);
+            // When recycling a view, it is possible the actionsView ViewStub was previously
+            // inflated so we should hide it in this case.
+            if (views.actionsView != null ) {
+                views.actionsView.setVisibility(View.GONE);
+            }
+
             callLogItem.setBackgroundColor(
                     callLogItem.getResources().getColor(R.color.background_dialer_list_items));
             callLogItem.setElevation(0);