Added haptic feedback when swipe/fling up from an app in fullscreen

This includes swiping/fling up from a fullscreen app and swiping/fling
down a task to a fullscreen app.

Test: swipe up when app is fullscreen
Fixes: 80543530
Change-Id: Iee259284cc6d4fe1e784532f0822ffd38cdee280
This commit is contained in:
Matthew Ng
2018-05-31 14:21:34 -07:00
parent 5ac259c46e
commit c4b75abf3b
3 changed files with 27 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ import android.support.annotation.AnyThread;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewTreeObserver.OnDrawListener;
import android.view.WindowManager;
@@ -157,7 +158,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
public static final long MAX_SWIPE_DURATION = 350;
public static final long MIN_SWIPE_DURATION = 80;
private static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
private static final float SWIPE_DURATION_MULTIPLIER =
Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
@@ -204,6 +205,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
private boolean mWasLauncherAlreadyVisible;
private boolean mPassedOverviewThreshold;
private boolean mGestureStarted;
private int mLogAction = Touch.SWIPE;
private float mCurrentQuickScrubProgress;
@@ -570,6 +572,15 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
}
private void updateFinalShiftUi() {
final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
if (passed != mPassedOverviewThreshold) {
mPassedOverviewThreshold = passed;
if (mRecentsView != null) {
mRecentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
}
if (mLauncherTransitionController == null || mLauncherTransitionController
.getAnimationPlayer().isStarted()) {
return;
@@ -618,6 +629,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
mRecentsAnimationWrapper.setController(controller, targets);
setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
mPassedOverviewThreshold = false;
}
public void onRecentsAnimationCanceled() {

View File

@@ -23,6 +23,7 @@ import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId;
import static com.android.quickstep.WindowTransformSwipeHandler.MIN_PROGRESS_FOR_OVERVIEW;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -49,6 +50,7 @@ import android.text.TextPaint;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.SparseBooleanArray;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -88,6 +90,7 @@ import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.shared.system.TaskStackChangeListener;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
/**
@@ -1193,6 +1196,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
TaskViewDrawable drawable = new TaskViewDrawable(tv, this);
getOverlay().add(drawable);
final boolean[] passedOverviewThreshold = new boolean[] {false};
ObjectAnimator drawableAnim =
ObjectAnimator.ofFloat(drawable, TaskViewDrawable.PROGRESS, 1, 0);
drawableAnim.setInterpolator(LINEAR);
@@ -1203,6 +1207,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD
? targetSysUiFlags
: 0);
// Passing the threshold from taskview to fullscreen app will vibrate
final boolean passed = animator.getAnimatedFraction() >= MIN_PROGRESS_FOR_OVERVIEW;
if (passed != passedOverviewThreshold[0]) {
passedOverviewThreshold[0] = passed;
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
});
AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv,

View File

@@ -326,7 +326,7 @@ public abstract class AbstractStateChangeTouchController
}
});
mAtomicAnim.start();
mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
}