Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f902967 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use snapshotView references in TaskContainer when possible" into main

parents b8f4e16f c06bc41e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -269,8 +269,8 @@ public class TaskbarUIController {
                                    foundTaskView,
                                    foundTask,
                                    taskContainer.getIconView().getDrawable(),
                                    taskContainer.getThumbnailViewDeprecated(),
                                    taskContainer.getThumbnailViewDeprecated().getThumbnail(),
                                    taskContainer.getSnapshotView(),
                                    taskContainer.getThumbnail(),
                                    null /* intent */,
                                    null /* user */,
                                    info);
+1 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ public abstract class TaskViewTouchController<CONTAINER extends Context & Recent
                    mTaskBeingDragged, maxDuration, currentInterpolator);

            // Since the thumbnail is what is filling the screen, based the end displacement on it.
            View thumbnailView = mTaskBeingDragged.getFirstThumbnailViewDeprecated();
            View thumbnailView = mTaskBeingDragged.getFirstSnapshotView();
            mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
            dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
            mEndDisplacement = secondaryLayerDimension - mTempCords[1];
+19 −25
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import com.android.quickstep.views.GroupedTaskView;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.quickstep.views.TaskThumbnailViewDeprecated;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.views.TaskView.TaskContainer;
import com.android.systemui.shared.recents.model.Task;
@@ -134,20 +133,20 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
            mApplicationContext = taskContainer.getTaskView().getContext().getApplicationContext();
            mTaskContainer = taskContainer;
            mImageApi = new ImageActionsApi(
                    mApplicationContext, mTaskContainer.getThumbnailViewDeprecated()::getThumbnail);
                    mApplicationContext, mTaskContainer::getThumbnail);
        }

        protected T getActionsView() {
            if (mActionsView == null) {
                mActionsView = BaseActivity.fromContext(
                        mTaskContainer.getThumbnailViewDeprecated().getContext()).findViewById(
                        mTaskContainer.getTaskView().getContext()).findViewById(
                        R.id.overview_actions_view);
            }
            return mActionsView;
        }

        public TaskThumbnailViewDeprecated getThumbnailView() {
            return mTaskContainer.getThumbnailViewDeprecated();
        public TaskView getTaskView() {
            return mTaskContainer.getTaskView();
        }

        /**
@@ -159,8 +158,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {

            if (thumbnail != null) {
                getActionsView().updateDisabledFlags(DISABLED_ROTATED, rotated);
                boolean isAllowedByPolicy =
                        mTaskContainer.getThumbnailViewDeprecated().isRealSnapshot();
                boolean isAllowedByPolicy = mTaskContainer.isRealSnapshot();
                getActionsView().setCallbacks(new OverlayUICallbacksImpl(isAllowedByPolicy, task));
            }
        }
@@ -172,7 +170,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         */
        public void endLiveTileMode(@NonNull Runnable callback) {
            RecentsView recentsView =
                    mTaskContainer.getThumbnailViewDeprecated().getTaskView().getRecentsView();
                    mTaskContainer.getTaskView().getRecentsView();
            // Task has already been dismissed
            if (recentsView == null) return;
            recentsView.switchToScreenshot(
@@ -185,8 +183,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         */
        @SuppressLint("NewApi")
        protected void saveScreenshot(Task task) {
            if (mTaskContainer.getThumbnailViewDeprecated().isRealSnapshot()) {
                mImageApi.saveScreenshot(mTaskContainer.getThumbnailViewDeprecated().getThumbnail(),
            if (mTaskContainer.isRealSnapshot()) {
                mImageApi.saveScreenshot(mTaskContainer.getThumbnail(),
                        getTaskSnapshotBounds(), getTaskSnapshotInsets(), task.key);
            } else {
                showBlockedByPolicyMessage();
@@ -194,17 +192,14 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
        }

        protected void enterSplitSelect() {
            RecentsView overviewPanel =
                    mTaskContainer.getThumbnailViewDeprecated().getTaskView().getRecentsView();
            RecentsView overviewPanel = mTaskContainer.getTaskView().getRecentsView();
            // Task has already been dismissed
            if (overviewPanel == null) return;
            overviewPanel.initiateSplitSelect(
                    mTaskContainer.getThumbnailViewDeprecated().getTaskView());
            overviewPanel.initiateSplitSelect(mTaskContainer.getTaskView());
        }

        protected void saveAppPair() {
            GroupedTaskView taskView =
                    (GroupedTaskView) mTaskContainer.getThumbnailViewDeprecated().getTaskView();
            GroupedTaskView taskView = (GroupedTaskView) mTaskContainer.getTaskView();
            taskView.getRecentsView().getSplitSelectController().getAppPairsController()
                    .saveAppPair(taskView);
        }
@@ -250,11 +245,11 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         */
        public Rect getTaskSnapshotBounds() {
            int[] location = new int[2];
            mTaskContainer.getThumbnailViewDeprecated().getLocationOnScreen(location);
            mTaskContainer.getSnapshotView().getLocationOnScreen(location);

            return new Rect(location[0], location[1],
                    mTaskContainer.getThumbnailViewDeprecated().getWidth() + location[0],
                    mTaskContainer.getThumbnailViewDeprecated().getHeight() + location[1]);
                    mTaskContainer.getSnapshotView().getWidth() + location[0],
                    mTaskContainer.getSnapshotView().getHeight() + location[1]);
        }

        /**
@@ -264,7 +259,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         */
        @RequiresApi(api = Build.VERSION_CODES.Q)
        public Insets getTaskSnapshotInsets() {
            return mTaskContainer.getThumbnailViewDeprecated().getScaledInsets();
            return mTaskContainer.getScaledInsets();
        }

        /**
@@ -275,14 +270,14 @@ public class TaskOverlayFactory implements ResourceBasedOverride {

        protected void showBlockedByPolicyMessage() {
            ActivityContext activityContext = ActivityContext.lookupContext(
                    mTaskContainer.getThumbnailViewDeprecated().getContext());
                    mTaskContainer.getTaskView().getContext());
            String message = activityContext.getStringCache() != null
                    ? activityContext.getStringCache().disabledByAdminMessage
                    : mTaskContainer.getThumbnailViewDeprecated().getContext().getString(
                    : mTaskContainer.getTaskView().getContext().getString(
                            R.string.blocked_by_policy);

            Snackbar.show(BaseActivity.fromContext(
                    mTaskContainer.getThumbnailViewDeprecated().getContext()), message, null);
                    mTaskContainer.getTaskView().getContext()), message, null);
        }

        /** Called when the snapshot has updated its full screen drawing parameters. */
@@ -304,8 +299,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {

            @Override
            public void onClick(View view) {
                saveScreenshot(
                        mTaskContainer.getThumbnailViewDeprecated().getTaskView().getFirstTask());
                saveScreenshot(mTaskContainer.getTaskView().getFirstTask());
                dismissTaskMenuView();
            }
        }
+16 −11
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.view.Surface.ROTATION_0;

import static com.android.launcher3.Flags.enableRefactorTaskThumbnail;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.window.flags.Flags.enableDesktopWindowingMode;
@@ -55,7 +56,6 @@ import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.views.GroupedTaskView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.quickstep.views.TaskThumbnailViewDeprecated;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.views.TaskView.TaskContainer;
import com.android.systemui.shared.recents.model.Task;
@@ -174,7 +174,7 @@ public interface TaskShortcutFactory {
        private Handler mHandler;

        private final RecentsView mRecentsView;
        private final TaskThumbnailViewDeprecated mThumbnailView;
        private final TaskContainer mTaskContainer;
        private final TaskView mTaskView;
        private final LauncherEvent mLauncherEvent;

@@ -186,7 +186,7 @@ public interface TaskShortcutFactory {
            mHandler = new Handler(Looper.getMainLooper());
            mTaskView = taskContainer.getTaskView();
            mRecentsView = container.getOverviewPanel();
            mThumbnailView = taskContainer.getThumbnailViewDeprecated();
            mTaskContainer = taskContainer;
        }

        @Override
@@ -220,20 +220,25 @@ public interface TaskShortcutFactory {
                };

                final int[] position = new int[2];
                mThumbnailView.getLocationOnScreen(position);
                final int width = (int) (mThumbnailView.getWidth() * mTaskView.getScaleX());
                final int height = (int) (mThumbnailView.getHeight() * mTaskView.getScaleY());
                View snapShotView = mTaskContainer.getSnapshotView();
                snapShotView.getLocationOnScreen(position);
                final int width = (int) (snapShotView.getWidth() * mTaskView.getScaleX());
                final int height = (int) (snapShotView.getHeight() * mTaskView.getScaleY());
                final Rect taskBounds = new Rect(position[0], position[1],
                        position[0] + width, position[1] + height);

                // Take the thumbnail of the task without a scrim and apply it back after
                float alpha = mThumbnailView.getDimAlpha();
                // TODO(b/348643341) add ability to get override the scrim for this Bitmap retrieval
                mThumbnailView.setDimAlpha(0);
                float alpha = 0f;
                if (!enableRefactorTaskThumbnail()) {
                    alpha = mTaskContainer.getThumbnailViewDeprecated().getDimAlpha();
                    mTaskContainer.getThumbnailViewDeprecated().setDimAlpha(0);
                }
                Bitmap thumbnail = RecentsTransition.drawViewIntoHardwareBitmap(
                        taskBounds.width(), taskBounds.height(), mThumbnailView, 1f,
                        Color.BLACK);
                mThumbnailView.setDimAlpha(alpha);
                        taskBounds.width(), taskBounds.height(), snapShotView, 1f, Color.BLACK);
                if (!enableRefactorTaskThumbnail()) {
                    mTaskContainer.getThumbnailViewDeprecated().setDimAlpha(alpha);
                }

                AppTransitionAnimationSpecsFuture future =
                        new AppTransitionAnimationSpecsFuture(mHandler) {
+3 −4
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ import com.android.quickstep.util.TransformParams;
import com.android.quickstep.views.DesktopTaskView;
import com.android.quickstep.views.GroupedTaskView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskThumbnailViewDeprecated;
import com.android.quickstep.views.TaskView;
import com.android.systemui.animation.RemoteAnimationTargetCompat;
import com.android.systemui.shared.recents.model.Task;
@@ -334,7 +333,7 @@ public final class TaskViewUtils {
            // During animation we apply transformation on the thumbnailView (and not the rootView)
            // to follow the TaskViewSimulator. So the final matrix applied on the thumbnailView is:
            //    Mt K(0)` K(t) Mt`
            TaskThumbnailViewDeprecated[] thumbnails = v.getThumbnailViews();
            View[] thumbnails = v.getSnapshotViews();

            // In case simulator copies and thumbnail size do no match, ensure we get the lesser.
            // This ensures we do not create arrays with empty elements or attempt to references
@@ -344,7 +343,7 @@ public final class TaskViewUtils {
            Matrix[] mt = new Matrix[matrixSize];
            Matrix[] mti = new Matrix[matrixSize];
            for (int i = 0; i < matrixSize; i++) {
                TaskThumbnailViewDeprecated ttv = thumbnails[i];
                View ttv = thumbnails[i];
                RectF localBounds = new RectF(0, 0,  ttv.getWidth(), ttv.getHeight());
                float[] tvBoundsMapped = new float[]{0, 0,  ttv.getWidth(), ttv.getHeight()};
                getDescendantCoordRelativeToAncestor(ttv, ttv.getRootView(), tvBoundsMapped, false);
@@ -391,7 +390,7 @@ public final class TaskViewUtils {
            out.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    for (TaskThumbnailViewDeprecated ttv : thumbnails) {
                    for (View ttv : thumbnails) {
                        ttv.setAnimationMatrix(null);
                    }
                }
Loading