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

Commit 501e139c authored by Adam Cohen's avatar Adam Cohen
Browse files

Draw the workspace scrim in the LauncherRootView instead of DragLayer

=> The entire DragLayer is translated during the -1 transition which creates a janky looking edge at the top of the screen

=> By bumping the scrim up a level, we avoid this

=> Separated WorkspaceAndHotseatScrim into two separate scrims, since only part of the scrim needed to be bumped up to a level. Further, it was an overloaded class.

=> We had previously been implicitly relying on the fact that the scrim was rendered in the Workspace parent; we need to make sure to propagate workspace inavlidations to the container of the scrim. While things would still work without this change, it's more correct to leave it, as we no longer assume a hierarchy for functinoality.

Bug: 178215332

Test: manual verification. See video in bug.

Change-Id: I0a76ddf35ceea8c9635367f69380ef24f42e9479
parent ea826f87
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ public class StaggeredWorkspaceAnim {

        addDepthAnimationForState(launcher, NORMAL, ALPHA_DURATION_MS);

        mAnimators.play(launcher.getDragLayer().getScrim().createSysuiMultiplierAnim(0f, 1f)
        mAnimators.play(launcher.getDragLayer().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f)
                .setDuration(ALPHA_DURATION_MS));
        mAnimators.addListener(new AnimatorListenerAdapter() {
            @Override
+17 −1
Original line number Diff line number Diff line
@@ -4,12 +4,14 @@ import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVIT

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.ViewDebug;
import android.view.WindowInsets;

import com.android.launcher3.graphics.SysUiScrim;
import com.android.launcher3.statemanager.StatefulActivity;

import java.util.Collections;
@@ -31,6 +33,8 @@ public class LauncherRootView extends InsettableFrameLayout {
    @ViewDebug.ExportedProperty(category = "launcher")
    private boolean mForceHideBackArrow;

    private SysUiScrim mSysUiScrim;

    public LauncherRootView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mActivity = StatefulActivity.fromContext(context);
@@ -89,6 +93,18 @@ public class LauncherRootView extends InsettableFrameLayout {
        }
    }

    public void setSysUiScrim(SysUiScrim scrim) {
        mSysUiScrim = scrim;
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        if (mSysUiScrim != null) {
            mSysUiScrim.draw(canvas);
        }
        super.dispatchDraw(canvas);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
+18 −1
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.graphics.PreloadIconDrawable;
import com.android.launcher3.graphics.WorkspaceDragScrim;
import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.StatsLogManager;
@@ -199,6 +200,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
    private boolean mStripScreensOnPageStopMoving = false;

    private DragPreviewProvider mOutlineProvider = null;

    private WorkspaceDragScrim mWorkspaceDragScrim;

    private boolean mWorkspaceFadeInAdjacentScreens;

    final WallpaperOffsetInterpolator mWallpaperOffset;
@@ -1161,6 +1165,19 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
        }
    }

    public void setWorkspaceDragScrim(WorkspaceDragScrim workspaceDragScrim) {
        mWorkspaceDragScrim = workspaceDragScrim;
    }

    @Override
    public void invalidate() {
        // The workspace scrim may need to be re-rendered based on the workspace scroll
        if (mWorkspaceDragScrim != null) {
            mWorkspaceDragScrim.invalidate();
        }
        super.invalidate();
    }

    @Override
    public void computeScroll() {
        super.computeScroll();
@@ -2028,7 +2045,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
        }
        // Invalidating the scrim will also force this CellLayout
        // to be invalidated so that it is highlighted if necessary.
        mLauncher.getDragLayer().getScrim().invalidate();
        mLauncher.getDragLayer().getWorkspaceDragScrim().invalidate();
    }

    public CellLayout getCurrentDragOverlappingLayout() {
+9 −6
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.ZOOM_OUT;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.graphics.Scrim.SCRIM_PROGRESS;
import static com.android.launcher3.graphics.WorkspaceAndHotseatScrim.SYSUI_PROGRESS;
import static com.android.launcher3.graphics.SysUiScrim.SYSUI_PROGRESS;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
@@ -49,7 +49,8 @@ import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.SpringAnimationBuilder;
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
import com.android.launcher3.graphics.SysUiScrim;
import com.android.launcher3.graphics.WorkspaceDragScrim;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.util.DynamicResource;
import com.android.systemui.plugins.ResourceProvider;
@@ -183,10 +184,12 @@ public class WorkspaceStateTransitionAnimation {
    }

    public void setScrim(PropertySetter propertySetter, LauncherState state) {
        WorkspaceAndHotseatScrim scrim = mLauncher.getDragLayer().getScrim();
        propertySetter.setFloat(scrim, SCRIM_PROGRESS, state.getWorkspaceScrimAlpha(mLauncher),
                LINEAR);
        propertySetter.setFloat(scrim, SYSUI_PROGRESS,
        WorkspaceDragScrim workspaceDragScrim = mLauncher.getDragLayer().getWorkspaceDragScrim();
        propertySetter.setFloat(workspaceDragScrim, SCRIM_PROGRESS,
                state.getWorkspaceScrimAlpha(mLauncher), LINEAR);

        SysUiScrim sysUiScrim = mLauncher.getDragLayer().getSysUiScrim();
        propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
                state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
    }

+26 −9
Original line number Diff line number Diff line
@@ -41,12 +41,14 @@ import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DropTargetBar;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherRootView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Workspace;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
import com.android.launcher3.graphics.SysUiScrim;
import com.android.launcher3.graphics.WorkspaceDragScrim;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.BaseDragLayer;
@@ -82,8 +84,10 @@ public class DragLayer extends BaseDragLayer<Launcher> {

    // Related to adjacent page hints
    private final ViewGroupFocusHelper mFocusIndicatorHelper;
    private final WorkspaceAndHotseatScrim mWorkspaceScrim;
    private final OverviewScrim mOverviewScrim;
    private WorkspaceDragScrim mWorkspaceDragScrim;
    private SysUiScrim mSysUiScrim;
    private LauncherRootView mRootView;

    /**
     * Used to create a new DragLayer from XML.
@@ -99,14 +103,23 @@ public class DragLayer extends BaseDragLayer<Launcher> {
        setChildrenDrawingOrderEnabled(true);

        mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
        mWorkspaceScrim = new WorkspaceAndHotseatScrim(this);
        mOverviewScrim = new OverviewScrim(this);
    }

    public void setup(DragController dragController, Workspace workspace) {
        mDragController = dragController;
        mWorkspaceScrim.setWorkspace(workspace);
        recreateControllers();

        mWorkspaceDragScrim = new WorkspaceDragScrim((this));
        mWorkspaceDragScrim.setWorkspace(workspace);

        // We delegate drawing of the workspace scrim to LauncherRootView (one level up), so as
        // to avoid artifacts when translating the entire drag layer in the -1 transition.
        mRootView = (LauncherRootView) getParent();
        mSysUiScrim = new SysUiScrim(mRootView);
        mRootView.setSysUiScrim(mSysUiScrim);


    }

    @Override
@@ -515,7 +528,7 @@ public class DragLayer extends BaseDragLayer<Launcher> {
    @Override
    protected void dispatchDraw(Canvas canvas) {
        // Draw the background below children.
        mWorkspaceScrim.draw(canvas);
        mWorkspaceDragScrim.draw(canvas);
        mOverviewScrim.updateCurrentScrimmedView(this);
        mFocusIndicatorHelper.draw(canvas);
        super.dispatchDraw(canvas);
@@ -535,18 +548,22 @@ public class DragLayer extends BaseDragLayer<Launcher> {
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mWorkspaceScrim.setSize(w, h);
        mSysUiScrim.setSize(w, h);
    }

    @Override
    public void setInsets(Rect insets) {
        super.setInsets(insets);
        mWorkspaceScrim.onInsetsChanged(insets, mAllowSysuiScrims);
        mSysUiScrim.onInsetsChanged(insets, mAllowSysuiScrims);
        mOverviewScrim.onInsetsChanged(insets);
    }

    public WorkspaceAndHotseatScrim getScrim() {
        return mWorkspaceScrim;
    public WorkspaceDragScrim getWorkspaceDragScrim() {
        return mWorkspaceDragScrim;
    }

    public SysUiScrim getSysUiScrim() {
        return mSysUiScrim;
    }

    public OverviewScrim getOverviewScrim() {
Loading