diff options
11 files changed, 161 insertions, 24 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 d9afd1503db5..cd5f7108857e 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 @@ -556,6 +556,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 8747f63e789f..4d8d6475c050 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 @@ -136,6 +136,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 666d4bd046dc..3553eb3b2dfe 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 @@ -36,7 +36,6 @@ import android.window.WindowContainerTransaction import com.android.internal.annotations.VisibleForTesting import com.android.launcher3.icons.BaseIconFactory import com.android.window.flags.Flags -import com.android.wm.shell.shared.FocusTransitionListener import com.android.wm.shell.R import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.ShellTaskOrganizer @@ -50,6 +49,7 @@ import com.android.wm.shell.desktopmode.DesktopTasksController.SnapPosition import com.android.wm.shell.desktopmode.DesktopUserRepositories import com.android.wm.shell.desktopmode.ReturnToDragStartAnimator import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler +import com.android.wm.shell.shared.FocusTransitionListener import com.android.wm.shell.shared.annotations.ShellBackgroundThread import com.android.wm.shell.shared.annotations.ShellMainThread import com.android.wm.shell.transition.FocusTransitionObserver @@ -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, @@ -502,9 +516,11 @@ class DesktopTilingWindowDecoration( } // Overriding FocusTransitionListener - override fun onFocusedTaskChanged(taskId: Int, - isFocusedOnDisplay: Boolean, - isFocusedGlobally: Boolean) { + override fun onFocusedTaskChanged( + taskId: Int, + isFocusedOnDisplay: Boolean, + isFocusedGlobally: Boolean, + ) { if (!Flags.enableDisplayFocusInShellTransitions()) return moveTiledPairToFront(taskId, isFocusedOnDisplay) } @@ -512,7 +528,7 @@ class DesktopTilingWindowDecoration( // Only called if [taskInfo] relates to a focused task private fun isTilingRefocused(taskId: Int): Boolean { return taskId == leftTaskResizingHelper?.taskInfo?.taskId || - taskId == rightTaskResizingHelper?.taskInfo?.taskId + taskId == rightTaskResizingHelper?.taskInfo?.taskId } private fun buildTiledTasksMoveToFront(leftOnTop: Boolean): WindowContainerTransaction { @@ -623,22 +639,12 @@ class DesktopTilingWindowDecoration( val t = transactionSupplier.get() if (!Flags.enableDisplayFocusInShellTransitions()) isTilingFocused = true if (taskId == leftTaskResizingHelper?.taskInfo?.taskId) { - desktopTilingDividerWindowManager?.onRelativeLeashChanged( - leftTiledTask.getLeash(), - t, - ) + desktopTilingDividerWindowManager?.onRelativeLeashChanged(leftTiledTask.getLeash(), t) } if (taskId == rightTaskResizingHelper?.taskInfo?.taskId) { - desktopTilingDividerWindowManager?.onRelativeLeashChanged( - rightTiledTask.getLeash(), - t, - ) + desktopTilingDividerWindowManager?.onRelativeLeashChanged(rightTiledTask.getLeash(), t) } - transitions.startTransition( - TRANSIT_TO_FRONT, - buildTiledTasksMoveToFront(isLeftOnTop), - null, - ) + transitions.startTransition(TRANSIT_TO_FRONT, buildTiledTasksMoveToFront(isLeftOnTop), null) t.apply() return true } 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 } |