Merge "Forward motion events to BackAnimation from EdgeBackGestureHandler." into tm-qpr-dev am: 6437eae845
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19386682 Change-Id: I16dd733f7c626bc70dfe9fd1be629fd1bc800a8f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -34,7 +34,6 @@ import android.view.ViewConfiguration
|
|||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import android.view.animation.PathInterpolator
|
import android.view.animation.PathInterpolator
|
||||||
import android.window.BackEvent
|
|
||||||
import androidx.dynamicanimation.animation.DynamicAnimation
|
import androidx.dynamicanimation.animation.DynamicAnimation
|
||||||
import androidx.dynamicanimation.animation.SpringForce
|
import androidx.dynamicanimation.animation.SpringForce
|
||||||
import com.android.internal.util.LatencyTracker
|
import com.android.internal.util.LatencyTracker
|
||||||
@@ -97,7 +96,6 @@ private val DECELERATE_INTERPOLATOR_SLOW = DecelerateInterpolator(0.7f)
|
|||||||
|
|
||||||
class BackPanelController private constructor(
|
class BackPanelController private constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
private var backAnimation: BackAnimation?,
|
|
||||||
private val windowManager: WindowManager,
|
private val windowManager: WindowManager,
|
||||||
private val viewConfiguration: ViewConfiguration,
|
private val viewConfiguration: ViewConfiguration,
|
||||||
@Main private val mainHandler: Handler,
|
@Main private val mainHandler: Handler,
|
||||||
@@ -124,7 +122,6 @@ class BackPanelController private constructor(
|
|||||||
fun create(context: Context, backAnimation: BackAnimation?): BackPanelController {
|
fun create(context: Context, backAnimation: BackAnimation?): BackPanelController {
|
||||||
val backPanelController = BackPanelController(
|
val backPanelController = BackPanelController(
|
||||||
context,
|
context,
|
||||||
backAnimation,
|
|
||||||
windowManager,
|
windowManager,
|
||||||
viewConfiguration,
|
viewConfiguration,
|
||||||
mainHandler,
|
mainHandler,
|
||||||
@@ -266,7 +263,6 @@ class BackPanelController private constructor(
|
|||||||
*/
|
*/
|
||||||
private fun updateConfiguration() {
|
private fun updateConfiguration() {
|
||||||
params.update(resources)
|
params.update(resources)
|
||||||
updateBackAnimationSwipeThresholds()
|
|
||||||
mView.updateArrowPaint(params.arrowThickness)
|
mView.updateArrowPaint(params.arrowThickness)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,13 +294,6 @@ class BackPanelController private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onMotionEvent(event: MotionEvent) {
|
override fun onMotionEvent(event: MotionEvent) {
|
||||||
backAnimation?.onBackMotion(
|
|
||||||
event.x,
|
|
||||||
event.y,
|
|
||||||
event.actionMasked,
|
|
||||||
if (mView.isLeftPanel) BackEvent.EDGE_LEFT else BackEvent.EDGE_RIGHT
|
|
||||||
)
|
|
||||||
|
|
||||||
velocityTracker!!.addMovement(event)
|
velocityTracker!!.addMovement(event)
|
||||||
when (event.actionMasked) {
|
when (event.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
@@ -483,18 +472,6 @@ class BackPanelController private constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setBackAnimation(backAnimation: BackAnimation?) {
|
|
||||||
this.backAnimation = backAnimation
|
|
||||||
updateBackAnimationSwipeThresholds()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateBackAnimationSwipeThresholds() {
|
|
||||||
backAnimation?.setSwipeThresholds(
|
|
||||||
params.swipeTriggerThreshold,
|
|
||||||
fullyStretchedThreshold
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
cancelFailsafe()
|
cancelFailsafe()
|
||||||
windowManager.removeView(mView)
|
windowManager.removeView(mView)
|
||||||
@@ -567,7 +544,6 @@ class BackPanelController private constructor(
|
|||||||
totalTouchDelta = 0f
|
totalTouchDelta = 0f
|
||||||
vibrationTime = 0
|
vibrationTime = 0
|
||||||
cancelFailsafe()
|
cancelFailsafe()
|
||||||
backAnimation?.setTriggerBack(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateYPosition(touchY: Float) {
|
private fun updateYPosition(touchY: Float) {
|
||||||
@@ -580,7 +556,6 @@ class BackPanelController private constructor(
|
|||||||
override fun setDisplaySize(displaySize: Point) {
|
override fun setDisplaySize(displaySize: Point) {
|
||||||
this.displaySize.set(displaySize.x, displaySize.y)
|
this.displaySize.set(displaySize.x, displaySize.y)
|
||||||
fullyStretchedThreshold = min(displaySize.x.toFloat(), params.swipeProgressThreshold)
|
fullyStretchedThreshold = min(displaySize.x.toFloat(), params.swipeProgressThreshold)
|
||||||
updateBackAnimationSwipeThresholds()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -664,7 +639,6 @@ class BackPanelController private constructor(
|
|||||||
updateRestingArrowDimens(animated = true, currentState)
|
updateRestingArrowDimens(animated = true, currentState)
|
||||||
}
|
}
|
||||||
GestureState.ACTIVE -> {
|
GestureState.ACTIVE -> {
|
||||||
backAnimation?.setTriggerBack(true)
|
|
||||||
updateRestingArrowDimens(animated = true, currentState)
|
updateRestingArrowDimens(animated = true, currentState)
|
||||||
// Vibrate the first time we transition to ACTIVE
|
// Vibrate the first time we transition to ACTIVE
|
||||||
if (!hasHapticPlayed) {
|
if (!hasHapticPlayed) {
|
||||||
@@ -674,7 +648,6 @@ class BackPanelController private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GestureState.INACTIVE -> {
|
GestureState.INACTIVE -> {
|
||||||
backAnimation?.setTriggerBack(false)
|
|
||||||
updateRestingArrowDimens(animated = true, currentState)
|
updateRestingArrowDimens(animated = true, currentState)
|
||||||
}
|
}
|
||||||
GestureState.FLUNG -> playFlingBackAnimation()
|
GestureState.FLUNG -> playFlingBackAnimation()
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.window.BackEvent;
|
||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.internal.policy.GestureNavigationSettingsObserver;
|
import com.android.internal.policy.GestureNavigationSettingsObserver;
|
||||||
@@ -208,6 +209,10 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
private float mBottomGestureHeight;
|
private float mBottomGestureHeight;
|
||||||
// The slop to distinguish between horizontal and vertical motion
|
// The slop to distinguish between horizontal and vertical motion
|
||||||
private float mTouchSlop;
|
private float mTouchSlop;
|
||||||
|
// The threshold for triggering back
|
||||||
|
private float mBackSwipeTriggerThreshold;
|
||||||
|
// The threshold for back swipe full progress.
|
||||||
|
private float mBackSwipeProgressThreshold;
|
||||||
// Duration after which we consider the event as longpress.
|
// Duration after which we consider the event as longpress.
|
||||||
private final int mLongPressTimeout;
|
private final int mLongPressTimeout;
|
||||||
private int mStartingQuickstepRotation = -1;
|
private int mStartingQuickstepRotation = -1;
|
||||||
@@ -274,6 +279,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
Log.d(DEBUG_MISSING_GESTURE_TAG, "Triggered back: down="
|
Log.d(DEBUG_MISSING_GESTURE_TAG, "Triggered back: down="
|
||||||
+ sendDown + ", up=" + sendUp);
|
+ sendDown + ", up=" + sendUp);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mBackAnimation.setTriggerBack(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x,
|
mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x,
|
||||||
@@ -285,6 +292,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelBack() {
|
public void cancelBack() {
|
||||||
|
if (mBackAnimation != null) {
|
||||||
|
mBackAnimation.setTriggerBack(false);
|
||||||
|
}
|
||||||
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE);
|
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE);
|
||||||
mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x,
|
mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x,
|
||||||
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
|
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
|
||||||
@@ -406,6 +416,11 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
final float backGestureSlop = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
|
final float backGestureSlop = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
SystemUiDeviceConfigFlags.BACK_GESTURE_SLOP_MULTIPLIER, 0.75f);
|
SystemUiDeviceConfigFlags.BACK_GESTURE_SLOP_MULTIPLIER, 0.75f);
|
||||||
mTouchSlop = mViewConfiguration.getScaledTouchSlop() * backGestureSlop;
|
mTouchSlop = mViewConfiguration.getScaledTouchSlop() * backGestureSlop;
|
||||||
|
mBackSwipeTriggerThreshold = res.getDimension(
|
||||||
|
R.dimen.navigation_edge_action_drag_threshold);
|
||||||
|
mBackSwipeProgressThreshold = res.getDimension(
|
||||||
|
R.dimen.navigation_edge_action_progress_threshold);
|
||||||
|
updateBackAnimationThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNavigationBarOverlayExcludeRegion(Rect exclude) {
|
public void updateNavigationBarOverlayExcludeRegion(Rect exclude) {
|
||||||
@@ -748,6 +763,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
MotionEvent cancelEv = MotionEvent.obtain(ev);
|
MotionEvent cancelEv = MotionEvent.obtain(ev);
|
||||||
cancelEv.setAction(MotionEvent.ACTION_CANCEL);
|
cancelEv.setAction(MotionEvent.ACTION_CANCEL);
|
||||||
mEdgeBackPlugin.onMotionEvent(cancelEv);
|
mEdgeBackPlugin.onMotionEvent(cancelEv);
|
||||||
|
dispatchToBackAnimation(cancelEv);
|
||||||
cancelEv.recycle();
|
cancelEv.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,6 +810,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
if (mAllowGesture) {
|
if (mAllowGesture) {
|
||||||
mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge);
|
mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge);
|
||||||
mEdgeBackPlugin.onMotionEvent(ev);
|
mEdgeBackPlugin.onMotionEvent(ev);
|
||||||
|
dispatchToBackAnimation(ev);
|
||||||
}
|
}
|
||||||
if (mLogGesture) {
|
if (mLogGesture) {
|
||||||
mDownPoint.set(ev.getX(), ev.getY());
|
mDownPoint.set(ev.getX(), ev.getY());
|
||||||
@@ -867,12 +884,23 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
if (mAllowGesture) {
|
if (mAllowGesture) {
|
||||||
// forward touch
|
// forward touch
|
||||||
mEdgeBackPlugin.onMotionEvent(ev);
|
mEdgeBackPlugin.onMotionEvent(ev);
|
||||||
|
dispatchToBackAnimation(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mProtoTracer.scheduleFrameUpdate();
|
mProtoTracer.scheduleFrameUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dispatchToBackAnimation(MotionEvent event) {
|
||||||
|
if (mBackAnimation != null) {
|
||||||
|
mBackAnimation.onBackMotion(
|
||||||
|
event.getX(),
|
||||||
|
event.getY(),
|
||||||
|
event.getActionMasked(),
|
||||||
|
mIsOnLeftEdge ? BackEvent.EDGE_LEFT : BackEvent.EDGE_RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateDisabledForQuickstep(Configuration newConfig) {
|
private void updateDisabledForQuickstep(Configuration newConfig) {
|
||||||
int rotation = newConfig.windowConfiguration.getRotation();
|
int rotation = newConfig.windowConfiguration.getRotation();
|
||||||
mDisabledForQuickstep = mStartingQuickstepRotation > -1 &&
|
mDisabledForQuickstep = mStartingQuickstepRotation > -1 &&
|
||||||
@@ -900,6 +928,16 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
if (mEdgeBackPlugin != null) {
|
if (mEdgeBackPlugin != null) {
|
||||||
mEdgeBackPlugin.setDisplaySize(mDisplaySize);
|
mEdgeBackPlugin.setDisplaySize(mDisplaySize);
|
||||||
}
|
}
|
||||||
|
updateBackAnimationThresholds();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBackAnimationThresholds() {
|
||||||
|
if (mBackAnimation == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mBackAnimation.setSwipeThresholds(
|
||||||
|
mBackSwipeTriggerThreshold,
|
||||||
|
Math.min(mDisplaySize.x, mBackSwipeProgressThreshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sendEvent(int action, int code) {
|
private boolean sendEvent(int action, int code) {
|
||||||
@@ -979,13 +1017,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
|
|||||||
|
|
||||||
public void setBackAnimation(BackAnimation backAnimation) {
|
public void setBackAnimation(BackAnimation backAnimation) {
|
||||||
mBackAnimation = backAnimation;
|
mBackAnimation = backAnimation;
|
||||||
if (mEdgeBackPlugin != null) {
|
updateBackAnimationThresholds();
|
||||||
if (mEdgeBackPlugin instanceof NavigationBarEdgePanel) {
|
|
||||||
((NavigationBarEdgePanel) mEdgeBackPlugin).setBackAnimation(backAnimation);
|
|
||||||
} else if (mEdgeBackPlugin instanceof BackPanelController) {
|
|
||||||
((BackPanelController) mEdgeBackPlugin).setBackAnimation(backAnimation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user