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

Commit d5ced7da authored by Yuichiro Hanada's avatar Yuichiro Hanada
Browse files

Implement a minimize button on a caption bar

This CL adds a minimize button on a caption bar used for
Android Desktop Mode.
The button icon is tentative and will be updated later.

Bug: 356843241
Test: WMShellUnitTests
Flag: com.android.window.flags.enable_minimize_button
Change-Id: Ieb0b0946b69f98a8686340d9230e3e3d2a46b093
parent 47b0a3cd
Loading
Loading
Loading
Loading
+26 −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="24dp"
    android:height="24dp"
    android:viewportHeight="24"
    android:viewportWidth="24">
    <path
        android:fillColor="#FF000000"
        android:pathData="M6,21V19H18V21Z"/>
</vector>
+12 −0
Original line number Diff line number Diff line
@@ -76,6 +76,18 @@
        android:layout_height="40dp"
        android:layout_weight="1"/>

    <ImageButton
        android:id="@+id/minimize_window"
        android:layout_width="44dp"
        android:layout_height="40dp"
        android:paddingHorizontal="10dp"
        android:paddingVertical="8dp"
        android:layout_marginEnd="8dp"
        android:contentDescription="@string/minimize_button_text"
        android:src="@drawable/desktop_mode_header_ic_minimize"
        android:scaleType="centerCrop"
        android:gravity="end"/>

    <com.android.wm.shell.windowdecor.MaximizeButtonView
        android:id="@+id/maximize_button_view"
        android:layout_width="44dp"
+12 −0
Original line number Diff line number Diff line
@@ -460,6 +460,11 @@
         start of this area. -->
    <dimen name="desktop_mode_customizable_caption_margin_end">152dp</dimen>

    <!-- The width of the right-aligned region that is taken up by caption elements and extra
         margins when the caption has the minimize button. This will be merged with the above value
         once the minimize button becomes default. -->
    <dimen name="desktop_mode_customizable_caption_with_minimize_button_margin_end">204dp</dimen>

    <!-- The default minimum allowed window width when resizing a window in desktop mode. -->
    <dimen name="desktop_mode_minimum_window_width">386dp</dimen>

@@ -579,6 +584,13 @@
    <!-- The vertical inset to apply to the app chip's ripple drawable -->
    <dimen name="desktop_mode_header_app_chip_ripple_inset_vertical">4dp</dimen>

    <!-- The corner radius of the minimize button's ripple drawable -->
    <dimen name="desktop_mode_header_minimize_ripple_radius">18dp</dimen>
    <!-- The vertical inset to apply to the minimize button's ripple drawable -->
    <dimen name="desktop_mode_header_minimize_ripple_inset_vertical">4dp</dimen>
    <!-- The horizontal inset to apply to the minimize button's ripple drawable -->
    <dimen name="desktop_mode_header_minimize_ripple_inset_horizontal">6dp</dimen>

    <!-- The corner radius of the maximize button's ripple drawable -->
    <dimen name="desktop_mode_header_maximize_ripple_radius">18dp</dimen>
    <!-- The vertical inset to apply to the maximize button's ripple drawable -->
+4 −2
Original line number Diff line number Diff line
@@ -235,7 +235,8 @@ public abstract class WMShellModule {
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer,
            InteractionJankMonitor interactionJankMonitor,
            AppToWebGenericLinksParser genericLinksParser,
            MultiInstanceHelper multiInstanceHelper) {
            MultiInstanceHelper multiInstanceHelper,
            Optional<DesktopTasksLimiter> desktopTasksLimiter) {
        if (DesktopModeStatus.canEnterDesktopMode(context)) {
            return new DesktopModeWindowDecorViewModel(
                    context,
@@ -256,7 +257,8 @@ public abstract class WMShellModule {
                    rootTaskDisplayAreaOrganizer,
                    interactionJankMonitor,
                    genericLinksParser,
                    multiInstanceHelper);
                    multiInstanceHelper,
                    desktopTasksLimiter);
        }
        return new CaptionWindowDecorViewModel(
                context,
+14 −0
Original line number Diff line number Diff line
@@ -431,6 +431,20 @@ class DesktopTasksController(
        taskRepository.addClosingTask(displayId, taskId)
    }

    /**
     * Perform clean up of the desktop wallpaper activity if the minimized window task is the last
     * active task.
     *
     * @param wct transaction to modify if the last active task is minimized
     * @param taskId task id of the window that's being minimized
     */
    fun onDesktopWindowMinimize(wct: WindowContainerTransaction, taskId: Int) {
        if (taskRepository.isOnlyVisibleNonClosingTask(taskId)) {
            removeWallpaperActivity(wct)
        }
        // Do not call taskRepository.minimizeTask because it will be called by DekstopTasksLimiter.
    }

    /** Move a task with given `taskId` to fullscreen */
    fun moveToFullscreen(taskId: Int, transitionSource: DesktopModeTransitionSource) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task ->
Loading