diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java new file mode 100644 index 0000000000000..2a6418530e87b --- /dev/null +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/MotionEventsHandlerBase.java @@ -0,0 +1,31 @@ +/* + * 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 5f6f11c16da2d..054e30056124c 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NavigationEdgeBackPlugin.java @@ -48,6 +48,9 @@ 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 6e927b071727e..1950c694e07d7 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt @@ -38,6 +38,7 @@ import androidx.dynamicanimation.animation.DynamicAnimation import androidx.dynamicanimation.animation.SpringForce 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 @@ -498,6 +499,10 @@ class BackPanelController private constructor( windowManager.addView(mView, layoutParams) } + override fun setMotionEventsHandler(motionEventsHandler: MotionEventsHandlerBase?) { + TODO("Not yet implemented") + } + private fun isFlung() = velocityTracker!!.run { computeCurrentVelocity(1000) abs(xVelocity) > MIN_FLING_VELOCITY 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 6c99b6764909c..e32c3011fbca7 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java @@ -18,6 +18,8 @@ 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; import android.app.ActivityManager; @@ -241,6 +243,7 @@ public class EdgeBackGestureHandler implements PluginListener