Get rid of multiple haptic feedbacks when long pressing on nav buttons

When returning false in a onLongClickListener, the touch event gets dispatched to onClickListener at release.

Fixes: 351457303
Test: long press and short press both result in one haptic feedback
Flag: EXEMPT bugfix
Change-Id: Id173a2d1fcf2f61c3289c653809207425b468a82
This commit is contained in:
Tracy Zhou committed 2024-07-05 23:26:45 -07:00
1 parent f49f87decf
commit d289ca471b
1 file changed
+10 -4
@@ -166,8 +166,12 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
if (buttonType == BUTTON_SPACE) {
return false;
}
// Provide the same haptic feedback that the system offers for virtual keys.
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
// 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.
if (buttonType != BUTTON_HOME) {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
switch (buttonType) {
case BUTTON_HOME:
logEvent(LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS);
@@ -179,10 +183,12 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
return true;
case BUTTON_BACK:
logEvent(LAUNCHER_TASKBAR_BACK_BUTTON_LONGPRESS);
return backRecentsLongpress(buttonType);
backRecentsLongpress(buttonType);
return true;
case BUTTON_RECENTS:
logEvent(LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS);
return backRecentsLongpress(buttonType);
backRecentsLongpress(buttonType);
return true;
case BUTTON_IME_SWITCH:
default:
return false;