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

Commit 11579eea authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix split select scroll range when TaskView aren't shifting" into sc-v2-dev

parents 15697545 02150305
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
@@ -72,6 +73,8 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        getTaskModalnessProperty().set(mRecentsView, state.getOverviewModalness());
        RECENTS_GRID_PROGRESS.set(mRecentsView,
                state.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f);

        applySplitScrollOffset(state);
    }

    @Override
@@ -117,6 +120,16 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        boolean showAsGrid = toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile());
        setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
                showAsGrid ? INSTANT : FINAL_FRAME);

        applySplitScrollOffset(toState);
    }

    private void applySplitScrollOffset(@NonNull final LauncherState state) {
        if (state == OVERVIEW_SPLIT_SELECT) {
            mRecentsView.applySplitPrimaryScrollOffset();
        } else {
            mRecentsView.resetSplitPrimaryScrollOffset();
        }
    }

    abstract FloatProperty getTaskModalnessProperty();
+6 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public class ClearAllButton extends Button {
    private float mGridTranslationPrimary;
    private float mGridScrollOffset;
    private float mScrollOffsetPrimary;
    private float mSplitSelectScrollOffsetPrimary;

    private int mSidePadding;

@@ -167,6 +168,10 @@ public class ClearAllButton extends Button {
        mScrollOffsetPrimary = scrollOffsetPrimary;
    }

    public void setSplitSelectScrollOffsetPrimary(float splitSelectScrollOffsetPrimary) {
        mSplitSelectScrollOffsetPrimary = splitSelectScrollOffsetPrimary;
    }

    public float getScrollAdjustment(boolean fullscreenEnabled, boolean gridEnabled) {
        float scrollAdjustment = 0;
        if (fullscreenEnabled) {
@@ -176,6 +181,7 @@ public class ClearAllButton extends Button {
            scrollAdjustment += mGridTranslationPrimary + mGridScrollOffset;
        }
        scrollAdjustment += mScrollOffsetPrimary;
        scrollAdjustment += mSplitSelectScrollOffsetPrimary;
        return scrollAdjustment;
    }

+51 −31
Original line number Diff line number Diff line
@@ -2646,8 +2646,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * and then animates it into the split position that was desired
     */
    private void createInitialSplitSelectAnimation(PendingAnimation anim) {
        float placeholderHeight = getResources().getDimension(R.dimen.split_placeholder_size);
        mOrientationHandler.getInitialSplitPlaceholderBounds((int) placeholderHeight,
        mOrientationHandler.getInitialSplitPlaceholderBounds(mSplitPlaceholderSize,
                mActivity.getDeviceProfile(),
                mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);

@@ -3241,14 +3240,13 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        }

        Rect splitBounds = new Rect();
        float placeholderSize = getResources().getDimension(R.dimen.split_placeholder_size);
        // This acts as a best approximation on where the splitplaceholder view would be,
        // doesn't need to be exact necessarily. This also doesn't need to take translations
        // into account since placeholder view is not translated
        if (stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT) {
            splitBounds.set((int) (getWidth() - placeholderSize), 0, getWidth(), getHeight());
            splitBounds.set(getWidth() - mSplitPlaceholderSize, 0, getWidth(), getHeight());
        } else {
            splitBounds.set(0, 0, (int) (placeholderSize), getHeight());
            splitBounds.set(0, 0, mSplitPlaceholderSize, getHeight());
        }
        Rect taskBounds = new Rect();
        int taskCount = getTaskViewCount();
@@ -3748,6 +3746,50 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        }
    }

    /**
     * Apply scroll offset to children of RecentsView when entering split select.
     */
    public void applySplitPrimaryScrollOffset() {
        if (!mActivity.getDeviceProfile().isLandscape || !showAsGrid()) {
            return;
        }

        @StagePosition int position = mSplitSelectStateController.getActiveSplitStagePosition();
        boolean shouldShiftThumbnailsForSplitSelect = shouldShiftThumbnailsForSplitSelect(
                position);
        boolean expandLeft = false;
        boolean expandRight = false;
        if (mIsRtl) {
            if (position == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT
                    && shouldShiftThumbnailsForSplitSelect) {
                expandLeft = true;
            } else if (position == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
                if (shouldShiftThumbnailsForSplitSelect) {
                    expandRight = true;
                } else {
                    expandLeft = true;
                }
            }
        } // TODO(b/200537659): Handle system RTL.
        if (expandRight) {
            for (int i = 0; i < getTaskViewCount(); i++) {
                getTaskViewAt(i).setSplitScrollOffsetPrimary(mSplitPlaceholderSize);
            }
        } else if (expandLeft) {
            mClearAllButton.setSplitSelectScrollOffsetPrimary(-mSplitPlaceholderSize);
        }
    }

    /**
     * Reset scroll offset on children of RecentsView when exiting split select.
     */
    public void resetSplitPrimaryScrollOffset() {
        for (int i = 0; i < getTaskViewCount(); i++) {
            getTaskViewAt(i).setSplitScrollOffsetPrimary(0);
        }
        mClearAllButton.setSplitSelectScrollOffsetPrimary(0);
    }

    /**
     * Resets the visuals when exit modal state.
     */
@@ -4369,27 +4411,16 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    @Override
    protected int computeMinScroll() {
        if (getTaskViewCount() > 0) {
            int minScroll;
            boolean isLandscapeGridSplit = mActivity.getDeviceProfile().isLandscape
                    && showAsGrid() && isSplitSelectionActive();
            if (mIsRtl) {
                // If we aren't showing the clear all button, use the rightmost task as the min
                // scroll.
                minScroll = getScrollForPage(mDisallowScrollToClearAll ? indexOfChild(
                return getScrollForPage(mDisallowScrollToClearAll ? indexOfChild(
                        getTaskViewAt(getTaskViewCount() - 1)) : indexOfChild(mClearAllButton));
                if (isLandscapeGridSplit
                        && mSplitSelectStateController.getActiveSplitStagePosition()
                        == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT) {
                    minScroll -= mSplitPlaceholderSize;
                }
            } else {
                TaskView focusedTaskView = mShowAsGridLastOnLayout ? getFocusedTaskView() : null;
                minScroll = getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                return getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                        : 0);
                // TODO(b/200537659): Adjust according to mSplitPlaceholderSize when
                //  isLandscapeGridSplit is true.
            }
            return minScroll;
        }
        return super.computeMinScroll();
    }
@@ -4397,27 +4428,16 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    @Override
    protected int computeMaxScroll() {
        if (getTaskViewCount() > 0) {
            int maxScroll;
            boolean isLandscapeGridSplit = mActivity.getDeviceProfile().isLandscape
                    && showAsGrid() && isSplitSelectionActive();
            if (mIsRtl) {
                TaskView focusedTaskView = mShowAsGridLastOnLayout ? getFocusedTaskView() : null;
                maxScroll = getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                return getScrollForPage(focusedTaskView != null ? indexOfChild(focusedTaskView)
                        : 0);
                if (isLandscapeGridSplit
                        && mSplitSelectStateController.getActiveSplitStagePosition()
                        == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
                    maxScroll += mSplitPlaceholderSize;
                }
            } else {
                // If we aren't showing the clear all button, use the leftmost task as the min
                // scroll.
                maxScroll = getScrollForPage(mDisallowScrollToClearAll ? indexOfChild(
                return getScrollForPage(mDisallowScrollToClearAll ? indexOfChild(
                        getTaskViewAt(getTaskViewCount() - 1)) : indexOfChild(mClearAllButton));
                // TODO(b/200537659): Adjust according to mSplitPlaceholderSize when
                //  isLandscapeGridSplit is true.
            }
            return maxScroll;
        }
        return super.computeMaxScroll();
    }
+7 −0
Original line number Diff line number Diff line
@@ -389,6 +389,7 @@ public class TaskView extends FrameLayout implements Reusable {
    // Used when in SplitScreenSelectState
    private float mSplitSelectTranslationY;
    private float mSplitSelectTranslationX;
    private float mSplitSelectScrollOffsetPrimary;

    private ObjectAnimator mIconAndDimAnimator;
    private float mIconScaleAnimStartProgress = 0;
@@ -1031,6 +1032,11 @@ public class TaskView extends FrameLayout implements Reusable {
        mSplitSelectTranslationY = y;
        applyTranslationY();
    }

    public void setSplitScrollOffsetPrimary(float splitSelectScrollOffsetPrimary) {
        mSplitSelectScrollOffsetPrimary = splitSelectScrollOffsetPrimary;
    }

    private void setDismissTranslationX(float x) {
        mDismissTranslationX = x;
        applyTranslationX();
@@ -1101,6 +1107,7 @@ public class TaskView extends FrameLayout implements Reusable {
        } else {
            scrollAdjustment += getPrimaryNonGridTranslationProperty().get(this);
        }
        scrollAdjustment += mSplitSelectScrollOffsetPrimary;
        return scrollAdjustment;
    }