From 96d7d2247bd36938133d4b9cd540f75ddfb31184 Mon Sep 17 00:00:00 2001 From: wangqi Date: Tue, 20 Mar 2018 10:37:13 -0700 Subject: Fix animation of first time showing dialpad FAB. In order to correctly show animation, we have to ensure: 1. fab.scaleIn() is not called before dialpad is slide up. 2. fab is invisible before scaleIn is called. Caveat: This change is not tested on old UI (DialtactsActivity) since it's deprecated. Test: manual PiperOrigin-RevId: 189765153 Change-Id: Iada96b2789f96ca1612ae2048020a649f8b57b6b --- .../dialer/dialpadview/DialpadFragment.java | 52 +++++++++---------- .../res/layout-land/dialpad_fragment.xml | 59 +++++++++++----------- .../dialpadview/res/layout/dialpad_fragment.xml | 1 + 3 files changed, 56 insertions(+), 56 deletions(-) (limited to 'java/com/android/dialer/dialpadview') diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java index 578f35e09..833b91f59 100644 --- a/java/com/android/dialer/dialpadview/DialpadFragment.java +++ b/java/com/android/dialer/dialpadview/DialpadFragment.java @@ -83,7 +83,6 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; -import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.UiAction; import com.android.dialer.oem.MotorolaUtils; @@ -648,6 +647,14 @@ public class DialpadFragment extends Fragment LogUtil.i("DialpadFragment.onStart", "first launch: %b", firstLaunch); Trace.beginSection(TAG + " onStart"); super.onStart(); + Resources res = getResources(); + int iconId = R.drawable.quantum_ic_call_vd_theme_24; + if (MotorolaUtils.isWifiCallingAvailable(getContext())) { + iconId = R.drawable.ic_wifi_calling; + } + floatingActionButtonController.changeIcon( + getContext(), iconId, res.getString(R.string.description_dial_button)); + // if the mToneGenerator creation fails, just continue without it. It is // a local audio signal, and is not as important as the dtmf tone itself. final long start = System.currentTimeMillis(); @@ -676,14 +683,6 @@ public class DialpadFragment extends Fragment Trace.beginSection(TAG + " onResume"); super.onResume(); - Resources res = getResources(); - int iconId = R.drawable.quantum_ic_call_vd_theme_24; - if (MotorolaUtils.isWifiCallingAvailable(getContext())) { - iconId = R.drawable.ic_wifi_calling; - } - floatingActionButtonController.changeIcon( - getContext(), iconId, res.getString(R.string.description_dial_button)); - dialpadQueryListener = FragmentUtils.getParentUnsafe(this, OnDialpadQueryChangedListener.class); final StopWatch stopWatch = StopWatch.start("Dialpad.onResume"); @@ -1247,19 +1246,14 @@ public class DialpadFragment extends Fragment if (dialpadView != null) { LogUtil.i("DialpadFragment.showDialpadChooser", "mDialpadView not null"); dialpadView.setVisibility(View.VISIBLE); - floatingActionButtonController.scaleIn(); + if (isDialpadSlideUp()) { + floatingActionButtonController.scaleIn(); + } } else { LogUtil.i("DialpadFragment.showDialpadChooser", "mDialpadView null"); digits.setVisibility(View.VISIBLE); } - // mFloatingActionButtonController must also be 'scaled in', in order to be visible after - // 'scaleOut()' hidden method. - if (!floatingActionButtonController.isVisible()) { - // Just call 'scaleIn()' method if the mFloatingActionButtonController was not already - // previously visible. - floatingActionButtonController.scaleIn(); - } dialpadChooser.setVisibility(View.GONE); } } @@ -1475,18 +1469,8 @@ public class DialpadFragment extends Fragment if (animate) { dialpadView.animateShow(); } - ThreadUtil.getUiThreadHandler() - .postDelayed( - () -> { - if (!isDialpadChooserVisible()) { - floatingActionButtonController.scaleIn(); - } - }, - animate ? dialpadSlideInDuration : 0); FragmentUtils.getParentUnsafe(this, DialpadListener.class).onDialpadShown(); digits.requestFocus(); - } else if (hidden) { - floatingActionButtonController.scaleOut(); } } @@ -1549,6 +1533,7 @@ public class DialpadFragment extends Fragment slideDown.setAnimationListener(listener); slideDown.setDuration(animate ? dialpadSlideInDuration : 0); getView().startAnimation(slideDown); + floatingActionButtonController.scaleOut(); } /** Animate the dialpad up onto the screen. */ @@ -1564,6 +1549,19 @@ public class DialpadFragment extends Fragment Animation slideUp = AnimationUtils.loadAnimation(getContext(), animation); slideUp.setInterpolator(AnimUtils.EASE_IN); slideUp.setDuration(animate ? dialpadSlideInDuration : 0); + slideUp.setAnimationListener( + new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) {} + + @Override + public void onAnimationEnd(Animation animation) { + floatingActionButtonController.scaleIn(); + } + + @Override + public void onAnimationRepeat(Animation animation) {} + }); getView().startAnimation(slideUp); } diff --git a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_fragment.xml b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_fragment.xml index 6389853d9..a2fbbab18 100644 --- a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_fragment.xml +++ b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_fragment.xml @@ -20,33 +20,33 @@ android:layout_height="wrap_content"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + android:id="@+id/spacer" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="4" + android:background="#00000000"/> + android:layout_width="@dimen/shadow_length" + android:layout_height="match_parent" + android:background="@drawable/shadow_fade_left"/> + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="6"> + layout="@layout/dialpad_view" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + android:id="@+id/dialpadChooser" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/background_dialer_light" + android:visibility="gone"/> + android:id="@+id/dialpad_floating_action_button_margin_bottom" + android:layout_width="match_parent" + android:layout_height="@dimen/floating_action_button_margin_bottom" + android:layout_alignParentBottom="true"/> + android:src="@drawable/quantum_ic_call_white_24" + android:visibility="invisible" + app:backgroundTint="@color/dialpad_fab_green" + app:elevation="@dimen/floating_action_button_translation_z"/> diff --git a/java/com/android/dialer/dialpadview/res/layout/dialpad_fragment.xml b/java/com/android/dialer/dialpadview/res/layout/dialpad_fragment.xml index 2e6b6eca0..4a8ac0786 100644 --- a/java/com/android/dialer/dialpadview/res/layout/dialpad_fragment.xml +++ b/java/com/android/dialer/dialpadview/res/layout/dialpad_fragment.xml @@ -67,6 +67,7 @@ android:contentDescription="@string/description_dial_button" android:src="@drawable/quantum_ic_call_vd_theme_24" android:tint="#ffffff" + android:visibility="invisible" app:backgroundTint="@color/dialpad_fab_green" app:colorControlNormal="#ffffff" app:elevation="@dimen/floating_action_button_translation_z"/> -- cgit v1.2.3