mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Play haptic on ACTION_DOWN for 3-button-nav buttons
Bug: 393959400
Test: Manual, i.e. verified that haptic happens on ACTION_DOWN and on
long press (except for back button which doesn't have a haptic on
long press). Also verified that Talkback works.
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:528bf70f61a6c161ec231d7447ac69dd4d97d1c8)
Merged-In: Ieb1892d69268d0bfba0ead9ec38c8ee9843addef
Change-Id: Ieb1892d69268d0bfba0ead9ec38c8ee9843addef
This commit is contained in:
committed by
Android Build Coastguard Worker
parent
327b059225
commit
c88baf38bf
@@ -58,6 +58,7 @@ import android.animation.ObjectAnimator;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.IdRes;
|
||||
import android.annotation.LayoutRes;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo.Config;
|
||||
import android.content.res.ColorStateList;
|
||||
@@ -880,6 +881,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
R.layout.taskbar_nav_button);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
|
||||
ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id,
|
||||
@LayoutRes int layoutId) {
|
||||
@@ -899,6 +901,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
navButtonController.onButtonClick(buttonType, view));
|
||||
buttonView.setOnLongClickListener(view ->
|
||||
navButtonController.onButtonLongClick(buttonType, view));
|
||||
buttonView.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return buttonView;
|
||||
}
|
||||
@@ -939,6 +947,7 @@ 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);
|
||||
}
|
||||
boolean isCancelled = motionEventAction == MotionEvent.ACTION_CANCEL
|
||||
|| (!rect.contains(event.getX(), event.getY())
|
||||
@@ -960,7 +969,6 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
navButtonController.sendBackKeyEvent(KeyEvent.ACTION_UP, isCancelled);
|
||||
if (motionEventAction == MotionEvent.ACTION_UP && !isCancelled) {
|
||||
buttonView.performClick();
|
||||
buttonView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -147,8 +147,6 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
|
||||
// prevent interactions with other buttons while back button is pressed
|
||||
return;
|
||||
}
|
||||
// Provide the same haptic feedback that the system offers for virtual keys.
|
||||
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
switch (buttonType) {
|
||||
case BUTTON_BACK:
|
||||
executeBack(/* keyEvent */ null);
|
||||
|
||||
Reference in New Issue
Block a user