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

Commit 1e58d995 authored by Zak Cohen's avatar Zak Cohen
Browse files

Overview actions - Add controller for actions.

Add the actions to the task overlay to simplify code sharing.

Test: added unit tests for controller

Change-Id: Ie497a717b189903cc1834685f4b7d0cb926a7f52
parent a11ff18d
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.quickstep;

import static com.android.launcher3.util.MainThreadInitializedObject.forOverride;

import android.view.View;

import com.android.launcher3.R;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.ResourceBasedOverride;

/**
 * Overview actions are shown in overview underneath the task snapshot. This factory class is
 * overrideable in an overlay. The {@link OverviewActions} class provides the view that should be
 * shown in the Overview.
 */
public class OverviewActionsFactory implements ResourceBasedOverride {

    public static final MainThreadInitializedObject<OverviewActionsFactory> INSTANCE =
            forOverride(OverviewActionsFactory.class, R.string.overview_actions_factory_class);

    /** Create a new Overview Actions for interacting between the actions and overview. */
    public OverviewActions createOverviewActions() {
        return new OverviewActions();
    }

    /** Overlay overrideable, base class does nothing. */
    public static class OverviewActions {
        /** Get the view to show in the overview. */
        public View getView() {
            return null;
        }
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.quickstep;
import static com.android.launcher3.util.MainThreadInitializedObject.forOverride;

import android.graphics.Matrix;
import android.view.View;

import androidx.annotation.Nullable;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseDraggingActivity;
@@ -75,6 +78,11 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         */
        public void initOverlay(Task task, ThumbnailData thumbnail, Matrix matrix) { }

        @Nullable
        public View getActionsView() {
            return null;
        }

        /**
         * Called when the overlay is no longer used.
         */
+4 −0
Original line number Diff line number Diff line
@@ -197,6 +197,10 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        updateThumbnailPaintFilter();
    }

    public TaskOverlay getTaskOverlay() {
        return mOverlay;
    }

    public float getDimAlpha() {
        return mDimAlpha;
    }
+1 −4
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.ViewPool.Reusable;
import com.android.quickstep.OverviewActionsFactory;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.TaskIconCache;
import com.android.quickstep.TaskOverlayFactory;
@@ -164,7 +163,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
    private final float mWindowCornerRadius;
    private final BaseDraggingActivity mActivity;

    private OverviewActionsFactory.OverviewActions mOverviewActions;
    @Nullable private View mActionsView;

    private ObjectAnimator mIconAndDimAnimator;
@@ -222,7 +220,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        mCurrentFullscreenParams = new FullscreenDrawParams(mCornerRadius);
        mDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this);

        mOverviewActions = OverviewActionsFactory.INSTANCE.get(context).createOverviewActions();
        mOutlineProvider = new TaskOutlineProvider(getResources(), mCurrentFullscreenParams);
        setOutlineProvider(mOutlineProvider);
    }
@@ -239,7 +236,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {


        if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
            mActionsView = mOverviewActions.getView();
            mActionsView = mSnapshotView.getTaskOverlay().getActionsView();
            if (mActionsView != null) {
                TaskView.LayoutParams params = new TaskView.LayoutParams(LayoutParams.MATCH_PARENT,
                        getResources().getDimensionPixelSize(R.dimen.overview_actions_height),
+0 −2
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
-->
<resources>
    <string name="task_overlay_factory_class" translatable="false"></string>
    <!-- Class name for factory object that creates the overview actions UI when enabled. -->
    <string name="overview_actions_factory_class" translatable="false" />

    <!-- Activity which blocks home gesture -->
    <string name="gesture_blocking_activity" translatable="false"></string>