Update Device Controls API layout

- choose items spacing depending on the screen size
 - add panel-like background for Device Controls
 - fix margins and paddings

I've attached the screenshots to the bug

Fixes: 273388668
Test: manual on foldable and tablet.
Change-Id: I9c6ea44722d306a0f8c37ab4008617dd0b4f8ffc
This commit is contained in:
Anton Potapov
2023-07-27 16:52:33 +01:00
parent 7bcdf0c096
commit 6fc67f22d0
16 changed files with 70 additions and 22 deletions

View File

@@ -0,0 +1,22 @@
<?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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/transparent" />
<size
android:width="@dimen/control_list_horizontal_spacing"
android:height="@dimen/control_list_vertical_spacing" />
</shape>

View File

@@ -15,6 +15,6 @@
-->
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/controls_list_divider"
android:drawable="@drawable/global_actions_list_divider"
android:insetRight="@dimen/control_spinner_padding_horizontal"
android:insetLeft="@dimen/control_spinner_padding_horizontal" />

View File

@@ -25,7 +25,6 @@
android:focusable="true"
android:screenReaderFocusable="true"
android:stateListAnimator="@anim/control_state_list_animator"
android:layout_marginStart="@dimen/control_spacing"
android:background="@drawable/control_background">
<ImageView

View File

@@ -0,0 +1,23 @@
<?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:id="@+id/controls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/controls_list_divider"
android:orientation="vertical"
android:showDividers="middle" />

View File

@@ -14,9 +14,9 @@
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:orientation="horizontal"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/control_spacing" />
android:divider="@drawable/controls_list_divider"
android:orientation="horizontal"
android:showDividers="middle" />

View File

@@ -20,7 +20,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/controls_header_menu_size"
android:paddingHorizontal="@dimen/controls_header_horizontal_padding"
android:layout_marginBottom="@dimen/controls_header_bottom_margin"
android:orientation="horizontal">
@@ -85,10 +85,11 @@
android:layout_weight="1"
android:clipChildren="true"
android:orientation="vertical"
android:paddingHorizontal="16dp"
android:padding="@dimen/controls_content_padding"
android:background="@drawable/controls_panel_background"
android:scrollbars="none">
<include layout="@layout/global_actions_controls_list_view" />
<include layout="@layout/controls_list_view" />
</ScrollView>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_actions_controls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/global_actions_side_margin"
android:layout_marginRight="@dimen/global_actions_side_margin" />

View File

@@ -18,7 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:divider="@drawable/controls_list_divider"
android:divider="@drawable/global_actions_list_divider"
android:showDividers="middle"
/>

View File

@@ -69,6 +69,9 @@
<dimen name="controls_header_horizontal_padding">12dp</dimen>
<dimen name="controls_content_margin_horizontal">16dp</dimen>
<dimen name="controls_content_padding">16dp</dimen>
<dimen name="control_list_vertical_spacing">8dp</dimen>
<dimen name="control_list_horizontal_spacing">16dp</dimen>
<!-- Rear Display Education dimens -->
<dimen name="rear_display_animation_width">246dp</dimen>

View File

@@ -103,4 +103,7 @@
<dimen name="controls_header_horizontal_padding">12dp</dimen>
<dimen name="controls_content_margin_horizontal">24dp</dimen>
<dimen name="controls_content_padding">24dp</dimen>
<dimen name="control_list_vertical_spacing">8dp</dimen>
<dimen name="control_list_horizontal_spacing">16dp</dimen>
</resources>

View File

@@ -24,6 +24,9 @@
<dimen name="controls_header_horizontal_padding">28dp</dimen>
<dimen name="controls_content_margin_horizontal">40dp</dimen>
<dimen name="controls_content_padding">32dp</dimen>
<dimen name="control_list_vertical_spacing">16dp</dimen>
<dimen name="control_list_horizontal_spacing">16dp</dimen>
<dimen name="large_screen_shade_header_height">56dp</dimen>

View File

@@ -195,7 +195,7 @@
<color name="control_primary_text">#E6FFFFFF</color>
<color name="control_secondary_text">#99FFFFFF</color>
<color name="control_default_foreground">@color/GM2_grey_500</color>
<color name="control_default_background">@color/GM2_grey_900</color>
<color name="control_default_background">#303134</color>
<color name="control_spinner_dropdown">@*android:color/foreground_material_dark</color>
<color name="control_more_vert">@*android:color/foreground_material_dark</color>
<color name="control_enabled_light_background">#413C2D</color>

View File

@@ -1238,6 +1238,7 @@
<dimen name="controls_header_app_icon_size">24dp</dimen>
<dimen name="controls_top_margin">48dp</dimen>
<dimen name="controls_content_margin_horizontal">0dp</dimen>
<dimen name="controls_content_padding">16dp</dimen>
<dimen name="control_header_text_size">24sp</dimen>
<dimen name="control_item_text_size">14sp</dimen>
<dimen name="control_menu_item_text_size">16sp</dimen>
@@ -1256,6 +1257,8 @@
<dimen name="control_chevron_icon_size">20dp</dimen>
<dimen name="control_spacing">8dp</dimen>
<dimen name="control_list_divider">1dp</dimen>
<dimen name="control_list_vertical_spacing">8dp</dimen>
<dimen name="control_list_horizontal_spacing">12dp</dimen>
<dimen name="control_corner_radius">14dp</dimen>
<dimen name="control_height">104dp</dimen>
<dimen name="control_padding">12dp</dimen>

View File

@@ -665,7 +665,7 @@ class ControlsUiControllerImpl @Inject constructor (
val maxColumns = ControlAdapter.findMaxColumns(activityContext.resources)
val listView = parent.requireViewById(R.id.global_actions_controls_list) as ViewGroup
val listView = parent.requireViewById(R.id.controls_list) as ViewGroup
listView.removeAllViews()
var lastRow: ViewGroup = createRow(inflater, listView)
selectedStructure.controls.forEach {

View File

@@ -87,7 +87,7 @@ public class GlobalActionsPopupMenu extends ListPopupWindow {
if (mIsDropDownMode) {
// use a divider
listView.setDividerHeight(res.getDimensionPixelSize(R.dimen.control_list_divider));
listView.setDivider(res.getDrawable(R.drawable.controls_list_divider_inset));
listView.setDivider(res.getDrawable(R.drawable.global_actions_list_divider_inset));
} else {
if (mAdapter == null) return;