Loading libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_maximize_menu.xml +35 −19 Original line number Original line Diff line number Diff line Loading @@ -18,23 +18,28 @@ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:id="@+id/maximize_menu" android:id="@+id/maximize_menu" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="@dimen/desktop_mode_maximize_menu_height" android:layout_height="wrap_content" android:background="@drawable/desktop_mode_maximize_menu_background" android:background="@drawable/desktop_mode_maximize_menu_background" android:elevation="1dp"> android:elevation="1dp"> <LinearLayout <LinearLayout android:id="@+id/container" android:id="@+id/container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="@dimen/desktop_mode_maximize_menu_height" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="horizontal" android:padding="16dp" android:paddingHorizontal="12dp" android:paddingVertical="16dp" android:measureWithLargestChild="true" android:gravity="center"> android:gravity="center"> <LinearLayout <LinearLayout android:id="@+id/maximize_menu_immersive_toggle_container" android:id="@+id/maximize_menu_immersive_toggle_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <Button <Button android:layout_width="94dp" android:layout_width="94dp" Loading @@ -44,21 +49,22 @@ android:stateListAnimator="@null" android:stateListAnimator="@null" android:importantForAccessibility="yes" android:importantForAccessibility="yes" android:contentDescription="@string/desktop_mode_maximize_menu_immersive_button_text" android:contentDescription="@string/desktop_mode_maximize_menu_immersive_button_text" android:layout_marginEnd="8dp" android:layout_marginBottom="4dp" android:layout_marginBottom="4dp" android:alpha="0"/> android:alpha="0"/> <TextView <TextView android:id="@+id/maximize_menu_immersive_toggle_button_text" android:id="@+id/maximize_menu_immersive_toggle_button_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:gravity="center" android:gravity="center" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:importantForAccessibility="no" android:importantForAccessibility="no" android:text="@string/desktop_mode_maximize_menu_immersive_button_text" android:text="@string/desktop_mode_maximize_menu_immersive_button_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> Loading @@ -66,7 +72,11 @@ android:id="@+id/maximize_menu_size_toggle_container" android:id="@+id/maximize_menu_size_toggle_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <Button <Button android:layout_width="94dp" android:layout_width="94dp" Loading @@ -81,15 +91,17 @@ <TextView <TextView android:id="@+id/maximize_menu_size_toggle_button_text" android:id="@+id/maximize_menu_size_toggle_button_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:gravity="center" android:gravity="center" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:importantForAccessibility="no" android:importantForAccessibility="no" android:text="@string/desktop_mode_maximize_menu_maximize_text" android:text="@string/desktop_mode_maximize_menu_maximize_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> Loading @@ -97,7 +109,11 @@ android:id="@+id/maximize_menu_snap_container" android:id="@+id/maximize_menu_snap_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <LinearLayout <LinearLayout android:id="@+id/maximize_menu_snap_menu_layout" android:id="@+id/maximize_menu_snap_menu_layout" android:layout_width="wrap_content" android:layout_width="wrap_content" Loading @@ -106,7 +122,6 @@ android:padding="4dp" android:padding="4dp" android:background="@drawable/desktop_mode_maximize_menu_layout_background" android:background="@drawable/desktop_mode_maximize_menu_layout_background" android:layout_marginBottom="4dp" android:layout_marginBottom="4dp" android:layout_marginStart="8dp" android:alpha="0"> android:alpha="0"> <Button <Button android:id="@+id/maximize_menu_snap_left_button" android:id="@+id/maximize_menu_snap_left_button" Loading @@ -131,16 +146,17 @@ </LinearLayout> </LinearLayout> <TextView <TextView android:id="@+id/maximize_menu_snap_window_text" android:id="@+id/maximize_menu_snap_window_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:layout_gravity="center" android:gravity="center" android:gravity="center" android:importantForAccessibility="no" android:importantForAccessibility="no" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:text="@string/desktop_mode_maximize_menu_snap_text" android:text="@string/desktop_mode_maximize_menu_snap_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout> Loading @@ -150,6 +166,6 @@ <View <View android:id="@+id/maximize_menu_overlay" android:id="@+id/maximize_menu_overlay" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="@dimen/desktop_mode_maximize_menu_height"/> android:layout_height="match_parent"/> </FrameLayout> </FrameLayout> libs/WindowManager/Shell/res/values/dimen.xml +0 −8 Original line number Original line Diff line number Diff line Loading @@ -498,14 +498,6 @@ <!-- The default minimum allowed window height when resizing a window in desktop mode. --> <!-- The default minimum allowed window height when resizing a window in desktop mode. --> <dimen name="desktop_mode_minimum_window_height">352dp</dimen> <dimen name="desktop_mode_minimum_window_height">352dp</dimen> <!-- The width of the maximize menu in desktop mode, depending on the number of options --> <dimen name="desktop_mode_maximize_menu_width_one_options">126dp</dimen> <dimen name="desktop_mode_maximize_menu_width_two_options">228dp</dimen> <dimen name="desktop_mode_maximize_menu_width_three_options">330dp</dimen> <!-- The height of the maximize menu in desktop mode. --> <dimen name="desktop_mode_maximize_menu_height">114dp</dimen> <!-- The padding of the maximize menu in desktop mode. --> <!-- The padding of the maximize menu in desktop mode. --> <dimen name="desktop_mode_menu_padding">16dp</dimen> <dimen name="desktop_mode_menu_padding">16dp</dimen> Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +4 −29 Original line number Original line Diff line number Diff line Loading @@ -803,8 +803,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin if (!mTaskInfo.isVisible()) { if (!mTaskInfo.isVisible()) { closeMaximizeMenu(); closeMaximizeMenu(); } else { } else { final int menuWidth = calculateMaximizeMenuWidth(); mMaximizeMenu.positionMenu(startT); mMaximizeMenu.positionMenu(calculateMaximizeMenuPosition(menuWidth), startT); } } } } Loading Loading @@ -1069,27 +1068,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return Resources.ID_NULL; return Resources.ID_NULL; } } private int calculateMaximizeMenuWidth() { private PointF calculateMaximizeMenuPosition(int menuWidth, int menuHeight) { final boolean showImmersive = DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && TaskInfoKt.getRequestingImmersive(mTaskInfo); final boolean showMaximize = true; final boolean showSnaps = mTaskInfo.isResizeable; int showCount = 0; if (showImmersive) showCount++; if (showMaximize) showCount++; if (showSnaps) showCount++; return switch (showCount) { case 1 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_one_options); case 2 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_two_options); case 3 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_three_options); default -> throw new IllegalArgumentException(""); }; } private PointF calculateMaximizeMenuPosition(int menuWidth) { final PointF position = new PointF(); final PointF position = new PointF(); final Resources resources = mContext.getResources(); final Resources resources = mContext.getResources(); final DisplayLayout displayLayout = final DisplayLayout displayLayout = Loading @@ -1105,9 +1084,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin final int[] maximizeButtonLocation = new int[2]; final int[] maximizeButtonLocation = new int[2]; maximizeWindowButton.getLocationInWindow(maximizeButtonLocation); maximizeWindowButton.getLocationInWindow(maximizeButtonLocation); final int menuHeight = loadDimensionPixelSize( resources, R.dimen.desktop_mode_maximize_menu_height); float menuLeft = (mPositionInParent.x + maximizeButtonLocation[0] - ((float) (menuWidth float menuLeft = (mPositionInParent.x + maximizeButtonLocation[0] - ((float) (menuWidth - maximizeWindowButton.getWidth()) / 2)); - maximizeWindowButton.getWidth()) / 2)); float menuTop = (mPositionInParent.y + captionHeight); float menuTop = (mPositionInParent.y + captionHeight); Loading Loading @@ -1294,17 +1270,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin * Create and display maximize menu window * Create and display maximize menu window */ */ void createMaximizeMenu() { void createMaximizeMenu() { final int menuWidth = calculateMaximizeMenuWidth(); mMaximizeMenu = mMaximizeMenuFactory.create(mSyncQueue, mRootTaskDisplayAreaOrganizer, mMaximizeMenu = mMaximizeMenuFactory.create(mSyncQueue, mRootTaskDisplayAreaOrganizer, mDisplayController, mTaskInfo, mContext, mDisplayController, mTaskInfo, mContext, calculateMaximizeMenuPosition(menuWidth), mSurfaceControlTransactionSupplier); (width, height) -> calculateMaximizeMenuPosition(width, height), mSurfaceControlTransactionSupplier); mMaximizeMenu.show( mMaximizeMenu.show( /* isTaskInImmersiveMode= */ /* isTaskInImmersiveMode= */ DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && mDesktopUserRepositories.getProfile(mTaskInfo.userId) && mDesktopUserRepositories.getProfile(mTaskInfo.userId) .isTaskInFullImmersiveState(mTaskInfo.taskId), .isTaskInFullImmersiveState(mTaskInfo.taskId), /* menuWidth= */ menuWidth, /* showImmersiveOption= */ /* showImmersiveOption= */ DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && TaskInfoKt.getRequestingImmersive(mTaskInfo), && TaskInfoKt.getRequestingImmersive(mTaskInfo), Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +37 −26 Original line number Original line Diff line number Diff line Loading @@ -90,7 +90,7 @@ class MaximizeMenu( private val displayController: DisplayController, private val displayController: DisplayController, private val taskInfo: RunningTaskInfo, private val taskInfo: RunningTaskInfo, private val decorWindowContext: Context, private val decorWindowContext: Context, private val menuPosition: PointF, private val positionSupplier: (Int, Int) -> PointF, private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() } private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() } ) { ) { private var maximizeMenu: AdditionalViewHostViewContainer? = null private var maximizeMenu: AdditionalViewHostViewContainer? = null Loading @@ -100,19 +100,19 @@ class MaximizeMenu( private val cornerRadius = loadDimensionPixelSize( private val cornerRadius = loadDimensionPixelSize( R.dimen.desktop_mode_maximize_menu_corner_radius R.dimen.desktop_mode_maximize_menu_corner_radius ).toFloat() ).toFloat() private val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) private lateinit var menuPosition: PointF private val menuPadding = loadDimensionPixelSize(R.dimen.desktop_mode_menu_padding) private val menuPadding = loadDimensionPixelSize(R.dimen.desktop_mode_menu_padding) /** Position the menu relative to the caption's position. */ /** Position the menu relative to the caption's position. */ fun positionMenu(position: PointF, t: Transaction) { fun positionMenu(t: Transaction) { menuPosition.set(position) menuPosition = positionSupplier(maximizeMenuView?.measureWidth() ?: 0, maximizeMenuView?.measureHeight() ?: 0) t.setPosition(leash, menuPosition.x, menuPosition.y) t.setPosition(leash, menuPosition.x, menuPosition.y) } } /** Creates and shows the maximize window. */ /** Creates and shows the maximize window. */ fun show( fun show( isTaskInImmersiveMode: Boolean, isTaskInImmersiveMode: Boolean, menuWidth: Int, showImmersiveOption: Boolean, showImmersiveOption: Boolean, showSnapOptions: Boolean, showSnapOptions: Boolean, onMaximizeOrRestoreClickListener: () -> Unit, onMaximizeOrRestoreClickListener: () -> Unit, Loading @@ -125,7 +125,6 @@ class MaximizeMenu( if (maximizeMenu != null) return if (maximizeMenu != null) return createMaximizeMenu( createMaximizeMenu( isTaskInImmersiveMode = isTaskInImmersiveMode, isTaskInImmersiveMode = isTaskInImmersiveMode, menuWidth = menuWidth, showImmersiveOption = showImmersiveOption, showImmersiveOption = showImmersiveOption, showSnapOptions = showSnapOptions, showSnapOptions = showSnapOptions, onMaximizeClickListener = onMaximizeOrRestoreClickListener, onMaximizeClickListener = onMaximizeOrRestoreClickListener, Loading Loading @@ -161,7 +160,6 @@ class MaximizeMenu( /** Create a maximize menu that is attached to the display area. */ /** Create a maximize menu that is attached to the display area. */ private fun createMaximizeMenu( private fun createMaximizeMenu( isTaskInImmersiveMode: Boolean, isTaskInImmersiveMode: Boolean, menuWidth: Int, showImmersiveOption: Boolean, showImmersiveOption: Boolean, showSnapOptions: Boolean, showSnapOptions: Boolean, onMaximizeClickListener: () -> Unit, onMaximizeClickListener: () -> Unit, Loading @@ -178,16 +176,6 @@ class MaximizeMenu( .setName("Maximize Menu") .setName("Maximize Menu") .setContainerLayer() .setContainerLayer() .build() .build() val lp = WindowManager.LayoutParams( menuWidth, menuHeight, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSPARENT ) lp.title = "Maximize Menu for Task=" + taskInfo.taskId lp.setTrustedOverlay() val windowManager = WindowlessWindowManager( val windowManager = WindowlessWindowManager( taskInfo.configuration, taskInfo.configuration, leash, leash, Loading @@ -207,7 +195,6 @@ class MaximizeMenu( MaximizeMenuView.ImmersiveConfig.Hidden MaximizeMenuView.ImmersiveConfig.Hidden }, }, showSnapOptions = showSnapOptions, showSnapOptions = showSnapOptions, menuHeight = menuHeight, menuPadding = menuPadding, menuPadding = menuPadding, ).also { menuView -> ).also { menuView -> menuView.bind(taskInfo) menuView.bind(taskInfo) Loading @@ -217,6 +204,19 @@ class MaximizeMenu( menuView.onRightSnapClickListener = onRightSnapClickListener menuView.onRightSnapClickListener = onRightSnapClickListener menuView.onMenuHoverListener = onHoverListener menuView.onMenuHoverListener = onHoverListener menuView.onOutsideTouchListener = onOutsideTouchListener menuView.onOutsideTouchListener = onOutsideTouchListener val menuWidth = menuView.measureWidth() val menuHeight = menuView.measureHeight() menuPosition = positionSupplier(menuWidth, menuHeight) val lp = WindowManager.LayoutParams( menuWidth.toInt(), menuHeight.toInt(), WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSPARENT ) lp.title = "Maximize Menu for Task=" + taskInfo.taskId lp.setTrustedOverlay() viewHost.setView(menuView.rootView, lp) viewHost.setView(menuView.rootView, lp) } } Loading Loading @@ -268,7 +268,6 @@ class MaximizeMenu( private val sizeToggleDirection: SizeToggleDirection, private val sizeToggleDirection: SizeToggleDirection, immersiveConfig: ImmersiveConfig, immersiveConfig: ImmersiveConfig, showSnapOptions: Boolean, showSnapOptions: Boolean, private val menuHeight: Int, private val menuPadding: Int private val menuPadding: Int ) { ) { val rootView = LayoutInflater.from(context) val rootView = LayoutInflater.from(context) Loading Loading @@ -583,7 +582,7 @@ class MaximizeMenu( // the menu. // the menu. val value = animatedValue as Float val value = animatedValue as Float val topPadding = menuPadding - val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() ((1 - value) * measureHeight()).toInt() container.setPadding(menuPadding, topPadding, container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) menuPadding, menuPadding) } } Loading @@ -604,7 +603,7 @@ class MaximizeMenu( } } }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { (STARTING_MENU_HEIGHT_SCALE - 1) * measureHeight(), 0f).apply { duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, Loading Loading @@ -667,7 +666,7 @@ class MaximizeMenu( // the menu. // the menu. val value = animatedValue as Float val value = animatedValue as Float val topPadding = menuPadding - val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() ((1 - value) * measureHeight()).toInt() container.setPadding(menuPadding, topPadding, container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) menuPadding, menuPadding) } } Loading @@ -688,7 +687,7 @@ class MaximizeMenu( } } }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight).apply { 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * measureHeight()).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN interpolator = FAST_OUT_LINEAR_IN }, }, Loading Loading @@ -792,6 +791,18 @@ class MaximizeMenu( ) ) } } /** Measure width of the root view of this menu. */ fun measureWidth() : Int { rootView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); return rootView.getMeasuredWidth() } /** Measure height of the root view of this menu. */ fun measureHeight() : Int { rootView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); return rootView.getMeasuredHeight() } private fun deactivateSnapOptions() { private fun deactivateSnapOptions() { // TODO(b/346440693): the background/colorStateList set on these buttons is overridden // TODO(b/346440693): the background/colorStateList set on these buttons is overridden // to a static resource & color on manually tracked hover events, which defeats the // to a static resource & color on manually tracked hover events, which defeats the Loading Loading @@ -1036,7 +1047,7 @@ interface MaximizeMenuFactory { displayController: DisplayController, displayController: DisplayController, taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo, decorWindowContext: Context, decorWindowContext: Context, menuPosition: PointF, positionSupplier: (Int, Int) -> PointF, transactionSupplier: Supplier<Transaction> transactionSupplier: Supplier<Transaction> ): MaximizeMenu ): MaximizeMenu } } Loading @@ -1049,7 +1060,7 @@ object DefaultMaximizeMenuFactory : MaximizeMenuFactory { displayController: DisplayController, displayController: DisplayController, taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo, decorWindowContext: Context, decorWindowContext: Context, menuPosition: PointF, positionSupplier: (Int, Int) -> PointF, transactionSupplier: Supplier<Transaction> transactionSupplier: Supplier<Transaction> ): MaximizeMenu { ): MaximizeMenu { return MaximizeMenu( return MaximizeMenu( Loading @@ -1058,7 +1069,7 @@ object DefaultMaximizeMenuFactory : MaximizeMenuFactory { displayController, displayController, taskInfo, taskInfo, decorWindowContext, decorWindowContext, menuPosition, positionSupplier, transactionSupplier transactionSupplier ) ) } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +12 −13 Original line number Original line Diff line number Diff line Loading @@ -120,6 +120,7 @@ import com.android.wm.shell.windowdecor.viewholder.AppHeaderViewHolder; import kotlin.Unit; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.MainCoroutineDispatcher; import kotlinx.coroutines.MainCoroutineDispatcher; Loading Loading @@ -998,8 +999,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); assertTrue(decoration.isMaximizeMenuActive()); assertTrue(decoration.isMaximizeMenuActive()); } } Loading @@ -1011,8 +1012,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); decoration.setAppHeaderMaximizeButtonHovered(false); decoration.setAppHeaderMaximizeButtonHovered(false); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.getValue().invoke(false); mOnMaxMenuHoverChangeListener.getValue().invoke(false); Loading Loading @@ -1050,8 +1051,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.getValue().invoke(true); mOnMaxMenuHoverChangeListener.getValue().invoke(true); Loading @@ -1065,8 +1066,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); decoration.setAppHeaderMaximizeButtonHovered(true); decoration.setAppHeaderMaximizeButtonHovered(true); Loading @@ -1086,7 +1087,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), /* showImmersiveOption= */ eq(true), /* showImmersiveOption= */ eq(true), anyBoolean(), anyBoolean(), any(), any(), Loading @@ -1111,7 +1111,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), /* showImmersiveOption= */ eq(false), /* showImmersiveOption= */ eq(false), anyBoolean(), anyBoolean(), any(), any(), Loading @@ -1136,7 +1135,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), /* showSnapOptions= */ eq(true), /* showSnapOptions= */ eq(true), any(), any(), Loading @@ -1161,7 +1159,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), /* showSnapOptions= */ eq(false), /* showSnapOptions= */ eq(false), any(), any(), Loading Loading @@ -1766,7 +1763,9 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @NonNull RootTaskDisplayAreaOrganizer rootTdaOrganizer, @NonNull RootTaskDisplayAreaOrganizer rootTdaOrganizer, @NonNull DisplayController displayController, @NonNull DisplayController displayController, @NonNull ActivityManager.RunningTaskInfo taskInfo, @NonNull ActivityManager.RunningTaskInfo taskInfo, @NonNull Context decorWindowContext, @NonNull PointF menuPosition, @NonNull Context decorWindowContext, @NonNull Function2<? super Integer,? super Integer,? extends PointF> positionSupplier, @NonNull Supplier<SurfaceControl.Transaction> transactionSupplier) { @NonNull Supplier<SurfaceControl.Transaction> transactionSupplier) { return mMaximizeMenu; return mMaximizeMenu; } } Loading Loading
libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_maximize_menu.xml +35 −19 Original line number Original line Diff line number Diff line Loading @@ -18,23 +18,28 @@ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:id="@+id/maximize_menu" android:id="@+id/maximize_menu" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="@dimen/desktop_mode_maximize_menu_height" android:layout_height="wrap_content" android:background="@drawable/desktop_mode_maximize_menu_background" android:background="@drawable/desktop_mode_maximize_menu_background" android:elevation="1dp"> android:elevation="1dp"> <LinearLayout <LinearLayout android:id="@+id/container" android:id="@+id/container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="@dimen/desktop_mode_maximize_menu_height" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="horizontal" android:padding="16dp" android:paddingHorizontal="12dp" android:paddingVertical="16dp" android:measureWithLargestChild="true" android:gravity="center"> android:gravity="center"> <LinearLayout <LinearLayout android:id="@+id/maximize_menu_immersive_toggle_container" android:id="@+id/maximize_menu_immersive_toggle_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <Button <Button android:layout_width="94dp" android:layout_width="94dp" Loading @@ -44,21 +49,22 @@ android:stateListAnimator="@null" android:stateListAnimator="@null" android:importantForAccessibility="yes" android:importantForAccessibility="yes" android:contentDescription="@string/desktop_mode_maximize_menu_immersive_button_text" android:contentDescription="@string/desktop_mode_maximize_menu_immersive_button_text" android:layout_marginEnd="8dp" android:layout_marginBottom="4dp" android:layout_marginBottom="4dp" android:alpha="0"/> android:alpha="0"/> <TextView <TextView android:id="@+id/maximize_menu_immersive_toggle_button_text" android:id="@+id/maximize_menu_immersive_toggle_button_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:gravity="center" android:gravity="center" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:importantForAccessibility="no" android:importantForAccessibility="no" android:text="@string/desktop_mode_maximize_menu_immersive_button_text" android:text="@string/desktop_mode_maximize_menu_immersive_button_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> Loading @@ -66,7 +72,11 @@ android:id="@+id/maximize_menu_size_toggle_container" android:id="@+id/maximize_menu_size_toggle_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <Button <Button android:layout_width="94dp" android:layout_width="94dp" Loading @@ -81,15 +91,17 @@ <TextView <TextView android:id="@+id/maximize_menu_size_toggle_button_text" android:id="@+id/maximize_menu_size_toggle_button_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:gravity="center" android:gravity="center" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:importantForAccessibility="no" android:importantForAccessibility="no" android:text="@string/desktop_mode_maximize_menu_maximize_text" android:text="@string/desktop_mode_maximize_menu_maximize_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> Loading @@ -97,7 +109,11 @@ android:id="@+id/maximize_menu_snap_container" android:id="@+id/maximize_menu_snap_container" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal" android:layout_marginStart="4dp" android:layout_marginEnd="4dp"> <LinearLayout <LinearLayout android:id="@+id/maximize_menu_snap_menu_layout" android:id="@+id/maximize_menu_snap_menu_layout" android:layout_width="wrap_content" android:layout_width="wrap_content" Loading @@ -106,7 +122,6 @@ android:padding="4dp" android:padding="4dp" android:background="@drawable/desktop_mode_maximize_menu_layout_background" android:background="@drawable/desktop_mode_maximize_menu_layout_background" android:layout_marginBottom="4dp" android:layout_marginBottom="4dp" android:layout_marginStart="8dp" android:alpha="0"> android:alpha="0"> <Button <Button android:id="@+id/maximize_menu_snap_left_button" android:id="@+id/maximize_menu_snap_left_button" Loading @@ -131,16 +146,17 @@ </LinearLayout> </LinearLayout> <TextView <TextView android:id="@+id/maximize_menu_snap_window_text" android:id="@+id/maximize_menu_snap_window_text" android:layout_width="94dp" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_height="wrap_content" android:textSize="11sp" android:textSize="11sp" android:layout_marginBottom="76dp" android:lineHeight="16sp" android:layout_gravity="center" android:gravity="center" android:gravity="center" android:importantForAccessibility="no" android:importantForAccessibility="no" android:fontFamily="google-sans-text" android:fontFamily="google-sans-text" android:textFontWeight="500" android:text="@string/desktop_mode_maximize_menu_snap_text" android:text="@string/desktop_mode_maximize_menu_snap_text" android:textColor="@androidprv:color/materialColorOnSurface" android:textColor="@androidprv:color/materialColorOnSurface" android:singleLine="true" android:alpha="0"/> android:alpha="0"/> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout> Loading @@ -150,6 +166,6 @@ <View <View android:id="@+id/maximize_menu_overlay" android:id="@+id/maximize_menu_overlay" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="@dimen/desktop_mode_maximize_menu_height"/> android:layout_height="match_parent"/> </FrameLayout> </FrameLayout>
libs/WindowManager/Shell/res/values/dimen.xml +0 −8 Original line number Original line Diff line number Diff line Loading @@ -498,14 +498,6 @@ <!-- The default minimum allowed window height when resizing a window in desktop mode. --> <!-- The default minimum allowed window height when resizing a window in desktop mode. --> <dimen name="desktop_mode_minimum_window_height">352dp</dimen> <dimen name="desktop_mode_minimum_window_height">352dp</dimen> <!-- The width of the maximize menu in desktop mode, depending on the number of options --> <dimen name="desktop_mode_maximize_menu_width_one_options">126dp</dimen> <dimen name="desktop_mode_maximize_menu_width_two_options">228dp</dimen> <dimen name="desktop_mode_maximize_menu_width_three_options">330dp</dimen> <!-- The height of the maximize menu in desktop mode. --> <dimen name="desktop_mode_maximize_menu_height">114dp</dimen> <!-- The padding of the maximize menu in desktop mode. --> <!-- The padding of the maximize menu in desktop mode. --> <dimen name="desktop_mode_menu_padding">16dp</dimen> <dimen name="desktop_mode_menu_padding">16dp</dimen> Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +4 −29 Original line number Original line Diff line number Diff line Loading @@ -803,8 +803,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin if (!mTaskInfo.isVisible()) { if (!mTaskInfo.isVisible()) { closeMaximizeMenu(); closeMaximizeMenu(); } else { } else { final int menuWidth = calculateMaximizeMenuWidth(); mMaximizeMenu.positionMenu(startT); mMaximizeMenu.positionMenu(calculateMaximizeMenuPosition(menuWidth), startT); } } } } Loading Loading @@ -1069,27 +1068,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return Resources.ID_NULL; return Resources.ID_NULL; } } private int calculateMaximizeMenuWidth() { private PointF calculateMaximizeMenuPosition(int menuWidth, int menuHeight) { final boolean showImmersive = DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && TaskInfoKt.getRequestingImmersive(mTaskInfo); final boolean showMaximize = true; final boolean showSnaps = mTaskInfo.isResizeable; int showCount = 0; if (showImmersive) showCount++; if (showMaximize) showCount++; if (showSnaps) showCount++; return switch (showCount) { case 1 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_one_options); case 2 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_two_options); case 3 -> loadDimensionPixelSize(mContext.getResources(), R.dimen.desktop_mode_maximize_menu_width_three_options); default -> throw new IllegalArgumentException(""); }; } private PointF calculateMaximizeMenuPosition(int menuWidth) { final PointF position = new PointF(); final PointF position = new PointF(); final Resources resources = mContext.getResources(); final Resources resources = mContext.getResources(); final DisplayLayout displayLayout = final DisplayLayout displayLayout = Loading @@ -1105,9 +1084,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin final int[] maximizeButtonLocation = new int[2]; final int[] maximizeButtonLocation = new int[2]; maximizeWindowButton.getLocationInWindow(maximizeButtonLocation); maximizeWindowButton.getLocationInWindow(maximizeButtonLocation); final int menuHeight = loadDimensionPixelSize( resources, R.dimen.desktop_mode_maximize_menu_height); float menuLeft = (mPositionInParent.x + maximizeButtonLocation[0] - ((float) (menuWidth float menuLeft = (mPositionInParent.x + maximizeButtonLocation[0] - ((float) (menuWidth - maximizeWindowButton.getWidth()) / 2)); - maximizeWindowButton.getWidth()) / 2)); float menuTop = (mPositionInParent.y + captionHeight); float menuTop = (mPositionInParent.y + captionHeight); Loading Loading @@ -1294,17 +1270,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin * Create and display maximize menu window * Create and display maximize menu window */ */ void createMaximizeMenu() { void createMaximizeMenu() { final int menuWidth = calculateMaximizeMenuWidth(); mMaximizeMenu = mMaximizeMenuFactory.create(mSyncQueue, mRootTaskDisplayAreaOrganizer, mMaximizeMenu = mMaximizeMenuFactory.create(mSyncQueue, mRootTaskDisplayAreaOrganizer, mDisplayController, mTaskInfo, mContext, mDisplayController, mTaskInfo, mContext, calculateMaximizeMenuPosition(menuWidth), mSurfaceControlTransactionSupplier); (width, height) -> calculateMaximizeMenuPosition(width, height), mSurfaceControlTransactionSupplier); mMaximizeMenu.show( mMaximizeMenu.show( /* isTaskInImmersiveMode= */ /* isTaskInImmersiveMode= */ DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && mDesktopUserRepositories.getProfile(mTaskInfo.userId) && mDesktopUserRepositories.getProfile(mTaskInfo.userId) .isTaskInFullImmersiveState(mTaskInfo.taskId), .isTaskInFullImmersiveState(mTaskInfo.taskId), /* menuWidth= */ menuWidth, /* showImmersiveOption= */ /* showImmersiveOption= */ DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() DesktopModeFlags.ENABLE_FULLY_IMMERSIVE_IN_DESKTOP.isTrue() && TaskInfoKt.getRequestingImmersive(mTaskInfo), && TaskInfoKt.getRequestingImmersive(mTaskInfo), Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +37 −26 Original line number Original line Diff line number Diff line Loading @@ -90,7 +90,7 @@ class MaximizeMenu( private val displayController: DisplayController, private val displayController: DisplayController, private val taskInfo: RunningTaskInfo, private val taskInfo: RunningTaskInfo, private val decorWindowContext: Context, private val decorWindowContext: Context, private val menuPosition: PointF, private val positionSupplier: (Int, Int) -> PointF, private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() } private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() } ) { ) { private var maximizeMenu: AdditionalViewHostViewContainer? = null private var maximizeMenu: AdditionalViewHostViewContainer? = null Loading @@ -100,19 +100,19 @@ class MaximizeMenu( private val cornerRadius = loadDimensionPixelSize( private val cornerRadius = loadDimensionPixelSize( R.dimen.desktop_mode_maximize_menu_corner_radius R.dimen.desktop_mode_maximize_menu_corner_radius ).toFloat() ).toFloat() private val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) private lateinit var menuPosition: PointF private val menuPadding = loadDimensionPixelSize(R.dimen.desktop_mode_menu_padding) private val menuPadding = loadDimensionPixelSize(R.dimen.desktop_mode_menu_padding) /** Position the menu relative to the caption's position. */ /** Position the menu relative to the caption's position. */ fun positionMenu(position: PointF, t: Transaction) { fun positionMenu(t: Transaction) { menuPosition.set(position) menuPosition = positionSupplier(maximizeMenuView?.measureWidth() ?: 0, maximizeMenuView?.measureHeight() ?: 0) t.setPosition(leash, menuPosition.x, menuPosition.y) t.setPosition(leash, menuPosition.x, menuPosition.y) } } /** Creates and shows the maximize window. */ /** Creates and shows the maximize window. */ fun show( fun show( isTaskInImmersiveMode: Boolean, isTaskInImmersiveMode: Boolean, menuWidth: Int, showImmersiveOption: Boolean, showImmersiveOption: Boolean, showSnapOptions: Boolean, showSnapOptions: Boolean, onMaximizeOrRestoreClickListener: () -> Unit, onMaximizeOrRestoreClickListener: () -> Unit, Loading @@ -125,7 +125,6 @@ class MaximizeMenu( if (maximizeMenu != null) return if (maximizeMenu != null) return createMaximizeMenu( createMaximizeMenu( isTaskInImmersiveMode = isTaskInImmersiveMode, isTaskInImmersiveMode = isTaskInImmersiveMode, menuWidth = menuWidth, showImmersiveOption = showImmersiveOption, showImmersiveOption = showImmersiveOption, showSnapOptions = showSnapOptions, showSnapOptions = showSnapOptions, onMaximizeClickListener = onMaximizeOrRestoreClickListener, onMaximizeClickListener = onMaximizeOrRestoreClickListener, Loading Loading @@ -161,7 +160,6 @@ class MaximizeMenu( /** Create a maximize menu that is attached to the display area. */ /** Create a maximize menu that is attached to the display area. */ private fun createMaximizeMenu( private fun createMaximizeMenu( isTaskInImmersiveMode: Boolean, isTaskInImmersiveMode: Boolean, menuWidth: Int, showImmersiveOption: Boolean, showImmersiveOption: Boolean, showSnapOptions: Boolean, showSnapOptions: Boolean, onMaximizeClickListener: () -> Unit, onMaximizeClickListener: () -> Unit, Loading @@ -178,16 +176,6 @@ class MaximizeMenu( .setName("Maximize Menu") .setName("Maximize Menu") .setContainerLayer() .setContainerLayer() .build() .build() val lp = WindowManager.LayoutParams( menuWidth, menuHeight, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSPARENT ) lp.title = "Maximize Menu for Task=" + taskInfo.taskId lp.setTrustedOverlay() val windowManager = WindowlessWindowManager( val windowManager = WindowlessWindowManager( taskInfo.configuration, taskInfo.configuration, leash, leash, Loading @@ -207,7 +195,6 @@ class MaximizeMenu( MaximizeMenuView.ImmersiveConfig.Hidden MaximizeMenuView.ImmersiveConfig.Hidden }, }, showSnapOptions = showSnapOptions, showSnapOptions = showSnapOptions, menuHeight = menuHeight, menuPadding = menuPadding, menuPadding = menuPadding, ).also { menuView -> ).also { menuView -> menuView.bind(taskInfo) menuView.bind(taskInfo) Loading @@ -217,6 +204,19 @@ class MaximizeMenu( menuView.onRightSnapClickListener = onRightSnapClickListener menuView.onRightSnapClickListener = onRightSnapClickListener menuView.onMenuHoverListener = onHoverListener menuView.onMenuHoverListener = onHoverListener menuView.onOutsideTouchListener = onOutsideTouchListener menuView.onOutsideTouchListener = onOutsideTouchListener val menuWidth = menuView.measureWidth() val menuHeight = menuView.measureHeight() menuPosition = positionSupplier(menuWidth, menuHeight) val lp = WindowManager.LayoutParams( menuWidth.toInt(), menuHeight.toInt(), WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSPARENT ) lp.title = "Maximize Menu for Task=" + taskInfo.taskId lp.setTrustedOverlay() viewHost.setView(menuView.rootView, lp) viewHost.setView(menuView.rootView, lp) } } Loading Loading @@ -268,7 +268,6 @@ class MaximizeMenu( private val sizeToggleDirection: SizeToggleDirection, private val sizeToggleDirection: SizeToggleDirection, immersiveConfig: ImmersiveConfig, immersiveConfig: ImmersiveConfig, showSnapOptions: Boolean, showSnapOptions: Boolean, private val menuHeight: Int, private val menuPadding: Int private val menuPadding: Int ) { ) { val rootView = LayoutInflater.from(context) val rootView = LayoutInflater.from(context) Loading Loading @@ -583,7 +582,7 @@ class MaximizeMenu( // the menu. // the menu. val value = animatedValue as Float val value = animatedValue as Float val topPadding = menuPadding - val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() ((1 - value) * measureHeight()).toInt() container.setPadding(menuPadding, topPadding, container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) menuPadding, menuPadding) } } Loading @@ -604,7 +603,7 @@ class MaximizeMenu( } } }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { (STARTING_MENU_HEIGHT_SCALE - 1) * measureHeight(), 0f).apply { duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, Loading Loading @@ -667,7 +666,7 @@ class MaximizeMenu( // the menu. // the menu. val value = animatedValue as Float val value = animatedValue as Float val topPadding = menuPadding - val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() ((1 - value) * measureHeight()).toInt() container.setPadding(menuPadding, topPadding, container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) menuPadding, menuPadding) } } Loading @@ -688,7 +687,7 @@ class MaximizeMenu( } } }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight).apply { 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * measureHeight()).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN interpolator = FAST_OUT_LINEAR_IN }, }, Loading Loading @@ -792,6 +791,18 @@ class MaximizeMenu( ) ) } } /** Measure width of the root view of this menu. */ fun measureWidth() : Int { rootView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); return rootView.getMeasuredWidth() } /** Measure height of the root view of this menu. */ fun measureHeight() : Int { rootView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); return rootView.getMeasuredHeight() } private fun deactivateSnapOptions() { private fun deactivateSnapOptions() { // TODO(b/346440693): the background/colorStateList set on these buttons is overridden // TODO(b/346440693): the background/colorStateList set on these buttons is overridden // to a static resource & color on manually tracked hover events, which defeats the // to a static resource & color on manually tracked hover events, which defeats the Loading Loading @@ -1036,7 +1047,7 @@ interface MaximizeMenuFactory { displayController: DisplayController, displayController: DisplayController, taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo, decorWindowContext: Context, decorWindowContext: Context, menuPosition: PointF, positionSupplier: (Int, Int) -> PointF, transactionSupplier: Supplier<Transaction> transactionSupplier: Supplier<Transaction> ): MaximizeMenu ): MaximizeMenu } } Loading @@ -1049,7 +1060,7 @@ object DefaultMaximizeMenuFactory : MaximizeMenuFactory { displayController: DisplayController, displayController: DisplayController, taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo, decorWindowContext: Context, decorWindowContext: Context, menuPosition: PointF, positionSupplier: (Int, Int) -> PointF, transactionSupplier: Supplier<Transaction> transactionSupplier: Supplier<Transaction> ): MaximizeMenu { ): MaximizeMenu { return MaximizeMenu( return MaximizeMenu( Loading @@ -1058,7 +1069,7 @@ object DefaultMaximizeMenuFactory : MaximizeMenuFactory { displayController, displayController, taskInfo, taskInfo, decorWindowContext, decorWindowContext, menuPosition, positionSupplier, transactionSupplier transactionSupplier ) ) } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +12 −13 Original line number Original line Diff line number Diff line Loading @@ -120,6 +120,7 @@ import com.android.wm.shell.windowdecor.viewholder.AppHeaderViewHolder; import kotlin.Unit; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.MainCoroutineDispatcher; import kotlinx.coroutines.MainCoroutineDispatcher; Loading Loading @@ -998,8 +999,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); assertTrue(decoration.isMaximizeMenuActive()); assertTrue(decoration.isMaximizeMenuActive()); } } Loading @@ -1011,8 +1012,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); decoration.setAppHeaderMaximizeButtonHovered(false); decoration.setAppHeaderMaximizeButtonHovered(false); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.getValue().invoke(false); mOnMaxMenuHoverChangeListener.getValue().invoke(false); Loading Loading @@ -1050,8 +1051,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.getValue().invoke(true); mOnMaxMenuHoverChangeListener.getValue().invoke(true); Loading @@ -1065,8 +1066,8 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, final DesktopModeWindowDecoration decoration = createWindowDecoration(taskInfo, new FakeMaximizeMenuFactory(menu)); new FakeMaximizeMenuFactory(menu)); createMaximizeMenu(decoration); createMaximizeMenu(decoration); verify(menu).show(anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), any(), any(), any(), verify(menu).show(anyBoolean(), anyBoolean(), anyBoolean(), any(), any(), any(), any(), any(), mOnMaxMenuHoverChangeListener.capture(), any()); mOnMaxMenuHoverChangeListener.capture(), any()); decoration.setAppHeaderMaximizeButtonHovered(true); decoration.setAppHeaderMaximizeButtonHovered(true); Loading @@ -1086,7 +1087,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), /* showImmersiveOption= */ eq(true), /* showImmersiveOption= */ eq(true), anyBoolean(), anyBoolean(), any(), any(), Loading @@ -1111,7 +1111,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), /* showImmersiveOption= */ eq(false), /* showImmersiveOption= */ eq(false), anyBoolean(), anyBoolean(), any(), any(), Loading @@ -1136,7 +1135,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), /* showSnapOptions= */ eq(true), /* showSnapOptions= */ eq(true), any(), any(), Loading @@ -1161,7 +1159,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { verify(menu).show( verify(menu).show( anyBoolean(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), /* showSnapOptions= */ eq(false), /* showSnapOptions= */ eq(false), any(), any(), Loading Loading @@ -1766,7 +1763,9 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @NonNull RootTaskDisplayAreaOrganizer rootTdaOrganizer, @NonNull RootTaskDisplayAreaOrganizer rootTdaOrganizer, @NonNull DisplayController displayController, @NonNull DisplayController displayController, @NonNull ActivityManager.RunningTaskInfo taskInfo, @NonNull ActivityManager.RunningTaskInfo taskInfo, @NonNull Context decorWindowContext, @NonNull PointF menuPosition, @NonNull Context decorWindowContext, @NonNull Function2<? super Integer,? super Integer,? extends PointF> positionSupplier, @NonNull Supplier<SurfaceControl.Transaction> transactionSupplier) { @NonNull Supplier<SurfaceControl.Transaction> transactionSupplier) { return mMaximizeMenu; return mMaximizeMenu; } } Loading