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
This commit is contained in:
Artsiom Mitrokhin
2024-12-10 15:21:23 -05:00
parent 9899283045
commit 2e0d122ed1
@@ -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;
}
}
}