From 76621e0972cf03f04dc0322993c9f3f232c5b8df Mon Sep 17 00:00:00 2001 From: Johannes Gallmann Date: Mon, 12 May 2025 15:35:57 +0000 Subject: [PATCH] Remove haptics for long presses in 3-button-nav This CL removes haptics for long presses on 3-button-nav buttons, except when the long press triggers a user visible action. This means that for example the haptics for long pressing the recents button are removed, whereas haptics for long pressing the home button remain active since that launches circle-to-search. Bug: 408968370 Test: Manual, i.e. verified that no haptic feedback is played when long pressing the recents button Flag: EXEMPT bugfix Change-Id: Icfeade8a659a8aa4882ef139696c66f410980303 --- quickstep/res/layout/taskbar_nav_button.xml | 1 + .../taskbar/NavbarButtonsViewController.java | 6 +++-- .../taskbar/TaskbarNavButtonController.java | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/quickstep/res/layout/taskbar_nav_button.xml b/quickstep/res/layout/taskbar_nav_button.xml index 8f1c90499c..dafb672c5f 100644 --- a/quickstep/res/layout/taskbar_nav_button.xml +++ b/quickstep/res/layout/taskbar_nav_button.xml @@ -21,5 +21,6 @@ android:background="@drawable/taskbar_icon_click_feedback_roundrect" android:focusable="false" android:scaleType="center" + android:hapticFeedbackEnabled="false" android:tint="@color/taskbar_nav_icon_light_color" tools:ignore="UseAppTint" /> \ No newline at end of file diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 8494323c2d..bbcc8487ce 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -922,7 +922,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT navButtonController.onButtonLongClick(buttonType, view)); buttonView.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_DOWN) { - buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } return false; }); @@ -966,7 +967,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT hasSentDownEvent.set(false); mHandler.postDelayed(longPressTimeout, PREDICTIVE_BACK_TIMEOUT_MS); rect.set(0, 0, v.getWidth(), v.getHeight()); - buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } boolean isCancelled = motionEventAction == MotionEvent.ACTION_CANCEL || (!rect.contains(event.getX(), event.getY()) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java index ac4f565860..597e8b9213 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java @@ -181,6 +181,9 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa } } + /** + * Handles long clicks and plays haptics for user visible actions. + */ public boolean onButtonLongClick(@TaskbarButton int buttonType, View view) { if (buttonType == BUTTON_SPACE) { return false; @@ -193,34 +196,39 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa return false; } - // Provide the same haptic feedback that the system offers for long press. - // The haptic feedback from long pressing on the home button is handled by circle to search. - // There are no haptics for long pressing the back button if predictive back is enabled - if (buttonType != BUTTON_HOME - && (!predictiveBackThreeButtonNav() || buttonType != BUTTON_BACK)) { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - } switch (buttonType) { case BUTTON_HOME: logEvent(LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS); onLongPressHome(); + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; case BUTTON_A11Y: logEvent(LAUNCHER_TASKBAR_A11Y_BUTTON_LONGPRESS); notifyA11yClick(true /* longClick */); + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; case BUTTON_BACK: logEvent(LAUNCHER_TASKBAR_BACK_BUTTON_LONGPRESS); - backRecentsLongpress(buttonType); + if (backRecentsLongpress(buttonType)) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); + } return true; case BUTTON_RECENTS: logEvent(LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS); - backRecentsLongpress(buttonType); + if (backRecentsLongpress(buttonType)) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); + } return true; case BUTTON_IME_SWITCH: if (Flags.imeSwitcherRevamp()) { logEvent(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS); onImeSwitcherLongPress(); + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; } return false;