mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 18:06:48 +00:00
Merge "Honors three_button_corner_swipe flag." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
cf4666fbad
@@ -37,6 +37,7 @@ import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo;
|
||||
import com.android.systemui.shared.Flags;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
@@ -242,7 +243,8 @@ class OrientationTouchTransformer {
|
||||
int rotation = display.rotation;
|
||||
int touchHeight = mNavBarGesturalHeight;
|
||||
OrientationRectF orientationRectF = new OrientationRectF(0, 0, size.x, size.y, rotation);
|
||||
if (mMode == NavigationMode.NO_BUTTON) {
|
||||
if (mMode == NavigationMode.NO_BUTTON
|
||||
|| (mMode == NavigationMode.THREE_BUTTONS && Flags.threeButtonCornerSwipe())) {
|
||||
orientationRectF.top = orientationRectF.bottom - touchHeight;
|
||||
updateAssistantRegions(orientationRectF);
|
||||
} else {
|
||||
|
||||
@@ -74,6 +74,7 @@ import com.android.quickstep.util.AssistStateManager;
|
||||
import com.android.quickstep.util.GestureExclusionManager;
|
||||
import com.android.quickstep.util.GestureExclusionManager.ExclusionListener;
|
||||
import com.android.quickstep.util.NavBarPosition;
|
||||
import com.android.systemui.shared.Flags;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
|
||||
@@ -547,6 +548,13 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener, E
|
||||
return mAssistantVisibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the Assistant gesture can be used in 3 button navigation mode.
|
||||
*/
|
||||
public boolean supportsAssistantGestureInButtonNav() {
|
||||
return Flags.threeButtonCornerSwipe();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ev An ACTION_DOWN motion event
|
||||
* @return whether the given motion event can trigger the assistant over the current task.
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
import com.android.systemui.shared.Flags;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListener;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||
@@ -157,7 +158,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
// Register for navigation mode changes
|
||||
mDisplayController.addChangeListener(this);
|
||||
DisplayController.Info info = mDisplayController.getInfo();
|
||||
onDisplayInfoChangedInternal(info, CHANGE_ALL, info.getNavigationMode().hasGestures);
|
||||
onDisplayInfoChangedInternal(info, CHANGE_ALL, hasGestures(info.getNavigationMode()));
|
||||
runOnDestroy(() -> mDisplayController.removeChangeListener(this));
|
||||
|
||||
mOrientationListener = new OrientationEventListener(mContext) {
|
||||
@@ -229,7 +230,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
* Updates the regions for detecting the swipe up/quickswitch and assistant gestures.
|
||||
*/
|
||||
public void updateGestureTouchRegions() {
|
||||
if (!mMode.hasGestures) {
|
||||
if (!hasGestures(mMode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
| CHANGE_SUPPORTED_BOUNDS)) != 0) {
|
||||
mDisplayRotation = info.rotation;
|
||||
|
||||
if (mMode.hasGestures) {
|
||||
if (hasGestures(mMode)) {
|
||||
updateGestureTouchRegions();
|
||||
mOrientationTouchTransformer.createOrAddTouchRegion(info);
|
||||
mCurrentAppRotation = mDisplayRotation;
|
||||
@@ -295,9 +296,9 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
mOrientationTouchTransformer.setNavigationMode(newMode, mDisplayController.getInfo(),
|
||||
mContext.getResources());
|
||||
|
||||
if (forceRegister || (!mMode.hasGestures && newMode.hasGestures)) {
|
||||
if (forceRegister || (!hasGestures(mMode) && hasGestures(newMode))) {
|
||||
setupOrientationSwipeHandler();
|
||||
} else if (mMode.hasGestures && !newMode.hasGestures) {
|
||||
} else if (hasGestures(mMode) && !hasGestures(newMode)) {
|
||||
destroyOrientationSwipeHandlerCallback();
|
||||
}
|
||||
|
||||
@@ -399,7 +400,7 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
}
|
||||
|
||||
public int getCurrentActiveRotation() {
|
||||
if (!mMode.hasGestures) {
|
||||
if (!hasGestures(mMode)) {
|
||||
// touch rotation should always match that of display for 3 button
|
||||
return mDisplayRotation;
|
||||
}
|
||||
@@ -416,4 +417,8 @@ public class RotationTouchHelper implements DisplayInfoChangeListener, SafeClose
|
||||
public OrientationTouchTransformer getOrientationTouchTransformer() {
|
||||
return mOrientationTouchTransformer;
|
||||
}
|
||||
|
||||
private boolean hasGestures(NavigationMode mode) {
|
||||
return mode.hasGestures || (mode == THREE_BUTTONS && Flags.threeButtonCornerSwipe());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,8 +675,9 @@ public class TouchInteractionService extends Service {
|
||||
private void initInputMonitor(String reason) {
|
||||
disposeEventHandlers("Initializing input monitor due to: " + reason);
|
||||
|
||||
if (mDeviceState.isButtonNavMode() && (!ENABLE_TRACKPAD_GESTURE.get()
|
||||
|| mTrackpadsConnected.isEmpty())) {
|
||||
if (mDeviceState.isButtonNavMode()
|
||||
&& !mDeviceState.supportsAssistantGestureInButtonNav()
|
||||
&& (!ENABLE_TRACKPAD_GESTURE.get() || mTrackpadsConnected.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -858,7 +859,9 @@ public class TouchInteractionService extends Service {
|
||||
.append("); cancelling gesture."),
|
||||
NAVIGATION_MODE_SWITCHED);
|
||||
event.setAction(ACTION_CANCEL);
|
||||
} else if (mDeviceState.isButtonNavMode() && !isTrackpadMotionEvent(event)) {
|
||||
} else if (mDeviceState.isButtonNavMode()
|
||||
&& !mDeviceState.supportsAssistantGestureInButtonNav()
|
||||
&& !isTrackpadMotionEvent(event)) {
|
||||
ActiveGestureLog.INSTANCE.addLog(new CompoundString("TIS.onInputEvent: ")
|
||||
.append("Cannot process input event: ")
|
||||
.append("using 3-button nav and event is not a trackpad event"));
|
||||
@@ -910,7 +913,22 @@ public class TouchInteractionService extends Service {
|
||||
if (isInSwipeUpTouchRegion && tac != null) {
|
||||
tac.closeKeyboardQuickSwitchView();
|
||||
}
|
||||
if ((!isOneHandedModeActive && isInSwipeUpTouchRegion)
|
||||
if (mDeviceState.isButtonNavMode()
|
||||
&& mDeviceState.supportsAssistantGestureInButtonNav()) {
|
||||
reasonString.append("in three button mode which supports Assistant gesture");
|
||||
// Consume gesture event for Assistant (all other gestures should do nothing).
|
||||
if (mDeviceState.canTriggerAssistantAction(event)) {
|
||||
reasonString.append(" and event can trigger assistant action")
|
||||
.append(", consuming gesture for assistant action");
|
||||
mGestureState =
|
||||
createGestureState(mGestureState, getTrackpadGestureType(event));
|
||||
mUncheckedConsumer = tryCreateAssistantInputConsumer(mGestureState, event);
|
||||
} else {
|
||||
reasonString.append(" but event cannot trigger Assistant")
|
||||
.append(", consuming gesture as no-op");
|
||||
mUncheckedConsumer = InputConsumer.NO_OP;
|
||||
}
|
||||
} else if ((!isOneHandedModeActive && isInSwipeUpTouchRegion)
|
||||
|| isHoverActionWithoutConsumer || isOnBubbles) {
|
||||
reasonString.append(!isOneHandedModeActive && isInSwipeUpTouchRegion
|
||||
? "one handed mode is not active and event is in swipe up region"
|
||||
@@ -932,8 +950,7 @@ public class TouchInteractionService extends Service {
|
||||
: "event is a trackpad multi-finger swipe")
|
||||
.append(" and event can trigger assistant action")
|
||||
.append(", consuming gesture for assistant action");
|
||||
mGestureState = createGestureState(mGestureState,
|
||||
getTrackpadGestureType(event));
|
||||
mGestureState = createGestureState(mGestureState, getTrackpadGestureType(event));
|
||||
// Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we
|
||||
// should not interrupt it. QuickSwitch assumes that interruption can only
|
||||
// happen if the next gesture is also quick switch.
|
||||
|
||||
Reference in New Issue
Block a user