Update Preference style
- Set Title/Summary left alignment - Update FooterPreference layout - Set Title font size to 20sp - Adjust preferenceCategory TextAppearence - Adjust ListItemPaddingStart and End - Move Theme.SettingsBase from Settings to SettingsLib - Create Theme.SubSettingsBase for client team Bug: 182374464 Test: visual Change-Id: Ia541e6e66dfdf029367c464eab96e5cf1e3f8d66
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingStart="@dimen/app_preference_padding_start"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<LinearLayout
|
||||
@@ -29,7 +29,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start|center_vertical"
|
||||
android:minWidth="56dp"
|
||||
android:minWidth="@dimen/app_icon_min_width"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="4dp"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="@dimen/icon_min_width"
|
||||
android:gravity="start|center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<androidx.preference.internal.PreferenceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:maxWidth="48dp"
|
||||
app:maxHeight="48dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:baselineAligned="false"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/PreferenceCategoryStartMargin">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
style="@style/PreferenceCategoryTitleTextStyle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"
|
||||
style="@style/PreferenceSummaryTextStyle"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<!-- We use a FrameLayout as we want to place the invisible spinner on top of the other views -->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<!-- This spinner should be invisible in the layout and take up no space, when the Preference
|
||||
is clicked the dropdown will appear from this location on screen. -->
|
||||
<Spinner
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/preference_dropdown_padding_start"
|
||||
android:layout_marginLeft="@dimen/preference_dropdown_padding_start"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<include layout="@layout/settings_preference" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clipToPadding="false"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<include layout="@layout/image_frame"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"
|
||||
style="@style/PreferenceSummaryTextStyle"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end|center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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="PreferenceCategoryStartMargin">
|
||||
<item name="android:paddingLeft">24dp</item>
|
||||
<item name="android:paddingStart">24dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
20
packages/SettingsLib/SettingsTheme/res/values-v31/config.xml
Normal file
20
packages/SettingsLib/SettingsTheme/res/values-v31/config.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<bool name="config_icon_space_reserved">false</bool>
|
||||
<bool name="config_allow_divider">false</bool>
|
||||
</resources>
|
||||
25
packages/SettingsLib/SettingsTheme/res/values-v31/dimens.xml
Normal file
25
packages/SettingsLib/SettingsTheme/res/values-v31/dimens.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2019 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>
|
||||
<dimen name="preference_title_font_size">20sp</dimen>
|
||||
<dimen name="icon_min_width">48dp</dimen>
|
||||
<dimen name="preference_padding_start">24dp</dimen>
|
||||
<dimen name="preference_padding_end">24dp</dimen>
|
||||
<dimen name="app_preference_padding_start">20dp</dimen>
|
||||
<dimen name="app_icon_min_width">52dp</dimen>
|
||||
</resources>
|
||||
20
packages/SettingsLib/SettingsTheme/res/values/config.xml
Normal file
20
packages/SettingsLib/SettingsTheme/res/values/config.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<bool name="config_icon_space_reserved">true</bool>
|
||||
<bool name="config_allow_divider">true</bool>
|
||||
</resources>
|
||||
@@ -17,4 +17,10 @@
|
||||
|
||||
<resources>
|
||||
<dimen name="secondary_app_icon_size">32dp</dimen>
|
||||
<dimen name="preference_title_font_size">16sp</dimen>
|
||||
<dimen name="icon_min_width">56dp</dimen>
|
||||
<dimen name="preference_padding_start">?android:attr/dialogPreferredPadding</dimen>
|
||||
<dimen name="preference_padding_end">?android:attr/dialogPreferredPadding</dimen>
|
||||
<dimen name="app_preference_padding_start">?android:attr/listPreferredItemPaddingStart</dimen>
|
||||
<dimen name="app_icon_min_width">56dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -15,16 +15,8 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<style name="TextAppearance.CategoryTitle"
|
||||
parent="@*android:style/TextAppearance.DeviceDefault.Body2">
|
||||
<item name="android:textAllCaps">true</item>
|
||||
<item name="android:textSize">11sp</item>
|
||||
<!-- 0.8 Spacing, 0.8/11 = 0.072727273 -->
|
||||
<item name="android:letterSpacing">0.072727273</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceCategoryStartMargin">
|
||||
<item name="android:paddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
|
||||
<item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
|
||||
<style name="TextAppearance.PreferenceTitle"
|
||||
parent="@*android:style/TextAppearance.DeviceDefault.ListItem">
|
||||
<item name="android:textSize">@dimen/preference_title_font_size</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -16,17 +16,54 @@
|
||||
-->
|
||||
<resources>
|
||||
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay">
|
||||
<item name="footerPreferenceStyle">@style/Preference.Material</item>
|
||||
<item name="preferenceCategoryStyle">@style/SettingsCategoryPreference</item>
|
||||
<!-- For preference category color -->
|
||||
<item name="preferenceCategoryTitleTextAppearance">@style/TextAppearance.CategoryTitle
|
||||
</item>
|
||||
<item name="preferenceCategoryTitleTextColor">?android:attr/textColorSecondary</item>
|
||||
<item name="preferenceStyle">@style/SettingsPreference</item>
|
||||
<item name="checkBoxPreferenceStyle">@style/SettingsCheckBoxPreference</item>
|
||||
<item name="dialogPreferenceStyle">@style/SettingsPreference</item>
|
||||
<item name="editTextPreferenceStyle">@style/SettingsEditTextPreference</item>
|
||||
<item name="dropdownPreferenceStyle">@style/SettingsDropdownPreference</item>
|
||||
<item name="switchPreferenceStyle">@style/SettingsSwitchPreference</item>
|
||||
<item name="seekBarPreferenceStyle">@style/SettingsSeekbarPreference</item>
|
||||
<item name="footerPreferenceStyle">@style/Preference.Material</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsCategoryPreference" parent="@style/Preference.Category.Material">
|
||||
<item name="android:layout">@layout/preference_category_settings</item>
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">false</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
<item name="allowDividerAbove">@bool/config_allow_divider</item>
|
||||
<item name="allowDividerBelow">@bool/config_allow_divider</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsPreference" parent="@style/Preference.Material">
|
||||
<item name="layout">@layout/settings_preference</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsCheckBoxPreference" parent="@style/Preference.CheckBoxPreference.Material">
|
||||
<item name="layout">@layout/settings_preference</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsEditTextPreference"
|
||||
parent="@style/Preference.DialogPreference.EditTextPreference.Material">
|
||||
<item name="layout">@layout/settings_preference</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsDropdownPreference" parent="@style/Preference.DropDown.Material">
|
||||
<item name="layout">@layout/settings_dropdown_preference</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsSwitchPreference" parent="@style/Preference.SwitchPreference.Material">
|
||||
<item name="layout">@layout/settings_preference</item>
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingsSeekbarPreference" parent="@style/Preference.SeekBarPreference.Material">
|
||||
<item name="iconSpaceReserved">@bool/config_icon_space_reserved</item>
|
||||
</style>
|
||||
|
||||
<style name="SettingFooterPreference" parent="@style/Preference.Material">
|
||||
<item name="allowDividerAbove">@bool/config_allow_divider</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
32
packages/SettingsLib/SettingsTheme/res/values/themes.xml
Normal file
32
packages/SettingsLib/SettingsTheme/res/values/themes.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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>
|
||||
<!-- Only using in Settings application -->
|
||||
<style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" >
|
||||
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle</item>
|
||||
<item name="android:listPreferredItemPaddingStart">@dimen/preference_padding_start</item>
|
||||
<item name="android:listPreferredItemPaddingEnd">@dimen/preference_padding_end</item>
|
||||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||
</style>
|
||||
|
||||
<!-- Using in SubSettings page including injected settings page -->
|
||||
<style name="Theme.SubSettingsBase" parent="Theme.SettingsBase">
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user