From f9c602d1d9cdcff0faafe20ab04ee6ccbe69c627 Mon Sep 17 00:00:00 2001 From: Saumya Prakash Date: Fri, 17 May 2024 23:30:17 +0000 Subject: [PATCH] Change Pinned taskbar corners to be fixed. Based on new UX guidelines, the corners for the pinned taskbar should be 16 dp. Fix: 337872323 Test: Put device in 3 button mode and pinned taskbar and observe sharper, fixed corners. Transient taskbar remains unchanged. Flag: EXEMPT bugfix Change-Id: I2130e91dcdc0afb007fde93438f3fa603bc15af8 --- .../taskbar/TaskbarActivityContext.java | 23 +++---------- .../taskbar/TaskbarBackgroundRenderer.kt | 33 ++++++++----------- .../com/android/quickstep/views/TaskView.kt | 17 +++++++++- res/values/dimens.xml | 3 ++ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 1571ac0ea5..b757842c3e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -63,7 +63,6 @@ import android.provider.Settings; import android.util.Log; import android.view.Display; import android.view.Gravity; -import android.view.RoundedCorner; import android.view.Surface; import android.view.View; import android.view.WindowInsets; @@ -167,7 +166,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext { private final TaskbarControllers mControllers; private final WindowManager mWindowManager; - private final @Nullable RoundedCorner mLeftCorner, mRightCorner; private DeviceProfile mDeviceProfile; private WindowManager.LayoutParams mWindowLayoutParams; private boolean mIsFullscreen; @@ -228,16 +226,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { Context c = getApplicationContext(); mWindowManager = c.getSystemService(WindowManager.class); - boolean phoneMode = isPhoneMode(); - mLeftCorner = phoneMode - ? null - : display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT); - mRightCorner = phoneMode - ? null - : display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT); - // Inflate views. - int taskbarLayout = DisplayController.isTransientTaskbar(this) && !phoneMode + int taskbarLayout = DisplayController.isTransientTaskbar(this) && !isPhoneMode() ? R.layout.transient_taskbar : R.layout.taskbar; mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(taskbarLayout, null, false); @@ -617,12 +607,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext { return mImeDrawsImeNavBar; } - public int getLeftCornerRadius() { - return mLeftCorner == null ? 0 : mLeftCorner.getRadius(); - } - - public int getRightCornerRadius() { - return mRightCorner == null ? 0 : mRightCorner.getRadius(); + public int getCornerRadius() { + return isPhoneMode() ? 0 : getResources().getDimensionPixelSize( + R.dimen.persistent_taskbar_corner_radius); } public WindowManager.LayoutParams getWindowLayoutParams() { @@ -1015,7 +1002,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { return mDeviceProfile.taskbarHeight - + Math.max(getLeftCornerRadius(), getRightCornerRadius()) + + getCornerRadius() + extraHeightForTaskbarTooltips; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt index e290c3fa3d..16ff665bfc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt @@ -66,15 +66,13 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { private var keyShadowDistance = 0f private var bottomMargin = 0 - private val fullLeftCornerRadius = context.leftCornerRadius.toFloat() - private val fullRightCornerRadius = context.rightCornerRadius.toFloat() - private var leftCornerRadius = fullLeftCornerRadius - private var rightCornerRadius = fullRightCornerRadius + private val fullCornerRadius = context.cornerRadius.toFloat() + private var cornerRadius = fullCornerRadius private var widthInsetPercentage = 0f - private val square: Path = Path() - private val circle: Path = Path() - private val invertedLeftCornerPath: Path = Path() - private val invertedRightCornerPath: Path = Path() + private val square = Path() + private val circle = Path() + private val invertedLeftCornerPath = Path() + private val invertedRightCornerPath = Path() private var stashedHandleWidth = context.resources.getDimensionPixelSize(R.dimen.taskbar_stashed_handle_width) @@ -103,7 +101,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { } /** - * Sets the roundness of the round corner above Taskbar. No effect on transient Taskkbar. + * Sets the roundness of the round corner above Taskbar. No effect on transient Taskbar. * * @param cornerRoundness 0 has no round corner, 1 has complete round corner. */ @@ -112,21 +110,18 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { return } - leftCornerRadius = fullLeftCornerRadius * cornerRoundness - rightCornerRadius = fullRightCornerRadius * cornerRoundness + cornerRadius = fullCornerRadius * 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. square.reset() - square.addRect(0f, 0f, leftCornerRadius, leftCornerRadius, Path.Direction.CW) + square.addRect(0f, 0f, cornerRadius, cornerRadius, Path.Direction.CW) circle.reset() - circle.addCircle(leftCornerRadius, 0f, leftCornerRadius, Path.Direction.CW) + circle.addCircle(cornerRadius, 0f, cornerRadius, Path.Direction.CW) invertedLeftCornerPath.op(square, circle, Path.Op.DIFFERENCE) - square.reset() - square.addRect(0f, 0f, rightCornerRadius, rightCornerRadius, Path.Direction.CW) circle.reset() - circle.addCircle(0f, 0f, rightCornerRadius, Path.Direction.CW) + circle.addCircle(0f, 0f, cornerRadius, Path.Direction.CW) invertedRightCornerPath.op(square, circle, Path.Op.DIFFERENCE) } @@ -160,10 +155,10 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { } // Draw the inverted rounded corners above the taskbar. - canvas.translate(0f, -leftCornerRadius) + canvas.translate(0f, -cornerRadius) canvas.drawPath(invertedLeftCornerPath, paint) - canvas.translate(0f, leftCornerRadius) - canvas.translate(canvas.width - rightCornerRadius, -rightCornerRadius) + canvas.translate(0f, cornerRadius) + canvas.translate(canvas.width - cornerRadius, -cornerRadius) canvas.drawPath(invertedRightCornerPath, paint) } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 05b9d40a7e..a38f8a08af 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -63,6 +63,7 @@ import com.android.launcher3.pm.UserCache import com.android.launcher3.testing.TestLogging import com.android.launcher3.testing.shared.TestProtocol import com.android.launcher3.util.CancellableTask +import com.android.launcher3.util.DisplayController import com.android.launcher3.util.Executors import com.android.launcher3.util.RunnableList import com.android.launcher3.util.SafeCloseable @@ -75,6 +76,7 @@ import com.android.launcher3.util.TraceHelper import com.android.launcher3.util.TransformingTouchDelegate import com.android.launcher3.util.ViewPool import com.android.launcher3.util.rects.set +import com.android.launcher3.views.ActivityContext import com.android.quickstep.RecentsModel import com.android.quickstep.RemoteAnimationTargets import com.android.quickstep.TaskAnimationManager @@ -1521,7 +1523,20 @@ constructor( @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) open fun computeWindowCornerRadius(context: Context): Float { - return QuickStepContract.getWindowCornerRadius(context) + val activityContext: ActivityContext? = ActivityContext.lookupContextNoThrow(context) + + // The corner radius is fixed to match when Taskbar is persistent mode + return if ( + activityContext != null && + activityContext.deviceProfile?.isTaskbarPresent == true && + DisplayController.isTransientTaskbar(context) + ) { + context.resources + .getDimensionPixelSize(R.dimen.persistent_taskbar_corner_radius) + .toFloat() + } else { + QuickStepContract.getWindowCornerRadius(context) + } } /** Sets the progress in range [0, 1] */ diff --git a/res/values/dimens.xml b/res/values/dimens.xml index e31a35ff6f..68641f38ad 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -443,6 +443,9 @@ 16dp + + 16dp + 1dp