diff options
| author | 2023-09-18 17:56:08 +0000 | |
|---|---|---|
| committer | 2023-09-20 22:35:22 +0000 | |
| commit | 94247f95a88b13d91348a6f4abafbbd4caa6c29a (patch) | |
| tree | 48388130bd7fedbf8dab6b28098eea54ab3e96fe | |
| parent | ddfe003f2be839fdc61141798a02108ee0f2c56c (diff) | |
Fix Handle Menu Color & Enable NightMode Toggle
Implemented new themes for handle menu of OnSurface (text) and onSurfaceBright (background).
Also implemented theme toggling for menu when night mode is toggled as per spec, by triggering relayout whenever night mode is changed.
Tested by changing night mode setting manually (swipe down and enable Dark Theme). Manually validated new and existing windows’ handle menus as well as the handle menu with close button visible (on full screen)
Test: Manual
Bug: 276785394
Change-Id: I5604eb12325acc1f6d109dbc369a0f62949448ab
8 files changed, 46 insertions, 22 deletions
diff --git a/libs/WindowManager/Shell/res/drawable/desktop_mode_decor_handle_menu_background.xml b/libs/WindowManager/Shell/res/drawable/desktop_mode_decor_handle_menu_background.xml index 4ee10f429b37..15837adc2c77 100644 --- a/libs/WindowManager/Shell/res/drawable/desktop_mode_decor_handle_menu_background.xml +++ b/libs/WindowManager/Shell/res/drawable/desktop_mode_decor_handle_menu_background.xml @@ -15,7 +15,8 @@ ~ limitations under the License. --> <shape android:shape="rectangle" - xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="@android:color/white" /> + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <corners android:radius="@dimen/desktop_mode_handle_menu_corner_radius" /> + <solid android:color="?androidprv:attr/materialColorSurfaceBright" /> </shape> diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_app_info_pill.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_app_info_pill.xml index c03d240d59f2..c2ee3066d059 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_app_info_pill.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_app_info_pill.xml @@ -15,6 +15,7 @@ ~ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="@dimen/desktop_mode_handle_menu_width" android:layout_height="@dimen/desktop_mode_handle_menu_app_info_pill_height" @@ -35,7 +36,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" tools:text="Gmail" - android:textColor="@color/desktop_mode_caption_menu_text_color" + android:textColor="?androidprv:attr/materialColorOnSurface" android:textSize="14sp" android:textFontWeight="500" android:lineHeight="20dp" @@ -52,6 +53,6 @@ android:contentDescription="@string/collapse_menu_text" android:src="@drawable/ic_baseline_expand_more_24" android:rotation="180" - android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:tint="?androidprv:attr/materialColorOnSurface" android:background="?android:selectableItemBackgroundBorderless"/> </LinearLayout>
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_more_actions_pill.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_more_actions_pill.xml index cdf4937599c9..e637671937bd 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_more_actions_pill.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_more_actions_pill.xml @@ -15,6 +15,7 @@ ~ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:layout_width="@dimen/desktop_mode_handle_menu_width" android:layout_height="@dimen/desktop_mode_handle_menu_more_actions_pill_height" android:orientation="vertical" @@ -25,7 +26,7 @@ android:contentDescription="@string/screenshot_text" android:text="@string/screenshot_text" android:drawableStart="@drawable/desktop_mode_ic_handle_menu_screenshot" - android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:drawableTint="?androidprv:attr/materialColorOnSurface" style="@style/DesktopModeHandleMenuActionButton"/> <Button @@ -33,15 +34,14 @@ android:contentDescription="@string/select_text" android:text="@string/select_text" android:drawableStart="@drawable/desktop_mode_ic_handle_menu_select" - android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:drawableTint="?androidprv:attr/materialColorOnSurface" style="@style/DesktopModeHandleMenuActionButton"/> - <Button android:id="@+id/close_button" android:contentDescription="@string/close_text" android:text="@string/close_text" android:drawableStart="@drawable/desktop_mode_ic_handle_menu_close" - android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:drawableTint="?androidprv:attr/materialColorOnSurface" style="@style/DesktopModeHandleMenuActionButton"/> </LinearLayout>
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_windowing_pill.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_windowing_pill.xml index 08d91498b338..c4b688daeb6e 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_windowing_pill.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_windowing_pill.xml @@ -15,6 +15,7 @@ ~ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:layout_width="@dimen/desktop_mode_handle_menu_width" android:layout_height="@dimen/desktop_mode_handle_menu_windowing_pill_height" android:orientation="horizontal" @@ -26,7 +27,7 @@ android:layout_marginEnd="4dp" android:contentDescription="@string/fullscreen_text" android:src="@drawable/desktop_mode_ic_handle_menu_fullscreen" - android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:tint="?androidprv:attr/materialColorOnSurface" android:layout_weight="1" style="@style/DesktopModeHandleMenuWindowingButton"/> @@ -36,7 +37,7 @@ android:layout_marginEnd="4dp" android:contentDescription="@string/split_screen_text" android:src="@drawable/desktop_mode_ic_handle_menu_splitscreen" - android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:tint="?androidprv:attr/materialColorOnSurface" android:layout_weight="1" style="@style/DesktopModeHandleMenuWindowingButton"/> @@ -46,7 +47,7 @@ android:layout_marginEnd="4dp" android:contentDescription="@string/float_button_text" android:src="@drawable/desktop_mode_ic_handle_menu_floating" - android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive" + android:tint="?androidprv:attr/materialColorOnSurface" android:layout_weight="1" style="@style/DesktopModeHandleMenuWindowingButton"/> @@ -55,7 +56,7 @@ android:layout_marginStart="4dp" android:contentDescription="@string/desktop_text" android:src="@drawable/desktop_mode_ic_handle_menu_desktop" - android:tint="@color/desktop_mode_caption_menu_buttons_color_active" + android:tint="?androidprv:attr/materialColorOnSurface" android:layout_weight="1" style="@style/DesktopModeHandleMenuWindowingButton"/> diff --git a/libs/WindowManager/Shell/res/values/colors.xml b/libs/WindowManager/Shell/res/values/colors.xml index f76a346a8f5d..9bfd1b44dcca 100644 --- a/libs/WindowManager/Shell/res/values/colors.xml +++ b/libs/WindowManager/Shell/res/values/colors.xml @@ -68,9 +68,6 @@ <color name="desktop_mode_caption_maximize_button_dark">#1C1C17</color> <color name="desktop_mode_caption_app_name_light">#EFF1F2</color> <color name="desktop_mode_caption_app_name_dark">#1C1C17</color> - <color name="desktop_mode_caption_menu_text_color">#191C1D</color> - <color name="desktop_mode_caption_menu_buttons_color_inactive">#191C1D</color> - <color name="desktop_mode_caption_menu_buttons_color_active">#00677E</color> <color name="desktop_mode_resize_veil_light">#EFF1F2</color> <color name="desktop_mode_resize_veil_dark">#1C1C17</color> <color name="desktop_mode_maximize_menu_button">#DDDACD</color> diff --git a/libs/WindowManager/Shell/res/values/styles.xml b/libs/WindowManager/Shell/res/values/styles.xml index d902fd49ba60..468cfd5260cc 100644 --- a/libs/WindowManager/Shell/res/values/styles.xml +++ b/libs/WindowManager/Shell/res/values/styles.xml @@ -14,7 +14,8 @@ limitations under the License. --> -<resources xmlns:android="http://schemas.android.com/apk/res/android"> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <!-- Theme used for the activity that shows when the system forced an app to be resizable --> <style name="ForcedResizableTheme" parent="@android:style/Theme.Translucent.NoTitleBar"> <item name="android:windowBackground">@drawable/forced_resizable_background</item> @@ -37,7 +38,7 @@ <item name="android:padding">16dp</item> <item name="android:textSize">14sp</item> <item name="android:textFontWeight">500</item> - <item name="android:textColor">@color/desktop_mode_caption_menu_text_color</item> + <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item> <item name="android:drawablePadding">16dp</item> <item name="android:background">?android:selectableItemBackground</item> </style> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.java index 1ec8a1749b55..f82b212c344c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.java @@ -26,7 +26,10 @@ import android.annotation.Nullable; import android.app.ActivityManager.RunningTaskInfo; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.PointF; import android.graphics.drawable.Drawable; import android.view.MotionEvent; @@ -167,10 +170,9 @@ class HandleMenu { desktopBtn.setOnClickListener(mOnClickListener); // The button corresponding to the windowing mode that the task is currently in uses a // different color than the others. - final ColorStateList activeColorStateList = ColorStateList.valueOf( - mContext.getColor(R.color.desktop_mode_caption_menu_buttons_color_active)); - final ColorStateList inActiveColorStateList = ColorStateList.valueOf( - mContext.getColor(R.color.desktop_mode_caption_menu_buttons_color_inactive)); + final int[] iconColors = getWindowingIconColor(); + final ColorStateList inActiveColorStateList = ColorStateList.valueOf(iconColors[0]); + final ColorStateList activeColorStateList = ColorStateList.valueOf(iconColors[1]); fullscreenBtn.setImageTintList( mTaskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN ? activeColorStateList : inActiveColorStateList); @@ -197,6 +199,23 @@ class HandleMenu { } /** + * Returns array of windowing icon color based on current UI theme. First element of the + * array is for inactive icons and the second is for active icons. + */ + private int[] getWindowingIconColor() { + final int mode = mContext.getResources().getConfiguration().uiMode + & Configuration.UI_MODE_NIGHT_MASK; + final boolean isNightMode = (mode == Configuration.UI_MODE_NIGHT_YES); + final TypedArray typedArray = mContext.obtainStyledAttributes(new int[]{ + com.android.internal.R.attr.materialColorOnSurface, + com.android.internal.R.attr.materialColorPrimary}); + final int inActiveColor = typedArray.getColor(0, isNightMode ? Color.WHITE : Color.BLACK); + final int activeColor = typedArray.getColor(1, isNightMode ? Color.WHITE : Color.BLACK); + typedArray.recycle(); + return new int[] {inActiveColor, activeColor}; + } + + /** * Updates the handle menu pills' position variables to reflect their next positions */ private void updateHandleMenuPillPositions() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java index 2d5ef72d2362..50bdc9eea527 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java @@ -194,13 +194,16 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> rootView = null; // Clear it just in case we use it accidentally final int oldDensityDpi = mWindowDecorConfig.densityDpi; + final int oldNightMode = mWindowDecorConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; mWindowDecorConfig = params.mWindowDecorConfig != null ? params.mWindowDecorConfig : mTaskInfo.getConfiguration(); final int newDensityDpi = mWindowDecorConfig.densityDpi; + final int newNightMode = mWindowDecorConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; if (oldDensityDpi != newDensityDpi || mDisplay == null || mDisplay.getDisplayId() != mTaskInfo.displayId - || oldLayoutResId != mLayoutResId) { + || oldLayoutResId != mLayoutResId + || oldNightMode != newNightMode) { releaseViews(); if (!obtainDisplayOrRegisterListener()) { @@ -208,6 +211,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> return; } mDecorWindowContext = mContext.createConfigurationContext(mWindowDecorConfig); + mDecorWindowContext.setTheme(mContext.getThemeResId()); if (params.mLayoutResId != 0) { outResult.mRootView = (T) LayoutInflater.from(mDecorWindowContext) .inflate(params.mLayoutResId, null); |