abtracting Activity from recentsView through recentsviewcontainer and basecontainerinterface interfaces

This change will let us move from activity to other parent views for recent views.

Summary: In prep for new recentsview containers outside of activity we needed to decouple recentsview from activity and state.
This change will let us move from activity to other parent views for recent views.

Test: Built and tested locally for 1p and 3p launchers on tablet, and portrait modes. Verified working functionality.

Bug: 292269949

Flag: NONE

Change-Id: I5c72745f438d466362ece988c35a97d829e9c1b4
This commit is contained in:
randypfohl committed 2024-04-10 09:14:28 -07:00
1 parent c2ee3f5001
commit 547d6fc472
76 files changed
+1386 -1106

No files matched your search

@@ -21,6 +21,7 @@ import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.os.VibrationEffect;
import android.view.MotionEvent;
import android.view.View;
@@ -28,7 +29,6 @@ import android.view.animation.Interpolator;
import com.android.app.animation.Interpolators;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -44,12 +44,13 @@ import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.util.VibrationConstants;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.quickstep.views.TaskView;
/**
* Touch controller for handling task view card swipes
*/
public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
public abstract class TaskViewTouchController<CONTAINER extends Context & RecentsViewContainer>
extends AnimatorListenerAdapter implements TouchController,
SingleAxisSwipeDetector.Listener {
@@ -63,7 +64,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
public static final VibrationEffect TASK_DISMISS_VIBRATION_FALLBACK =
VibrationConstants.EFFECT_TEXTURE_TICK;
protected final T mActivity;
protected final CONTAINER mContainer;
private final SingleAxisSwipeDetector mDetector;
private final RecentsView mRecentsView;
private final int[] mTempCords = new int[2];
@@ -87,13 +88,13 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
private boolean mIsDismissHapticRunning = false;
public TaskViewTouchController(T activity) {
mActivity = activity;
mRecentsView = activity.getOverviewPanel();
mIsRtl = Utilities.isRtl(activity.getResources());
public TaskViewTouchController(CONTAINER container) {
mContainer = container;
mRecentsView = container.getOverviewPanel();
mIsRtl = Utilities.isRtl(container.getResources());
SingleAxisSwipeDetector.Direction dir =
mRecentsView.getPagedOrientationHandler().getUpDownSwipeDirection();
mDetector = new SingleAxisSwipeDetector(activity, this, dir);
mDetector = new SingleAxisSwipeDetector(container, this, dir);
}
private boolean canInterceptTouch(MotionEvent ev) {
@@ -113,7 +114,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
return true;
}
if (AbstractFloatingView.getTopOpenViewWithType(
mActivity, TYPE_TOUCH_CONTROLLER_NO_INTERCEPT) != null) {
mContainer, TYPE_TOUCH_CONTROLLER_NO_INTERCEPT) != null) {
return false;
}
return isRecentsInteractive();
@@ -159,7 +160,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
for (int i = 0; i < mRecentsView.getTaskViewCount(); i++) {
TaskView view = mRecentsView.getTaskViewAt(i);
if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer()
if (mRecentsView.isTaskViewVisible(view) && mContainer.getDragLayer()
.isEventOverView(view, ev)) {
// Disable swiping up and down if the task overlay is modal.
if (isRecentsModal()) {
@@ -179,7 +180,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
// - It's the focused task if in grid view
// - The task is snapped
mAllowGoingDown = i == mRecentsView.getCurrentPage()
&& DisplayController.getNavigationMode(mActivity).hasGestures
&& DisplayController.getNavigationMode(mContainer).hasGestures
&& (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
&& mRecentsView.isTaskInExpectedScrollPosition(i);
@@ -228,7 +229,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
RecentsPagedOrientationHandler orientationHandler =
mRecentsView.getPagedOrientationHandler();
mCurrentAnimationIsGoingUp = goingUp;
BaseDragLayer dl = mActivity.getDragLayer();
BaseDragLayer dl = mContainer.getDragLayer();
final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
long maxDuration = 2 * secondaryLayerDimension;
int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
@@ -372,10 +373,10 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
MIN_TASK_DISMISS_ANIMATION_DURATION, MAX_TASK_DISMISS_ANIMATION_DURATION);
mCurrentAnimation.setEndAction(this::clearState);
mCurrentAnimation.startWithVelocity(mActivity, goingToEnd, Math.abs(velocity),
mCurrentAnimation.startWithVelocity(mContainer, goingToEnd, Math.abs(velocity),
mEndDisplacement, animationDuration);
if (goingUp && goingToEnd && !mIsDismissHapticRunning) {
VibratorWrapper.INSTANCE.get(mActivity).vibrate(TASK_DISMISS_VIBRATION_PRIMITIVE,
VibratorWrapper.INSTANCE.get(mContainer).vibrate(TASK_DISMISS_VIBRATION_PRIMITIVE,
TASK_DISMISS_VIBRATION_PRIMITIVE_SCALE, TASK_DISMISS_VIBRATION_FALLBACK);
mIsDismissHapticRunning = true;
}