diff options
| author | 2025-02-25 10:03:02 -0800 | |
|---|---|---|
| committer | 2025-02-25 10:03:02 -0800 | |
| commit | ccb979d47754ec6dfaa42594becd5bb693bec68e (patch) | |
| tree | baa9b8ca42c5892e00de669cd676856b95c3b986 | |
| parent | 0401f6e4476a982c66a2230bb8ebacc6031b0f43 (diff) | |
| parent | d86df12d17a882dea67ab4d1b69ad034f59d2f81 (diff) | |
Merge "Fixing tiling divider rounded corners and spec colors" into main
11 files changed, 151 insertions, 6 deletions
diff --git a/libs/WindowManager/Shell/res/values/colors.xml b/libs/WindowManager/Shell/res/values/colors.xml index d754243a2b07..8d18f959951b 100644 --- a/libs/WindowManager/Shell/res/values/colors.xml +++ b/libs/WindowManager/Shell/res/values/colors.xml @@ -68,4 +68,8 @@ <color name="desktop_mode_caption_button_on_hover_light">#11000000</color> <color name="desktop_mode_caption_button_on_hover_dark">#11FFFFFF</color> <color name="desktop_mode_caption_button">#00000000</color> + <color name="tiling_divider_background_light">#C9C7B6</color> + <color name="tiling_divider_background_dark">#4A4739</color> + <color name="tiling_handle_background_light">#000000</color> + <color name="tiling_handle_background_dark">#FFFFFF</color> </resources> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerHandleView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerHandleView.java index 6c04e2aa57a7..d304e20bcffc 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerHandleView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerHandleView.java @@ -80,7 +80,19 @@ public class DividerHandleView extends View { private int mHoveringWidth; private int mHoveringHeight; private boolean mIsLeftRightSplit; - + private boolean mIsSplitScreen; + + /** + * Notifies the divider of ui mode change. + * + * @param isDarkMode Whether the mode is ui dark mode. + */ + public void onUiModeChange(boolean isDarkMode) { + if (!mIsSplitScreen) { + mPaint.setColor(getTilingHandleColor(isDarkMode)); + invalidate(); + } + } public DividerHandleView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mPaint.setColor(getResources().getColor(R.color.docked_divider_handle, null)); @@ -103,6 +115,27 @@ public class DividerHandleView extends View { mHoveringHeight = mHeight > mWidth ? ((int) (mHeight * 1.5f)) : mHeight; } + /** + * Used by tiling infrastructure to specify display light/dark mode and + * whether handle colors should be overridden on display mode change in case + * of non split screen. + * @param isSplitScreen Whether the divider is used by split screen or tiling. + * @param isDarkMode Whether the mode is ui dark mode. + */ + public void setup(boolean isSplitScreen, boolean isDarkMode) { + mIsSplitScreen = isSplitScreen; + if (!mIsSplitScreen) { + mPaint.setColor(getTilingHandleColor(isDarkMode)); + setAlpha(.9f); + } + } + + private int getTilingHandleColor(Boolean isDarkMode) { + return isDarkMode ? getResources().getColor( + R.color.tiling_handle_background_dark, null /* theme */) : getResources().getColor( + R.color.tiling_handle_background_light, null /* theme */); + } + /** sets whether it's a left/right or top/bottom split */ public void setIsLeftRightSplit(boolean isLeftRightSplit) { mIsLeftRightSplit = isLeftRightSplit; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerRoundedCorner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerRoundedCorner.java index d5aaf752c3e0..cf0ecae7c815 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerRoundedCorner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerRoundedCorner.java @@ -47,15 +47,17 @@ public class DividerRoundedCorner extends View { private InvertedRoundedCornerDrawInfo mBottomLeftCorner; private InvertedRoundedCornerDrawInfo mBottomRightCorner; private boolean mIsLeftRightSplit; + private boolean mIsSplitScreen; public DividerRoundedCorner(Context context, @Nullable AttributeSet attrs) { super(context, attrs); mDividerWidth = getResources().getDimensionPixelSize(R.dimen.split_divider_bar_width); mDividerBarBackground = new Paint(); mDividerBarBackground.setColor( - getResources().getColor(R.color.split_divider_background, null)); + getResources().getColor(R.color.split_divider_background, null /* theme */)); mDividerBarBackground.setFlags(Paint.ANTI_ALIAS_FLAG); mDividerBarBackground.setStyle(Paint.Style.FILL); + mIsSplitScreen = false; } @Override @@ -99,7 +101,41 @@ public class DividerRoundedCorner extends View { } /** + * Used by tiling infrastructure to specify display light/dark mode and + * whether handle colors should be overridden on display mode change in case + * of non split screen. + * + * @param isSplitScreen Whether the divider is used by split screen or tiling. + * @param isDarkMode Whether the mode is ui dark mode. + */ + public void setup(boolean isSplitScreen, boolean isDarkMode) { + mIsSplitScreen = isSplitScreen; + if (!isSplitScreen) { + mDividerBarBackground.setColor(getTilingHandleColor(isDarkMode)); + } + } + + /** + * Notifies the divider of ui mode change. + * + * @param isDarkMode Whether the mode is ui dark mode. + */ + public void onUiModeChange(boolean isDarkMode) { + if (!mIsSplitScreen) { + mDividerBarBackground.setColor(getTilingHandleColor(isDarkMode)); + invalidate(); + } + } + + private int getTilingHandleColor(boolean isDarkMode) { + return isDarkMode ? getResources().getColor( + R.color.tiling_divider_background_dark, null /* theme */) : getResources().getColor( + R.color.tiling_divider_background_light, null /* theme */); + } + + /** * Set whether the rounded corner is for a left/right split. + * * @param isLeftRightSplit whether it's a left/right split or top/bottom split. */ public void setIsLeftRightSplit(boolean isLeftRightSplit) { @@ -123,7 +159,16 @@ public class DividerRoundedCorner extends View { mCornerPosition = cornerPosition; final RoundedCorner roundedCorner = getDisplay().getRoundedCorner(cornerPosition); - mRadius = roundedCorner == null ? 0 : roundedCorner.getRadius(); + if (mIsSplitScreen) { + mRadius = roundedCorner == null ? 0 : roundedCorner.getRadius(); + } else { + mRadius = mContext + .getResources() + .getDimensionPixelSize( + com.android.wm.shell.shared.R.dimen + .desktop_windowing_freeform_rounded_corner_radius); + } + // Starts with a filled square, and then subtracting out a circle from the appropriate // corner. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java index 0d773ecf88e4..7ef1a93cbe45 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java @@ -558,6 +558,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, } else { decoration.relayout(taskInfo, taskInfo.isFocused, decoration.mExclusionRegion); } + mDesktopTilingDecorViewModel.onTaskInfoChange(taskInfo); mActivityOrientationChangeHandler.ifPresent(handler -> handler.handleActivityOrientationChange(oldTaskInfo, taskInfo)); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt index ee5d0e80d90c..e9426d2f67ad 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt @@ -137,6 +137,10 @@ class DesktopTilingDecorViewModel( } } + fun onTaskInfoChange(taskInfo: RunningTaskInfo) { + tilingTransitionHandlerByDisplayId.get(taskInfo.displayId)?.onTaskInfoChange(taskInfo) + } + override fun onDisplayChange( displayId: Int, fromRotation: Int, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManager.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManager.kt index fbbf1a5db72c..cb45c1732476 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManager.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManager.kt @@ -57,6 +57,7 @@ class DesktopTilingDividerWindowManager( private val transactionSupplier: Supplier<SurfaceControl.Transaction>, private var dividerBounds: Rect, private val displayContext: Context, + private val isDarkMode: Boolean, ) : WindowlessWindowManager(config, leash, null), DividerMoveCallback, View.OnLayoutChangeListener { private lateinit var viewHost: SurfaceControlViewHost private var tilingDividerView: TilingDividerView? = null @@ -153,7 +154,7 @@ class DesktopTilingDividerWindowManager( surfaceControlViewHost.setView(dividerView, lp) val tmpDividerBounds = Rect() getDividerBounds(tmpDividerBounds) - dividerView.setup(this, tmpDividerBounds, handleRegionSize) + dividerView.setup(this, tmpDividerBounds, handleRegionSize, isDarkMode) t.setRelativeLayer(leash, relativeLeash, 1) .setPosition( leash, @@ -172,6 +173,11 @@ class DesktopTilingDividerWindowManager( updateTouchRegion() } + /** Changes divider colour if dark/light mode is toggled. */ + fun onUiModeChange(isDarkMode: Boolean) { + tilingDividerView?.onUiModeChange(isDarkMode) + } + /** Hides the divider bar. */ fun hideDividerBar() { if (!dividerShown) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt index 983332565bd9..a45df045041f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt @@ -103,6 +103,7 @@ class DesktopTilingWindowDecoration( @VisibleForTesting var desktopTilingDividerWindowManager: DesktopTilingDividerWindowManager? = null private lateinit var dividerBounds: Rect + private var isDarkMode = false private var isResizing = false private var isTilingFocused = false @@ -129,6 +130,7 @@ class DesktopTilingWindowDecoration( val isTiled = destinationBounds != taskInfo.configuration.windowConfiguration.bounds initTilingApps(resizeMetadata, position, taskInfo) + isDarkMode = isTaskInDarkMode(taskInfo) // Observe drag resizing to break tiling if a task is drag resized. desktopModeWindowDecoration.addDragResizeListener(this) @@ -232,6 +234,7 @@ class DesktopTilingWindowDecoration( transactionSupplier, dividerBounds, displayContext, + isDarkMode, ) } // a leash to present the divider on top of, without re-parenting. @@ -356,6 +359,17 @@ class DesktopTilingWindowDecoration( transitions.startTransition(TRANSIT_CHANGE, wct, this) } + fun onTaskInfoChange(taskInfo: RunningTaskInfo) { + val isCurrentTaskInDarkMode = isTaskInDarkMode(taskInfo) + if (isCurrentTaskInDarkMode == isDarkMode || !isTilingManagerInitialised) return + isDarkMode = isCurrentTaskInDarkMode + desktopTilingDividerWindowManager?.onUiModeChange(isDarkMode) + } + + fun isTaskInDarkMode(taskInfo: RunningTaskInfo): Boolean = + (taskInfo.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == + Configuration.UI_MODE_NIGHT_YES + override fun startAnimation( transition: IBinder, info: TransitionInfo, diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/TilingDividerView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/TilingDividerView.kt index b8e3b0fdb8d8..54dcd2d082dc 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/TilingDividerView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/TilingDividerView.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.windowdecor.tiling import android.content.Context +import android.content.res.Configuration import android.graphics.Canvas import android.graphics.Paint import android.graphics.Rect @@ -85,11 +86,14 @@ class TilingDividerView : FrameLayout, View.OnTouchListener, DragDetector.Motion dividerMoveCallback: DividerMoveCallback, dividerBounds: Rect, handleRegionSize: Size, + isDarkMode: Boolean, ) { callback = dividerMoveCallback this.dividerBounds.set(dividerBounds) handle.setIsLeftRightSplit(true) + handle.setup(/* isSplitScreen= */ false, isDarkMode) corners.setIsLeftRightSplit(true) + corners.setup(/* isSplitScreen= */ false, isDarkMode) handleRegionHeight = handleRegionSize.height handleRegionWidth = handleRegionSize.width cornersRadius = @@ -103,6 +107,18 @@ class TilingDividerView : FrameLayout, View.OnTouchListener, DragDetector.Motion ) } + fun onUiModeChange(isDarkMode: Boolean) { + handle.onUiModeChange(isDarkMode) + corners.onUiModeChange(isDarkMode) + paint.color = + if (isDarkMode) { + resources.getColor(R.color.tiling_divider_background_dark, null /* theme */) + } else { + resources.getColor(R.color.tiling_divider_background_light, null /* theme */) + } + invalidate() + } + override fun onFinishInflate() { super.onFinishInflate() dividerBar = requireViewById(R.id.divider_bar) @@ -112,7 +128,15 @@ class TilingDividerView : FrameLayout, View.OnTouchListener, DragDetector.Motion resources.getDimensionPixelSize(R.dimen.docked_stack_divider_lift_elevation) setOnTouchListener(this) setWillNotDraw(false) - paint.color = resources.getColor(R.color.split_divider_background, null) + paint.color = + if ( + context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == + Configuration.UI_MODE_NIGHT_YES + ) { + resources.getColor(R.color.tiling_divider_background_dark, /* theme= */null) + } else { + resources.getColor(R.color.tiling_divider_background_light, /* theme= */ null) + } paint.isAntiAlias = true paint.style = Paint.Style.FILL } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt index 16c793587ade..e89a122595d5 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt @@ -321,6 +321,19 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest } @Test + fun testOnTaskInfoChanged_tilingNotified() { + val task = createTask( + windowingMode = WINDOWING_MODE_FREEFORM + ) + setUpMockDecorationsForTasks(task) + + onTaskOpening(task) + desktopModeWindowDecorViewModel.onTaskInfoChanged(task) + + verify(mockTilingWindowDecoration).onTaskInfoChange(task) + } + + @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_IMMERSIVE_HANDLE_HIDING) fun testInsetsStateChanged_notifiesAllDecorsInDisplay() { val task1 = createTask(windowingMode = WINDOWING_MODE_FREEFORM, displayId = 1) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManagerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManagerTest.kt index 121e0e915d08..844205682d31 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManagerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDividerWindowManagerTest.kt @@ -81,6 +81,7 @@ class DesktopTilingDividerWindowManagerTest : ShellTestCase() { transactionSupplierMock, BOUNDS, context, + /* isDarkMode= */ true ) } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/TilingDividerViewTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/TilingDividerViewTest.kt index 9a9d05a72442..9a3d5d871456 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/TilingDividerViewTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/TilingDividerViewTest.kt @@ -60,7 +60,7 @@ class TilingDividerViewTest : ShellTestCase() { tilingDividerView = LayoutInflater.from(mContext).inflate(R.layout.tiling_split_divider, /* root= */ null) as TilingDividerView - tilingDividerView.setup(dividerMoveCallbackMock, DIVIDER_BOUNDS, HANDLE_SIZE) + tilingDividerView.setup(dividerMoveCallbackMock, DIVIDER_BOUNDS, HANDLE_SIZE, true) tilingDividerView.handleY = 0..1500 } |