diff options
author | 2023-10-05 04:57:23 +0000 | |
---|---|---|
committer | 2023-10-05 04:57:23 +0000 | |
commit | b88840e2aa50434d06a24e84ebcf28a7a83649f6 (patch) | |
tree | ab6d846af6ba80a3aeb0a37aa8db3e3be845822e | |
parent | b46e244120e769ed4fb0951a84b60d6b25073d34 (diff) | |
parent | 34b09f6d33e2315be3efc01553321db392a93af1 (diff) |
Merge "Refactor Handle Menu as Single Window" into main
9 files changed, 253 insertions, 367 deletions
diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml new file mode 100644 index 000000000000..ee9f070f6765 --- /dev/null +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ 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="wrap_content" + android:orientation="vertical"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/desktop_mode_handle_menu_app_info_pill_height" + android:layout_marginTop="@dimen/desktop_mode_handle_menu_margin_top" + android:layout_marginStart="1dp" + android:elevation="1dp" + android:orientation="horizontal" + android:background="@drawable/desktop_mode_decor_handle_menu_background" + android:gravity="center_vertical"> + + <ImageView + android:id="@+id/application_icon" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_marginStart="14dp" + android:layout_marginEnd="14dp" + android:contentDescription="@string/app_icon_text"/> + + <TextView + android:id="@+id/application_name" + android:layout_width="0dp" + android:layout_height="wrap_content" + tools:text="Gmail" + android:textColor="?androidprv:attr/materialColorOnSurface" + android:textSize="14sp" + android:textFontWeight="500" + android:lineHeight="20dp" + android:textStyle="normal" + android:layout_weight="1"/> + + <ImageButton + android:id="@+id/collapse_menu_button" + android:layout_width="32dp" + android:layout_height="32dp" + android:padding="4dp" + android:layout_marginEnd="14dp" + android:layout_marginStart="14dp" + android:contentDescription="@string/collapse_menu_text" + android:src="@drawable/ic_baseline_expand_more_24" + android:rotation="180" + android:tint="?androidprv:attr/materialColorOnSurface" + android:background="?android:selectableItemBackgroundBorderless"/> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/desktop_mode_handle_menu_windowing_pill_height" + android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" + android:layout_marginStart="1dp" + android:orientation="horizontal" + android:elevation="1dp" + android:background="@drawable/desktop_mode_decor_handle_menu_background" + android:gravity="center_vertical"> + + <ImageButton + android:id="@+id/fullscreen_button" + android:layout_marginEnd="4dp" + android:contentDescription="@string/fullscreen_text" + android:src="@drawable/desktop_mode_ic_handle_menu_fullscreen" + android:tint="?androidprv:attr/materialColorOnSurface" + android:layout_weight="1" + style="@style/DesktopModeHandleMenuWindowingButton"/> + + <ImageButton + android:id="@+id/split_screen_button" + android:layout_marginStart="4dp" + android:layout_marginEnd="4dp" + android:contentDescription="@string/split_screen_text" + android:src="@drawable/desktop_mode_ic_handle_menu_splitscreen" + android:tint="?androidprv:attr/materialColorOnSurface" + android:layout_weight="1" + style="@style/DesktopModeHandleMenuWindowingButton"/> + + <ImageButton + android:id="@+id/floating_button" + android:layout_marginStart="4dp" + android:layout_marginEnd="4dp" + android:contentDescription="@string/float_button_text" + android:src="@drawable/desktop_mode_ic_handle_menu_floating" + android:tint="?androidprv:attr/materialColorOnSurface" + android:layout_weight="1" + style="@style/DesktopModeHandleMenuWindowingButton"/> + + <ImageButton + android:id="@+id/desktop_button" + android:layout_marginStart="4dp" + android:contentDescription="@string/desktop_text" + android:src="@drawable/desktop_mode_ic_handle_menu_desktop" + android:tint="?androidprv:attr/materialColorOnSurface" + android:layout_weight="1" + style="@style/DesktopModeHandleMenuWindowingButton"/> + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/desktop_mode_handle_menu_more_actions_pill_height" + android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" + android:layout_marginStart="1dp" + android:orientation="vertical" + android:elevation="1dp" + android:background="@drawable/desktop_mode_decor_handle_menu_background"> + + <Button + android:id="@+id/screenshot_button" + android:contentDescription="@string/screenshot_text" + android:text="@string/screenshot_text" + android:drawableStart="@drawable/desktop_mode_ic_handle_menu_screenshot" + android:drawableTint="?androidprv:attr/materialColorOnSurface" + style="@style/DesktopModeHandleMenuActionButton"/> + + <Button + android:id="@+id/select_button" + android:contentDescription="@string/select_text" + android:text="@string/select_text" + android:drawableStart="@drawable/desktop_mode_ic_handle_menu_select" + android:drawableTint="?androidprv:attr/materialColorOnSurface" + style="@style/DesktopModeHandleMenuActionButton"/> + + </LinearLayout> +</LinearLayout> + 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 deleted file mode 100644 index c2ee3066d059..000000000000 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_app_info_pill.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2023 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ 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" - android:orientation="horizontal" - android:background="@drawable/desktop_mode_decor_handle_menu_background" - android:gravity="center_vertical"> - - <ImageView - android:id="@+id/application_icon" - android:layout_width="24dp" - android:layout_height="24dp" - android:layout_marginStart="14dp" - android:layout_marginEnd="14dp" - android:contentDescription="@string/app_icon_text"/> - - <TextView - android:id="@+id/application_name" - android:layout_width="0dp" - android:layout_height="wrap_content" - tools:text="Gmail" - android:textColor="?androidprv:attr/materialColorOnSurface" - android:textSize="14sp" - android:textFontWeight="500" - android:lineHeight="20dp" - android:textStyle="normal" - android:layout_weight="1"/> - - <ImageButton - android:id="@+id/collapse_menu_button" - android:layout_width="32dp" - android:layout_height="32dp" - android:padding="4dp" - android:layout_marginEnd="14dp" - android:layout_marginStart="14dp" - android:contentDescription="@string/collapse_menu_text" - android:src="@drawable/ic_baseline_expand_more_24" - android:rotation="180" - 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 deleted file mode 100644 index e637671937bd..000000000000 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_more_actions_pill.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2023 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ 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" - android:background="@drawable/desktop_mode_decor_handle_menu_background"> - - <Button - android:id="@+id/screenshot_button" - android:contentDescription="@string/screenshot_text" - android:text="@string/screenshot_text" - android:drawableStart="@drawable/desktop_mode_ic_handle_menu_screenshot" - android:drawableTint="?androidprv:attr/materialColorOnSurface" - style="@style/DesktopModeHandleMenuActionButton"/> - - <Button - android:id="@+id/select_button" - android:contentDescription="@string/select_text" - android:text="@string/select_text" - android:drawableStart="@drawable/desktop_mode_ic_handle_menu_select" - 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="?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 deleted file mode 100644 index c4b688daeb6e..000000000000 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu_windowing_pill.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2023 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ 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" - android:background="@drawable/desktop_mode_decor_handle_menu_background" - android:gravity="center_vertical"> - - <ImageButton - android:id="@+id/fullscreen_button" - android:layout_marginEnd="4dp" - android:contentDescription="@string/fullscreen_text" - android:src="@drawable/desktop_mode_ic_handle_menu_fullscreen" - android:tint="?androidprv:attr/materialColorOnSurface" - android:layout_weight="1" - style="@style/DesktopModeHandleMenuWindowingButton"/> - - <ImageButton - android:id="@+id/split_screen_button" - android:layout_marginStart="4dp" - android:layout_marginEnd="4dp" - android:contentDescription="@string/split_screen_text" - android:src="@drawable/desktop_mode_ic_handle_menu_splitscreen" - android:tint="?androidprv:attr/materialColorOnSurface" - android:layout_weight="1" - style="@style/DesktopModeHandleMenuWindowingButton"/> - - <ImageButton - android:id="@+id/floating_button" - android:layout_marginStart="4dp" - android:layout_marginEnd="4dp" - android:contentDescription="@string/float_button_text" - android:src="@drawable/desktop_mode_ic_handle_menu_floating" - android:tint="?androidprv:attr/materialColorOnSurface" - android:layout_weight="1" - style="@style/DesktopModeHandleMenuWindowingButton"/> - - <ImageButton - android:id="@+id/desktop_button" - android:layout_marginStart="4dp" - android:contentDescription="@string/desktop_text" - android:src="@drawable/desktop_mode_ic_handle_menu_desktop" - android:tint="?androidprv:attr/materialColorOnSurface" - android:layout_weight="1" - style="@style/DesktopModeHandleMenuWindowingButton"/> - -</LinearLayout>
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 705e38731a0c..7a309f5758a0 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -434,11 +434,11 @@ <!-- The height of the handle menu's "Windowing" pill in desktop mode. --> <dimen name="desktop_mode_handle_menu_windowing_pill_height">52dp</dimen> - <!-- The height of the handle menu's "More Actions" pill in desktop mode, but not freeform. --> - <dimen name="desktop_mode_handle_menu_more_actions_pill_height">104dp</dimen> + <!-- The height of the handle menu's "More Actions" pill in desktop mode. --> + <dimen name="desktop_mode_handle_menu_more_actions_pill_height">52dp</dimen> - <!-- The height of the handle menu's "More Actions" pill in freeform desktop windowing mode. --> - <dimen name="desktop_mode_handle_menu_more_actions_pill_freeform_height">52dp</dimen> + <!-- The height of the handle menu in desktop mode. --> + <dimen name="desktop_mode_handle_menu_height">328dp</dimen> <!-- The top margin of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_margin_top">4dp</dimen> 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 780bbb5c9f31..bf99ab35cdd7 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 @@ -376,7 +376,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { public void onClick(View v) { final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); final int id = v.getId(); - if (id == R.id.close_window || id == R.id.close_button) { + if (id == R.id.close_window) { mTaskOperations.closeTask(mTaskToken); if (isTaskInSplitScreen(mTaskId)) { RunningTaskInfo remainingTask = getOtherSplitTask(mTaskId); 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 a7a11dee80f2..15f8f1cfadf2 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 @@ -42,7 +42,6 @@ import android.widget.TextView; import android.window.SurfaceSyncGroup; import com.android.wm.shell.R; -import com.android.wm.shell.desktopmode.DesktopModeStatus; /** * Handle menu opened when the appropriate button is clicked on. @@ -56,12 +55,8 @@ class HandleMenu { private static final String TAG = "HandleMenu"; private final Context mContext; private final WindowDecoration mParentDecor; - private WindowDecoration.AdditionalWindow mAppInfoPill; - private WindowDecoration.AdditionalWindow mWindowingPill; - private WindowDecoration.AdditionalWindow mMoreActionsPill; - private final PointF mAppInfoPillPosition = new PointF(); - private final PointF mWindowingPillPosition = new PointF(); - private final PointF mMoreActionsPillPosition = new PointF(); + private WindowDecoration.AdditionalWindow mHandleMenuWindow; + private final PointF mHandleMenuPosition = new PointF(); private final boolean mShouldShowWindowingPill; private final Drawable mAppIcon; private final CharSequence mAppName; @@ -73,13 +68,8 @@ class HandleMenu { private final int mCaptionY; private int mMarginMenuTop; private int mMarginMenuStart; - private int mMarginMenuSpacing; + private int mMenuHeight; private int mMenuWidth; - private int mAppInfoPillHeight; - private int mWindowingPillHeight; - private int mMoreActionsPillHeight; - private int mShadowRadius; - private int mCornerRadius; HandleMenu(WindowDecoration parentDecor, int layoutResId, int captionX, int captionY, @@ -104,102 +94,86 @@ class HandleMenu { final SurfaceSyncGroup ssg = new SurfaceSyncGroup(TAG); SurfaceControl.Transaction t = new SurfaceControl.Transaction(); - createAppInfoPill(t, ssg); - if (mShouldShowWindowingPill) { - createWindowingPill(t, ssg); - } - createMoreActionsPill(t, ssg); + createHandleMenuWindow(t, ssg); ssg.addTransaction(t); ssg.markSyncReady(); setupHandleMenu(); } - private void createAppInfoPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) { - final int x = (int) mAppInfoPillPosition.x; - final int y = (int) mAppInfoPillPosition.y; - mAppInfoPill = mParentDecor.addWindow( - R.layout.desktop_mode_window_decor_handle_menu_app_info_pill, - "Menu's app info pill", - t, ssg, x, y, mMenuWidth, mAppInfoPillHeight, mShadowRadius, mCornerRadius); + private void createHandleMenuWindow(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) { + final int x = (int) mHandleMenuPosition.x; + final int y = (int) mHandleMenuPosition.y; + mHandleMenuWindow = mParentDecor.addWindow( + R.layout.desktop_mode_window_decor_handle_menu, "Handle Menu", + t, ssg, x, y, mMenuWidth, mMenuHeight); } - private void createWindowingPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) { - final int x = (int) mWindowingPillPosition.x; - final int y = (int) mWindowingPillPosition.y; - mWindowingPill = mParentDecor.addWindow( - R.layout.desktop_mode_window_decor_handle_menu_windowing_pill, - "Menu's windowing pill", - t, ssg, x, y, mMenuWidth, mWindowingPillHeight, mShadowRadius, mCornerRadius); - } - - private void createMoreActionsPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) { - final int x = (int) mMoreActionsPillPosition.x; - final int y = (int) mMoreActionsPillPosition.y; - mMoreActionsPill = mParentDecor.addWindow( - R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill, - "Menu's more actions pill", - t, ssg, x, y, mMenuWidth, mMoreActionsPillHeight, mShadowRadius, mCornerRadius); + /** + * Set up all three pills of the handle menu: app info pill, windowing pill, & more actions + * pill. + */ + private void setupHandleMenu() { + final View handleMenu = mHandleMenuWindow.mWindowViewHost.getView(); + handleMenu.setOnTouchListener(mOnTouchListener); + setupAppInfoPill(handleMenu); + if (mShouldShowWindowingPill) { + setupWindowingPill(handleMenu); + } + setupMoreActionsPill(handleMenu); } /** - * Set up interactive elements and color of this handle menu + * Set up interactive elements of handle menu's app info pill. */ - private void setupHandleMenu() { - // App Info pill setup. - final View appInfoPillView = mAppInfoPill.mWindowViewHost.getView(); - final ImageButton collapseBtn = appInfoPillView.findViewById(R.id.collapse_menu_button); - final ImageView appIcon = appInfoPillView.findViewById(R.id.application_icon); - final TextView appName = appInfoPillView.findViewById(R.id.application_name); + private void setupAppInfoPill(View handleMenu) { + final ImageButton collapseBtn = handleMenu.findViewById(R.id.collapse_menu_button); + final ImageView appIcon = handleMenu.findViewById(R.id.application_icon); + final TextView appName = handleMenu.findViewById(R.id.application_name); collapseBtn.setOnClickListener(mOnClickListener); - appInfoPillView.setOnTouchListener(mOnTouchListener); appIcon.setImageDrawable(mAppIcon); appName.setText(mAppName); + } - // Windowing pill setup. - if (mShouldShowWindowingPill) { - final View windowingPillView = mWindowingPill.mWindowViewHost.getView(); - final ImageButton fullscreenBtn = windowingPillView.findViewById( - R.id.fullscreen_button); - final ImageButton splitscreenBtn = windowingPillView.findViewById( - R.id.split_screen_button); - final ImageButton floatingBtn = windowingPillView.findViewById(R.id.floating_button); - // TODO: Remove once implemented. - floatingBtn.setVisibility(View.GONE); - - final ImageButton desktopBtn = windowingPillView.findViewById(R.id.desktop_button); - fullscreenBtn.setOnClickListener(mOnClickListener); - splitscreenBtn.setOnClickListener(mOnClickListener); - floatingBtn.setOnClickListener(mOnClickListener); - desktopBtn.setOnClickListener(mOnClickListener); - // The button corresponding to the windowing mode that the task is currently in uses a - // different color than the others. - 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); - splitscreenBtn.setImageTintList( - mTaskInfo.getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW - ? activeColorStateList : inActiveColorStateList); - floatingBtn.setImageTintList(mTaskInfo.getWindowingMode() == WINDOWING_MODE_PINNED - ? activeColorStateList : inActiveColorStateList); - desktopBtn.setImageTintList(mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM - ? activeColorStateList : inActiveColorStateList); - } + /** + * Set up interactive elements and color of handle menu's windowing pill. + */ + private void setupWindowingPill(View handleMenu) { + final ImageButton fullscreenBtn = handleMenu.findViewById( + R.id.fullscreen_button); + final ImageButton splitscreenBtn = handleMenu.findViewById( + R.id.split_screen_button); + final ImageButton floatingBtn = handleMenu.findViewById(R.id.floating_button); + // TODO: Remove once implemented. + floatingBtn.setVisibility(View.GONE); + + final ImageButton desktopBtn = handleMenu.findViewById(R.id.desktop_button); + fullscreenBtn.setOnClickListener(mOnClickListener); + splitscreenBtn.setOnClickListener(mOnClickListener); + floatingBtn.setOnClickListener(mOnClickListener); + 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[] iconColors = getWindowingIconColor(); + final ColorStateList inActiveColorStateList = iconColors[0]; + final ColorStateList activeColorStateList = iconColors[1]; + final int windowingMode = mTaskInfo.getWindowingMode(); + fullscreenBtn.setImageTintList(windowingMode == WINDOWING_MODE_FULLSCREEN + ? activeColorStateList : inActiveColorStateList); + splitscreenBtn.setImageTintList(windowingMode == WINDOWING_MODE_MULTI_WINDOW + ? activeColorStateList : inActiveColorStateList); + floatingBtn.setImageTintList(windowingMode == WINDOWING_MODE_PINNED + ? activeColorStateList : inActiveColorStateList); + desktopBtn.setImageTintList(windowingMode == WINDOWING_MODE_FREEFORM + ? activeColorStateList : inActiveColorStateList); + } - // More Actions pill setup. - final View moreActionsPillView = mMoreActionsPill.mWindowViewHost.getView(); - final Button closeBtn = moreActionsPillView.findViewById(R.id.close_button); - if (shouldShowCloseButton()) { - closeBtn.setVisibility(View.GONE); - } else { - closeBtn.setVisibility(View.VISIBLE); - closeBtn.setOnClickListener(mOnClickListener); - } - final Button selectBtn = moreActionsPillView.findViewById(R.id.select_button); + /** + * Set up interactive elements & height of handle menu's more actions pill + */ + private void setupMoreActionsPill(View handleMenu) { + final Button selectBtn = handleMenu.findViewById(R.id.select_button); selectBtn.setOnClickListener(mOnClickListener); - final Button screenshotBtn = moreActionsPillView.findViewById(R.id.screenshot_button); + final Button screenshotBtn = handleMenu.findViewById(R.id.screenshot_button); // TODO: Remove once implemented. screenshotBtn.setVisibility(View.GONE); } @@ -208,7 +182,7 @@ 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() { + private ColorStateList[] getWindowingIconColor() { final int mode = mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; final boolean isNightMode = (mode == Configuration.UI_MODE_NIGHT_YES); @@ -218,11 +192,12 @@ class HandleMenu { 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}; + return new ColorStateList[]{ColorStateList.valueOf(inActiveColor), + ColorStateList.valueOf(activeColor)}; } /** - * Updates the handle menu pills' position variables to reflect their next positions + * Updates handle menu's position variables to reflect its next position. */ private void updateHandleMenuPillPositions() { final int menuX, menuY; @@ -239,39 +214,19 @@ class HandleMenu { menuY = mCaptionY + mMarginMenuStart; } - // App Info pill setup. - final int appInfoPillY = menuY; - mAppInfoPillPosition.set(menuX, appInfoPillY); + // Handle Menu position setup. + mHandleMenuPosition.set(menuX, menuY); - final int windowingPillY, moreActionsPillY; - if (mShouldShowWindowingPill) { - windowingPillY = appInfoPillY + mAppInfoPillHeight + mMarginMenuSpacing; - mWindowingPillPosition.set(menuX, windowingPillY); - moreActionsPillY = windowingPillY + mWindowingPillHeight + mMarginMenuSpacing; - mMoreActionsPillPosition.set(menuX, moreActionsPillY); - } else { - // Just start after the end of the app info pill + margins. - moreActionsPillY = appInfoPillY + mAppInfoPillHeight + mMarginMenuSpacing; - mMoreActionsPillPosition.set(menuX, moreActionsPillY); - } } /** * Update pill layout, in case task changes have caused positioning to change. */ void relayout(SurfaceControl.Transaction t) { - if (mAppInfoPill != null) { + if (mHandleMenuWindow != null) { updateHandleMenuPillPositions(); - t.setPosition(mAppInfoPill.mWindowSurface, - mAppInfoPillPosition.x, mAppInfoPillPosition.y); - // Only show windowing buttons in proto2. Proto1 uses a system-level mode only. - final boolean shouldShowWindowingPill = DesktopModeStatus.isEnabled(); - if (shouldShowWindowingPill) { - t.setPosition(mWindowingPill.mWindowSurface, - mWindowingPillPosition.x, mWindowingPillPosition.y); - } - t.setPosition(mMoreActionsPill.mWindowSurface, - mMoreActionsPillPosition.x, mMoreActionsPillPosition.y); + t.setPosition(mHandleMenuWindow.mWindowSurface, + mHandleMenuPosition.x, mHandleMenuPosition.y); } } @@ -283,12 +238,12 @@ class HandleMenu { * @param ev the MotionEvent to compare against. */ void checkClickEvent(MotionEvent ev) { - final View appInfoPill = mAppInfoPill.mWindowViewHost.getView(); - final ImageButton collapse = appInfoPill.findViewById(R.id.collapse_menu_button); + final View handleMenu = mHandleMenuWindow.mWindowViewHost.getView(); + final ImageButton collapse = handleMenu.findViewById(R.id.collapse_menu_button); // Translate the input point from display coordinates to the same space as the collapse // button, meaning its parent (app info pill view). - final PointF inputPoint = new PointF(ev.getX() - mAppInfoPillPosition.x, - ev.getY() - mAppInfoPillPosition.y); + final PointF inputPoint = new PointF(ev.getX() - mHandleMenuPosition.x, + ev.getY() - mHandleMenuPosition.y); if (pointInView(collapse, inputPoint.x, inputPoint.y)) { mOnClickListener.onClick(collapse); } @@ -303,23 +258,10 @@ class HandleMenu { */ boolean isValidMenuInput(PointF inputPoint) { if (!viewsLaidOut()) return true; - final boolean pointInAppInfoPill = pointInView( - mAppInfoPill.mWindowViewHost.getView(), - inputPoint.x - mAppInfoPillPosition.x, - inputPoint.y - mAppInfoPillPosition.y); - boolean pointInWindowingPill = false; - if (mWindowingPill != null) { - pointInWindowingPill = pointInView( - mWindowingPill.mWindowViewHost.getView(), - inputPoint.x - mWindowingPillPosition.x, - inputPoint.y - mWindowingPillPosition.y); - } - final boolean pointInMoreActionsPill = pointInView( - mMoreActionsPill.mWindowViewHost.getView(), - inputPoint.x - mMoreActionsPillPosition.x, - inputPoint.y - mMoreActionsPillPosition.y); - - return pointInAppInfoPill || pointInWindowingPill || pointInMoreActionsPill; + return pointInView( + mHandleMenuWindow.mWindowViewHost.getView(), + inputPoint.x - mHandleMenuPosition.x, + inputPoint.y - mHandleMenuPosition.y); } private boolean pointInView(View v, float x, float y) { @@ -331,33 +273,31 @@ class HandleMenu { * Check if the views for handle menu can be seen. */ private boolean viewsLaidOut() { - return mAppInfoPill.mWindowViewHost.getView().isLaidOut(); + return mHandleMenuWindow.mWindowViewHost.getView().isLaidOut(); } - private void loadHandleMenuDimensions() { final Resources resources = mContext.getResources(); mMenuWidth = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_width); + mMenuHeight = getHandleMenuHeight(resources); mMarginMenuTop = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_margin_top); mMarginMenuStart = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_margin_start); - mMarginMenuSpacing = loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_pill_spacing_margin); - mAppInfoPillHeight = loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_app_info_pill_height); - mWindowingPillHeight = loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_windowing_pill_height); - mMoreActionsPillHeight = shouldShowCloseButton() - ? loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_more_actions_pill_freeform_height) - : loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_more_actions_pill_height); - mShadowRadius = loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_shadow_radius); - mCornerRadius = loadDimensionPixelSize(resources, - R.dimen.desktop_mode_handle_menu_corner_radius); + } + + /** + * Determines handle menu height based on if windowing pill should be shown. + */ + private int getHandleMenuHeight(Resources resources) { + int menuHeight = loadDimensionPixelSize(resources, + R.dimen.desktop_mode_handle_menu_height); + if (!mShouldShowWindowingPill) { + menuHeight -= loadDimensionPixelSize(resources, + R.dimen.desktop_mode_handle_menu_windowing_pill_height); + } + return menuHeight; } private int loadDimensionPixelSize(Resources resources, int resourceId) { @@ -367,19 +307,9 @@ class HandleMenu { return resources.getDimensionPixelSize(resourceId); } - private boolean shouldShowCloseButton() { - return mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM; - } - void close() { - mAppInfoPill.releaseView(); - mAppInfoPill = null; - if (mWindowingPill != null) { - mWindowingPill.releaseView(); - mWindowingPill = null; - } - mMoreActionsPill.releaseView(); - mMoreActionsPill = null; + mHandleMenuWindow.releaseView(); + mHandleMenuWindow = null; } static final class Builder { 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 07fee4316c08..6062e34cd601 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 @@ -425,13 +425,10 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> * @param yPos y position of new window * @param width width of new window * @param height height of new window - * @param shadowRadius radius of the shadow of the new window - * @param cornerRadius radius of the corners of the new window * @return the {@link AdditionalWindow} that was added. */ AdditionalWindow addWindow(int layoutId, String namePrefix, SurfaceControl.Transaction t, - SurfaceSyncGroup ssg, int xPos, int yPos, int width, int height, int shadowRadius, - int cornerRadius) { + SurfaceSyncGroup ssg, int xPos, int yPos, int width, int height) { final SurfaceControl.Builder builder = mSurfaceControlBuilderSupplier.get(); SurfaceControl windowSurfaceControl = builder .setName(namePrefix + " of Task=" + mTaskInfo.taskId) @@ -442,8 +439,6 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> t.setPosition(windowSurfaceControl, xPos, yPos) .setWindowCrop(windowSurfaceControl, width, height) - .setShadowRadius(windowSurfaceControl, shadowRadius) - .setCornerRadius(windowSurfaceControl, cornerRadius) .show(windowSurfaceControl); final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java index 76bc25aa66ef..966a99eea925 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java @@ -119,8 +119,6 @@ public class WindowDecorationTests extends ShellTestCase { private WindowDecoration.RelayoutParams mRelayoutParams = new WindowDecoration.RelayoutParams(); private Configuration mWindowConfiguration = new Configuration(); private int mCaptionMenuWidthId; - private int mCaptionMenuShadowRadiusId; - private int mCaptionMenuCornerRadiusId; @Before public void setUp() { @@ -131,8 +129,6 @@ public class WindowDecorationTests extends ShellTestCase { mRelayoutParams.mLayoutResId = 0; mRelayoutParams.mCaptionHeightId = R.dimen.test_freeform_decor_caption_height; mCaptionMenuWidthId = R.dimen.test_freeform_decor_caption_menu_width; - mCaptionMenuShadowRadiusId = R.dimen.test_caption_menu_shadow_radius; - mCaptionMenuCornerRadiusId = R.dimen.test_caption_menu_corner_radius; mRelayoutParams.mShadowRadiusId = R.dimen.test_window_decor_shadow_radius; mRelayoutParams.mCornerRadius = CORNER_RADIUS; @@ -417,16 +413,6 @@ public class WindowDecorationTests extends ShellTestCase { final int height = WindowDecoration.loadDimensionPixelSize( windowDecor.mDecorWindowContext.getResources(), mRelayoutParams.mCaptionHeightId); verify(mMockSurfaceControlAddWindowT).setWindowCrop(additionalWindowSurface, width, height); - final int shadowRadius = WindowDecoration.loadDimensionPixelSize( - windowDecor.mDecorWindowContext.getResources(), - mCaptionMenuShadowRadiusId); - verify(mMockSurfaceControlAddWindowT) - .setShadowRadius(additionalWindowSurface, shadowRadius); - final int cornerRadius = WindowDecoration.loadDimensionPixelSize( - windowDecor.mDecorWindowContext.getResources(), - mCaptionMenuCornerRadiusId); - verify(mMockSurfaceControlAddWindowT) - .setCornerRadius(additionalWindowSurface, cornerRadius); verify(mMockSurfaceControlAddWindowT).show(additionalWindowSurface); verify(mMockSurfaceControlViewHostFactory, Mockito.times(2)) .create(any(), eq(defaultDisplay), any()); @@ -588,13 +574,11 @@ public class WindowDecorationTests extends ShellTestCase { int y = mRelayoutParams.mCaptionY; int width = loadDimensionPixelSize(resources, mCaptionMenuWidthId); int height = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionHeightId); - int shadowRadius = loadDimensionPixelSize(resources, mCaptionMenuShadowRadiusId); - int cornerRadius = loadDimensionPixelSize(resources, mCaptionMenuCornerRadiusId); String name = "Test Window"; WindowDecoration.AdditionalWindow additionalWindow = - addWindow(R.layout.desktop_mode_window_decor_handle_menu_app_info_pill, name, + addWindow(R.layout.desktop_mode_window_decor_handle_menu, name, mMockSurfaceControlAddWindowT, mMockSurfaceSyncGroup, x, y, - width, height, shadowRadius, cornerRadius); + width, height); return additionalWindow; } } |