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

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

[Predictive Back] Fix predictive back swipe on task bar all apps [1/n]

For taskbar all apps, the background scrim is child view of AbstractSlideInView, thus scaling AbstracSlideInView during PB swipe will scale down background scrim. There is no need to re-apply scale effect on background scrim separately.

Bug: 327490078
Flag: aconfig com.android.launcher3.enable_predictive_back_gesture TEAMFOOD
Test: manual
Change-Id: I125670d14bc788664a1371008589e4106496ae2e
parent 544f6e22
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -196,7 +196,13 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla

    @Override
    protected void dispatchDraw(Canvas canvas) {
        mAppsView.drawOnScrimWithScale(canvas, mSlideInViewScale.value);
        // We should call drawOnScrimWithBottomOffset() rather than drawOnScrimWithScale(). Because
        // for taskbar all apps, the scrim view is a child view of AbstractSlideInView. Thus scaling
        // down in AbstractSlideInView#onScaleProgressChanged() with SCALE_PROPERTY has already
        // done the job - there is no need to re-apply scale effect here. But it also means we need
        // to pass extra bottom offset to background scrim to fill the bottom gap during predictive
        // back swipe.
        mAppsView.drawOnScrimWithBottomOffset(canvas, getBottomOffsetPx());
        super.dispatchDraw(canvas);
    }

+4 −2
Original line number Diff line number Diff line
@@ -1372,7 +1372,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    }

    @Override
    public void drawOnScrimWithScale(Canvas canvas, float scale) {
    public void drawOnScrimWithScaleAndBottomOffset(
            Canvas canvas, float scale, @Px int bottomOffsetPx) {
        final View panel = mBottomSheetBackground;
        final boolean hasBottomSheet = panel.getVisibility() == VISIBLE;
        final float translationY = ((View) panel.getParent()).getTranslationY();
@@ -1384,6 +1385,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        final float topWithScale = topNoScale + verticalScaleOffset;
        final float leftWithScale = panel.getLeft() + horizontalScaleOffset;
        final float rightWithScale = panel.getRight() - horizontalScaleOffset;
        final float bottomWithOffset = panel.getBottom() + bottomOffsetPx;
        // Draw full background panel for tablets.
        if (hasBottomSheet) {
            mHeaderPaint.setColor(mBottomSheetBackgroundColor);
@@ -1393,7 +1395,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
                    leftWithScale,
                    topWithScale,
                    rightWithScale,
                    panel.getBottom());
                    bottomWithOffset);
            mTmpPath.reset();
            mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
            canvas.drawPath(mTmpPath, mHeaderPaint);
+15 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.BaseActivity;
@@ -187,9 +188,19 @@ public class ScrimView extends View implements Insettable {
     * A Utility interface allowing for other surfaces to draw on ScrimView
     */
    public interface ScrimDrawingController {
        /**
         * Called inside ScrimView#OnDraw
         */
        void drawOnScrimWithScale(Canvas canvas, float scale);

        /** Draw scrim view on canvas with scale. */
        default void drawOnScrimWithScale(Canvas canvas, float scale) {
            drawOnScrimWithScaleAndBottomOffset(canvas, scale, 0);
        }

        /** Draw scrim view on canvas with bottomOffset. */
        default void drawOnScrimWithBottomOffset(Canvas canvas, @Px int bottomOffsetPx) {
            drawOnScrimWithScaleAndBottomOffset(canvas, 1f, bottomOffsetPx);
        }

        /** Draw scrim view on canvas with scale and bottomOffset. */
        void drawOnScrimWithScaleAndBottomOffset(
                Canvas canvas, float scale, @Px int bottomOffsetPx);
    }
}