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

Commit 3cf77927 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Change taskbar corner roundness when entering overview" into tm-qpr-dev

parents 5b80c914 68e7fe6b
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -44,8 +44,12 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
    private var keyShadowDistance = 0f
    private var bottomMargin = 0

    private val leftCornerRadius = context.leftCornerRadius.toFloat()
    private val rightCornerRadius = context.rightCornerRadius.toFloat()
    private val fullLeftCornerRadius = context.leftCornerRadius.toFloat()
    private val fullRightCornerRadius = context.rightCornerRadius.toFloat()
    private var leftCornerRadius = fullLeftCornerRadius
    private var rightCornerRadius = fullRightCornerRadius
    private val square: Path = Path()
    private val circle: Path = Path()
    private val invertedLeftCornerPath: Path = Path()
    private val invertedRightCornerPath: Path = Path()

@@ -63,13 +67,29 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
            keyShadowDistance = res.getDimension(R.dimen.transient_taskbar_key_shadow_distance)
        }

        setCornerRoundness(DEFAULT_ROUNDNESS)
    }

    /**
     * Sets the roundness of the round corner above Taskbar. No effect on transient Taskkbar.
     * @param cornerRoundness 0 has no round corner, 1 has complete round corner.
     */
    fun setCornerRoundness(cornerRoundness: Float) {
        if (isTransientTaskbar && !transientBackgroundBounds.isEmpty) {
            return
        }

        leftCornerRadius = fullLeftCornerRadius * cornerRoundness
        rightCornerRadius = fullRightCornerRadius * cornerRoundness

        // Create the paths for the inverted rounded corners above the taskbar. Start with a filled
        // square, and then subtract out a circle from the appropriate corner.
        val square = Path()
        square.reset()
        square.addRect(0f, 0f, leftCornerRadius, leftCornerRadius, Path.Direction.CW)
        val circle = Path()
        circle.reset()
        circle.addCircle(leftCornerRadius, 0f, leftCornerRadius, Path.Direction.CW)
        invertedLeftCornerPath.op(square, circle, Path.Op.DIFFERENCE)

        square.reset()
        square.addRect(0f, 0f, rightCornerRadius, rightCornerRadius, Path.Direction.CW)
        circle.reset()
@@ -121,4 +141,8 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {

        canvas.restore()
    }

    companion object {
        const val DEFAULT_ROUNDNESS = 1f
    }
}
+36 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.annotation.VisibleForTesting;

import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.quickstep.AnimatedFloat;
import com.android.systemui.shared.rotation.RotationButtonController;

import java.io.PrintWriter;
@@ -58,6 +59,7 @@ public class TaskbarControllers {
    public final TaskbarOverlayController taskbarOverlayController;

    @Nullable private LoggableTaskbarController[] mControllersToLog = null;
    @Nullable private BackgroundRendererController[] mBackgroundRendererControllers = null;

    /** Do not store this controller, as it may change at runtime. */
    @NonNull public TaskbarUIController uiController = TaskbarUIController.DEFAULT;
@@ -67,6 +69,9 @@ public class TaskbarControllers {

    @Nullable private TaskbarSharedState mSharedState = null;

    // Roundness property for round corner above taskbar .
    private final AnimatedFloat mCornerRoundness = new AnimatedFloat(this::updateCornerRoundness);

    public TaskbarControllers(TaskbarActivityContext taskbarActivityContext,
            TaskbarDragController taskbarDragController,
            TaskbarNavButtonController navButtonController,
@@ -148,6 +153,11 @@ public class TaskbarControllers {
                taskbarAutohideSuspendController, taskbarPopupController, taskbarInsetsController,
                voiceInteractionWindowController
        };
        mBackgroundRendererControllers = new BackgroundRendererController[] {
                taskbarDragLayerController, taskbarScrimViewController,
                voiceInteractionWindowController
        };
        mCornerRoundness.updateValue(TaskbarBackgroundRenderer.DEFAULT_ROUNDNESS);

        mAreAllControllersInitialized = true;
        for (Runnable postInitCallback : mPostInitCallbacks) {
@@ -191,6 +201,7 @@ public class TaskbarControllers {
        taskbarRecentAppsController.onDestroy();

        mControllersToLog = null;
        mBackgroundRendererControllers = null;
    }

    /**
@@ -224,6 +235,23 @@ public class TaskbarControllers {
        rotationButtonController.dumpLogs(prefix + "\t", pw);
    }

    /**
     * Returns a float property that animates roundness of the round corner above Taskbar.
     */
    public AnimatedFloat getTaskbarCornerRoundness() {
        return mCornerRoundness;
    }

    private void updateCornerRoundness() {
        if (mBackgroundRendererControllers == null) {
            return;
        }

        for (BackgroundRendererController controller : mBackgroundRendererControllers) {
            controller.setCornerRoundness(mCornerRoundness.value);
        }
    }

    @VisibleForTesting
    TaskbarActivityContext getTaskbarActivityContext() {
        // Used to mock
@@ -233,4 +261,12 @@ public class TaskbarControllers {
    protected interface LoggableTaskbarController {
        void dumpLogs(String prefix, PrintWriter pw);
    }

    protected interface BackgroundRendererController {
        /**
         * Sets the roundness of the round corner above Taskbar.
         * @param cornerRoundness 0 has no round corner, 1 has complete round corner.
         */
        void setCornerRoundness(float cornerRoundness);
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -158,6 +158,15 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
        invalidate();
    }

    /**
     * Sets the roundness of the round corner above Taskbar.
     * @param cornerRoundness 0 has no round corner, 1 has complete round corner.
     */
    protected void setCornerRoundness(float cornerRoundness) {
        mBackgroundRenderer.setCornerRoundness(cornerRoundness);
        invalidate();
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        TestLogging.recordMotionEvent(TestProtocol.SEQUENCE_MAIN, "Touch event", ev);
+7 −1
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ import java.io.PrintWriter;
/**
 * Handles properties/data collection, then passes the results to TaskbarDragLayer to render.
 */
public class TaskbarDragLayerController implements TaskbarControllers.LoggableTaskbarController {
public class TaskbarDragLayerController implements TaskbarControllers.LoggableTaskbarController,
        TaskbarControllers.BackgroundRendererController {

    private final TaskbarActivityContext mActivity;
    private final TaskbarDragLayer mTaskbarDragLayer;
@@ -138,6 +139,11 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
        updateNavBarDarkIntensityMultiplier();
    }

    @Override
    public void setCornerRoundness(float cornerRoundness) {
        mTaskbarDragLayer.setCornerRoundness(cornerRoundness);
    }

    private void updateNavBarDarkIntensityMultiplier() {
        // Zero out the app-requested dark intensity when we're drawing our own background.
        float effectiveBgAlpha = mLastSetBackgroundAlpha * (1 - mBgOffset.value);
+16 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import java.util.StringJoiner;

    private TaskbarControllers mControllers;
    private AnimatedFloat mTaskbarBackgroundAlpha;
    private AnimatedFloat mTaskbarCornerRoundness;
    private MultiProperty mIconAlphaForHome;
    private QuickstepLauncher mLauncher;

@@ -133,6 +134,7 @@ import java.util.StringJoiner;

        mTaskbarBackgroundAlpha = mControllers.taskbarDragLayerController
                .getTaskbarBackgroundAlpha();
        mTaskbarCornerRoundness = mControllers.getTaskbarCornerRoundness();
        mIconAlphaForHome = mControllers.taskbarViewController
                .getTaskbarIconAlpha().get(ALPHA_INDEX_HOME);

@@ -316,6 +318,19 @@ import java.util.StringJoiner;
                    .setDuration(duration));
        }

        float cornerRoundness = goingToLauncher ? 0 : 1;
        // Don't animate if corner roundness has reached desired value.
        if (mTaskbarCornerRoundness.isAnimating()
                || mTaskbarCornerRoundness.value != cornerRoundness) {
            mTaskbarCornerRoundness.cancelAnimation();
            if (DEBUG) {
                Log.d(TAG, "onStateChangeApplied - taskbarCornerRoundness - "
                        + mTaskbarCornerRoundness.value
                        + " -> " + cornerRoundness + ": " + duration);
            }
            animatorSet.play(mTaskbarCornerRoundness.animateToValue(cornerRoundness));
        }

        if (mIconAlignment.isAnimatingToValue(toAlignment)
                || mIconAlignment.isSettledOnValue(toAlignment)) {
            // Already at desired value, but make sure we run the callback at the end.
@@ -333,6 +348,7 @@ import java.util.StringJoiner;
            }
            animatorSet.play(iconAlignAnim);
        }

        animatorSet.setInterpolator(EMPHASIZED);

        if (start) {
Loading