diff options
author | Andrew Lee <anwlee@google.com> | 2015-04-08 18:20:52 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-08 18:20:53 +0000 |
commit | 64c031c7529d98c53e4d917e3bb6e935bbdb6bd6 (patch) | |
tree | 2ca31847632d92542909230f4ef01194139dfc09 /src | |
parent | ff6adf9a746a6199729a9e227396929667496306 (diff) | |
parent | c6fde8d1b9a4e586ca65b82e9911089a9da14508 (diff) |
Merge "Remove expand/collapse animations in the Call Log."
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 42 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogFragment.java | 153 | ||||
-rw-r--r-- | src/com/android/dialerbind/ObjectFactory.java | 12 |
3 files changed, 12 insertions, 195 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 18854f51f..914e7baf7 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -95,12 +95,6 @@ public class CallLogAdapter extends GroupingListAdapter protected ContactInfoCache mContactInfoCache; /** - * Tracks the call log row which was previously expanded. Used so that the closure of a - * previously expanded call log entry can be animated on rebind. - */ - private long mPreviouslyExpanded = NONE_EXPANDED; - - /** * Tracks the currently expanded call log row. */ private long mCurrentlyExpanded = NONE_EXPANDED; @@ -192,15 +186,16 @@ public class CallLogAdapter extends GroupingListAdapter return true; } - public CallLogAdapter(Context context, CallFetcher callFetcher, - ContactInfoHelper contactInfoHelper, CallItemExpandedListener callItemExpandedListener, + public CallLogAdapter( + Context context, + CallFetcher callFetcher, + ContactInfoHelper contactInfoHelper, OnReportButtonClickListener onReportButtonClickListener) { super(context); mContext = context; mCallFetcher = callFetcher; mContactInfoHelper = contactInfoHelper; - mCallItemExpandedListener = callItemExpandedListener; mOnReportButtonClickListener = onReportButtonClickListener; @@ -499,14 +494,10 @@ public class CallLogAdapter extends GroupingListAdapter private boolean toggleExpansion(long rowId) { if (rowId == mCurrentlyExpanded) { // Collapsing currently expanded row. - mPreviouslyExpanded = NONE_EXPANDED; mCurrentlyExpanded = NONE_EXPANDED; - return false; } else { // Expanding a row (collapsing current expanded one). - - mPreviouslyExpanded = mCurrentlyExpanded; mCurrentlyExpanded = rowId; return true; } @@ -670,30 +661,5 @@ public class CallLogAdapter extends GroupingListAdapter mActionListener, mPhoneNumberUtilsWrapper, mCallLogViewsHelper); - - // Animate the expansion or collapse. - if (mCallItemExpandedListener != null) { - if (animate) { - mCallItemExpandedListener.onItemExpanded(view); - } - - // Animate the collapse of the previous item if it is still visible on screen. - if (mPreviouslyExpanded != NONE_EXPANDED) { - View previousItem = mCallItemExpandedListener.getViewForCallId(mPreviouslyExpanded); - - if (previousItem != null) { - ((CallLogListItemViews) previousItem.getTag()).expandOrCollapseActions( - false /* isExpanded */, - mOnReportButtonClickListener, - mActionListener, - mPhoneNumberUtilsWrapper, - mCallLogViewsHelper); - if (animate) { - mCallItemExpandedListener.onItemExpanded(previousItem); - } - } - mPreviouslyExpanded = NONE_EXPANDED; - } - } } } diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 2410b6079..904b9c542 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -62,8 +62,7 @@ import java.util.List; */ public class CallLogFragment extends ListFragment implements CallLogQueryHandler.Listener, CallLogAdapter.OnReportButtonClickListener, - CallLogAdapter.CallFetcher, - CallLogAdapter.CallItemExpandedListener { + CallLogAdapter.CallFetcher { private static final String TAG = "CallLogFragment"; private static final String REPORT_DIALOG_TAG = "report_dialog"; @@ -97,12 +96,6 @@ public class CallLogFragment extends ListFragment private boolean mCallLogFetched; private boolean mVoicemailStatusFetched; - private float mExpandedItemTranslationZ; - private int mFadeInDuration; - private int mFadeInStartDelay; - private int mFadeOutDuration; - private int mExpandCollapseDuration; - private final Handler mHandler = new Handler(); private class CustomContentObserver extends ContentObserver { @@ -186,7 +179,7 @@ public class CallLogFragment extends ListFragment String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), this, this); + new ContactInfoHelper(getActivity(), currentCountryIso), this); setListAdapter(mAdapter); mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), this, mLogLimit); @@ -200,14 +193,6 @@ public class CallLogFragment extends ListFragment Status.CONTENT_URI, true, mVoicemailStatusObserver); setHasOptionsMenu(true); fetchCalls(); - - mExpandedItemTranslationZ = - getResources().getDimension(R.dimen.call_log_expanded_translation_z); - mFadeInDuration = getResources().getInteger(R.integer.call_log_actions_fade_in_duration); - mFadeInStartDelay = getResources().getInteger(R.integer.call_log_actions_fade_start); - mFadeOutDuration = getResources().getInteger(R.integer.call_log_actions_fade_out_duration); - mExpandCollapseDuration = getResources().getInteger( - R.integer.call_log_expand_collapse_duration); } /** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */ @@ -521,140 +506,6 @@ public class CallLogFragment extends ListFragment ViewUtil.addBottomPaddingToListViewForFab(listView, getResources()); } - @Override - public void onItemExpanded(final View view) { - final int startingHeight = view.getHeight(); - final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); - final ViewTreeObserver observer = getListView().getViewTreeObserver(); - observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - // We don't want to continue getting called for every draw. - if (observer.isAlive()) { - observer.removeOnPreDrawListener(this); - } - // Calculate some values to help with the animation. - final int endingHeight = view.getHeight(); - final int distance = Math.abs(endingHeight - startingHeight); - final int baseHeight = Math.min(endingHeight, startingHeight); - final boolean isExpand = endingHeight > startingHeight; - - // Set the views back to the start state of the animation - view.getLayoutParams().height = startingHeight; - if (!isExpand) { - viewHolder.actionsView.setVisibility(View.VISIBLE); - } - viewHolder.expandVoicemailTranscriptionView(!isExpand); - - // Set up the fade effect for the action buttons. - if (isExpand) { - // 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(mFadeInStartDelay) - .setDuration(mFadeInDuration) - .start(); - } else { - viewHolder.actionsView.setAlpha(1f); - viewHolder.actionsView.animate() - .alpha(0f) - .setDuration(mFadeOutDuration) - .start(); - } - view.requestLayout(); - - // Set up the animator to animate the expansion and shadow depth. - ValueAnimator animator = isExpand ? ValueAnimator.ofFloat(0f, 1f) - : ValueAnimator.ofFloat(1f, 0f); - - // Figure out how much scrolling is needed to make the view fully visible. - final Rect localVisibleRect = new Rect(); - view.getLocalVisibleRect(localVisibleRect); - final int scrollingNeeded = localVisibleRect.top > 0 ? -localVisibleRect.top - : view.getMeasuredHeight() - localVisibleRect.height(); - final ListView listView = getListView(); - animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - - private int mCurrentScroll = 0; - - @Override - public void onAnimationUpdate(ValueAnimator animator) { - Float value = (Float) animator.getAnimatedValue(); - - // For each value from 0 to 1, animate the various parts of the layout. - view.getLayoutParams().height = (int) (value * distance + baseHeight); - float z = mExpandedItemTranslationZ * value; - viewHolder.callLogEntryView.setTranslationZ(z); - view.setTranslationZ(z); // WAR - view.requestLayout(); - - if (isExpand) { - if (listView != null) { - int scrollBy = (int) (value * scrollingNeeded) - mCurrentScroll; - listView.smoothScrollBy(scrollBy, /* duration = */ 0); - mCurrentScroll += scrollBy; - } - } - } - }); - // Set everything to their final values when the animation's done. - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - view.getLayoutParams().height = LayoutParams.WRAP_CONTENT; - - if (!isExpand) { - viewHolder.actionsView.setVisibility(View.GONE); - } else { - // This seems like it should be unnecessary, but without this, after - // navigating out of the activity and then back, the action view alpha - // is defaulting to the value (0) at the start of the expand animation. - viewHolder.actionsView.setAlpha(1); - } - viewHolder.expandVoicemailTranscriptionView(isExpand); - } - }); - - animator.setDuration(mExpandCollapseDuration); - animator.start(); - - // Return false so this draw does not occur to prevent the final frame from - // being drawn for the single frame before the animations start. - return false; - } - }); - } - - /** - * Retrieves the call log view for the specified call Id. If the view is not currently - * visible, returns null. - * - * @param callId The call Id. - * @return The call log view. - */ - @Override - public View getViewForCallId(long callId) { - ListView listView = getListView(); - - int firstPosition = listView.getFirstVisiblePosition(); - int lastPosition = listView.getLastVisiblePosition(); - - for (int position = 0; position <= lastPosition - firstPosition; position++) { - View view = listView.getChildAt(position); - - if (view != null) { - final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); - if (viewHolder != null && viewHolder.rowId == callId) { - return view; - } - } - } - - return null; - } - public void onBadDataReported(String number) { if (number == null) { return; diff --git a/src/com/android/dialerbind/ObjectFactory.java b/src/com/android/dialerbind/ObjectFactory.java index e5c39d078..dfacd3f6d 100644 --- a/src/com/android/dialerbind/ObjectFactory.java +++ b/src/com/android/dialerbind/ObjectFactory.java @@ -42,15 +42,15 @@ public class ObjectFactory { * @param context The context to use. * @param callFetcher Instance of call fetcher to use. * @param contactInfoHelper Instance of contact info helper class to use. - * @param isCallLog Is this call log adapter being used on the call log? * @return Instance of CallLogAdapter. */ - public static CallLogAdapter newCallLogAdapter(Context context, - CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, - CallItemExpandedListener callItemExpandedListener, + public static CallLogAdapter newCallLogAdapter( + Context context, + CallFetcher callFetcher, + ContactInfoHelper contactInfoHelper, OnReportButtonClickListener onReportButtonClickListener) { - return new CallLogAdapter(context, callFetcher, contactInfoHelper, - callItemExpandedListener, onReportButtonClickListener); + return new CallLogAdapter( + context, callFetcher, contactInfoHelper, onReportButtonClickListener); } public static DialogFragment getReportDialogFragment(String number) { |