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

Commit dde9ccdc authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add aspect ratio setting button in window handle menu

The button will be visible if the task is fullscreen windowing mode
and the display is ignore-orientation-request (i.e. large screen).
Currently it only applies if desktop mode is enabled.

This is to make it easier for users to switch aspect ratio of app.

Bug: 376395315
Flag: EXEMPT add a common button
Test: adb shell setprop \
    persist.wm.debug.desktop_mode_enforce_device_restrictions false
  adb shell settings put global enable_freeform_support 1
  adb shell settings put global override_desktop_mode_features 1
  adb shell cmd window set-ignore-orientation-request 1
  adb reboot
  Open an app in fullscreen mode. Click top bar to see the button.

Change-Id: I5908286624cd426daeca317e9803e6619fe994be
parent 428aef40
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2024 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="@color/compat_controls_text"
        android:pathData="M19,12h-2v3h-3v2h5v-5zM7,9h3L10,7L5,7v5h2L7,9zM21,3L3,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,19.01L3,19.01L3,4.99h18v14.02z"/>
</vector>
+8 −0
Original line number Diff line number Diff line
@@ -157,6 +157,14 @@
            android:drawableStart="@drawable/desktop_mode_ic_handle_menu_manage_windows"
            android:drawableTint="?androidprv:attr/materialColorOnSurface"
            style="@style/DesktopModeHandleMenuActionButton" />

        <Button
            android:id="@+id/change_aspect_ratio_button"
            android:contentDescription="@string/change_aspect_ratio_text"
            android:text="@string/change_aspect_ratio_text"
            android:drawableStart="@drawable/desktop_mode_ic_handle_menu_change_aspect_ratio"
            android:drawableTint="?androidprv:attr/materialColorOnSurface"
            style="@style/DesktopModeHandleMenuActionButton" />
    </LinearLayout>

    <LinearLayout
+6 −2
Original line number Diff line number Diff line
@@ -523,8 +523,9 @@
    <dimen name="desktop_mode_handle_menu_width">216dp</dimen>

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

    <!-- The elevation set on the handle menu pills. -->
    <dimen name="desktop_mode_handle_menu_pill_elevation">1dp</dimen>
@@ -547,6 +548,9 @@
    <!-- The height of the handle menu's "Open in browser" pill in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_open_in_browser_pill_height">52dp</dimen>

    <!-- 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 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
@@ -305,6 +305,8 @@
    <string name="new_window_text">New Window</string>
    <!-- Accessibility text for the handle menu new window button [CHAR LIMIT=NONE] -->
    <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 close button [CHAR LIMIT=NONE] -->
    <string name="close_text">Close</string>
    <!-- Accessibility text for the handle menu close menu button [CHAR LIMIT=NONE] -->
+7 −1
Original line number Diff line number Diff line
@@ -688,6 +688,12 @@ public class CompatUIController implements OnDisplaysChangedListener,

    private void launchUserAspectRatioSettings(
            @NonNull TaskInfo taskInfo, @NonNull ShellTaskOrganizer.TaskListener taskListener) {
        launchUserAspectRatioSettings(mContext, taskInfo);
    }

    /** Launch the user aspect ratio settings for the package of the given task. */
    public static void launchUserAspectRatioSettings(
            @NonNull Context context, @NonNull TaskInfo taskInfo) {
        final Intent intent = new Intent(Settings.ACTION_MANAGE_USER_ASPECT_RATIO_SETTINGS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
@@ -697,7 +703,7 @@ public class CompatUIController implements OnDisplaysChangedListener,
            intent.setData(packageUri);
        }
        final UserHandle userHandle = UserHandle.of(taskInfo.userId);
        mContext.startActivityAsUser(intent, userHandle);
        context.startActivityAsUser(intent, userHandle);
    }

    @VisibleForTesting
Loading