Cleaning up shadowing and animation of call log expansion.

Bug: 13962594
Change-Id: Ifbbf7fa75ffccfb893e6825774565c1e21e86c76
diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml
index 5cddbe7..7b6aa28 100644
--- a/res/layout/call_log_fragment.xml
+++ b/res/layout/call_log_fragment.xml
@@ -68,6 +68,7 @@
             android:layout_height="match_parent"
             android:fadingEdge="none"
             android:scrollbarStyle="outsideOverlay"
+            android:background="@color/background_dialer_list_items"
             android:divider="@null"
             android:nestedScrollingEnabled="true"
             android:clipChildren="false"
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index ff6b7ba..9182bd7 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -19,6 +19,7 @@
     class="com.android.dialer.calllog.CallLogListItemView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:paddingBottom="@dimen/call_log_outer_margin"
     android:id="@+id/call_log_list_item"
     android:orientation="vertical"
     android:clipChildren="false"
@@ -40,6 +41,7 @@
          information and the secondary action (call details / play voicemail). -->
     <LinearLayout
         android:id="@+id/call_log_row"
+        android:background="@color/background_dialer_list_items"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:baselineAligned="false"
@@ -53,7 +55,9 @@
             android:background="@drawable/call_log_background"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:padding="@dimen/call_log_outer_margin"
+            android:paddingLeft="@dimen/call_log_outer_margin"
+            android:paddingRight="@dimen/call_log_outer_margin"
+            android:paddingTop="@dimen/call_log_outer_margin"
             android:orientation="horizontal"
             android:gravity="center_vertical"
             android:focusable="true"
@@ -136,5 +140,4 @@
               android:layout="@layout/call_log_list_item_extra"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"/>
-
 </view>
diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml
index 4e4bc36..7863060 100644
--- a/res/values/animation_constants.xml
+++ b/res/values/animation_constants.xml
@@ -27,4 +27,16 @@
     <dimen name="min_swipe">0dip</dimen>
     <dimen name="min_vert">10dip</dimen>
     <dimen name="min_lock">20dip</dimen>
+
+    <!-- Expand/collapse of call log entry duration. -->
+    <integer name="call_log_expand_collapse_duration">200</integer>
+
+    <!-- Start delay for the fade in of the call log actions. -->
+    <integer name="call_log_actions_fade_start">150</integer>
+
+    <!-- Duration of the fade in of the call log actions. -->
+    <integer name="call_log_actions_fade_in_duration">200</integer>
+
+    <!-- Duration of the fade out of the call log actions. -->
+    <integer name="call_log_actions_fade_out_duration">20</integer>
 </resources>
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 2b2d43c..6caa25c 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -17,6 +17,8 @@
 package com.android.dialer.calllog;
 
 import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ArgbEvaluator;
 import android.animation.ValueAnimator;
 import android.animation.Animator.AnimatorListener;
 import android.app.Activity;
@@ -541,9 +543,33 @@
                 if (!isExpand) {
                     viewHolder.actionsView.setVisibility(View.VISIBLE);
                 }
+
+                // Set up the fade effect for the action buttons.
+                if (isExpand) {
+                    int fadeDuration = getResources().getInteger(
+                            R.integer.call_log_actions_fade_in_duration);
+                    int startDelay = getResources().getInteger(
+                            R.integer.call_log_actions_fade_start);
+                    // Start the fade in after the expansion has partly completed, otherwise it
+                    // will be mostly over before the expansion completes.
+                    viewHolder.actionsView.setAlpha(0f);
+                    viewHolder.actionsView.animate()
+                            .alpha(1f)
+                            .setStartDelay(startDelay)
+                            .setDuration(fadeDuration)
+                            .start();
+                } else {
+                    int fadeDuration = getResources().getInteger(
+                            R.integer.call_log_actions_fade_out_duration);
+                    viewHolder.actionsView.setAlpha(1f);
+                    viewHolder.actionsView.animate()
+                            .alpha(0f)
+                            .setDuration(fadeDuration)
+                            .start();
+                }
                 view.requestLayout();
 
-                // Set up the animator to animate the expansion.
+                // Set up the animator to animate the expansion and shadow depth.
                 ValueAnimator animator = isExpand ? ValueAnimator.ofFloat(0f, 1f)
                         : ValueAnimator.ofFloat(1f, 0f);
 
@@ -555,7 +581,8 @@
                         // For each value from 0 to 1, animate the various parts of the layout.
                         view.getLayoutParams().height =
                                 (int) (value * distance + baseHeight);
-                        view.setElevation(mExpandedItemElevation * value);
+                        viewHolder.callLogEntryView
+                                .setElevation(mExpandedItemElevation * value);
                         view.requestLayout();
                     }
                 });
@@ -564,6 +591,7 @@
                     @Override
                     public void onAnimationEnd(Animator animation) {
                         view.getLayoutParams().height = LayoutParams.WRAP_CONTENT;
+
                         if (!isExpand) {
                             viewHolder.actionsView.setVisibility(View.GONE);
                         }
@@ -576,6 +604,11 @@
                     @Override
                     public void onAnimationStart(Animator animation) { }
                 });
+
+                final int expandCollapseDuration = getResources().getInteger(
+                        R.integer.call_log_expand_collapse_duration);
+
+                animator.setDuration(expandCollapseDuration);
                 animator.start();
 
                 // Return false so this draw does not occur to prevent the final frame from