From 99ff985abcfff11f90c99873245d883245f9d6c8 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Tue, 7 Feb 2023 06:29:02 +0000 Subject: [PATCH] Use movement of the motion events on the screen instead of on the trackpad since they are proportional This simplifies the logic we have to track the movements in the code. Also a slight fix to not cancel back gesture on pointer down from trackpad Bug: 255697805 Test: 3 finger swipe to go back with the flag turned on Change-Id: Ie85ad1d61f846ece8e515ddd456bd1729a45354e --- .../plugins/MotionEventsHandlerBase.java | 31 ---- .../plugins/NavigationEdgeBackPlugin.java | 3 - .../gestural/BackPanelController.kt | 7 +- .../gestural/EdgeBackGestureHandler.java | 14 +- .../gestural/MotionEventsHandler.java | 114 -------------- .../gestural/NavigationBarEdgePanel.java | 25 ++-- .../navigationbar/gestural/Utilities.java | 8 - .../gestural/MotionEventsHandlerTest.java | 141 ------------------ 8 files changed, 17 insertions(+), 326 deletions(-) delete mode 100644 packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java delete mode 100644 packages/SystemUI/src/com/android/systemui/navigationbar/gestural/MotionEventsHandler.java delete mode 100644 packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/MotionEventsHandlerTest.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java deleted file mode 100644 index 2a6418530e87b..0000000000000 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 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.systemui.plugins; - -import android.view.MotionEvent; - -/** Handles both trackpad and touch events and report displacements in both axis's. */ -public interface MotionEventsHandlerBase { - - void onMotionEvent(MotionEvent ev); - - float getDisplacementX(MotionEvent ev); - - float getDisplacementY(MotionEvent ev); - - String dump(); -} diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java index 054e30056124c..5f6f11c16da2d 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java @@ -48,9 +48,6 @@ public interface NavigationEdgeBackPlugin extends Plugin { /** Sets the base LayoutParams for the UI. */ void setLayoutParams(WindowManager.LayoutParams layoutParams); - /** Sets the motion events handler for the plugin. */ - default void setMotionEventsHandler(MotionEventsHandlerBase motionEventsHandler) {} - /** Updates the UI based on the motion events passed in device coordinates. */ void onMotionEvent(MotionEvent motionEvent); diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt index e0ba543a731d1..f409b23cf4e29 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt @@ -36,7 +36,6 @@ import androidx.core.view.isVisible import androidx.dynamicanimation.animation.DynamicAnimation import com.android.internal.util.LatencyTracker import com.android.systemui.dagger.qualifiers.Main -import com.android.systemui.plugins.MotionEventsHandlerBase import com.android.systemui.plugins.NavigationEdgeBackPlugin import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.statusbar.policy.ConfigurationController @@ -592,10 +591,6 @@ class BackPanelController internal constructor( windowManager.addView(mView, layoutParams) } - override fun setMotionEventsHandler(motionEventsHandler: MotionEventsHandlerBase?) { - // TODO(255697805): Integrate MotionEventHandler for trackpad. - } - private fun isDragAwayFromEdge(velocityPxPerSecThreshold: Int = 0) = velocityTracker!!.run { computeCurrentVelocity(PX_PER_SEC) val velocity = xVelocity.takeIf { mView.isLeftPanel } ?: (xVelocity * -1) @@ -1048,4 +1043,4 @@ class Step( else -> startValue }.also { previousValue = it } } -} \ No newline at end of file +} diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java index 3e6eb05ff96d5..389034af8a330 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java @@ -18,7 +18,6 @@ package com.android.systemui.navigationbar.gestural; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION; import static com.android.systemui.classifier.Classifier.BACK_GESTURE; -import static com.android.systemui.navigationbar.gestural.Utilities.getTrackpadScale; import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadMotionEvent; import android.annotation.NonNull; @@ -272,7 +271,6 @@ public class EdgeBackGestureHandler implements PluginListener