diff options
| author | 2024-02-29 23:05:07 +0000 | |
|---|---|---|
| committer | 2024-03-01 02:13:18 +0000 | |
| commit | 2b188846c50f5cb9b44d180ef284c248d1c45877 (patch) | |
| tree | 49bdea0e8f42eec2e4ef105e1cd4536ae95a2ac2 /libs | |
| parent | cb5c34af4ba852aa1fbd354cba493bb97a46c47a (diff) | |
Update window header spec
1) Remove app name when app is using custom headers
2) Adjust padding/margins to support hiding the app name
3) Add empty drag zone on right-aligned bounding rect
4) Update close button vector, size and padding
5) Update app chip app icon size to 24x24dp
Bug: 316387515
Test: enable/disable APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND flag
and observe window header UI updating to allow more custom space and a
drag-only area.
Change-Id: Ic27b98861521dbcf1253ff7618e8e773bb763988
Diffstat (limited to 'libs')
5 files changed, 62 insertions, 28 deletions
diff --git a/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_close.xml b/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_close.xml new file mode 100644 index 000000000000..ff49edb7a699 --- /dev/null +++ b/libs/WindowManager/Shell/res/drawable/desktop_mode_header_ic_close.xml @@ -0,0 +1,26 @@ +<?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="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> +</vector> diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_app_controls_window_decor.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_app_controls_window_decor.xml index 490f0883fbfb..a5605a7ff50a 100644 --- a/libs/WindowManager/Shell/res/layout/desktop_mode_app_controls_window_decor.xml +++ b/libs/WindowManager/Shell/res/layout/desktop_mode_app_controls_window_decor.xml @@ -33,14 +33,15 @@ android:orientation="horizontal" android:clickable="true" android:focusable="true" - android:paddingStart="6dp" - android:paddingEnd="8dp"> + android:paddingStart="12dp"> <ImageView android:id="@+id/application_icon" android:layout_width="@dimen/desktop_mode_caption_icon_radius" android:layout_height="@dimen/desktop_mode_caption_icon_radius" android:layout_gravity="center_vertical" - android:contentDescription="@string/app_icon_text" /> + android:contentDescription="@string/app_icon_text" + android:layout_marginStart="6dp" + android:scaleType="centerCrop"/> <TextView android:id="@+id/application_name" @@ -53,8 +54,7 @@ android:lineHeight="20dp" android:layout_gravity="center_vertical" android:layout_weight="1" - android:paddingStart="8dp" - android:paddingEnd="8dp" + android:layout_marginStart="8dp" tools:text="Gmail"/> <ImageButton @@ -67,6 +67,7 @@ android:scaleType="fitCenter" android:clickable="false" android:focusable="false" + android:layout_marginHorizontal="8dp" android:layout_gravity="center_vertical"/> </LinearLayout> @@ -87,14 +88,15 @@ <ImageButton android:id="@+id/close_window" - android:layout_width="40dp" + android:layout_width="44dp" android:layout_height="40dp" - android:padding="4dp" + android:paddingHorizontal="10dp" + android:paddingVertical="8dp" android:layout_marginEnd="8dp" android:tint="?androidprv:attr/materialColorOnSurface" android:background="?android:selectableItemBackgroundBorderless" android:contentDescription="@string/close_button_text" - android:src="@drawable/decor_close_button_dark" - android:scaleType="fitCenter" + android:src="@drawable/desktop_mode_header_ic_close" + android:scaleType="centerCrop" android:gravity="end"/> </com.android.wm.shell.windowdecor.WindowDecorLinearLayout>
\ 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 48e6428524ae..74967ef0d97c 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -434,15 +434,22 @@ <!-- (32 dp buttons + 10dp margins) * 3 buttons--> <dimen name="caption_right_buttons_width">126dp</dimen> - <!-- 2 buttons * 48dp button size. --> - <dimen name="desktop_mode_right_edge_buttons_width">96dp</dimen> + <!-- 2 buttons * 44dp button size + 16dp total margins. --> + <dimen name="desktop_mode_right_edge_buttons_width">104dp</dimen> <!-- 22dp padding + 24dp app icon + 16dp expand button. Text varies in size, we will calculate that width separately. --> <dimen name="desktop_mode_app_details_width_minus_text">62dp</dimen> - <!-- 22dp padding + 24dp app icon + 16dp expand button + 86dp text (max) --> - <dimen name="desktop_mode_app_details_max_width">148dp</dimen> + <!-- When custom headers are requested, this is the width of the left-aligned region that is + taken up by caption elements and extra margins. The customizable region starts at the + end of this area. --> + <dimen name="desktop_mode_customizable_caption_margin_start">84dp</dimen> + + <!-- When custom headers are requested, this is the width of the right-aligned region that is + taken up by caption elements and extra margins. The customizable region ends at the + start of this area. --> + <dimen name="desktop_mode_customizable_caption_margin_end">152dp</dimen> <!-- The width of the maximize menu in desktop mode. --> <dimen name="desktop_mode_maximize_menu_width">287dp</dimen> @@ -490,7 +497,7 @@ <dimen name="desktop_mode_handle_menu_corner_radius">26dp</dimen> <!-- The radius of the caption menu icon. --> - <dimen name="desktop_mode_caption_icon_radius">28dp</dimen> + <dimen name="desktop_mode_caption_icon_radius">24dp</dimen> <!-- The radius of the caption menu shadow. --> <dimen name="desktop_mode_handle_menu_shadow_radius">2dp</dimen> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index 9e999ae52835..39803e2afd34 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -318,28 +318,25 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin relayoutParams.mCaptionHeightId = getCaptionHeightIdStatic(taskInfo.getWindowingMode()); relayoutParams.mCaptionWidthId = getCaptionWidthId(relayoutParams.mLayoutResId); - // The "app controls" type caption bar should report the occluding elements as bounding - // rects to the insets system so that apps can draw in the empty space left in the center. - if (captionLayoutId == R.layout.desktop_mode_app_controls_window_decor) { - // The "app chip" section of the caption bar, it's aligned to the left and its width - // varies depending on the length of the app name, but we'll report its max width for - // now. - // TODO(b/316387515): consider reporting the true width after it's been laid out. + if (captionLayoutId == R.layout.desktop_mode_app_controls_window_decor + && TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) { + // App is requesting to customize the caption bar. Allow input to fall through to the + // windows below so that the app can respond to input events on their custom content. + relayoutParams.mAllowCaptionInputFallthrough = true; + // Report occluding elements as bounding rects to the insets system so that apps can + // draw in the empty space in the center: + // First, the "app chip" section of the caption bar (+ some extra margins). final RelayoutParams.OccludingCaptionElement appChipElement = new RelayoutParams.OccludingCaptionElement(); - appChipElement.mWidthResId = R.dimen.desktop_mode_app_details_max_width; + appChipElement.mWidthResId = R.dimen.desktop_mode_customizable_caption_margin_start; appChipElement.mAlignment = RelayoutParams.OccludingCaptionElement.Alignment.START; relayoutParams.mOccludingCaptionElements.add(appChipElement); - // The "controls" section of the caption bar (maximize, close btns). These are aligned - // to the right of the caption bar and have a fixed width. - // TODO(b/316387515): add additional padding for an exclusive drag-move region. + // Then, the right-aligned section (drag space, maximize and close buttons). final RelayoutParams.OccludingCaptionElement controlsElement = new RelayoutParams.OccludingCaptionElement(); - controlsElement.mWidthResId = R.dimen.desktop_mode_right_edge_buttons_width; + controlsElement.mWidthResId = R.dimen.desktop_mode_customizable_caption_margin_end; controlsElement.mAlignment = RelayoutParams.OccludingCaptionElement.Alignment.END; relayoutParams.mOccludingCaptionElements.add(controlsElement); - relayoutParams.mAllowCaptionInputFallthrough = - TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo); } if (DesktopModeStatus.useWindowShadow(/* isFocusedWindow= */ taskInfo.isFocused)) { relayoutParams.mShadowRadiusId = taskInfo.isFocused diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt index b7dd01faa543..58bbb030da01 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt @@ -12,6 +12,7 @@ import android.widget.ImageButton import android.widget.ImageView import android.widget.TextView import androidx.core.content.withStyledAttributes +import androidx.core.view.isVisible import com.android.internal.R.attr.materialColorOnSecondaryContainer import com.android.internal.R.attr.materialColorOnSurface import com.android.internal.R.attr.materialColorSecondaryContainer @@ -76,6 +77,7 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder( closeWindowButton.imageTintList = ColorStateList.valueOf(color) maximizeWindowButton.imageTintList = ColorStateList.valueOf(color) expandMenuButton.imageTintList = ColorStateList.valueOf(color) + appNameTextView.isVisible = !taskInfo.isTransparentCaptionBarAppearance appNameTextView.setTextColor(color) appIconImageView.imageAlpha = alpha maximizeWindowButton.imageAlpha = alpha |