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

Commit 191152d6 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal Committed by Sahil Sonar
Browse files

fix(qsb): remove padding only from -1 screen



[SahilSonar - adapted to A14]

Signed-off-by: default avatarSahilSonar <sss.sonar2003@gmail.com>
parent aeadc0af
Loading
Loading
Loading
Loading
Loading
+120 −7
Original line number Diff line number Diff line
@@ -59,12 +59,16 @@ import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.PagedOrientationHandler.ChildBounds;
import com.android.launcher3.util.EdgeEffectCompat;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.window.WindowManagerProxy;
import com.android.launcher3.views.ActivityContext;

import java.util.ArrayList;
import java.util.function.Consumer;

import foundation.e.bliss.utils.Logger;

/**
 * An abstraction of the original Workspace which supports browsing through a
 * sequential list of "pages"
@@ -155,6 +159,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou

    protected EdgeEffectCompat mEdgeGlowLeft;
    protected EdgeEffectCompat mEdgeGlowRight;
    protected NavigationMode navMode;

    public PagedView(Context context) {
        this(context, null);
@@ -183,6 +188,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        mTouchSlop = configuration.getScaledTouchSlop();
        mPageSlop = configuration.getScaledPagingTouchSlop();
        mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
        navMode = WindowManagerProxy.INSTANCE.get(getContext()).getNavigationMode(getContext());

        updateVelocityValues();

@@ -667,6 +673,47 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        super.forceLayout();
    }

    public static class LayoutParams extends ViewGroup.LayoutParams {
        public boolean isFullScreenPage = false;

        /**
         * {@inheritDoc}
         */
        public LayoutParams(int width, int height) {
            super(width, height);
        }

        public LayoutParams(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public LayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }
    }


    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new LayoutParams(getContext(), attrs);
    }

    @Override
    protected LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    }

    @Override
    protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
        return new LayoutParams(p);
    }

    public void addFullScreenPage(View page, int index) {
        LayoutParams lp = generateDefaultLayoutParams();
        lp.isFullScreenPage = true;
        super.addView(page, index, lp);
    }

    private int getPageWidthSize(int widthSize) {
        // It's necessary to add the padding back because it is remove when measuring children,
        // like when MeasureSpec.getSize in CellLayout.
@@ -688,6 +735,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        int heightSize = MeasureSpec.getSize(heightMeasureSpec);

        /* Allow the height to be set as WRAP_CONTENT. This allows the particular case
         * of the All apps view on XLarge displays to not take up more space then it needs. Width
         * is still not allowed to be set as WRAP_CONTENT since many parts of the code expect
         * each effect_page to have the same width.
         */
        final int verticalPadding = getPaddingTop() + getPaddingBottom();
        final int horizontalPadding = getPaddingLeft() + getPaddingRight();

        if (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            return;
@@ -703,6 +758,63 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        // unless they were set to WRAP_CONTENT
        if (DEBUG) Log.d(TAG, "PagedView.onMeasure(): " + widthSize + ", " + heightSize);

        if (this instanceof Workspace) {
            for (int i = 0; i < getChildCount(); i++) {
                final View child = getPageAt(i);
                if (child.getVisibility() != GONE) {
                    final LayoutParams lp = (LayoutParams) child.getLayoutParams();

                    int childWidthMode;
                    int childHeightMode;
                    int childWidth;
                    int childHeight;
                    int topPadding;
                    int bottomPadding;

                    if (!lp.isFullScreenPage) {
                        if (lp.width == LayoutParams.WRAP_CONTENT) {
                            childWidthMode = MeasureSpec.AT_MOST;
                        } else {
                            childWidthMode = MeasureSpec.EXACTLY;
                        }

                        if (lp.height == LayoutParams.WRAP_CONTENT) {
                            childHeightMode = MeasureSpec.AT_MOST;
                        } else {
                            childHeightMode = MeasureSpec.EXACTLY;
                        }

                        childWidth = getPageWidthSize(widthSize);
                        childHeight = heightSize - mInsets.top - mInsets.bottom - verticalPadding;
                    } else {
                        childWidthMode = MeasureSpec.EXACTLY;
                        childHeightMode = MeasureSpec.EXACTLY;

                        childWidth = getPageWidthSize(widthSize) - horizontalPadding
                                - mInsets.left - mInsets.right;
                        childHeight = heightSize + verticalPadding;

                        topPadding = verticalPadding;
                        bottomPadding = mInsets.bottom;

                        if (navMode == NavigationMode.NO_BUTTON) {
                            topPadding += mInsets.top;
                        } else {
                            topPadding += mInsets.top + 40;
                            bottomPadding -= 40;
                        }

                        child.setPadding(child.getPaddingLeft(), topPadding,
                                child.getPaddingRight(), bottomPadding);
                    }
                    final int childWidthMeasureSpec =
                            MeasureSpec.makeMeasureSpec(childWidth, childWidthMode);
                    final int childHeightMeasureSpec =
                            MeasureSpec.makeMeasureSpec(childHeight, childHeightMode);
                    child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
                }
            }
        } else {
            int myWidthSpec = MeasureSpec.makeMeasureSpec(
                    getPageWidthSize(widthSize), MeasureSpec.EXACTLY);
            int myHeightSpec = MeasureSpec.makeMeasureSpec(
@@ -711,6 +823,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
            // measureChildren takes accounts for content padding, we only need to care about extra
            // space due to insets.
            measureChildren(myWidthSpec, myHeightSpec);
        }
        setMeasuredDimension(widthSize, heightSize);
    }

+9 −3
Original line number Diff line number Diff line
@@ -733,7 +733,11 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>

        mWorkspaceScreens.put(screenId, newScreen);
        mScreenOrder.add(insertIndex, screenId);
        if (screenId == FIRST_SCREEN_ID && FeatureFlags.QSB_ON_FIRST_SCREEN.get()) {
            addFullScreenPage(newScreen, insertIndex);
        } else {
            addView(newScreen, insertIndex);
        }
        mStateTransitionAnimation.applyChildState(
                mLauncher.getStateManager().getState(), newScreen, insertIndex);

@@ -1378,8 +1382,10 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>

        getHotseat().setForcedTranslationY(dockTranslationY);
        ((PageIndicatorDots) getPageIndicator()).setForcedTranslationY(dockTranslationY);
        setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(),
                progress != 0 ? (int) qsbPadding : getPaddingBottom());
        CellLayout firstScreen = mWorkspaceScreens.get(FIRST_SCREEN_ID);
        firstScreen.setPadding(
                firstScreen.getPaddingLeft(), firstScreen.getPaddingTop(), firstScreen.getPaddingRight(),
                progress != 0 ? (int) qsbPadding : firstScreen.getPaddingBottom());

        if (getCurrentPage() != 0) {
            mLauncher.mBlurLayer.setAlpha(0f);