From 2e0d122ed17d6274a2cbe5609bcad3f968b969ee Mon Sep 17 00:00:00 2001 From: Artsiom Mitrokhin Date: Tue, 10 Dec 2024 15:21:23 -0500 Subject: [PATCH] Add haptics for opening taskbar pinning popup view from anywhere The divider's listener is implemented via `View.OnLongClickListener`, which automatically handles haptics. While the taskbar view uses a custom gesture detector (to get the associated event and its x/y coordinates), which doesn't have the same logic out of the box. This CL adds a manual call to perform haptic feedback for long press events (this also corresponds to the implementation in a similar gesture detector - `WorkspaceTouchListener`). Bug: 382056013 Flag: com.android.launcher3.show_taskbar_pinning_popup_from_anywhere Test: manual on a fold Change-Id: I3887e0f9839a7992ccd8b6786bdf1268bfafd09e --- .../launcher3/taskbar/TaskbarViewCallbacks.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java index c7841c1340..ba0fc10d08 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java @@ -25,6 +25,7 @@ import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLA import android.annotation.SuppressLint; import android.content.Context; import android.view.GestureDetector; +import android.view.HapticFeedbackConstants; import android.view.InputDevice; import android.view.MotionEvent; import android.view.View; @@ -232,15 +233,19 @@ public class TaskbarViewCallbacks { @Override public void onLongPress(@NonNull MotionEvent event) { - maybeShowPinningView(event); + if (maybeShowPinningView(event)) { + mTaskbarView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } } - private void maybeShowPinningView(@NonNull MotionEvent event) { + /** Returns true if the taskbar pinning popup view was shown for {@code event}. */ + private boolean maybeShowPinningView(@NonNull MotionEvent event) { if (!DisplayController.isPinnedTaskbar(mActivity) || mTaskbarView.isEventOverAnyItem( event)) { - return; + return false; } mControllers.taskbarPinningController.showPinningView(mTaskbarView, event.getRawX()); + return true; } } }