添加手势注释

This commit is contained in:
MoXiang committed 2025-11-18 23:49:25 +08:00
1 parent bbf3dbb572
commit 654821d620
4 files changed
+18 -12

No files matched your search

@@ -704,7 +704,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
? 0
: (mUnstashedHeight - mStashedHeight);
if (!supportsVisualStashing()) {
if (!supportsVisualStashing()) {// 三键导航
// Just hide/show the icons and background instead of stashing into a handle.
mAnimator.play(mIconAlphaForStash.animateToValue(isStashed ? 0 : 1)
.setDuration(duration));
@@ -724,7 +724,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
return;
}
if (mActivity.isTransientTaskbar()) {
if (mActivity.isTransientTaskbar()) {// 非手机设备,手势模式
createTransientAnimToIsStashed(mAnimator, isStashed, duration,
shouldDelayBackground, animationType);
} else {
@@ -792,10 +792,10 @@ object InputConsumerUtils {
event: MotionEvent,
): InputConsumer where T : RecentsViewContainer, T : StatefulContainer<S> {
val shouldDefer =
(!overviewComponentObserver.isHomeAndOverviewSame ||
(!overviewComponentObserver.isHomeAndOverviewSame ||// 三方Launcher为默认Launcher
gestureState
.getContainerInterface<S, T>()
.deferStartingActivity(deviceState, event))
.deferStartingActivity(deviceState, event))// 手指在Taskbar部分区域上
val disableHorizontalSwipe = deviceState.isInExclusionRegion(event)
return OtherActivityInputConsumer(
/* base= */ context,
@@ -167,7 +167,7 @@ public final class LauncherActivityInterface extends
@Override
public LauncherTaskbarUIController getTaskbarController() {
QuickstepLauncher launcher = getCreatedContainer();
if (launcher == null) {
if (launcher == null) {// 三方Launcher为默认Launcher
return null;
}
return launcher.getTaskbarUIController();
@@ -327,10 +327,10 @@ public final class LauncherActivityInterface extends
@Override
public boolean deferStartingActivity(RecentsAnimationDeviceState deviceState, MotionEvent ev) {
LauncherTaskbarUIController uiController = getTaskbarController();
if (uiController == null) {
if (uiController == null) {// 三方Launcher为默认Launcher
return super.deferStartingActivity(deviceState, ev);
}
return uiController.isEventOverAnyTaskbarItem(ev)
return uiController.isEventOverAnyTaskbarItem(ev)// 手指在Taskbar上面的所有图标范围内或者旋转按钮上
|| super.deferStartingActivity(deviceState, ev);
}
@@ -249,7 +249,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
if (DEBUG) {
Log.d(TAG, "ACTION_DOWN: mIsDeferredDownTarget=" + mIsDeferredDownTarget);
}
if (!mIsDeferredDownTarget) {
if (!mIsDeferredDownTarget) {// 非延迟目标,down事件就开始启动动画
startTouchTrackingForWindowAnimation(ev.getEventTime());
}
@@ -285,7 +285,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
break;
}
mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
float displacement = getDisplacement(ev);
float displacement = getDisplacement(ev);// 计算位移(垂直方向)
float displacementX = mLastPos.x - mDownPos.x;
float displacementY = mLastPos.y - mDownPos.y;
@@ -302,10 +302,11 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
}
float horizontalDist = Math.abs(displacementX);
float upDist = -displacement;
float upDist = -displacement;// 向上滑动距离
boolean isTrackpadGesture = mGestureState.isTrackpadGesture();
float squaredHypot = squaredHypot(displacementX, displacementY);
boolean isInExtendedSlopRegion = mGestureState.isInExtendedSlopRegion();
// 是否越过有效滑动阈值(触控板手势总是true,普通手势需距离足够且不在扩展 slop 区域)。
boolean passedSlop = isTrackpadGesture
|| (squaredHypot >= mSquaredTouchSlop
&& !isInExtendedSlopRegion);
@@ -324,13 +325,16 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
// the gesture (in which case mPassedPilferInputSlop starts as true).
boolean haveNotPassedSlopOnContinuedGesture =
!mPassedSlopOnThisGesture && mPassedPilferInputSlop;
// 计算滑动角度
double degrees = Math.toDegrees(Math.atan(upDist / horizontalDist));
// Regarding degrees >= -OVERVIEW_MIN_DEGREES - Trackpad gestures can start anywhere
// on the screen, allowing downward swipes. We want to impose the same angle in that
// scenario.
// 角度在±OVERVIEW_MIN_DEGREES内(接近水平)视为快速切换任务
boolean swipeWithinQuickSwitchRange = degrees <= OVERVIEW_MIN_DEGREES
&& (!mGestureState.isTrackpadGesture() || degrees >= -OVERVIEW_MIN_DEGREES);
// 预测是否启动新任务
boolean isLikelyToStartNewTask =
haveNotPassedSlopOnContinuedGesture || swipeWithinQuickSwitchRange;
@@ -358,7 +362,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mPassedPilferInputSlop = true;
if (mIsDeferredDownTarget) {
if (mIsDeferredDownTarget) {// 延迟目标,此时启动动画
// Deferred gesture, start the animation and gesture tracking once
// we pass the actual touch slop
startTouchTrackingForWindowAnimation(ev.getEventTime());
@@ -367,6 +371,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mPassedWindowMoveSlop = true;
mStartDisplacement = -mTouchSlop;
}
// 通知手势开始
notifyGestureStarted(isLikelyToStartNewTask);
}
}
@@ -384,7 +389,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mInteractionHandler.setCanSlowSwipeGoHome(minSwipeMet);
mMotionPauseDetector.setDisallowPause(!minSwipeMet
|| isLikelyToStartNewTask);
mMotionPauseDetector.addPosition(ev);
mMotionPauseDetector.addPosition(ev);// 检测停顿
mInteractionHandler.setIsLikelyToStartNewTask(isLikelyToStartNewTask);
}
}
@@ -410,6 +415,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
return;
}
TestLogging.recordEvent(TestProtocol.SEQUENCE_PILFER, "pilferPointers");
// 关键:拦截后续触摸事件(不再传给其他View,防止Launcher或其他应用干扰。)
mInputMonitorCompat.pilferPointers();
// Once we detect the gesture, we can enable batching to reduce further updates
mInputEventReceiver.setBatchingEnabled(true);