Add the KeyboardQuickSwitchView (1/2)

Preparatory change for adding the KeyboardQuickSwitchView and associated flows.

Test: Manually tested alt-tab and alt-shift-tab in and out of overview on a tablet and phone
Bug: 258854035
Change-Id: I468481a023e82d3ef7c7d4d44c5b9435173b49ae
This commit is contained in:
Schneider Victor-tulias
2023-01-24 15:05:08 -08:00
parent 5147b1d509
commit f908729fa8
14 changed files with 442 additions and 44 deletions

View File

@@ -31,6 +31,7 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
import static com.android.launcher3.util.SplitConfigurationOptions.getLogEventForPosition;
import static com.android.quickstep.util.BorderAnimator.DEFAULT_BORDER_COLOR;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -42,6 +43,7 @@ import android.annotation.IdRes;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -94,6 +96,7 @@ import com.android.quickstep.TaskOverlayFactory;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TaskViewUtils;
import com.android.quickstep.util.BorderAnimator;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.util.SplitSelectStateController;
@@ -405,6 +408,8 @@ public class TaskView extends FrameLayout implements Reusable {
private boolean mIsClickableAsLiveTile = true;
@Nullable private final BorderAnimator mBorderAnimator;
public TaskView(Context context) {
this(context, null);
}
@@ -414,12 +419,46 @@ public class TaskView extends FrameLayout implements Reusable {
}
public TaskView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this(context, attrs, defStyleAttr, 0);
}
public TaskView(
Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mActivity = StatefulActivity.fromContext(context);
setOnClickListener(this::onClick);
mCurrentFullscreenParams = new FullscreenDrawParams(context);
mDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this);
setWillNotDraw(!FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH.get());
mBorderAnimator = !FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH.get()
? null
: new BorderAnimator(
/* borderBoundsBuilder= */ this::updateBorderBounds,
/* borderWidthPx= */ context.getResources().getDimensionPixelSize(
R.dimen.keyboard_quick_switch_border_width),
/* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
/* borderColor= */ attrs == null
? DEFAULT_BORDER_COLOR
: context.getTheme()
.obtainStyledAttributes(
attrs,
R.styleable.TaskView,
defStyleAttr,
defStyleRes)
.getColor(
R.styleable.TaskView_borderColor,
DEFAULT_BORDER_COLOR),
/* invalidateViewCallback= */ TaskView.this::invalidate);
}
protected void updateBorderBounds(Rect bounds) {
bounds.set(mSnapshotView.getLeft() + Math.round(mSnapshotView.getTranslationX()),
mSnapshotView.getTop() + Math.round(mSnapshotView.getTranslationY()),
mSnapshotView.getRight() + Math.round(mSnapshotView.getTranslationX()),
mSnapshotView.getBottom() + Math.round(mSnapshotView.getTranslationY()));
}
public void setTaskViewId(int id) {
@@ -463,6 +502,22 @@ public class TaskView extends FrameLayout implements Reusable {
mIconTouchDelegate = new TransformingTouchDelegate(mIconView);
}
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
if (mBorderAnimator != null) {
mBorderAnimator.buildAnimator(gainFocus).start();
}
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
if (mBorderAnimator != null) {
mBorderAnimator.drawBorder(canvas);
}
}
/**
* Whether the taskview should take the touch event from parent. Events passed to children
* that might require special handling.