Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 187d2a31 authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Add "Optimize View" option to Handle Menu

This is the new app-compat UI element to give users the option
to restart apps when they move between displays and get some
app-specific UI issues. (See the mock attached in the bug for
more details.)

The visibility of the menu is controlled by
AppCompatTaskInfo.isRestartMenuEnabledForDisplayMove, which
becomes true when an app moves between displays, and reset to
false when an app actually gets restarted.

When the button is pressed, it invokes
CompatUIHandler#sendCompatUIRequest() and the restart dialog gets
shown.

Flag: com.android.window.flags.enable_restart_menu_for_connected_displays
Bug: 400575337
Test: DesktopModeWindowDecorationTests
Change-Id: I398b01fe044ccdc960603a0b9391eb90e16575b3
parent 8105f876
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="20dp"
    android:height="20dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="#1C1C14"
        android:pathData="M6,13c0,-1.65 0.67,-3.15 1.76,-4.24L6.34,7.34C4.9,8.79 4,10.79 4,13c0,4.08 3.05,7.44 7,7.93v-2.02C8.17,18.43 6,15.97 6,13z"/>
    <path
        android:fillColor="#1C1C14"
        android:pathData="M20,13c0,-4.42 -3.58,-8 -8,-8c-0.06,0 -0.12,0.01 -0.18,0.01v0l1.09,-1.09L11.5,2.5L8,6l3.5,3.5l1.41,-1.41l-1.08,-1.08C11.89,7.01 11.95,7 12,7c3.31,0 6,2.69 6,6c0,2.97 -2.17,5.43 -5,5.91v2.02C16.95,20.44 20,17.08 20,13z"/>
</vector>
+7 −0
Original line number Diff line number Diff line
@@ -163,6 +163,13 @@
            android:text="@string/change_aspect_ratio_text"
            android:src="@drawable/desktop_mode_ic_handle_menu_change_aspect_ratio"
            style="@style/DesktopModeHandleMenuActionButton"/>

        <com.android.wm.shell.windowdecor.HandleMenuActionButton
            android:id="@+id/handle_menu_restart_button"
            android:contentDescription="@string/handle_menu_restart_text"
            android:text="@string/handle_menu_restart_text"
            android:src="@drawable/desktop_mode_ic_handle_menu_restart"
            style="@style/DesktopModeHandleMenuActionButton"/>
    </LinearLayout>

    <LinearLayout
+7 −4
Original line number Diff line number Diff line
@@ -534,10 +534,10 @@
         pill elevation. -->
    <dimen name="desktop_mode_handle_menu_width">218dp</dimen>

    <!-- The maximum height of the handle menu in desktop mode. Three pills at 52dp each plus
         additional actions pill 208dp plus 2dp spacing between them plus 4dp top padding
         plus 2dp bottom padding: 52*3 + 52*4 + (4-1)*2 + 4 + 2 = 376 -->
    <dimen name="desktop_mode_handle_menu_height">376dp</dimen>
    <!-- The maximum height of the handle menu in desktop mode. Three pills at 52dp each,
         additional actions pill 260dp, plus 2dp spacing between them plus 4dp top padding.
         52*3 + 52*5 + (5-1)*2 + 4 = 428 -->
    <dimen name="desktop_mode_handle_menu_height">428dp</dimen>

    <!-- The elevation set on the handle menu pills. -->
    <dimen name="desktop_mode_handle_menu_pill_elevation">1dp</dimen>
@@ -566,6 +566,9 @@
    <!-- The height of the handle menu's "Change aspect ratio" pill in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_change_aspect_ratio_height">52dp</dimen>

    <!-- The height of the handle menu's "Optimize View" pill in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_restart_button_height">52dp</dimen>

    <!-- The margin between pills of the handle menu in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen>

+2 −0
Original line number Diff line number Diff line
@@ -314,6 +314,8 @@
    <string name="manage_windows_text">Manage Windows</string>
    <!-- Accessibility text for the handle menu change aspect ratio button [CHAR LIMIT=NONE] -->
    <string name="change_aspect_ratio_text">Change aspect ratio</string>
    <!-- Accessibility text for the handle menu restart button [CHAR LIMIT=NONE] -->
    <string name="handle_menu_restart_text">Optimize View</string>
    <!-- Accessibility text for the handle menu close button [CHAR LIMIT=NONE] -->
    <string name="close_text">Close</string>
    <!-- Accessibility text for the handle menu close menu button [CHAR LIMIT=NONE] -->
+4 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.common.UserProfileContexts;
import com.android.wm.shell.common.split.SplitState;
import com.android.wm.shell.compatui.api.CompatUIHandler;
import com.android.wm.shell.compatui.letterbox.LetterboxCommandHandler;
import com.android.wm.shell.compatui.letterbox.LetterboxTransitionObserver;
import com.android.wm.shell.crashhandling.ShellCrashHandler;
@@ -1044,7 +1045,8 @@ public abstract class WMShellModule {
            RecentsTransitionHandler recentsTransitionHandler,
            DesktopModeCompatPolicy desktopModeCompatPolicy,
            DesktopTilingDecorViewModel desktopTilingDecorViewModel,
            MultiDisplayDragMoveIndicatorController multiDisplayDragMoveIndicatorController
            MultiDisplayDragMoveIndicatorController multiDisplayDragMoveIndicatorController,
            Optional<CompatUIHandler> compatUI
    ) {
        if (!DesktopModeStatus.canEnterDesktopModeOrShowAppHandle(context)) {
            return Optional.empty();
@@ -1062,7 +1064,7 @@ public abstract class WMShellModule {
                activityOrientationChangeHandler, focusTransitionObserver, desktopModeEventLogger,
                desktopModeUiEventLogger, taskResourceLoader, recentsTransitionHandler,
                desktopModeCompatPolicy, desktopTilingDecorViewModel,
                multiDisplayDragMoveIndicatorController));
                multiDisplayDragMoveIndicatorController, compatUI.orElse(null)));
    }

    @WMSingleton
Loading