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

Commit ab04ffb4 authored by Fengjiang Li's avatar Fengjiang Li
Browse files

[Predictive Back] All apps to home on tablet

Scale down bottom sheet background during predictive back on tablet

Test: manual
Bug: b/267226579, b/267226556
Change-Id: Ie67689a05d631a480bcc2ae602b5caf4feaf8182
parent b9f27271
Loading
Loading
Loading
Loading
+51 −21
Original line number Diff line number Diff line
@@ -1101,15 +1101,26 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>

    @Override
    public void drawOnScrimWithScale(Canvas canvas, float scale) {
        boolean isTablet = mActivityContext.getDeviceProfile().isTablet;
        final boolean isTablet = mActivityContext.getDeviceProfile().isTablet;
        final View panel = mBottomSheetBackground;
        final float translationY = ((View) panel.getParent()).getTranslationY();

        final float horizontalScaleOffset = (1 - scale) * panel.getWidth() / 2;
        final float verticalScaleOffset = (1 - scale) * (panel.getHeight() - getHeight() / 2);

        final float topNoScale = panel.getTop() + translationY;
        final float topWithScale = topNoScale + verticalScaleOffset;
        final float leftWithScale = panel.getLeft() + horizontalScaleOffset;
        final float rightWithScale = panel.getRight() - horizontalScaleOffset;
        // Draw full background panel for tablets.
        if (isTablet) {
            mHeaderPaint.setColor(mBottomSheetBackgroundColor);
            View panel = (View) mBottomSheetBackground;
            float translationY = ((View) panel.getParent()).getTranslationY();
            mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY,
                    panel.getRight(), panel.getBottom());

            mTmpRectF.set(
                    leftWithScale,
                    topWithScale,
                    rightWithScale,
                    panel.getBottom());
            mTmpPath.reset();
            mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
            canvas.drawPath(mTmpPath, mHeaderPaint);
@@ -1125,25 +1136,33 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        if (mHeaderPaint.getColor() == mScrimColor || mHeaderPaint.getColor() == 0) {
            return;
        }
        final float offset = (getVisibleContainerView().getHeight() * (1 - scale) / 2);
        final float bottom =
                scale * (getHeaderBottom() + getVisibleContainerView().getPaddingTop()) + offset;
        FloatingHeaderView headerView = getFloatingHeaderView();

        // Draw header on background panel
        final float headerBottomNoScale =
                getHeaderBottom() + getVisibleContainerView().getPaddingTop();
        final float headerHeightNoScale = headerBottomNoScale - topNoScale;
        final float headerBottomWithScaleOnTablet = topWithScale + headerHeightNoScale * scale;
        final float headerBottomOffset = (getVisibleContainerView().getHeight() * (1 - scale) / 2);
        final float headerBottomWithScaleOnPhone = headerBottomNoScale * scale + headerBottomOffset;
        final FloatingHeaderView headerView = getFloatingHeaderView();
        if (isTablet) {
            // Start adding header protection if search bar or tabs will attach to the top.
            if (!isSearchBarOnBottom() || mUsingTabs) {
                View panel = (View) mBottomSheetBackground;
                float translationY = ((View) panel.getParent()).getTranslationY();
                mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY, panel.getRight(),
                        bottom);
            if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
                mTmpRectF.set(
                        leftWithScale,
                        topWithScale,
                        rightWithScale,
                        headerBottomWithScaleOnTablet);
                mTmpPath.reset();
                mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
                canvas.drawPath(mTmpPath, mHeaderPaint);
            }
        } else {
            canvas.drawRect(0, 0, canvas.getWidth(), bottom, mHeaderPaint);
            canvas.drawRect(0, 0, canvas.getWidth(), headerBottomWithScaleOnPhone, mHeaderPaint);
        }
        int tabsHeight = headerView.getPeripheralProtectionHeight();

        // If tab exist (such as work profile), extend header with tab height
        final int tabsHeight = headerView.getPeripheralProtectionHeight();
        if (mTabsProtectionAlpha > 0 && tabsHeight != 0) {
            if (DEBUG_HEADER_PROTECTION) {
                mHeaderPaint.setColor(Color.BLUE);
@@ -1151,13 +1170,24 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
            } else {
                mHeaderPaint.setAlpha((int) (getAlpha() * mTabsProtectionAlpha));
            }
            int left = 0;
            int right = canvas.getWidth();
            float left = 0f;
            float right = canvas.getWidth();
            if (isTablet) {
                left = mBottomSheetBackground.getLeft();
                right = mBottomSheetBackground.getRight();
                left = mBottomSheetBackground.getLeft() + horizontalScaleOffset;
                right = mBottomSheetBackground.getRight() - horizontalScaleOffset;
            }
            canvas.drawRect(left, bottom, right, bottom + tabsHeight, mHeaderPaint);

            final float tabTopWithScale = isTablet
                    ? headerBottomWithScaleOnTablet
                    : headerBottomWithScaleOnPhone;
            final float tabBottomWithScale = tabTopWithScale + tabsHeight * scale;

            canvas.drawRect(
                    left,
                    tabTopWithScale,
                    right,
                    tabBottomWithScale,
                    mHeaderPaint);
        }
    }