Apply new style for SwitchPreference
- Moving two_target_min_width to SettingsTheme. - Apply new Switch in SettingsTheme. Bug: 185549116 Test: manual Change-Id: Iae31b430728113b25f7c9055372f60ee80a6a58f
This commit is contained in:
@@ -90,7 +90,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical|end"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -15,6 +15,7 @@ android_library {
|
||||
|
||||
static_libs: [
|
||||
"androidx.preference_preference",
|
||||
"SettingsLibSettingsTheme",
|
||||
],
|
||||
|
||||
sdk_version: "system_current",
|
||||
|
||||
@@ -18,13 +18,4 @@
|
||||
<resources>
|
||||
<color name="settingslib_switchbar_switch_track_tint">#82000000</color>
|
||||
<color name="settingslib_switchbar_switch_thumb_tint">@android:color/black</color>
|
||||
|
||||
<!-- Material next thumb off color-->
|
||||
<color name="settingslib_thumb_off_color">@android:color/system_neutral2_300</color>
|
||||
|
||||
<!-- Material next track on color-->
|
||||
<color name="settingslib_track_on_color">@android:color/system_accent2_700</color>
|
||||
|
||||
<!-- Material next track off color-->
|
||||
<color name="settingslib_track_off_color">@android:color/system_neutral1_700</color>
|
||||
</resources>
|
||||
|
||||
@@ -19,19 +19,4 @@
|
||||
<color name="settingslib_switchbar_background_color">@*android:color/material_grey_600</color>
|
||||
<color name="settingslib_switchbar_switch_track_tint">#BFFFFFFF</color>
|
||||
<color name="settingslib_switchbar_switch_thumb_tint">@android:color/white</color>
|
||||
|
||||
<!-- Material next state on color-->
|
||||
<color name="settingslib_state_on_color">?androidprv:attr/colorAccentPrimary</color>
|
||||
|
||||
<!-- Material next state off color-->
|
||||
<color name="settingslib_state_off_color">?androidprv:attr/colorAccentSecondary</color>
|
||||
|
||||
<!-- Material next thumb off color-->
|
||||
<color name="settingslib_thumb_off_color">@android:color/system_neutral2_100</color>
|
||||
|
||||
<!-- Material next track on color-->
|
||||
<color name="settingslib_track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
|
||||
|
||||
<!-- Material next track off color-->
|
||||
<color name="settingslib_track_off_color">@android:color/system_neutral2_600</color>
|
||||
</resources>
|
||||
|
||||
@@ -58,13 +58,14 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:maxLines="2"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
|
||||
<LinearLayout
|
||||
@@ -109,12 +110,13 @@
|
||||
android:background="?android:attr/dividerVertical" />
|
||||
<ImageView
|
||||
android:id="@+id/radio_extra_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:layout_height="fill_parent"
|
||||
android:src="@drawable/ic_settings_accent"
|
||||
android:contentDescription="@string/settings_label"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="?android:attr/selectableItemBackground" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Disabled status of thumb -->
|
||||
<item android:state_enabled="false"
|
||||
android:color="@color/settingslib_thumb_off_color" />
|
||||
<!-- Toggle off status of thumb -->
|
||||
<item android:state_checked="false"
|
||||
android:color="@color/settingslib_thumb_off_color" />
|
||||
<!-- Enabled or toggle on status of thumb -->
|
||||
<item android:color="@color/settingslib_state_on_color" />
|
||||
</selector>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Disabled status of thumb -->
|
||||
<item android:state_enabled="false"
|
||||
android:color="@color/settingslib_track_off_color"
|
||||
android:alpha="?android:attr/disabledAlpha" />
|
||||
<!-- Toggle off status of thumb -->
|
||||
<item android:state_checked="false"
|
||||
android:color="@color/settingslib_track_off_color" />
|
||||
<!-- Enabled or toggle on status of thumb -->
|
||||
<item android:color="@color/settingslib_track_on_color" />
|
||||
</selector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="4dp"
|
||||
android:left="4dp"
|
||||
android:right="4dp"
|
||||
android:bottom="4dp">
|
||||
<shape android:shape="oval" >
|
||||
<size android:height="20dp" android:width="20dp" />
|
||||
<solid android:color="@color/settingslib_switch_thumb_color" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle"
|
||||
android:width="52dp"
|
||||
android:height="28dp">
|
||||
|
||||
<solid android:color="@color/settingslib_switch_track_color" />
|
||||
<corners android:radius="35dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||
<!-- Material next thumb off color-->
|
||||
<color name="settingslib_thumb_off_color">@android:color/system_neutral2_300</color>
|
||||
|
||||
<!-- Material next track on color-->
|
||||
<color name="settingslib_track_on_color">@android:color/system_accent2_700</color>
|
||||
|
||||
<!-- Material next track off color-->
|
||||
<color name="settingslib_track_off_color">@android:color/system_neutral1_700</color>
|
||||
</resources>
|
||||
33
packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml
Normal file
33
packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||
<!-- Material next state on color-->
|
||||
<color name="settingslib_state_on_color">?androidprv:attr/colorAccentPrimary</color>
|
||||
|
||||
<!-- Material next state off color-->
|
||||
<color name="settingslib_state_off_color">?androidprv:attr/colorAccentSecondary</color>
|
||||
|
||||
<!-- Material next thumb off color-->
|
||||
<color name="settingslib_thumb_off_color">@android:color/system_neutral2_100</color>
|
||||
|
||||
<!-- Material next track on color-->
|
||||
<color name="settingslib_track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
|
||||
|
||||
<!-- Material next track off color-->
|
||||
<color name="settingslib_track_off_color">@android:color/system_neutral2_600</color>
|
||||
</resources>
|
||||
@@ -22,4 +22,10 @@
|
||||
|
||||
<style name="TextAppearance.CategoryTitle.SettingsLib"
|
||||
parent="@*android:style/TextAppearance.DeviceDefault.Body2" />
|
||||
|
||||
<style name="Switch.SettingsLib" parent="@android:style/Widget.Material.CompoundButton.Switch">
|
||||
<item name="android:switchMinWidth">52dp</item>
|
||||
<item name="android:track">@drawable/settingslib_switch_track</item>
|
||||
<item name="android:thumb">@drawable/settingslib_switch_thumb</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<item name="android:listPreferredItemPaddingStart">24dp</item>
|
||||
<item name="android:listPreferredItemPaddingEnd">16dp</item>
|
||||
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
||||
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||
</style>
|
||||
|
||||
<!-- Using in SubSettings page including injected settings page -->
|
||||
|
||||
@@ -19,4 +19,5 @@
|
||||
<dimen name="secondary_app_icon_size">32dp</dimen>
|
||||
<dimen name="app_preference_padding_start">?android:attr/listPreferredItemPaddingStart</dimen>
|
||||
<dimen name="app_icon_min_width">56dp</dimen>
|
||||
<dimen name="two_target_min_width">72dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" />
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
@@ -31,9 +33,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start|center_vertical"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_frame"
|
||||
@@ -89,7 +89,7 @@
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" />
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
android:id="@+id/icon_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:minHeight="@dimen/min_tap_target_size"
|
||||
android:layout_gravity="center"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@android:color/transparent"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
@@ -32,9 +34,7 @@
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="start|center_vertical"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/checkbox_container"
|
||||
@@ -86,7 +86,7 @@
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user