summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-04-06 16:32:06 -0700
committerAndrew Lee <anwlee@google.com>2015-04-06 16:47:36 -0700
commitc6fde8d1b9a4e586ca65b82e9911089a9da14508 (patch)
tree39359b89dc0980fe551ae3134aca74c470285e48 /src
parent2370e85a8203b4dc3722f2e013124e1e88d15b7c (diff)
Remove expand/collapse animations in the Call Log.
- Remove animation logic in CallLogFragment. - Remove expand listener from CallLogAdapter. + Update tests and constructor. This preemptively removes expand/collapse behavior. While this will result in a janky short-term experience, this is an incremental step in shifting to RecyclerView and the new "Card" UI. I figured it would be most efficient to delete it straight up, rather than coding in intermediate logic to work with the RecyclerView because it will be made obsolete by the Cards UI anyways. In the long run, expand/collapse animation behavior will be restored once the call log is migrated to RecyclerView and converted to Cards. Bug: 19372817 Change-Id: Icbdc7dcb9f2f2223456c29334c826d38917b087a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java42
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java153
-rw-r--r--src/com/android/dialerbind/ObjectFactory.java12
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 f5a3f62ed..78da6e8f0 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -96,12 +96,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;
@@ -193,15 +187,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;
@@ -500,14 +495,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;
}
@@ -671,30 +662,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 cc2ce9cc9..d6fb4566a 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";
@@ -96,12 +95,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 {
@@ -185,7 +178,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);
@@ -199,14 +192,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. */
@@ -515,140 +500,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) {