Drag up gesture improvements
- Use current velocity of finger for the animation, makes it feel
smoother.
- When flinging downwards, maximize the docked stack again to cancel
the gesture.
Change-Id: I284c851e2e418d21e890b9dfe983cfe63300fe10
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 4a3bb11..a9f570e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -16,6 +16,8 @@
package com.android.systemui.recents.views;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -27,6 +29,8 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewPropertyAnimator;
import android.view.WindowInsets;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -55,6 +59,8 @@
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.stackdivider.WindowManagerProxy;
+import com.android.systemui.statusbar.FlingAnimationUtils;
import java.util.ArrayList;
import java.util.List;
@@ -94,8 +100,10 @@
Rect mSystemInsets = new Rect();
+ final FlingAnimationUtils mFlingAnimationUtils;
+
public RecentsView(Context context) {
- super(context);
+ this(context, null);
}
public RecentsView(Context context, AttributeSet attrs) {
@@ -118,6 +126,7 @@
com.android.internal.R.interpolator.fast_out_linear_in);
mHistoryTransitionDuration = res.getInteger(R.integer.recents_history_transition_duration);
mTouchHandler = new RecentsViewTouchHandler(this);
+ mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f);
LayoutInflater inflater = LayoutInflater.from(context);
mHistoryButton = inflater.inflate(R.layout.recents_history_button, this, false);
@@ -511,7 +520,22 @@
}
public final void onBusEvent(DraggingInRecentsEndedEvent event) {
- animate().translationY(0f);
+ ViewPropertyAnimator animator = animate();
+ if (event.velocity > ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity()) {
+ animator.translationY(getHeight());
+ animator.withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ WindowManagerProxy.getInstance().maximizeDockedStack();
+ }
+ });
+ mFlingAnimationUtils.apply(animator, getTranslationY(), getHeight(), event.velocity);
+ } else {
+ animator.translationY(0f);
+ animator.setListener(null);
+ mFlingAnimationUtils.apply(animator, getTranslationY(), 0, event.velocity);
+ }
+ animator.start();
}
public final void onBusEvent(ShowHistoryEvent event) {
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 98f3f0c..93264ff 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -74,7 +74,7 @@
private final Rect mTmpRect = new Rect();
private final Rect mLastResizeRect = new Rect();
- private final WindowManagerProxy mWindowManagerProxy = new WindowManagerProxy();
+ private final WindowManagerProxy mWindowManagerProxy = WindowManagerProxy.getInstance();
private Interpolator mFastOutSlowInInterpolator;
private final Interpolator mTouchResponseInterpolator =
new PathInterpolator(0.3f, 0f, 0.1f, 1f);
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
index 0d3f803..58de5d5 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
@@ -37,6 +37,8 @@
private static final String TAG = "WindowManagerProxy";
+ private static final WindowManagerProxy sInstance = new WindowManagerProxy();
+
@GuardedBy("mResizeRect")
private final Rect mResizeRect = new Rect();
private final Rect mTmpRect = new Rect();
@@ -78,6 +80,13 @@
}
};
+ private WindowManagerProxy() {
+ }
+
+ public static WindowManagerProxy getInstance() {
+ return sInstance;
+ }
+
public void resizeDockedStack(Rect rect) {
synchronized (mResizeRect) {
mResizeRect.set(rect);