diff options
author | Yorke Lee <yorkelee@google.com> | 2015-03-27 22:27:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-27 22:27:36 +0000 |
commit | 1143f3077c8d1d7ca3ff162723d75ead0a3f780e (patch) | |
tree | 16f33f8b3a02cccf201a89c4160201f9184fe1bb | |
parent | b47803f0420649d495db546944d42849225712e0 (diff) | |
parent | 7e9763e4b3806c9edaf3df4f59a3d5a6452a361c (diff) |
Merge "Fix some jank during shrink animation"
4 files changed, 46 insertions, 8 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 9a5228f7e..d8e76c7b5 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -22,6 +22,7 @@ import com.android.contacts.common.testing.NeededForTesting; import android.content.Context; import android.net.Uri; import android.os.Bundle; +import android.os.Trace; import android.telecom.CallProperties; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; @@ -212,6 +213,7 @@ public class Call { } private void update() { + Trace.beginSection("Update"); int oldState = getState(); updateFromTelecommCall(); if (oldState != getState() && getState() == Call.State.DISCONNECTED) { @@ -219,6 +221,7 @@ public class Call { } else { CallList.getInstance().onUpdate(this); } + Trace.endSection(); } private void updateFromTelecommCall() { diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 94e4ef161..af588767d 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -21,6 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; +import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; @@ -110,6 +112,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private Animation mPulseAnimation; private int mVideoAnimationDuration; + // Whether or not the call card is currently in the process of an animation + private boolean mIsAnimating; private MaterialPalette mCurrentThemeColors; @@ -601,6 +605,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mInCallMessageLabel.setVisibility(View.VISIBLE); } + public boolean isAnimating() { + return mIsAnimating; + } + private void showInternetCallLabel(boolean show) { if (show) { final String label = getView().getContext().getString( @@ -864,6 +872,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr final LayoutTransition transition = mPrimaryCallInfo.getLayoutTransition(); transition.disableTransitionType(LayoutTransition.CHANGING); + mIsAnimating = true; + observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { @@ -892,6 +902,13 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallTypeLabel.setAlpha(0); mCallNumberAndLabel.setAlpha(0); + assignTranslateAnimation(mCallStateLabel, 1); + assignTranslateAnimation(mCallStateIcon, 1); + assignTranslateAnimation(mPrimaryName, 2); + assignTranslateAnimation(mCallNumberAndLabel, 3); + assignTranslateAnimation(mCallTypeLabel, 4); + assignTranslateAnimation(mCallButtonsContainer, 5); + final Animator animator = getShrinkAnimator(parent.getHeight(), originalHeight); animator.addListener(new AnimatorListenerAdapter() { @@ -900,6 +917,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPrimaryCallCardContainer.setTag(R.id.view_tag_callcard_actual_height, null); setViewStatePostAnimation(listener); + mIsAnimating = false; + InCallPresenter.getInstance().onShrinkAnimationComplete(); } }); animator.start(); @@ -988,19 +1007,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr * and then translated upwards together with the scrim. */ private Animator getShrinkAnimator(int startHeight, int endHeight) { - final Animator shrinkAnimator = + final ObjectAnimator shrinkAnimator = ObjectAnimator.ofInt(mPrimaryCallCardContainer, "bottom", startHeight, endHeight); shrinkAnimator.setDuration(mShrinkAnimationDuration); shrinkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - assignTranslateAnimation(mCallStateLabel, 1); - assignTranslateAnimation(mCallStateIcon, 1); - assignTranslateAnimation(mPrimaryName, 2); - assignTranslateAnimation(mCallNumberAndLabel, 3); - assignTranslateAnimation(mCallTypeLabel, 4); - assignTranslateAnimation(mCallButtonsContainer, 5); - mFloatingActionButton.setEnabled(true); } }); @@ -1009,6 +1021,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } private void assignTranslateAnimation(View view, int offset) { + view.setLayerType(View.LAYER_TYPE_HARDWARE, null); + view.buildLayer(); view.setTranslationY(mTranslationOffset * offset); view.animate().translationY(0).alpha(1).withLayer() .setDuration(mShrinkAnimationDuration).setInterpolator(AnimUtils.EASE_IN); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index db43b1657..111d48d2e 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -21,6 +21,7 @@ import com.google.common.base.Preconditions; import android.os.Handler; import android.os.Message; +import android.os.Trace; import android.telecom.DisconnectCause; import android.telecom.Phone; @@ -71,12 +72,14 @@ public class CallList implements InCallPhoneListener { private Phone.Listener mPhoneListener = new Phone.Listener() { @Override public void onCallAdded(Phone phone, android.telecom.Call telecommCall) { + Trace.beginSection("onCallAdded"); Call call = new Call(telecommCall); if (call.getState() == Call.State.INCOMING) { onIncoming(call, call.getCannedSmsResponses()); } else { onUpdate(call); } + Trace.endSection(); } @Override public void onCallRemoved(Phone phone, android.telecom.Call telecommCall) { @@ -139,8 +142,10 @@ public class CallList implements InCallPhoneListener { * Called when a single call has changed. */ public void onUpdate(Call call) { + Trace.beginSection("onUpdate"); onUpdateCall(call); notifyGenericListeners(); + Trace.endSection(); } public void notifyCallUpdateListeners(Call call) { diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 225b1a259..b98eadaa1 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -388,6 +388,8 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, } } + private boolean mAwaitingCallListUpdate = false; + /** * Called when there is a change to the call list. * Sets the In-Call state for the entire in-call app based on the information it gets from @@ -396,9 +398,17 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, */ @Override public void onCallListChange(CallList callList) { + if (mInCallActivity != null && mInCallActivity.getCallCardFragment() != null && + mInCallActivity.getCallCardFragment().isAnimating()) { + mAwaitingCallListUpdate = true; + return; + } if (callList == null) { return; } + + mAwaitingCallListUpdate = false; + InCallState newState = getPotentialStateFromCallList(callList); InCallState oldState = mInCallState; newState = startOrFinishUi(newState); @@ -514,6 +524,12 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener, } } + public void onShrinkAnimationComplete() { + if (mAwaitingCallListUpdate) { + onCallListChange(mCallList); + } + } + public void addIncomingCallListener(IncomingCallListener listener) { Preconditions.checkNotNull(listener); mIncomingCallListeners.add(listener); |