From c26986ec0380030e4938ea29a5535854e5b5bf9e Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 16 May 2014 15:39:29 -0700 Subject: Cleaning up shadowing and animation of call log expansion. Bug: 13962594 Change-Id: Ifbbf7fa75ffccfb893e6825774565c1e21e86c76 --- res/layout/call_log_fragment.xml | 1 + res/layout/call_log_list_item.xml | 7 ++-- res/values/animation_constants.xml | 12 +++++++ .../android/dialer/calllog/CallLogFragment.java | 37 ++++++++++++++++++++-- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml index 5cddbe749..7b6aa28bc 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 ff6b7ba86..9182bd758 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). --> - diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml index 4e4bc36e1..786306092 100644 --- a/res/values/animation_constants.xml +++ b/res/values/animation_constants.xml @@ -27,4 +27,16 @@ 0dip 10dip 20dip + + + 200 + + + 150 + + + 200 + + + 20 diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 2b2d43c82..6caa25cf3 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 @@ public class CallLogFragment extends ListFragment 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 @@ public class CallLogFragment extends ListFragment // 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 @@ public class CallLogFragment extends ListFragment @Override public void onAnimationEnd(Animator animation) { view.getLayoutParams().height = LayoutParams.WRAP_CONTENT; + if (!isExpand) { viewHolder.actionsView.setVisibility(View.GONE); } @@ -576,6 +604,11 @@ public class CallLogFragment extends ListFragment @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 -- cgit v1.2.3