Controls UI - Spinner cleanup
Fix background colors. Fix '+' sign color. Limit the width. Override light theme when needed. Fix crash on structure switching Bug: 150758646 Test: manual Change-Id: I3b232bbeba5eaeef8ce68ec71914ea059f65b88f
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 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.
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:paddingMode="stack"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="40dp"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp">
|
||||
<item
|
||||
android:gravity="end|fill_vertical"
|
||||
android:width="40dp"
|
||||
android:drawable="@*android:drawable/control_background_40dp_material" />
|
||||
|
||||
<item
|
||||
android:drawable="@drawable/ic_ksh_key_down"
|
||||
android:gravity="end|bottom"
|
||||
android:paddingBottom="6dp"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:end="12dp" />
|
||||
</layer-list>
|
||||
@@ -29,22 +29,18 @@
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="10dp" />
|
||||
|
||||
<TextView
|
||||
style="@style/Control.Spinner.Item"
|
||||
android:id="@+id/controls_spinner_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="25sp"
|
||||
android:textColor="@color/control_secondary_text"
|
||||
android:fontFamily="@*android:string/config_headlineFontFamily" />
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<Space
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -14,47 +14,49 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/controls_header"
|
||||
android:orientation="horizontal"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="12dp">
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<Space
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="10dp" />
|
||||
|
||||
<TextView
|
||||
style="@style/Control.Spinner.Header"
|
||||
android:clickable="false"
|
||||
android:id="@+id/app_or_structure_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/controls_header"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end" />
|
||||
android:layout_marginStart="@dimen/controls_header_side_margin"
|
||||
android:layout_marginEnd="@dimen/controls_header_side_margin"
|
||||
android:gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" >
|
||||
|
||||
<Space
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="10dp" />
|
||||
|
||||
<TextView
|
||||
style="@style/Control.Spinner.Header"
|
||||
android:clickable="false"
|
||||
android:id="@+id/app_or_structure_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/global_actions_controls_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="20dp" />
|
||||
android:paddingTop="12dp" />
|
||||
</merge>
|
||||
|
||||
@@ -223,4 +223,6 @@
|
||||
<color name="control_secondary_text">@*android:color/dim_foreground_dark</color>
|
||||
<color name="control_default_foreground">@*android:color/foreground_material_dark</color>
|
||||
<color name="control_default_background">@*android:color/background_floating_material_dark</color>
|
||||
<color name="control_list_popup_background">@*android:color/background_floating_material_dark</color>
|
||||
<color name="control_spinner_dropdown">@*android:color/foreground_material_dark</color>
|
||||
</resources>
|
||||
|
||||
@@ -1216,6 +1216,8 @@
|
||||
<dimen name="magnifier_up_down_controls_height">40dp</dimen>
|
||||
|
||||
<!-- Home Controls -->
|
||||
<dimen name="controls_header_side_margin">32dp</dimen>
|
||||
<dimen name="control_header_text">24sp</dimen>
|
||||
<dimen name="control_spacing">4dp</dimen>
|
||||
<dimen name="control_list_divider">1dp</dimen>
|
||||
<dimen name="control_corner_radius">15dp</dimen>
|
||||
|
||||
@@ -656,10 +656,22 @@
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
</style>
|
||||
|
||||
<style name="Control.Spinner.Header" parent="@*android:style/Widget.DeviceDefault.Spinner.DropDown">
|
||||
<item name="android:textSize">25sp</item>
|
||||
<item name="android:textColor">@color/control_primary_text</item>
|
||||
<style name="Control" />
|
||||
|
||||
<style name="Control.Spinner">
|
||||
<item name="android:textSize">@dimen/control_header_text</item>
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
|
||||
<style name="Control.Spinner.Header">
|
||||
<item name="android:background">@drawable/control_spinner_background</item>
|
||||
<item name="android:textColor">@color/control_primary_text</item>
|
||||
</style>
|
||||
|
||||
<style name="Control.Spinner.Item">
|
||||
<item name="android:textColor">@color/control_secondary_text</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Control.Status">
|
||||
@@ -675,8 +687,11 @@
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:textColor">@color/control_secondary_text</item>
|
||||
</style>
|
||||
<style name="Control.ListPopupWindow" parent="@android:style/Widget.ListPopupWindow">
|
||||
<style name="Control.ListPopupWindow" parent="@*android:style/Widget.DeviceDefault.ListPopupWindow">
|
||||
<item name="android:overlapAnchor">true</item>
|
||||
|
||||
<!-- used to override dark/light theming -->
|
||||
<item name="*android:colorPopupBackground">@color/control_list_popup_background</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.IBinder
|
||||
import android.service.controls.Control
|
||||
import android.service.controls.TokenProvider
|
||||
@@ -152,12 +153,19 @@ class ControlsUiControllerImpl @Inject constructor (
|
||||
private lateinit var lastItems: List<SelectionItem>
|
||||
private var popup: ListPopupWindow? = null
|
||||
|
||||
private val addControlsItem = SelectionItem(
|
||||
context.resources.getString(R.string.controls_providers_title),
|
||||
"",
|
||||
context.getDrawable(R.drawable.ic_add),
|
||||
EMPTY_COMPONENT
|
||||
)
|
||||
private val addControlsItem: SelectionItem
|
||||
|
||||
init {
|
||||
val addDrawable = context.getDrawable(R.drawable.ic_add).apply {
|
||||
setTint(context.resources.getColor(R.color.control_secondary_text, null))
|
||||
}
|
||||
addControlsItem = SelectionItem(
|
||||
context.resources.getString(R.string.controls_providers_title),
|
||||
"",
|
||||
addDrawable,
|
||||
EMPTY_COMPONENT
|
||||
)
|
||||
}
|
||||
|
||||
override val available: Boolean
|
||||
get() = controlsController.get().available
|
||||
@@ -296,6 +304,9 @@ class ControlsUiControllerImpl @Inject constructor (
|
||||
val item = adapter.findSelectionItem(selectedStructure) ?: adapter.getItem(0)
|
||||
parent.requireViewById<TextView>(R.id.app_or_structure_spinner).apply {
|
||||
setText(item.getTitle())
|
||||
// override the default color on the dropdown drawable
|
||||
(getBackground() as LayerDrawable).getDrawable(1)
|
||||
.setTint(context.resources.getColor(R.color.control_spinner_dropdown, null))
|
||||
}
|
||||
parent.requireViewById<ImageView>(R.id.app_icon).apply {
|
||||
setContentDescription(item.getTitle())
|
||||
@@ -368,7 +379,8 @@ class ControlsUiControllerImpl @Inject constructor (
|
||||
if (newSelection != selectedStructure) {
|
||||
selectedStructure = newSelection
|
||||
updatePreferences(selectedStructure)
|
||||
showControlsView(lastItems)
|
||||
controlsListingController.get().removeCallback(listingCallback)
|
||||
show(parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user