diff options
Diffstat (limited to 'java/com/android/dialer/app/widget')
-rw-r--r-- | java/com/android/dialer/app/widget/ActionBarController.java | 29 | ||||
-rw-r--r-- | java/com/android/dialer/app/widget/SearchEditTextLayout.java | 9 |
2 files changed, 30 insertions, 8 deletions
diff --git a/java/com/android/dialer/app/widget/ActionBarController.java b/java/com/android/dialer/app/widget/ActionBarController.java index d0eb326ab..c1b4cc2b4 100644 --- a/java/com/android/dialer/app/widget/ActionBarController.java +++ b/java/com/android/dialer/app/widget/ActionBarController.java @@ -49,6 +49,20 @@ public class ActionBarController { } }; + private final AnimationCallback mFadeInCallback = + new AnimationCallback() { + @Override + public void onAnimationEnd() { + slideActionBar(false /* slideUp */, false /* animate */); + } + + @Override + public void onAnimationCancel() { + slideActionBar(false /* slideUp */, false /* animate */); + } + }; + private ValueAnimator mAnimator; + public ActionBarController(ActivityUi activityUi, SearchEditTextLayout searchBox) { mActivityUi = activityUi; mSearchBox = searchBox; @@ -107,7 +121,7 @@ public class ActionBarController { } slideActionBar(false /* slideUp */, true /* animate */); } else { - mSearchBox.fadeIn(); + mSearchBox.fadeIn(mFadeInCallback); } } } @@ -129,14 +143,18 @@ public class ActionBarController { public void slideActionBar(boolean slideUp, boolean animate) { LogUtil.d("ActionBarController.slidingActionBar", "up: %b, animate: %b", slideUp, animate); + if (mAnimator != null && mAnimator.isRunning()) { + mAnimator.cancel(); + mAnimator.removeAllUpdateListeners(); + } if (animate) { - ValueAnimator animator = slideUp ? ValueAnimator.ofFloat(0, 1) : ValueAnimator.ofFloat(1, 0); - animator.addUpdateListener( + mAnimator = slideUp ? ValueAnimator.ofFloat(0, 1) : ValueAnimator.ofFloat(1, 0); + mAnimator.addUpdateListener( animation -> { final float value = (float) animation.getAnimatedValue(); setHideOffset((int) (mActivityUi.getActionBarHeight() * value)); }); - animator.start(); + mAnimator.start(); } else { setHideOffset(slideUp ? mActivityUi.getActionBarHeight() : 0); } @@ -147,8 +165,7 @@ public class ActionBarController { mSearchBox.animate().alpha(alphaValue).start(); } - public void setHideOffset(int offset) { - mIsActionBarSlidUp = offset >= mActivityUi.getActionBarHeight(); + private void setHideOffset(int offset) { mActivityUi.setActionBarHideOffset(offset); } diff --git a/java/com/android/dialer/app/widget/SearchEditTextLayout.java b/java/com/android/dialer/app/widget/SearchEditTextLayout.java index be850f9a0..f83c48288 100644 --- a/java/com/android/dialer/app/widget/SearchEditTextLayout.java +++ b/java/com/android/dialer/app/widget/SearchEditTextLayout.java @@ -95,11 +95,11 @@ public class SearchEditTextLayout extends FrameLayout { // Convert a long click into a click to expand the search box, and then long click on the // search view. This accelerates the long-press scenario for copy/paste. - mCollapsedSearchBox.setOnLongClickListener( + mCollapsed.setOnLongClickListener( new OnLongClickListener() { @Override public boolean onLongClick(View view) { - mCollapsedSearchBox.performClick(); + mCollapsed.performClick(); mSearchView.performLongClick(); return false; } @@ -188,6 +188,11 @@ public class SearchEditTextLayout extends FrameLayout { mIsFadedOut = false; } + public void fadeIn(AnimUtils.AnimationCallback callback) { + AnimUtils.fadeIn(this, ANIMATION_DURATION, AnimUtils.NO_DELAY, callback); + mIsFadedOut = false; + } + public void setVisible(boolean visible) { if (visible) { setAlpha(1); |