From 2df4538eb90b896be15eebc1d9adf1206131c8a3 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 16 Mar 2017 20:19:43 +0000 Subject: Revert "Update dialer to tap green cl 150332012." This reverts commit 1019500220518fb5fb023fcb7d370ab3cbf12307. Change-Id: Ie6e4f81a995fca7345132b596521b0bd06ceffb9 --- .../incallui/incall/impl/FakeDragAnimation.java | 62 ++++++++++++++++++++++ .../incallui/incall/impl/InCallFragment.java | 15 +++--- 2 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 java/com/android/incallui/incall/impl/FakeDragAnimation.java (limited to 'java/com/android/incallui/incall') diff --git a/java/com/android/incallui/incall/impl/FakeDragAnimation.java b/java/com/android/incallui/incall/impl/FakeDragAnimation.java new file mode 100644 index 000000000..c84c3c409 --- /dev/null +++ b/java/com/android/incallui/incall/impl/FakeDragAnimation.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.incallui.incall.impl; + +import android.animation.ValueAnimator; +import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.support.v4.view.ViewPager; +import android.support.v4.view.animation.FastOutSlowInInterpolator; + +/** + * An animation that controls the fake drag of a {@link ViewPager}. See {@link + * ViewPager#fakeDragBy(float)} for more details. + */ +public class FakeDragAnimation implements AnimatorUpdateListener { + + /** The view to animate. */ + private final ViewPager pager; + + private final ValueAnimator animator; + private int oldDragPosition; + + public FakeDragAnimation(ViewPager pager) { + this.pager = pager; + animator = ValueAnimator.ofInt(0, pager.getWidth()); + animator.addUpdateListener(this); + animator.setInterpolator(new FastOutSlowInInterpolator()); + animator.setDuration(600); + } + + public void start() { + animator.start(); + } + + @Override + public void onAnimationUpdate(ValueAnimator animation) { + if (!pager.isFakeDragging()) { + pager.beginFakeDrag(); + } + int dragPosition = (Integer) animation.getAnimatedValue(); + int dragOffset = dragPosition - oldDragPosition; + oldDragPosition = dragPosition; + pager.fakeDragBy(-dragOffset); + + if (animation.getAnimatedFraction() == 1) { + pager.endFakeDrag(); + } + } +} diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index b6ae4902a..3f31651a0 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -253,16 +253,13 @@ public class InCallFragment extends Fragment if (!stateRestored) { new Handler() .postDelayed( - new Runnable() { - @Override - public void run() { - // In order to prevent user confusion and educate the user on our UI, we animate - // the view pager to the button grid after 2 seconds show them when the UI is - // that they are more familiar with. - pager.setCurrentItem(adapter.getButtonGridPosition()); - } + () -> { + // In order to prevent user confusion and educate the user on our UI, we animate + // the view pager to the button grid after a short period to show them where the + // UI that they are more familiar with is located. + new FakeDragAnimation(pager).start(); }, - 2000); + 333); } } else { tabLayout.setVisibility(View.GONE); -- cgit v1.2.3