Merge "Fine tune Spinner style" into tm-dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2018 The Android Open Source Project
|
Copyright (C) 2022 The Android Open Source Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -16,5 +16,6 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="spinner_height">36dp</dimen>
|
<dimen name="spinner_height">36dp</dimen>
|
||||||
|
<dimen name="spinner_dropdown_height">48dp</dimen>
|
||||||
<dimen name="spinner_padding_top_or_bottom">8dp</dimen>
|
<dimen name="spinner_padding_top_or_bottom">8dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
||||||
<item name="android:maxLines">1</item>
|
<item name="android:maxLines">1</item>
|
||||||
<item name="android:ellipsize">marquee</item>
|
<item name="android:ellipsize">marquee</item>
|
||||||
<item name="android:minHeight">@dimen/spinner_height</item>
|
<item name="android:minHeight">@dimen/spinner_dropdown_height</item>
|
||||||
<item name="android:paddingStart">16dp</item>
|
<item name="android:paddingStart">16dp</item>
|
||||||
<item name="android:paddingEnd">36dp</item>
|
<item name="android:paddingEnd">36dp</item>
|
||||||
<item name="android:paddingTop">@dimen/spinner_padding_top_or_bottom</item>
|
<item name="android:paddingTop">@dimen/spinner_padding_top_or_bottom</item>
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2018 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<resources>
|
|
||||||
<style name="SettingsSpinnerTitleBar">
|
|
||||||
<item name="android:textAppearance">?android:attr/textAppearanceButton</item>
|
|
||||||
<item name="android:maxLines">1</item>
|
|
||||||
<item name="android:ellipsize">marquee</item>
|
|
||||||
<item name="android:paddingStart">16dp</item>
|
|
||||||
<item name="android:paddingEnd">36dp</item>
|
|
||||||
<item name="android:paddingTop">@dimen/spinner_padding_top_or_bottom</item>
|
|
||||||
<item name="android:paddingBottom">@dimen/spinner_padding_top_or_bottom</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
|
||||||
@@ -41,7 +41,7 @@ public class SettingsSpinnerAdapter<T> extends ArrayAdapter<T> {
|
|||||||
* access the current theme, resources, etc.
|
* access the current theme, resources, etc.
|
||||||
*/
|
*/
|
||||||
public SettingsSpinnerAdapter(Context context) {
|
public SettingsSpinnerAdapter(Context context) {
|
||||||
super(context, DEFAULT_RESOURCE);
|
super(context, getDefaultResource());
|
||||||
|
|
||||||
setDropDownViewResource(getDropdownResource());
|
setDropDownViewResource(getDropdownResource());
|
||||||
mDefaultInflater = LayoutInflater.from(context);
|
mDefaultInflater = LayoutInflater.from(context);
|
||||||
@@ -51,7 +51,7 @@ public class SettingsSpinnerAdapter<T> extends ArrayAdapter<T> {
|
|||||||
* In overridded {@link #getView(int, View, ViewGroup)}, use this method to get default view.
|
* In overridded {@link #getView(int, View, ViewGroup)}, use this method to get default view.
|
||||||
*/
|
*/
|
||||||
public View getDefaultView(int position, View convertView, ViewGroup parent) {
|
public View getDefaultView(int position, View convertView, ViewGroup parent) {
|
||||||
return mDefaultInflater.inflate(DEFAULT_RESOURCE, parent, false /* attachToRoot */);
|
return mDefaultInflater.inflate(getDefaultResource(), parent, false /* attachToRoot */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,8 +62,12 @@ public class SettingsSpinnerAdapter<T> extends ArrayAdapter<T> {
|
|||||||
return mDefaultInflater.inflate(getDropdownResource(), parent, false /* attachToRoot */);
|
return mDefaultInflater.inflate(getDropdownResource(), parent, false /* attachToRoot */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDropdownResource() {
|
private static int getDefaultResource() {
|
||||||
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
|
||||||
|
? DEFAULT_RESOURCE : android.R.layout.simple_spinner_dropdown_item;
|
||||||
|
}
|
||||||
|
private static int getDropdownResource() {
|
||||||
|
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
|
||||||
? DFAULT_DROPDOWN_RESOURCE : android.R.layout.simple_spinner_dropdown_item;
|
? DFAULT_DROPDOWN_RESOURCE : android.R.layout.simple_spinner_dropdown_item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<ripple
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:color="@color/settingslib_ripple_color">
|
|
||||||
|
|
||||||
<item android:id="@android:id/background">
|
|
||||||
<layer-list android:paddingMode="stack">
|
|
||||||
<item
|
|
||||||
android:top="8dp"
|
|
||||||
android:bottom="8dp">
|
|
||||||
|
|
||||||
<shape>
|
|
||||||
<corners android:radius="28dp"/>
|
|
||||||
<solid android:color="@android:color/system_accent1_100"/>
|
|
||||||
<size android:height="@dimen/settingslib_spinner_height"/>
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:gravity="center|end"
|
|
||||||
android:width="18dp"
|
|
||||||
android:height="18dp"
|
|
||||||
android:end="12dp"
|
|
||||||
android:drawable="@drawable/settingslib_arrow_drop_down"/>
|
|
||||||
</layer-list>
|
|
||||||
</item>
|
|
||||||
</ripple>
|
|
||||||
@@ -20,29 +20,26 @@ xmlns:android="http://schemas.android.com/apk/res/android"
|
|||||||
android:color="@color/settingslib_ripple_color">
|
android:color="@color/settingslib_ripple_color">
|
||||||
|
|
||||||
<item android:id="@android:id/background">
|
<item android:id="@android:id/background">
|
||||||
<layer-list android:paddingMode="stack">
|
<layer-list
|
||||||
|
android:paddingMode="stack"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="24dp">
|
||||||
<item
|
<item
|
||||||
android:top="8dp"
|
android:top="8dp"
|
||||||
android:bottom="8dp">
|
android:bottom="8dp">
|
||||||
|
|
||||||
<shape>
|
<shape>
|
||||||
<corners
|
<corners android:radius="28dp"/>
|
||||||
android:radius="20dp"/>
|
<solid android:color="@android:color/system_accent1_100"/>
|
||||||
<solid
|
<size android:height="@dimen/settingslib_spinner_height"/>
|
||||||
android:color="?android:attr/colorPrimary"/>
|
|
||||||
<stroke
|
|
||||||
android:color="#1f000000"
|
|
||||||
android:width="1dp"/>
|
|
||||||
<size
|
|
||||||
android:height="32dp"/>
|
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:gravity="center|end"
|
android:gravity="center|end"
|
||||||
android:width="24dp"
|
android:width="18dp"
|
||||||
android:height="24dp"
|
android:height="18dp"
|
||||||
android:end="4dp"
|
android:end="12dp"
|
||||||
android:drawable="@drawable/settingslib_arrow_drop_down"/>
|
android:drawable="@drawable/settingslib_arrow_drop_down"/>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
</item>
|
</item>
|
||||||
@@ -20,9 +20,17 @@
|
|||||||
android:color="@color/settingslib_ripple_color">
|
android:color="@color/settingslib_ripple_color">
|
||||||
|
|
||||||
<item android:id="@android:id/background">
|
<item android:id="@android:id/background">
|
||||||
|
<layer-list
|
||||||
|
android:paddingMode="stack"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="12dp">
|
||||||
|
|
||||||
|
<item>
|
||||||
<shape>
|
<shape>
|
||||||
<corners android:radius="10dp"/>
|
<corners android:radius="10dp"/>
|
||||||
<solid android:color="@android:color/system_accent2_100"/>
|
<solid android:color="@android:color/system_accent2_100"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
</layer-list>
|
||||||
|
</item>
|
||||||
</ripple>
|
</ripple>
|
||||||
@@ -25,6 +25,4 @@
|
|||||||
<dimen name="settingslib_listPreferredItemPaddingStart">24dp</dimen>
|
<dimen name="settingslib_listPreferredItemPaddingStart">24dp</dimen>
|
||||||
<!-- Right padding of the preference -->
|
<!-- Right padding of the preference -->
|
||||||
<dimen name="settingslib_listPreferredItemPaddingEnd">24dp</dimen>
|
<dimen name="settingslib_listPreferredItemPaddingEnd">24dp</dimen>
|
||||||
|
|
||||||
<dimen name="settingslib_spinner_height">36dp</dimen>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -45,24 +45,4 @@
|
|||||||
<item name="android:progressDrawable">@drawable/settingslib_progress_horizontal</item>
|
<item name="android:progressDrawable">@drawable/settingslib_progress_horizontal</item>
|
||||||
<item name="android:scaleY">0.5</item>
|
<item name="android:scaleY">0.5</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Spinner.SettingsLib"
|
|
||||||
parent="android:style/Widget.Material.Spinner">
|
|
||||||
<item name="android:background">@drawable/settingslib_spinner_background</item>
|
|
||||||
<item name="android:popupBackground">@drawable/settingslib_spinner_dropdown_background</item>
|
|
||||||
<item name="android:dropDownVerticalOffset">48dp</item>
|
|
||||||
<item name="android:layout_marginTop">16dp</item>
|
|
||||||
<item name="android:layout_marginBottom">8dp</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="SpinnerItem.SettingsLib"
|
|
||||||
parent="@android:style/Widget.DeviceDefault.TextView.SpinnerItem">
|
|
||||||
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="SpinnerDropDownItem.SettingsLib"
|
|
||||||
parent="@android:style/Widget.Material.DropDownItem.Spinner">
|
|
||||||
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Only using in Settings application -->
|
<!-- Only using in Settings application -->
|
||||||
<style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" >
|
<style name="Theme.SettingsBase_v31" parent="@android:style/Theme.DeviceDefault.Settings" >
|
||||||
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item>
|
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item>
|
||||||
<item name="android:listPreferredItemPaddingStart">@dimen/settingslib_listPreferredItemPaddingStart</item>
|
<item name="android:listPreferredItemPaddingStart">@dimen/settingslib_listPreferredItemPaddingStart</item>
|
||||||
<item name="android:listPreferredItemPaddingLeft">@dimen/settingslib_listPreferredItemPaddingStart</item>
|
<item name="android:listPreferredItemPaddingLeft">@dimen/settingslib_listPreferredItemPaddingStart</item>
|
||||||
@@ -26,11 +26,10 @@
|
|||||||
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
||||||
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||||
<item name="android:progressBarStyleHorizontal">@style/HorizontalProgressBar.SettingsLib</item>
|
<item name="android:progressBarStyleHorizontal">@style/HorizontalProgressBar.SettingsLib</item>
|
||||||
<item name="android:spinnerStyle">@style/Spinner.SettingsLib</item>
|
|
||||||
<item name="android:spinnerItemStyle">@style/SpinnerItem.SettingsLib</item>
|
|
||||||
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem.SettingsLib</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.SettingsBase" parent="Theme.SettingsBase_v31" />
|
||||||
|
|
||||||
<!-- Using in SubSettings page including injected settings page -->
|
<!-- Using in SubSettings page including injected settings page -->
|
||||||
<style name="Theme.SubSettingsBase" parent="Theme.SettingsBase">
|
<style name="Theme.SubSettingsBase" parent="Theme.SettingsBase">
|
||||||
<!-- Suppress the built-in action bar -->
|
<!-- Suppress the built-in action bar -->
|
||||||
|
|||||||
@@ -15,12 +15,6 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<resources>
|
||||||
android:viewportWidth="24"
|
<dimen name="settingslib_spinner_height">36dp</dimen>
|
||||||
android:viewportHeight="24"
|
</resources>
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp">
|
|
||||||
<path
|
|
||||||
android:pathData="M7 10l5 5 5 -5z"
|
|
||||||
android:fillColor="?android:attr/textColorPrimary"/>
|
|
||||||
</vector>
|
|
||||||
39
packages/SettingsLib/SettingsTheme/res/values-v33/styles.xml
Normal file
39
packages/SettingsLib/SettingsTheme/res/values-v33/styles.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<style name="Spinner.SettingsLib"
|
||||||
|
parent="android:style/Widget.Material.Spinner">
|
||||||
|
<item name="android:background">@drawable/settingslib_spinner_background</item>
|
||||||
|
<item name="android:popupBackground">@drawable/settingslib_spinner_dropdown_background
|
||||||
|
</item>
|
||||||
|
<item name="android:dropDownVerticalOffset">48dp</item>
|
||||||
|
<item name="android:layout_marginTop">16dp</item>
|
||||||
|
<item name="android:layout_marginBottom">8dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="SpinnerItem.SettingsLib"
|
||||||
|
parent="@android:style/Widget.DeviceDefault.TextView.SpinnerItem">
|
||||||
|
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
||||||
|
<item name="android:paddingStart">16dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="SpinnerDropDownItem.SettingsLib"
|
||||||
|
parent="@android:style/Widget.Material.DropDownItem.Spinner">
|
||||||
|
<item name="android:textColor">@color/settingslib_spinner_dropdown_color</item>
|
||||||
|
<item name="android:paddingStart">16dp</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
24
packages/SettingsLib/SettingsTheme/res/values-v33/themes.xml
Normal file
24
packages/SettingsLib/SettingsTheme/res/values-v33/themes.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.SettingsBase" parent="Theme.SettingsBase_v31" >
|
||||||
|
<item name="android:spinnerStyle">@style/Spinner.SettingsLib</item>
|
||||||
|
<item name="android:spinnerItemStyle">@style/SpinnerItem.SettingsLib</item>
|
||||||
|
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem.SettingsLib</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -26,10 +26,4 @@
|
|||||||
<style name="TextAppearance.CategoryTitle.SettingsLib"
|
<style name="TextAppearance.CategoryTitle.SettingsLib"
|
||||||
parent="@android:style/TextAppearance.DeviceDefault.Medium">
|
parent="@android:style/TextAppearance.DeviceDefault.Medium">
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Spinner.SettingsLib"
|
|
||||||
parent="android:style/Widget.Material.Spinner">
|
|
||||||
<item name="android:background">@drawable/settingslib_spinner_background</item>
|
|
||||||
<item name="android:dropDownVerticalOffset">48dp</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<!-- Only using in Settings application -->
|
<!-- Only using in Settings application -->
|
||||||
<style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings">
|
<style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings">
|
||||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
||||||
<item name="android:spinnerStyle">@style/Spinner.SettingsLib</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Using in SubSettings page including injected settings page -->
|
<!-- Using in SubSettings page including injected settings page -->
|
||||||
|
|||||||
Reference in New Issue
Block a user