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

Commit 75f7e649 authored by Sreyas Rangaraju's avatar Sreyas Rangaraju Committed by Android (Google) Code Review
Browse files

Merge "OverviewActions: Creating single view instance. Makes use of there...

Merge "OverviewActions: Creating single view instance. Makes use of there being a single instance of OverviewActionsView rather than each Task having it's own." into ub-launcher3-master
parents c74ab044 321bfae9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -28,4 +28,9 @@
        android:clipToPadding="false"
        android:outlineProvider="none"
        android:theme="@style/HomeScreenElementTheme" />

    <include
        android:id="@+id/overview_actions_view"
        layout="@layout/overview_actions_holder" />

</com.android.quickstep.fallback.RecentsRootView>
+9 −15
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
     Copyright (C) 2017 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,17 +13,12 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.launcher3.InsettableFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
<com.android.quickstep.views.LauncherRecentsView
        android:id="@+id/overview_panel_recents"
        android:theme="@style/HomeScreenElementTheme"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:accessibilityPaneTitle="@string/accessibility_recent_apps"
    android:clipChildren="false"
    android:clipToPadding="false"
        android:accessibilityPaneTitle="@string/accessibility_recent_apps"
    android:theme="@style/HomeScreenElementTheme"
    android:visibility="invisible" />
</com.android.launcher3.InsettableFrameLayout>
+60 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
import static com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS;
@@ -66,6 +67,7 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
import android.util.SparseBooleanArray;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -84,6 +86,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
@@ -113,6 +116,7 @@ import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.RecentsAnimationTargets;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel.TaskVisualsChangeListener;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskUtils;
@@ -206,7 +210,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    private boolean mDwbToastShown;
    protected boolean mDisallowScrollToClearAll;
    private boolean mOverlayEnabled;
    private boolean mFreezeViewVisibility;
    protected boolean mFreezeViewVisibility;

    /**
     * TODO: Call reloadIdNeeded in onTaskStackChanged.
@@ -325,6 +329,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl

    // Keeps track of the index where the first TaskView should be
    private int mTaskViewStartIndex = 0;
    private View mActionsView;
    private boolean mGestureRunning = false;

    private BaseActivity.MultiWindowModeChangedListener mMultiWindowModeChangedListener =
            (inMultiWindowMode) -> {
@@ -383,6 +389,11 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                int rotation = RotationHelper.getRotationFromDegrees(i);
                if (mPreviousRotation != rotation) {
                    animateRecentsRotationInPlace(rotation);
                    if (rotation == 0) {
                        showActionsView();
                    } else {
                        hideActionsView();
                    }
                    mPreviousRotation = rotation;
                }
            }
@@ -473,6 +484,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                mIPinnedStackAnimationListener);
        Launcher launcher = Launcher.getLauncher(getContext());
        launcher.getRotationHelper().addForcedRotationCallback(mForcedRotationChangedListener);
        addActionsView();
    }

    @Override
@@ -636,6 +648,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        if (getTaskViewCount() != requiredTaskCount) {
            if (indexOfChild(mClearAllButton) != -1) {
                removeView(mClearAllButton);
                hideActionsView();
            }
            for (int i = getTaskViewCount(); i < requiredTaskCount; i++) {
                addView(mTaskViewPool.getView());
@@ -645,6 +658,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
            }
            if (requiredTaskCount > 0) {
                addView(mClearAllButton);
                showActionsView();
            }
        }

@@ -684,6 +698,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        if (indexOfChild(mClearAllButton) != -1) {
            removeView(mClearAllButton);
        }
        hideActionsView();
    }

    public int getTaskViewCount() {
@@ -931,6 +946,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        setEnableDrawingLiveTile(false);
        setRunningTaskHidden(true);
        setRunningTaskIconScaledDown(true);
        mGestureRunning = true;
    }

    /**
@@ -1000,6 +1016,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        }
        setRunningTaskHidden(false);
        animateUpRunningTaskIconScale();
        mGestureRunning = false;
    }

    /**
@@ -1016,6 +1033,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
            addView(taskView, mTaskViewStartIndex);
            if (wasEmpty) {
                addView(mClearAllButton);
                showActionsView();
            }
            // The temporary running task is only used for the duration between the start of the
            // gesture and the task list is loaded and applied
@@ -1341,6 +1359,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl

                    if (getTaskViewCount() == 0) {
                        removeView(mClearAllButton);
                        hideActionsView();
                        startHome();
                    } else {
                        snapToPageImmediately(pageToSnapTo);
@@ -1485,15 +1504,17 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
            }
        }
        mClearAllButton.setContentAlpha(mContentAlpha);

        int alphaInt = Math.round(alpha * 255);
        mEmptyMessagePaint.setAlpha(alphaInt);
        mEmptyIcon.setAlpha(alphaInt);

        if (alpha > 0) {
            setVisibility(VISIBLE);
            if (!mGestureRunning) {
                showActionsView();
            }
        } else if (!mFreezeViewVisibility) {
            setVisibility(GONE);
            hideActionsView();
        }
    }

@@ -1507,6 +1528,11 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl

            if (!mFreezeViewVisibility) {
                setVisibility(mContentAlpha > 0 ? VISIBLE : GONE);
                if (mContentAlpha > 0) {
                    showActionsView();
                } else {
                    hideActionsView();
                }
            }
        }
    }
@@ -2057,6 +2083,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        void onEmptyMessageUpdated(boolean isEmpty);
    }


    private static class PinnedStackAnimationListener<T extends BaseActivity> extends
            IPinnedStackAnimationListener.Stub {
        private T mActivity;
@@ -2072,4 +2099,34 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
            mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
        }
    }

    private void showActionsView() {
        if (mActionsView != null && getTaskViewCount() > 0) {
            mActionsView.setVisibility(VISIBLE);
        }
    }

    private void hideActionsView() {
        if (mActionsView != null) {
            mActionsView.setVisibility(GONE);
        }
    }

    private void addActionsView() {
        if (mActionsView == null && ENABLE_OVERVIEW_ACTIONS.get()
                && SysUINavigationMode.removeShelfFromOverview(mActivity)) {
            mActionsView = ((ViewGroup) getParent()).findViewById(R.id.overview_actions_view);
            if (mActionsView != null) {
                Rect rect = new Rect();
                getTaskSize(rect);
                InsettableFrameLayout.LayoutParams layoutParams =
                        new InsettableFrameLayout.LayoutParams(rect.width(),
                                getResources().getDimensionPixelSize(
                                        R.dimen.overview_actions_height));
                layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
                mActionsView.setLayoutParams(layoutParams);
                showActionsView();
            }
        }
    }
}
+14 −72
Original line number Diff line number Diff line
@@ -16,6 +16,20 @@

package com.android.quickstep.views;

import static android.view.Gravity.BOTTOM;
import static android.view.Gravity.CENTER_HORIZONTAL;
import static android.view.Gravity.CENTER_VERTICAL;
import static android.view.Gravity.END;
import static android.view.Gravity.START;
import static android.view.Gravity.TOP;
import static android.widget.Toast.LENGTH_SHORT;

import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
@@ -39,14 +53,11 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.states.RotationHelper;
@@ -76,20 +87,6 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

import static android.view.Gravity.BOTTOM;
import static android.view.Gravity.CENTER_HORIZONTAL;
import static android.view.Gravity.CENTER_VERTICAL;
import static android.view.Gravity.END;
import static android.view.Gravity.START;
import static android.view.Gravity.TOP;
import static android.widget.Toast.LENGTH_SHORT;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview;

/**
 * A task in the Recents view.
 */
@@ -173,8 +170,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
    private final float mWindowCornerRadius;
    private final BaseDraggingActivity mActivity;

    @Nullable private View mActionsView;

    private ObjectAnimator mIconAndDimAnimator;
    private float mIconScaleAnimStartProgress = 0;
    private float mFocusTransitionProgress = 1;
@@ -193,8 +188,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
    private float mFooterVerticalOffset = 0;
    private float mFooterAlpha = 1;
    private int mStackHeight;
    private boolean mHideActionsView;
    private PagedOrientationHandler mOrientationHandler;

    public TaskView(Context context) {
        this(context, null);
@@ -246,18 +239,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        TaskView.LayoutParams thumbnailParams = (LayoutParams) mSnapshotView.getLayoutParams();
        thumbnailParams.bottomMargin = LayoutUtils.thumbnailBottomMargin(context);
        mSnapshotView.setLayoutParams(thumbnailParams);


        if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(context)) {
            mActionsView = mSnapshotView.getTaskOverlay().getActionsView();
            if (mActionsView != null) {
                TaskView.LayoutParams params = new TaskView.LayoutParams(LayoutParams.MATCH_PARENT,
                        getResources().getDimensionPixelSize(R.dimen.overview_actions_height),
                        BOTTOM);
                addView(mActionsView, params);
                mActionsView.setAlpha(0);
            }
        }
    }

    public boolean isTaskOverlayModal() {
@@ -457,7 +438,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        int thumbnailPadding = (int) getResources().getDimension(R.dimen.task_thumbnail_top_margin);
        LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams();
        int rotation = RotationHelper.getDegreesFromRotation(iconRotation);
        mHideActionsView = true;
        switch (iconRotation) {
            case Surface.ROTATION_90:
                iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL;
@@ -479,13 +459,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
                iconParams.gravity = TOP | CENTER_HORIZONTAL;
                iconParams.leftMargin = iconParams.topMargin = iconParams.rightMargin =
                    iconParams.bottomMargin = 0;
                mHideActionsView = false;
                break;
        }
        mSnapshotView.setLayoutParams(snapshotParams);
        mIconView.setLayoutParams(iconParams);
        mIconView.setRotation(rotation);
        updateActionsViewVisibility(!mHideActionsView);
    }

    private void setIconAndDimTransitionProgress(float progress, boolean invert) {
@@ -502,11 +480,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        mIconView.setScaleX(scale);
        mIconView.setScaleY(scale);


        if (mActionsView != null && isRunningTask()) {
            mActionsView.setAlpha(scale);
        }

        mFooterVerticalOffset = 1.0f - scale;
        for (FooterWrapper footer : mFooters) {
            if (footer != null) {
@@ -597,31 +570,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
            mMenuView.setScaleX(getScaleX());
            mMenuView.setScaleY(getScaleY());
        }

        // This is not the proper implementation and will be replaced with a proper layout.
        if (mActionsView != null) {
            if (mFocusTransitionProgress == 1f) {
                mActionsView.setAlpha(1 - curveInterpolation / MAX_PAGE_SCRIM_ALPHA);
            }
            maintainActionViewPosition(curveScaleForCurveInterpolation);
        }

    }

    private void maintainActionViewPosition(float curveScaleForCurveInterpolation) {
        float inverseCurveScaleFactor = curveScaleForCurveInterpolation == 0 ? 0 :
                (1f / curveScaleForCurveInterpolation);
        mActionsView.setScaleX(inverseCurveScaleFactor);
        mActionsView.setScaleY(inverseCurveScaleFactor);
        mActionsView.setTranslationX(inverseCurveScaleFactor * (-getX()
                + getRecentsView().getScrollX() + getRecentsView().scrollOffsetLeft()));
        mActionsView.setTranslationY(
                (1f - curveScaleForCurveInterpolation) * (mSnapshotView.getHeight()
                        + mActionsView.getHeight()) / 2f
                        + inverseCurveScaleFactor * (-getTranslationY()));
    }


    /**
     * Sets the footer at the specific index and returns the previously set footer.
     */
@@ -903,7 +853,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        mFullscreenProgress = progress;
        boolean isFullscreen = mFullscreenProgress > 0;
        mIconView.setVisibility(progress < 1 ? VISIBLE : INVISIBLE);
        updateActionsViewVisibility(progress < 1 && !mHideActionsView);
        setClipChildren(!isFullscreen);
        setClipToPadding(!isFullscreen);

@@ -937,12 +886,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        invalidateOutline();
    }

    private void updateActionsViewVisibility(boolean isVisible) {
        if (mActionsView != null) {
            mActionsView.setVisibility(isVisible ? VISIBLE : GONE);
        }
    }

    public boolean isRunningTask() {
        if (getRecentsView() == null) {
            return false;
@@ -990,5 +933,4 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
            mScale = scale;
        }
    }

}
+4 −1
Original line number Diff line number Diff line
@@ -196,7 +196,10 @@ public abstract class BaseQuickstepLauncher extends Launcher

        if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(this)) {
            // Overview is above all other launcher elements, including qsb, so move it to the top.
            getOverviewPanelContainer().bringToFront();
            getOverviewPanel().bringToFront();
            if (getActionsView() != null) {
                getActionsView().bringToFront();
            }
        }
    }

Loading