summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/incall
diff options
context:
space:
mode:
authorSailesh Nepal <sail@google.com>2017-03-16 20:19:43 +0000
committerSailesh Nepal <sail@google.com>2017-03-16 20:19:43 +0000
commit2df4538eb90b896be15eebc1d9adf1206131c8a3 (patch)
treeb54abbb51fb7d66e7755a1fbb5db023ff601090b /java/com/android/incallui/incall
parent1019500220518fb5fb023fcb7d370ab3cbf12307 (diff)
Revert "Update dialer to tap green cl 150332012."
This reverts commit 1019500220518fb5fb023fcb7d370ab3cbf12307. Change-Id: Ie6e4f81a995fca7345132b596521b0bd06ceffb9
Diffstat (limited to 'java/com/android/incallui/incall')
-rw-r--r--java/com/android/incallui/incall/impl/FakeDragAnimation.java62
-rw-r--r--java/com/android/incallui/incall/impl/InCallFragment.java15
2 files changed, 68 insertions, 9 deletions
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);