mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Revert "Revert "Listen for hover events over stashed taskbar.""
This reverts commit c27605099c.
Reason for revert: DroidMonitor-triggered revert due to breakage <https://android-build.googleplex.com/builds/quarterdeck?branch=git_udc-dev&target=cf_x86_64_phone-userdebug&lkgb=10076607&lkbb=10076982&fkbb=10076788>, bug <281093059>
Change-Id: I71e7fd07232c27a004243df0ffb0457fe53fe13b
This commit is contained in:
committed by
Android (Google) Code Review
parent
c27605099c
commit
2482c8dcd4
@@ -928,6 +928,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is currently visually stashed.
|
||||
*/
|
||||
public boolean isTaskbarStashed() {
|
||||
return mControllers.taskbarStashController.isStashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we detect a long press in the nav region before passing the gesture slop.
|
||||
* @return Whether taskbar handled the long press, and thus should cancel the gesture.
|
||||
@@ -972,10 +979,23 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
|
||||
/**
|
||||
* Called when we detect a motion down or up/cancel in the nav region while stashed.
|
||||
*
|
||||
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
|
||||
*/
|
||||
public void startTaskbarUnstashHint(boolean animateForward) {
|
||||
mControllers.taskbarStashController.startUnstashHint(animateForward);
|
||||
// TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
|
||||
startTaskbarUnstashHint(animateForward, /* forceUnstash = */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we detect a motion down or up/cancel in the nav region while stashed.
|
||||
*
|
||||
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
|
||||
* @param forceUnstash Whether we force the unstash hint.
|
||||
*/
|
||||
public void startTaskbarUnstashHint(boolean animateForward, boolean forceUnstash) {
|
||||
// TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
|
||||
mControllers.taskbarStashController.startUnstashHint(animateForward, forceUnstash);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1123,4 +1143,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
public int getTaskbarAllAppsScroll() {
|
||||
return mControllers.taskbarAllAppsController.getTaskbarAllAppsScroll();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public float getStashedTaskbarScale() {
|
||||
return mControllers.stashedHandleViewController.getStashedHandleHintScale().value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,15 +856,18 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
/**
|
||||
* Creates and starts a partial unstash animation, hinting at the new state that will trigger
|
||||
* when long press is detected.
|
||||
*
|
||||
* @param animateForward Whether we are going towards the new unstashed state or returning to
|
||||
* the stashed state.
|
||||
* @param forceUnstash Whether we force the unstash hint to animate.
|
||||
*/
|
||||
public void startUnstashHint(boolean animateForward) {
|
||||
protected void startUnstashHint(boolean animateForward, boolean forceUnstash) {
|
||||
if (!isStashed()) {
|
||||
// Already unstashed, no need to hint in that direction.
|
||||
return;
|
||||
}
|
||||
if (!canCurrentlyManuallyUnstash()) {
|
||||
// TODO(b/270395798): Clean up after removing long-press unstashing code path.
|
||||
if (!canCurrentlyManuallyUnstash() && !forceUnstash) {
|
||||
// If any other flags are causing us to be stashed, long press won't cause us to
|
||||
// unstash, so don't hint that it will.
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL
|
||||
import com.android.launcher3.util.DisplayController
|
||||
import com.android.launcher3.util.TouchController
|
||||
import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer
|
||||
import com.android.quickstep.inputconsumers.TaskbarUnstashInputConsumer
|
||||
|
||||
/**
|
||||
* A helper [TouchController] for [TaskbarDragLayerController], specifically to handle touch events
|
||||
@@ -34,7 +34,7 @@ import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer
|
||||
* or [MotionEvent.ACTION_OUTSIDE].
|
||||
* - Touches inside Transient Taskbar bounds will stash if it is detected as a swipe down gesture.
|
||||
*
|
||||
* Note: touches to *unstash* Taskbar are handled by [TaskbarStashInputConsumer].
|
||||
* Note: touches to *unstash* Taskbar are handled by [TaskbarUnstashInputConsumer].
|
||||
*/
|
||||
class TaskbarStashViaTouchController(val controllers: TaskbarControllers) : TouchController {
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public interface InputConsumer {
|
||||
int TYPE_ONE_HANDED = 1 << 11;
|
||||
int TYPE_TASKBAR_STASH = 1 << 12;
|
||||
int TYPE_STATUS_BAR = 1 << 13;
|
||||
int TYPE_CURSOR_HOVER = 1 << 14;
|
||||
|
||||
String[] NAMES = new String[] {
|
||||
"TYPE_NO_OP", // 0
|
||||
@@ -57,6 +58,7 @@ public interface InputConsumer {
|
||||
"TYPE_ONE_HANDED", // 11
|
||||
"TYPE_TASKBAR_STASH", // 12
|
||||
"TYPE_STATUS_BAR", // 13
|
||||
"TYPE_CURSOR_HOVER", // 14
|
||||
};
|
||||
|
||||
InputConsumer NO_OP = () -> TYPE_NO_OP;
|
||||
|
||||
@@ -116,6 +116,16 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_STASHED_TASKBAR_SCALE: {
|
||||
runOnTISBinder(tisBinder -> {
|
||||
response.putFloat(TestProtocol.TEST_INFO_RESPONSE_FIELD,
|
||||
tisBinder.getTaskbarManager()
|
||||
.getCurrentActivityContext()
|
||||
.getStashedTaskbarScale());
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_TASKBAR_ALL_APPS_TOP_PADDING: {
|
||||
return getTISBinderUIProperty(Bundle::putInt, tisBinder ->
|
||||
tisBinder.getTaskbarManager()
|
||||
|
||||
@@ -29,6 +29,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.quickstep.GestureState.DEFAULT_STATE;
|
||||
import static com.android.quickstep.GestureState.TrackpadGestureType.getTrackpadGestureType;
|
||||
import static com.android.quickstep.InputConsumer.TYPE_CURSOR_HOVER;
|
||||
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.FLAG_USING_OTHER_ACTIVITY_INPUT_CONSUMER;
|
||||
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_DOWN;
|
||||
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_MOVE;
|
||||
@@ -109,7 +110,7 @@ import com.android.quickstep.inputconsumers.ResetGestureInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.StatusBarInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.SysUiOverlayInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.TaskbarUnstashInputConsumer;
|
||||
import com.android.quickstep.util.ActiveGestureLog;
|
||||
import com.android.quickstep.util.ActiveGestureLog.CompoundString;
|
||||
import com.android.quickstep.util.ProtoTracer;
|
||||
@@ -637,12 +638,17 @@ public class TouchInteractionService extends Service
|
||||
TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
|
||||
|
||||
final int action = event.getActionMasked();
|
||||
if (action == ACTION_DOWN) {
|
||||
// Note this will create a new consumer every mouse click, as after ACTION_UP from the click
|
||||
// an ACTION_HOVER_ENTER will fire as well.
|
||||
boolean isHoverActionWithoutConsumer =
|
||||
event.isHoverEvent() && (mUncheckedConsumer.getType() & TYPE_CURSOR_HOVER) == 0;
|
||||
if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
|
||||
mRotationTouchHelper.setOrientationTransformIfNeeded(event);
|
||||
|
||||
if (!mDeviceState.isOneHandedModeActive()
|
||||
if ((!mDeviceState.isOneHandedModeActive()
|
||||
&& mRotationTouchHelper.isInSwipeUpTouchRegion(event,
|
||||
mOverviewComponentObserver.getActivityInterface())) {
|
||||
mOverviewComponentObserver.getActivityInterface()))
|
||||
|| isHoverActionWithoutConsumer) {
|
||||
// Clone the previous gesture state since onConsumerAboutToBeSwitched might trigger
|
||||
// onConsumerInactive and wipe the previous gesture state
|
||||
GestureState prevGestureState = new GestureState(mGestureState);
|
||||
@@ -719,6 +725,8 @@ public class TouchInteractionService extends Service
|
||||
if (action == ACTION_POINTER_DOWN) {
|
||||
mGestureState.setTrackpadGestureType(getTrackpadGestureType(event));
|
||||
}
|
||||
} else if (event.isHoverEvent()) {
|
||||
mUncheckedConsumer.onHoverEvent(event);
|
||||
} else {
|
||||
mUncheckedConsumer.onMotionEvent(event);
|
||||
}
|
||||
@@ -842,7 +850,7 @@ public class TouchInteractionService extends Service
|
||||
base = tryCreateAssistantInputConsumer(base, newGestureState, event, reasonString);
|
||||
}
|
||||
|
||||
// If Taskbar is present, we listen for long press to unstash it.
|
||||
// If Taskbar is present, we listen for long press or cursor hover events to unstash it.
|
||||
TaskbarActivityContext tac = mTaskbarManager.getCurrentActivityContext();
|
||||
if (tac != null) {
|
||||
// Present always on large screen or on small screen w/ flag
|
||||
@@ -853,8 +861,8 @@ public class TouchInteractionService extends Service
|
||||
.append(reasonPrefix)
|
||||
.append(SUBSTRING_PREFIX)
|
||||
.append("TaskbarActivityContext != null, "
|
||||
+ "using TaskbarStashInputConsumer");
|
||||
base = new TaskbarStashInputConsumer(this, base, mInputMonitorCompat, tac);
|
||||
+ "using TaskbarUnstashInputConsumer");
|
||||
base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,20 @@ import static android.view.MotionEvent.INVALID_POINTER_ID;
|
||||
|
||||
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
|
||||
import static com.android.launcher3.Utilities.squaredHypot;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_CURSOR_HOVER_STATES;
|
||||
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TOUCHING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
@@ -40,9 +43,11 @@ import com.android.quickstep.InputConsumer;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
|
||||
/**
|
||||
* Listens for a long press, and cancels the current gesture if that causes Taskbar to be unstashed.
|
||||
* Listens for touch and hover events to unstash the Taskbar.
|
||||
*
|
||||
* <p>Cancels the current gesture if the long press causes the Taskbar to be unstashed.
|
||||
*/
|
||||
public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
private final TaskbarActivityContext mTaskbarActivityContext;
|
||||
private final GestureDetector mLongPressDetector;
|
||||
@@ -64,9 +69,15 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
private final boolean mIsTransientTaskbar;
|
||||
|
||||
private boolean mIsStashedTaskbarHovered = false;
|
||||
private final Rect mStashedTaskbarHandleBounds = new Rect();
|
||||
private final Rect mBottomEdgeBounds = new Rect();
|
||||
private final int mBottomScreenEdge;
|
||||
private final int mStashedTaskbarBottomEdge;
|
||||
|
||||
private final @Nullable TransitionCallback mTransitionCallback;
|
||||
|
||||
public TaskbarStashInputConsumer(Context context, InputConsumer delegate,
|
||||
public TaskbarUnstashInputConsumer(Context context, InputConsumer delegate,
|
||||
InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext) {
|
||||
super(delegate, inputMonitor);
|
||||
mTaskbarActivityContext = taskbarActivityContext;
|
||||
@@ -90,6 +101,11 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
});
|
||||
|
||||
mBottomScreenEdge = res.getDimensionPixelSize(
|
||||
R.dimen.taskbar_stashed_screen_edge_hover_deadzone_height);
|
||||
mStashedTaskbarBottomEdge =
|
||||
res.getDimensionPixelSize(R.dimen.taskbar_stashed_below_hover_deadzone_height);
|
||||
|
||||
mTransitionCallback = mIsTransientTaskbar
|
||||
? taskbarActivityContext.getTranslationCallbacks()
|
||||
: null;
|
||||
@@ -97,7 +113,7 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE_TASKBAR_STASH | mDelegate.getType();
|
||||
return TYPE_TASKBAR_STASH | TYPE_CURSOR_HOVER | mDelegate.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,4 +229,73 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for hover events for the stashed taskbar.
|
||||
*
|
||||
* <p>When hovered over the stashed taskbar handle, show the unstash hint.
|
||||
* <p>When the cursor is touching the bottom edge below the stashed taskbar, unstash it.
|
||||
* <p>When the cursor is within a defined threshold of the screen's bottom edge outside of
|
||||
* the stashed taskbar, unstash it.
|
||||
*/
|
||||
@Override
|
||||
public void onHoverEvent(MotionEvent ev) {
|
||||
if (!ENABLE_CURSOR_HOVER_STATES.get() || mTaskbarActivityContext == null
|
||||
|| !mTaskbarActivityContext.isTaskbarStashed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsStashedTaskbarHovered) {
|
||||
updateHoveredTaskbarState((int) ev.getX(), (int) ev.getY());
|
||||
} else {
|
||||
updateUnhoveredTaskbarState((int) ev.getX(), (int) ev.getY());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHoveredTaskbarState(int x, int y) {
|
||||
DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
|
||||
mStashedTaskbarHandleBounds.set(
|
||||
(dp.widthPx - (int) mUnstashArea) / 2,
|
||||
dp.heightPx - dp.stashedTaskbarHeight,
|
||||
(int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
|
||||
dp.heightPx);
|
||||
mBottomEdgeBounds.set(mStashedTaskbarHandleBounds);
|
||||
mBottomEdgeBounds.top = dp.heightPx - mStashedTaskbarBottomEdge;
|
||||
|
||||
if (mBottomEdgeBounds.contains(x, y)) {
|
||||
// If hovering stashed taskbar and then hover screen bottom edge, unstash it.
|
||||
mTaskbarActivityContext.onSwipeToUnstashTaskbar();
|
||||
mIsStashedTaskbarHovered = false;
|
||||
} else if (!mStashedTaskbarHandleBounds.contains(x, y)) {
|
||||
// If exit hovering stashed taskbar, remove hint.
|
||||
startStashedTaskbarHover(/* isHovered = */ false);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUnhoveredTaskbarState(int x, int y) {
|
||||
DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
|
||||
mStashedTaskbarHandleBounds.set(
|
||||
(dp.widthPx - (int) mUnstashArea) / 2,
|
||||
dp.heightPx - dp.stashedTaskbarHeight,
|
||||
(int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
|
||||
dp.heightPx);
|
||||
mBottomEdgeBounds.set(
|
||||
0,
|
||||
dp.heightPx - mBottomScreenEdge,
|
||||
dp.widthPx,
|
||||
dp.heightPx);
|
||||
|
||||
if (mStashedTaskbarHandleBounds.contains(x, y)) {
|
||||
// If enter hovering stashed taskbar, start hint.
|
||||
startStashedTaskbarHover(/* isHovered = */ true);
|
||||
} else if (mBottomEdgeBounds.contains(x, y)) {
|
||||
// If hover screen's bottom edge not below the stashed taskbar, unstash it.
|
||||
mTaskbarActivityContext.onSwipeToUnstashTaskbar();
|
||||
}
|
||||
}
|
||||
|
||||
private void startStashedTaskbarHover(boolean isHovered) {
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(isHovered, /* forceUnstash = */ true);
|
||||
mIsStashedTaskbarHovered = isHovered;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user