Implement new handle menu UI

Updates the handle menu to the newest spec. The menu is now divided
into three floating windows so three windowless windows associated
with the window decoration are created.

Menu in proto 2 (fullscreen):
https://screenshot.googleplex.com/4KGBDtRZ9mRedTS.png
Menu in proto 2 (desktop):
https://screenshot.googleplex.com/5DhrrPavNSSKrbH.png
Menu in proto 1: https://screenshot.googleplex.com/6GyUqpJGKdPt2MX.png

Bug: 274630524
Test: proto1/proto2 - open handle menu, see new UI, test buttons
still work

Change-Id: I9157ec0223cd1077dd3ae24cb39e535289775557
This commit is contained in:
Jorge Gil
2023-03-23 23:41:37 +00:00
parent 1aed6ba89b
commit 145b2a2c48
25 changed files with 529 additions and 445 deletions

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="6.0"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M5.958,37.708Q4.458,37.708 3.354,36.604Q2.25,35.5 2.25,34V18.292Q2.25,16.792 3.354,15.688Q4.458,14.583 5.958,14.583H9.5V5.958Q9.5,4.458 10.625,3.354Q11.75,2.25 13.208,2.25H34Q35.542,2.25 36.646,3.354Q37.75,4.458 37.75,5.958V21.667Q37.75,23.167 36.646,24.271Q35.542,25.375 34,25.375H30.5V34Q30.5,35.5 29.396,36.604Q28.292,37.708 26.792,37.708ZM5.958,34H26.792Q26.792,34 26.792,34Q26.792,34 26.792,34V21.542H5.958V34Q5.958,34 5.958,34Q5.958,34 5.958,34ZM30.5,21.667H34Q34,21.667 34,21.667Q34,21.667 34,21.667V9.208H13.208V14.583H26.833Q28.375,14.583 29.438,15.667Q30.5,16.75 30.5,18.25Z"/>
</group>
</vector>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="6.0"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M18.167,21.875H29.833V10.208H18.167ZM7.875,35.833Q6.375,35.833 5.271,34.729Q4.167,33.625 4.167,32.125V7.875Q4.167,6.375 5.271,5.271Q6.375,4.167 7.875,4.167H32.125Q33.625,4.167 34.729,5.271Q35.833,6.375 35.833,7.875V32.125Q35.833,33.625 34.729,34.729Q33.625,35.833 32.125,35.833ZM7.875,32.125H32.125Q32.125,32.125 32.125,32.125Q32.125,32.125 32.125,32.125V7.875Q32.125,7.875 32.125,7.875Q32.125,7.875 32.125,7.875H7.875Q7.875,7.875 7.875,7.875Q7.875,7.875 7.875,7.875V32.125Q7.875,32.125 7.875,32.125Q7.875,32.125 7.875,32.125ZM7.875,7.875Q7.875,7.875 7.875,7.875Q7.875,7.875 7.875,7.875V32.125Q7.875,32.125 7.875,32.125Q7.875,32.125 7.875,32.125Q7.875,32.125 7.875,32.125Q7.875,32.125 7.875,32.125V7.875Q7.875,7.875 7.875,7.875Q7.875,7.875 7.875,7.875Z"/>
</group>
</vector>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="6.0"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M34.042,14.625V9.333Q34.042,9.333 34.042,9.333Q34.042,9.333 34.042,9.333H28.708V5.708H33.917Q35.458,5.708 36.562,6.833Q37.667,7.958 37.667,9.458V14.625ZM2.375,14.625V9.458Q2.375,7.958 3.479,6.833Q4.583,5.708 6.125,5.708H11.292V9.333H6Q6,9.333 6,9.333Q6,9.333 6,9.333V14.625ZM28.708,34.25V30.667H34.042Q34.042,30.667 34.042,30.667Q34.042,30.667 34.042,30.667V25.333H37.667V30.542Q37.667,32 36.562,33.125Q35.458,34.25 33.917,34.25ZM6.125,34.25Q4.583,34.25 3.479,33.125Q2.375,32 2.375,30.542V25.333H6V30.667Q6,30.667 6,30.667Q6,30.667 6,30.667H11.292V34.25ZM9.333,27.292V12.667H30.708V27.292ZM12.917,23.708H27.125V16.25H12.917ZM12.917,23.708V16.25V23.708Z"/>
</group>
</vector>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateX="6.0"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M8.083,22.833Q6.917,22.833 6.104,22Q5.292,21.167 5.292,20Q5.292,18.833 6.125,18Q6.958,17.167 8.125,17.167Q9.292,17.167 10.125,18Q10.958,18.833 10.958,20Q10.958,21.167 10.125,22Q9.292,22.833 8.083,22.833ZM20,22.833Q18.833,22.833 18,22Q17.167,21.167 17.167,20Q17.167,18.833 18,18Q18.833,17.167 20,17.167Q21.167,17.167 22,18Q22.833,18.833 22.833,20Q22.833,21.167 22,22Q21.167,22.833 20,22.833ZM31.875,22.833Q30.708,22.833 29.875,22Q29.042,21.167 29.042,20Q29.042,18.833 29.875,18Q30.708,17.167 31.917,17.167Q33.083,17.167 33.896,18Q34.708,18.833 34.708,20Q34.708,21.167 33.875,22Q33.042,22.833 31.875,22.833Z"/>
</group>
</vector>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group
android:translateX="4.0"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M13.7021 12.5833L16.5676 15.5L15.426 16.7333L12.526 13.8333L10.4426 15.9167V10.5H15.9176L13.7021 12.5833ZM13.8343 3.83333H15.501V5.5H13.8343V3.83333ZM15.501 2.16667H13.8343V0.566667C14.751 0.566667 15.501 1.33333 15.501 2.16667ZM10.501 0.5H12.1676V2.16667H10.501V0.5ZM13.8343 7.16667H15.501V8.83333H13.8343V7.16667ZM5.50098 15.5H3.83431V13.8333H5.50098V15.5ZM2.16764 5.5H0.500977V3.83333H2.16764V5.5ZM2.16764 0.566667V2.16667H0.500977C0.500977 1.33333 1.33431 0.566667 2.16764 0.566667ZM2.16764 12.1667H0.500977V10.5H2.16764V12.1667ZM5.50098 2.16667H3.83431V0.5H5.50098V2.16667ZM8.83431 2.16667H7.16764V0.5H8.83431V2.16667ZM8.83431 15.5H7.16764V13.8333H8.83431V15.5ZM2.16764 8.83333H0.500977V7.16667H2.16764V8.83333ZM2.16764 15.5667C1.25098 15.5667 0.500977 14.6667 0.500977 13.8333H2.16764V15.5667Z"/>
</group>
</vector>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:translateX="6.0"
android:translateY="8.0">
<path
android:fillColor="@android:color/black"
android:pathData="M18 14L13 14L13 2L18 2L18 14ZM20 14L20 2C20 0.9 19.1 -3.93402e-08 18 -8.74228e-08L13 -3.0598e-07C11.9 -3.54062e-07 11 0.9 11 2L11 14C11 15.1 11.9 16 13 16L18 16C19.1 16 20 15.1 20 14ZM7 14L2 14L2 2L7 2L7 14ZM9 14L9 2C9 0.9 8.1 -5.20166e-07 7 -5.68248e-07L2 -7.86805e-07C0.9 -8.34888e-07 -3.93403e-08 0.9 -8.74228e-08 2L-6.11959e-07 14C-6.60042e-07 15.1 0.9 16 2 16L7 16C8.1 16 9 15.1 9 14Z"/> </group>
</vector>

View File

@@ -17,6 +17,5 @@
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="@dimen/caption_menu_corner_radius" />
<stroke android:width="1dp" android:color="#b3b3b3"/>
<corners android:radius="@dimen/desktop_mode_handle_menu_corner_radius" />
</shape>

View File

@@ -15,16 +15,12 @@
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
>
<group android:scaleX="1.25"
android:scaleY="1.75"
android:translateY="6.0">
<path
android:fillColor="@android:color/black"
android:pathData="M10.3937 6.93935L11.3337 5.99935L6.00033 0.666016L0.666992 5.99935L1.60699 6.93935L6.00033 2.55268"/>
</group>
android:height="20dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="20dp">
<path
android:fillColor="@android:color/white"
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>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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="20"
android:viewportHeight="20">
<path
android:pathData="M16.667,15H3.333V5H16.667V15ZM16.667,16.667C17.583,16.667 18.333,15.917 18.333,15V5C18.333,4.083 17.583,3.333 16.667,3.333H3.333C2.417,3.333 1.667,4.083 1.667,5V15C1.667,15.917 2.417,16.667 3.333,16.667H16.667ZM15,6.667H9.167V8.333H13.333V10H15V6.667ZM5,9.167H12.5V13.333H5V9.167Z"
android:fillColor="#1C1C14"
android:fillType="evenOdd"/>
</vector>

View File

@@ -15,16 +15,12 @@
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateY="4.0">
<path
android:fillColor="#FFFF0000"
android:pathData="M12.45,38.35 L9.65,35.55 21.2,24 9.65,12.45 12.45,9.65 24,21.2 35.55,9.65 38.35,12.45 26.8,24 38.35,35.55 35.55,38.35 24,26.8Z"/>
</group>
android:width="21dp"
android:height="20dp"
android:viewportWidth="21"
android:viewportHeight="20">
<path
android:pathData="M3.667,15H17V5H3.667V15ZM18.667,15C18.667,15.917 17.917,16.667 17,16.667H3.667C2.75,16.667 2,15.917 2,15V5C2,4.083 2.75,3.333 3.667,3.333H17C17.917,3.333 18.667,4.083 18.667,5V15ZM11.167,6.667H15.333V11.667H11.167V6.667Z"
android:fillColor="#1C1C14"
android:fillType="evenOdd"/>
</vector>

View File

@@ -15,16 +15,12 @@
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32.0dp"
android:height="32.0dp"
android:viewportWidth="32.0"
android:viewportHeight="32.0"
>
<group android:scaleX="0.5"
android:scaleY="0.5"
android:translateY="4.0">
<path
android:fillColor="@android:color/black"
android:pathData="M10,38V28.35H13V35H19.65V38ZM10,19.65V10H19.65V13H13V19.65ZM28.35,38V35H35V28.35H38V38ZM35,19.65V13H28.35V10H38V19.65Z"/>
</group>
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M3.333,15H16.667V5H3.333V15ZM18.333,15C18.333,15.917 17.583,16.667 16.667,16.667H3.333C2.417,16.667 1.667,15.917 1.667,15V5C1.667,4.083 2.417,3.333 3.333,3.333H16.667C17.583,3.333 18.333,4.083 18.333,5V15ZM5,6.667H15V13.333H5V6.667Z"
android:fillColor="#1C1C14"
android:fillType="evenOdd"/>
</vector>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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="20"
android:viewportHeight="20">
<path
android:pathData="M18.333,5.833L18.333,8.333L16.667,8.333L16.667,5.833L13.333,5.833L13.333,4.167L16.667,4.167C17.587,4.167 18.333,4.913 18.333,5.833Z"
android:fillColor="#1C1C14"/>
<path
android:pathData="M6.667,4.167L3.333,4.167C2.413,4.167 1.667,4.913 1.667,5.833L1.667,8.333L3.333,8.333L3.333,5.833L6.667,5.833L6.667,4.167Z"
android:fillColor="#1C1C14"/>
<path
android:pathData="M6.667,14.167L3.333,14.167L3.333,11.667L1.667,11.667L1.667,14.167C1.667,15.087 2.413,15.833 3.333,15.833L6.667,15.833L6.667,14.167Z"
android:fillColor="#1C1C14"/>
<path
android:pathData="M13.333,15.833L16.667,15.833C17.587,15.833 18.333,15.087 18.333,14.167L18.333,11.667L16.667,11.667L16.667,14.167L13.333,14.167L13.333,15.833Z"
android:fillColor="#1C1C14"/>
</vector>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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="20"
android:viewportHeight="20">
<path
android:pathData="M15.701,14.583L18.567,17.5L17.425,18.733L14.525,15.833L12.442,17.917V12.5H17.917L15.701,14.583ZM15.833,5.833H17.5V7.5H15.833V5.833ZM17.5,4.167H15.833V2.567C16.75,2.567 17.5,3.333 17.5,4.167ZM12.5,2.5H14.167V4.167H12.5V2.5ZM15.833,9.167H17.5V10.833H15.833V9.167ZM7.5,17.5H5.833V15.833H7.5V17.5ZM4.167,7.5H2.5V5.833H4.167V7.5ZM4.167,2.567V4.167H2.5C2.5,3.333 3.333,2.567 4.167,2.567ZM4.167,14.167H2.5V12.5H4.167V14.167ZM7.5,4.167H5.833V2.5H7.5V4.167ZM10.833,4.167H9.167V2.5H10.833V4.167ZM10.833,17.5H9.167V15.833H10.833V17.5ZM4.167,10.833H2.5V9.167H4.167V10.833ZM4.167,17.567C3.25,17.567 2.5,16.667 2.5,15.833H4.167V17.567Z"
android:fillColor="#1C1C14"/>
</vector>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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="21dp"
android:height="20dp"
android:viewportWidth="21"
android:viewportHeight="20">
<path
android:pathData="M17.333,15H4V5H17.333V15ZM17.333,16.667C18.25,16.667 19,15.917 19,15V5C19,4.083 18.25,3.333 17.333,3.333H4C3.083,3.333 2.333,4.083 2.333,5V15C2.333,15.917 3.083,16.667 4,16.667H17.333ZM9.833,6.667H5.667V13.333H9.833V6.667ZM11.5,6.667H15.667V13.333H11.5V6.667Z"
android:fillColor="#1C1C14"
android:fillType="evenOdd"/>
</vector>

View File

@@ -61,7 +61,7 @@
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="4dp"
android:contentDescription="@string/collapse_menu_text"
android:contentDescription="@string/expand_menu_text"
android:src="@drawable/ic_baseline_expand_more_24"
android:tint="@color/desktop_mode_caption_expand_button_dark"
android:background="@null"

View File

@@ -1,136 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<com.android.wm.shell.windowdecor.WindowDecorLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/handle_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/desktop_mode_decor_menu_background"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="middle"
android:dividerPadding="18dip">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/application_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_margin="12dp"
android:contentDescription="@string/app_icon_text"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/application_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/application_icon"
android:layout_toStartOf="@+id/collapse_menu_button"
android:textColor="#FF000000"
android:layout_centerVertical="true"/>
<Button
android:id="@+id/collapse_menu_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="10dp"
android:contentDescription="@string/collapse_menu_text"
android:layout_alignParentEnd="true"
android:background="@drawable/ic_baseline_expand_more_24"
android:layout_centerVertical="true"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/windowing_mode_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="0.5" />
<ImageButton
style="@style/CaptionWindowingButtonStyle"
android:id="@+id/fullscreen_button"
android:contentDescription="@string/fullscreen_text"
android:src="@drawable/caption_fullscreen_button"
android:scaleType="fitCenter"
android:background="?android:selectableItemBackgroundBorderless"/>
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageButton
style="@style/CaptionWindowingButtonStyle"
android:id="@+id/split_screen_button"
android:contentDescription="@string/split_screen_text"
android:src="@drawable/caption_split_screen_button"
android:scaleType="fitCenter"
android:background="?android:selectableItemBackgroundBorderless"/>
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageButton
style="@style/CaptionWindowingButtonStyle"
android:id="@+id/floating_button"
android:contentDescription="@string/float_button_text"
android:src="@drawable/caption_floating_button"
android:scaleType="fitCenter"
android:background="?android:selectableItemBackgroundBorderless"/>
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageButton
style="@style/CaptionWindowingButtonStyle"
android:id="@+id/desktop_button"
android:contentDescription="@string/desktop_text"
android:src="@drawable/caption_desktop_button"
android:scaleType="fitCenter"
android:background="?android:selectableItemBackgroundBorderless"/>
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:id="@+id/menu_buttons_misc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
style="@style/CaptionMenuButtonStyle"
android:id="@+id/screenshot_button"
android:contentDescription="@string/screenshot_text"
android:text="@string/screenshot_text"
android:drawableStart="@drawable/caption_screenshot_button"/>
<Button
style="@style/CaptionMenuButtonStyle"
android:id="@+id/select_button"
android:contentDescription="@string/select_text"
android:text="@string/select_text"
android:drawableStart="@drawable/caption_select_button"/>
<Button
style="@style/CaptionMenuButtonStyle"
android:id="@+id/close_button"
android:contentDescription="@string/close_text"
android:text="@string/close_text"
android:drawableStart="@drawable/caption_close_button"
android:textColor="#FFFF0000"/>
</LinearLayout>
</com.android.wm.shell.windowdecor.WindowDecorLinearLayout>

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/desktop_mode_handle_menu_width"
android:layout_height="@dimen/desktop_mode_handle_menu_app_info_pill_height"
android:orientation="horizontal"
android:background="@drawable/desktop_mode_decor_menu_background"
android:gravity="center_vertical">
<ImageView
android:id="@+id/application_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="14dp"
android:layout_marginEnd="14dp"
android:contentDescription="@string/app_icon_text"/>
<TextView
android:id="@+id/application_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="Gmail"
android:textColor="@color/desktop_mode_caption_menu_text_color"
android:textSize="14sp"
android:textFontWeight="500"
android:lineHeight="20dp"
android:textStyle="normal"
android:layout_weight="1"/>
<ImageButton
android:id="@+id/collapse_menu_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="4dp"
android:layout_marginEnd="14dp"
android:layout_marginStart="14dp"
android:contentDescription="@string/collapse_menu_text"
android:src="@drawable/ic_baseline_expand_more_24"
android:rotation="180"
android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive"
android:background="?android:selectableItemBackgroundBorderless"/>
</LinearLayout>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/desktop_mode_handle_menu_width"
android:layout_height="@dimen/desktop_mode_handle_menu_more_actions_pill_height"
android:orientation="vertical"
android:background="@drawable/desktop_mode_decor_menu_background">
<Button
android:id="@+id/screenshot_button"
android:contentDescription="@string/screenshot_text"
android:text="@string/screenshot_text"
android:drawableStart="@drawable/desktop_mode_ic_handle_menu_screenshot"
android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive"
style="@style/DesktopModeHandleMenuActionButton"/>
<Button
android:id="@+id/select_button"
android:contentDescription="@string/select_text"
android:text="@string/select_text"
android:drawableStart="@drawable/desktop_mode_ic_handle_menu_select"
android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive"
style="@style/DesktopModeHandleMenuActionButton"/>
<Button
android:id="@+id/close_button"
android:contentDescription="@string/close_text"
android:text="@string/close_text"
android:drawableStart="@drawable/desktop_mode_ic_handle_menu_close"
android:drawableTint="@color/desktop_mode_caption_menu_buttons_color_inactive"
style="@style/DesktopModeHandleMenuActionButton"/>
</LinearLayout>

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/desktop_mode_handle_menu_width"
android:layout_height="@dimen/desktop_mode_handle_menu_windowing_pill_height"
android:orientation="horizontal"
android:background="@drawable/desktop_mode_decor_menu_background"
android:gravity="center_vertical">
<ImageButton
android:id="@+id/fullscreen_button"
android:layout_marginEnd="4dp"
android:contentDescription="@string/fullscreen_text"
android:src="@drawable/desktop_mode_ic_handle_menu_fullscreen"
android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive"
android:layout_weight="1"
style="@style/DesktopModeHandleMenuWindowingButton"/>
<ImageButton
android:id="@+id/split_screen_button"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/split_screen_text"
android:src="@drawable/desktop_mode_ic_handle_menu_splitscreen"
android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive"
android:layout_weight="1"
style="@style/DesktopModeHandleMenuWindowingButton"/>
<ImageButton
android:id="@+id/floating_button"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:contentDescription="@string/float_button_text"
android:src="@drawable/desktop_mode_ic_handle_menu_floating"
android:tint="@color/desktop_mode_caption_menu_buttons_color_inactive"
android:layout_weight="1"
style="@style/DesktopModeHandleMenuWindowingButton"/>
<ImageButton
android:id="@+id/desktop_button"
android:layout_marginStart="4dp"
android:contentDescription="@string/desktop_text"
android:src="@drawable/desktop_mode_ic_handle_menu_desktop"
android:tint="@color/desktop_mode_caption_menu_buttons_color_active"
android:layout_weight="1"
style="@style/DesktopModeHandleMenuWindowingButton"/>
</LinearLayout>

View File

@@ -67,4 +67,7 @@
<color name="desktop_mode_caption_close_button_dark">#1C1C17</color>
<color name="desktop_mode_caption_app_name_light">#EFF1F2</color>
<color name="desktop_mode_caption_app_name_dark">#1C1C17</color>
<color name="desktop_mode_caption_menu_text_color">#191C1D</color>
<color name="desktop_mode_caption_menu_buttons_color_inactive">#191C1D</color>
<color name="desktop_mode_caption_menu_buttons_color_active">#00677E</color>
</resources>

View File

@@ -372,20 +372,34 @@
<!-- Height of button (32dp) + 2 * margin (5dp each). -->
<dimen name="freeform_decor_caption_height">42dp</dimen>
<!-- Width of buttons (32dp each) + padding (128dp total). -->
<dimen name="freeform_decor_caption_menu_width">256dp</dimen>
<!-- The width of the handle menu in desktop mode. -->
<dimen name="desktop_mode_handle_menu_width">216dp</dimen>
<dimen name="freeform_decor_caption_menu_height">250dp</dimen>
<dimen name="freeform_decor_caption_menu_height_no_windowing_controls">210dp</dimen>
<!-- The height of the handle menu's "App Info" pill in desktop mode. -->
<dimen name="desktop_mode_handle_menu_app_info_pill_height">52dp</dimen>
<!-- The height of the handle menu's "Windowing" pill in desktop mode. -->
<dimen name="desktop_mode_handle_menu_windowing_pill_height">52dp</dimen>
<!-- The height of the handle menu's "More Actions" pill in desktop mode. -->
<dimen name="desktop_mode_handle_menu_more_actions_pill_height">156dp</dimen>
<!-- The top margin of the handle menu in desktop mode. -->
<dimen name="desktop_mode_handle_menu_margin_top">4dp</dimen>
<!-- The start margin of the handle menu in desktop mode. -->
<dimen name="desktop_mode_handle_menu_margin_start">6dp</dimen>
<!-- The margin between pills of the handle menu in desktop mode. -->
<dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen>
<!-- The radius of the caption menu corners. -->
<dimen name="desktop_mode_handle_menu_corner_radius">26dp</dimen>
<!-- The radius of the caption menu shadow. -->
<dimen name="desktop_mode_handle_menu_shadow_radius">2dp</dimen>
<dimen name="freeform_resize_handle">30dp</dimen>
<dimen name="freeform_resize_corner">44dp</dimen>
<!-- The radius of the caption menu shadow. -->
<dimen name="caption_menu_shadow_radius">4dp</dimen>
<!-- The radius of the caption menu corners. -->
<dimen name="caption_menu_corner_radius">20dp</dimen>
</resources>

View File

@@ -263,4 +263,6 @@
<string name="close_text">Close</string>
<!-- Accessibility text for the handle menu close menu button [CHAR LIMIT=NONE] -->
<string name="collapse_menu_text">Close Menu</string>
<!-- Accessibility text for the handle menu open menu button [CHAR LIMIT=NONE] -->
<string name="expand_menu_text">Open Menu</string>
</resources>

View File

@@ -30,6 +30,26 @@
<item name="android:activityCloseExitAnimation">@anim/forced_resizable_exit</item>
</style>
<style name="DesktopModeHandleMenuActionButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">52dp</item>
<item name="android:gravity">start|center_vertical</item>
<item name="android:padding">16dp</item>
<item name="android:textSize">14sp</item>
<item name="android:textFontWeight">500</item>
<item name="android:textColor">@color/desktop_mode_caption_menu_text_color</item>
<item name="android:drawablePadding">16dp</item>
<item name="android:background">?android:selectableItemBackground</item>
</style>
<style name="DesktopModeHandleMenuWindowingButton">
<item name="android:layout_width">48dp</item>
<item name="android:layout_height">48dp</item>
<item name="android:padding">14dp</item>
<item name="android:scaleType">fitCenter</item>
<item name="android:background">?android:selectableItemBackgroundBorderless</item>
</style>
<style name="CaptionButtonStyle">
<item name="android:layout_width">32dp</item>
<item name="android:layout_height">32dp</item>
@@ -37,20 +57,6 @@
<item name="android:padding">4dp</item>
</style>
<style name="CaptionWindowingButtonStyle">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:padding">4dp</item>
</style>
<style name="CaptionMenuButtonStyle" parent="@style/Widget.AppCompat.Button.Borderless">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">52dp</item>
<item name="android:layout_marginStart">10dp</item>
<item name="android:padding">4dp</item>
<item name="android:gravity">start|center_vertical</item>
</style>
<style name="DockedDividerBackground">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/split_divider_bar_width</item>

View File

@@ -17,11 +17,15 @@
package com.android.wm.shell.windowdecor;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
@@ -34,7 +38,8 @@ import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.window.WindowContainerTransaction;
@@ -71,17 +76,17 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
private DragDetector mDragDetector;
private RelayoutParams mRelayoutParams = new RelayoutParams();
private final int mCaptionMenuHeightId = R.dimen.freeform_decor_caption_menu_height;
private final int mCaptionMenuHeightWithoutWindowingControlsId =
R.dimen.freeform_decor_caption_menu_height_no_windowing_controls;
private final WindowDecoration.RelayoutResult<WindowDecorLinearLayout> mResult =
new WindowDecoration.RelayoutResult<>();
private AdditionalWindow mHandleMenu;
private final int mHandleMenuWidthId = R.dimen.freeform_decor_caption_menu_width;
private final int mHandleMenuShadowRadiusId = R.dimen.caption_menu_shadow_radius;
private final int mHandleMenuCornerRadiusId = R.dimen.caption_menu_corner_radius;
private PointF mHandleMenuPosition = new PointF();
private final PointF mHandleMenuAppInfoPillPosition = new PointF();
private final PointF mHandleMenuWindowingPillPosition = new PointF();
private final PointF mHandleMenuMoreActionsPillPosition = new PointF();
// Collection of additional windows that comprise the handle menu.
private AdditionalWindow mHandleMenuAppInfoPill;
private AdditionalWindow mHandleMenuWindowingPill;
private AdditionalWindow mHandleMenuMoreActionsPill;
private Drawable mAppIcon;
private CharSequence mAppName;
@@ -234,30 +239,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
mResult.mWidth, mResult.mHeight, resize_handle, resize_corner, touchSlop);
}
private void setupHandleMenu() {
final View menu = mHandleMenu.mWindowViewHost.getView();
final View fullscreen = menu.findViewById(R.id.fullscreen_button);
fullscreen.setOnClickListener(mOnCaptionButtonClickListener);
final View desktop = menu.findViewById(R.id.desktop_button);
desktop.setOnClickListener(mOnCaptionButtonClickListener);
final ViewGroup windowingBtns = menu.findViewById(R.id.windowing_mode_buttons);
windowingBtns.setVisibility(DesktopModeStatus.isProto1Enabled() ? View.GONE : View.VISIBLE);
final View split = menu.findViewById(R.id.split_screen_button);
split.setOnClickListener(mOnCaptionButtonClickListener);
final View close = menu.findViewById(R.id.close_button);
close.setOnClickListener(mOnCaptionButtonClickListener);
final View collapse = menu.findViewById(R.id.collapse_menu_button);
collapse.setOnClickListener(mOnCaptionButtonClickListener);
menu.setOnTouchListener(mOnCaptionTouchListener);
final ImageView appIcon = menu.findViewById(R.id.application_icon);
final TextView appName = menu.findViewById(R.id.application_name);
appIcon.setImageDrawable(mAppIcon);
appName.setText(mAppName);
}
boolean isHandleMenuActive() {
return mHandleMenu != null;
return mHandleMenuAppInfoPill != null;
}
private void loadAppInfo() {
@@ -291,34 +274,142 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
final Resources resources = mDecorWindowContext.getResources();
final int captionWidth = mTaskInfo.getConfiguration()
.windowConfiguration.getBounds().width();
final int menuWidth = loadDimensionPixelSize(resources, mHandleMenuWidthId);
// The windowing controls are disabled in proto1.
final int menuHeight = loadDimensionPixelSize(resources, DesktopModeStatus.isProto1Enabled()
? mCaptionMenuHeightWithoutWindowingControlsId : mCaptionMenuHeightId);
final int shadowRadius = loadDimensionPixelSize(resources, mHandleMenuShadowRadiusId);
final int cornerRadius = loadDimensionPixelSize(resources, mHandleMenuCornerRadiusId);
final int menuWidth = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_width);
final int shadowRadius = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_shadow_radius);
final int cornerRadius = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_corner_radius);
final int marginMenuTop = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_margin_top);
final int marginMenuStart = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_margin_start);
final int marginMenuSpacing = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_pill_spacing_margin);
final int appInfoPillHeight = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_app_info_pill_height);
final int windowingPillHeight = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_windowing_pill_height);
final int moreActionsPillHeight = loadDimensionPixelSize(resources,
R.dimen.desktop_mode_handle_menu_more_actions_pill_height);
final int x, y;
final int menuX, menuY;
if (mRelayoutParams.mLayoutResId
== R.layout.desktop_mode_app_controls_window_decor) {
// Align the handle menu to the left of the caption.
x = mRelayoutParams.mCaptionX - mResult.mDecorContainerOffsetX;
y = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY;
menuX = mRelayoutParams.mCaptionX - mResult.mDecorContainerOffsetX + marginMenuStart;
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + marginMenuTop;
} else {
// Position the handle menu at the center of the caption.
x = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
menuX = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
- mResult.mDecorContainerOffsetX;
y = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY;
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + marginMenuStart;
}
mHandleMenuPosition.set(x, y);
final String namePrefix = "Caption Menu";
mHandleMenu = addWindow(R.layout.desktop_mode_decor_handle_menu, namePrefix, t, x, y,
menuWidth, menuHeight, shadowRadius, cornerRadius);
final int appInfoPillY = menuY;
createAppInfoPill(t, menuX, appInfoPillY, menuWidth, appInfoPillHeight, shadowRadius,
cornerRadius);
// Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
final int windowingPillY = appInfoPillY + appInfoPillHeight + marginMenuSpacing;
if (shouldShowWindowingPill) {
createWindowingPill(t, menuX, windowingPillY, menuWidth, windowingPillHeight,
shadowRadius,
cornerRadius);
}
final int moreActionsPillY;
if (shouldShowWindowingPill) {
// Take into account the windowing pill height and margins.
moreActionsPillY = windowingPillY + windowingPillHeight + marginMenuSpacing;
} else {
// Just start after the end of the app info pill + margins.
moreActionsPillY = appInfoPillY + appInfoPillHeight + marginMenuSpacing;
}
createMoreActionsPill(t, menuX, moreActionsPillY, menuWidth, moreActionsPillHeight,
shadowRadius, cornerRadius);
mSyncQueue.runInSync(transaction -> {
transaction.merge(t);
t.close();
});
setupHandleMenu();
setupHandleMenu(shouldShowWindowingPill);
}
private void createAppInfoPill(SurfaceControl.Transaction t, int x, int y, int width,
int height, int shadowRadius, int cornerRadius) {
mHandleMenuAppInfoPillPosition.set(x, y);
mHandleMenuAppInfoPill = addWindow(
R.layout.desktop_mode_window_decor_handle_menu_app_info_pill,
"Menu's app info pill",
t, x, y, width, height, shadowRadius, cornerRadius);
}
private void createWindowingPill(SurfaceControl.Transaction t, int x, int y, int width,
int height, int shadowRadius, int cornerRadius) {
mHandleMenuWindowingPillPosition.set(x, y);
mHandleMenuWindowingPill = addWindow(
R.layout.desktop_mode_window_decor_handle_menu_windowing_pill,
"Menu's windowing pill",
t, x, y, width, height, shadowRadius, cornerRadius);
}
private void createMoreActionsPill(SurfaceControl.Transaction t, int x, int y, int width,
int height, int shadowRadius, int cornerRadius) {
mHandleMenuMoreActionsPillPosition.set(x, y);
mHandleMenuMoreActionsPill = addWindow(
R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill,
"Menu's more actions pill",
t, x, y, width, height, shadowRadius, cornerRadius);
}
private void setupHandleMenu(boolean windowingPillShown) {
// App Info pill setup.
final View appInfoPillView = mHandleMenuAppInfoPill.mWindowViewHost.getView();
final ImageButton collapseBtn = appInfoPillView.findViewById(R.id.collapse_menu_button);
final ImageView appIcon = appInfoPillView.findViewById(R.id.application_icon);
final TextView appName = appInfoPillView.findViewById(R.id.application_name);
collapseBtn.setOnClickListener(mOnCaptionButtonClickListener);
appInfoPillView.setOnTouchListener(mOnCaptionTouchListener);
appIcon.setImageDrawable(mAppIcon);
appName.setText(mAppName);
// Windowing pill setup.
if (windowingPillShown) {
final View windowingPillView = mHandleMenuWindowingPill.mWindowViewHost.getView();
final ImageButton fullscreenBtn = windowingPillView.findViewById(
R.id.fullscreen_button);
final ImageButton splitscreenBtn = windowingPillView.findViewById(
R.id.split_screen_button);
final ImageButton floatingBtn = windowingPillView.findViewById(R.id.floating_button);
final ImageButton desktopBtn = windowingPillView.findViewById(R.id.desktop_button);
fullscreenBtn.setOnClickListener(mOnCaptionButtonClickListener);
splitscreenBtn.setOnClickListener(mOnCaptionButtonClickListener);
floatingBtn.setOnClickListener(mOnCaptionButtonClickListener);
desktopBtn.setOnClickListener(mOnCaptionButtonClickListener);
// The button corresponding to the windowing mode that the task is currently in uses a
// different color than the others.
final ColorStateList activeColorStateList = ColorStateList.valueOf(
mContext.getColor(R.color.desktop_mode_caption_menu_buttons_color_active));
final ColorStateList inActiveColorStateList = ColorStateList.valueOf(
mContext.getColor(R.color.desktop_mode_caption_menu_buttons_color_inactive));
fullscreenBtn.setImageTintList(
mTaskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
? activeColorStateList : inActiveColorStateList);
splitscreenBtn.setImageTintList(
mTaskInfo.getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW
? activeColorStateList : inActiveColorStateList);
floatingBtn.setImageTintList(mTaskInfo.getWindowingMode() == WINDOWING_MODE_PINNED
? activeColorStateList : inActiveColorStateList);
desktopBtn.setImageTintList(mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM
? activeColorStateList : inActiveColorStateList);
}
// More Actions pill setup.
final View moreActionsPillView = mHandleMenuMoreActionsPill.mWindowViewHost.getView();
final Button closeBtn = moreActionsPillView.findViewById(R.id.close_button);
closeBtn.setOnClickListener(mOnCaptionButtonClickListener);
}
/**
@@ -326,8 +417,14 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
*/
void closeHandleMenu() {
if (!isHandleMenuActive()) return;
mHandleMenu.releaseView();
mHandleMenu = null;
mHandleMenuAppInfoPill.releaseView();
mHandleMenuAppInfoPill = null;
if (mHandleMenuWindowingPill != null) {
mHandleMenuWindowingPill.releaseView();
mHandleMenuWindowingPill = null;
}
mHandleMenuMoreActionsPill.releaseView();
mHandleMenuMoreActionsPill = null;
}
@Override
@@ -346,12 +443,29 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
// When this is called before the layout is fully inflated, width will be 0.
// Menu is not visible in this scenario, so skip the check if that is the case.
if (mHandleMenu.mWindowViewHost.getView().getWidth() == 0) return;
if (mHandleMenuAppInfoPill.mWindowViewHost.getView().getWidth() == 0) return;
PointF inputPoint = offsetCaptionLocation(ev);
if (!pointInView(mHandleMenu.mWindowViewHost.getView(),
inputPoint.x - mHandleMenuPosition.x - mResult.mDecorContainerOffsetX,
inputPoint.y - mHandleMenuPosition.y - mResult.mDecorContainerOffsetY)) {
final boolean pointInAppInfoPill = pointInView(
mHandleMenuAppInfoPill.mWindowViewHost.getView(),
inputPoint.x - mHandleMenuAppInfoPillPosition.x - mResult.mDecorContainerOffsetX,
inputPoint.y - mHandleMenuAppInfoPillPosition.y
- mResult.mDecorContainerOffsetY);
boolean pointInWindowingPill = false;
if (mHandleMenuWindowingPill != null) {
pointInWindowingPill = pointInView(mHandleMenuWindowingPill.mWindowViewHost.getView(),
inputPoint.x - mHandleMenuWindowingPillPosition.x
- mResult.mDecorContainerOffsetX,
inputPoint.y - mHandleMenuWindowingPillPosition.y
- mResult.mDecorContainerOffsetY);
}
final boolean pointInMoreActionsPill = pointInView(
mHandleMenuMoreActionsPill.mWindowViewHost.getView(),
inputPoint.x - mHandleMenuMoreActionsPillPosition.x
- mResult.mDecorContainerOffsetX,
inputPoint.y - mHandleMenuMoreActionsPillPosition.y
- mResult.mDecorContainerOffsetY);
if (!pointInAppInfoPill && !pointInWindowingPill && !pointInMoreActionsPill) {
closeHandleMenu();
}
}
@@ -408,14 +522,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
final View handle = caption.findViewById(R.id.caption_handle);
clickIfPointInView(new PointF(ev.getX(), ev.getY()), handle);
} else {
final View menu = mHandleMenu.mWindowViewHost.getView();
final int captionWidth = mTaskInfo.getConfiguration().windowConfiguration
.getBounds().width();
final int menuX = mRelayoutParams.mCaptionX + (captionWidth / 2)
- (menu.getWidth() / 2);
final PointF inputPoint = new PointF(ev.getX() - menuX, ev.getY());
final View collapse = menu.findViewById(R.id.collapse_menu_button);
if (clickIfPointInView(inputPoint, collapse)) return;
final View appInfoPill = mHandleMenuAppInfoPill.mWindowViewHost.getView();
final ImageButton collapse = appInfoPill.findViewById(R.id.collapse_menu_button);
// Translate the input point from display coordinates to the same space as the collapse
// button, meaning its parent (app info pill view).
final PointF inputPoint = new PointF(ev.getX() - mHandleMenuAppInfoPillPosition.x,
ev.getY() - mHandleMenuAppInfoPillPosition.y);
clickIfPointInView(inputPoint, collapse);
}
}

View File

@@ -583,7 +583,7 @@ public class WindowDecorationTests extends ShellTestCase {
int cornerRadius = loadDimensionPixelSize(resources, mCaptionMenuCornerRadiusId);
String name = "Test Window";
WindowDecoration.AdditionalWindow additionalWindow =
addWindow(R.layout.desktop_mode_decor_handle_menu, name,
addWindow(R.layout.desktop_mode_window_decor_handle_menu_app_info_pill, name,
mMockSurfaceControlAddWindowT,
x - mRelayoutResult.mDecorContainerOffsetX,
y - mRelayoutResult.mDecorContainerOffsetY,