Merge "Disable 3-button-nav buttons during back button hold" into main

This commit is contained in:
Johannes Gallmann
2024-11-20 08:39:42 +00:00
committed by Android (Google) Code Review
3 changed files with 93 additions and 14 deletions
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar;
import static android.view.KeyEvent.ACTION_UP;
import static android.view.View.AccessibilityDelegate;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
@@ -72,7 +73,6 @@ import android.graphics.drawable.PaintDrawable;
import android.graphics.drawable.RotateDrawable;
import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Property;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -864,17 +864,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
TaskbarNavButtonController navButtonController) {
buttonView.setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_MOVE) return false;
long time = SystemClock.uptimeMillis();
int action = event.getAction();
KeyEvent keyEvent = new KeyEvent(time, time,
action == MotionEvent.ACTION_DOWN ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_BACK, 0);
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
keyEvent.cancel();
}
navButtonController.executeBack(keyEvent);
if (action == MotionEvent.ACTION_UP) {
int motionEventAction = event.getAction();
int keyEventAction = motionEventAction == MotionEvent.ACTION_DOWN
? KeyEvent.ACTION_DOWN : ACTION_UP;
boolean isCancelled = event.getAction() == MotionEvent.ACTION_CANCEL;
navButtonController.sendBackKeyEvent(keyEventAction, isCancelled);
if (motionEventAction == MotionEvent.ACTION_UP) {
buttonView.performClick();
}
return false;