diff options
author | 2025-01-06 17:12:32 +0000 | |
---|---|---|
committer | 2025-01-16 05:36:44 +0000 | |
commit | c3e0d8109ed0d2c21b4811ea1424e6f850f144b9 (patch) | |
tree | 89dba056426b57ab6373153e642544e8ebe6c9c4 | |
parent | a4e6cc06acba11f1a150b276aed28048a279075c (diff) |
[Expressive design] Add BannerMessagePreferenceGroup
Bug: 367533951
Test: manual
Flag: EXEMPT library update
Change-Id: I616678711d7b0c2b9c0f2ed6bc30a4b752cff479
37 files changed, 1259 insertions, 87 deletions
diff --git a/packages/SettingsLib/BannerMessagePreference/Android.bp b/packages/SettingsLib/BannerMessagePreference/Android.bp index 3f671b9e7b10..77e2cc735895 100644 --- a/packages/SettingsLib/BannerMessagePreference/Android.bp +++ b/packages/SettingsLib/BannerMessagePreference/Android.bp @@ -14,12 +14,16 @@ android_library { "SettingsLintDefaults", ], - srcs: ["src/**/*.java"], + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], resource_dirs: ["res"], static_libs: [ - "androidx.preference_preference", + "SettingsLibButtonPreference", "SettingsLibSettingsTheme", + "androidx.preference_preference", ], sdk_version: "system_current", diff --git a/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_high.xml b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_high.xml new file mode 100644 index 000000000000..d113b547bf3e --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_high.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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"> + <item android:state_enabled="false" + android:alpha="@dimen/material_emphasis_disabled_background" android:color="@color/settingslib_colorBackgroundLevel_high"/> + <item android:state_checked="true" android:color="?attr/colorContainerChecked"/> + <item android:state_checkable="true" android:color="?attr/colorContainerUnchecked"/> + <item android:color="@color/settingslib_colorBackgroundLevel_high" /> +</selector>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_low.xml b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_low.xml new file mode 100644 index 000000000000..cb89d9a18fc2 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_low.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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"> + <item android:state_enabled="false" + android:alpha="@dimen/material_emphasis_disabled_background" android:color="@color/settingslib_colorBackgroundLevel_low"/> + <item android:state_checked="true" android:color="?attr/colorContainerChecked"/> + <item android:state_checkable="true" android:color="?attr/colorContainerUnchecked"/> + <item android:color="@color/settingslib_colorBackgroundLevel_low" /> +</selector>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_medium.xml b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_medium.xml new file mode 100644 index 000000000000..f820c352632d --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_medium.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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"> + <item android:state_enabled="false" + android:alpha="@dimen/material_emphasis_disabled_background" android:color="@color/settingslib_colorBackgroundLevel_medium"/> + <item android:state_checked="true" android:color="?attr/colorContainerChecked"/> + <item android:state_checkable="true" android:color="?attr/colorContainerUnchecked"/> + <item android:color="@color/settingslib_colorBackgroundLevel_medium" /> +</selector>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_normal.xml b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_normal.xml new file mode 100644 index 000000000000..8037a8bb75be --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/color/settingslib_banner_button_background_normal.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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"> + <item android:state_enabled="false" + android:alpha="@dimen/material_emphasis_disabled_background" android:color="?attr/colorOnSurface"/> + <item android:state_checked="true" android:color="?attr/colorContainerChecked"/> + <item android:state_checkable="true" android:color="?attr/colorContainerUnchecked"/> + <item android:color="?attr/colorContainer" /> +</selector>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/drawable-v31/settingslib_card_background.xml b/packages/SettingsLib/BannerMessagePreference/res/drawable-v31/settingslib_card_background.xml index 072eb5873ce5..3f806e1574b7 100644 --- a/packages/SettingsLib/BannerMessagePreference/res/drawable-v31/settingslib_card_background.xml +++ b/packages/SettingsLib/BannerMessagePreference/res/drawable-v31/settingslib_card_background.xml @@ -16,6 +16,6 @@ --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="?android:attr/background" /> + <solid android:color="@android:color/white" /> <corners android:radius="28dp"/> </shape>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/drawable-v35/settingslib_expressive_card_background.xml b/packages/SettingsLib/BannerMessagePreference/res/drawable-v35/settingslib_expressive_card_background.xml new file mode 100644 index 000000000000..a677a66f86e7 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/drawable-v35/settingslib_expressive_card_background.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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/settingslib_materialColorSurfaceBright" /> + <corners android:radius="28dp"/> +</shape>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/layout-v31/settingslib_banner_message.xml b/packages/SettingsLib/BannerMessagePreference/res/layout-v31/settingslib_banner_message.xml index 9d53e39c7bf8..ca596d89fab6 100644 --- a/packages/SettingsLib/BannerMessagePreference/res/layout-v31/settingslib_banner_message.xml +++ b/packages/SettingsLib/BannerMessagePreference/res/layout-v31/settingslib_banner_message.xml @@ -15,85 +15,92 @@ limitations under the License. --> -<com.android.settingslib.widget.BannerMessageView - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" - style="@style/Banner.Preference.SettingsLib"> + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:paddingStart="?android:attr/listPreferredItemPaddingStart"> - <RelativeLayout - android:id="@+id/top_row" + <com.android.settingslib.widget.BannerMessageView + android:id="@+id/banner_background" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingBottom="8dp" - android:orientation="horizontal"> + android:orientation="vertical" + style="@style/Banner.Preference.SettingsLib"> - <ImageView - android:id="@+id/banner_icon" - android:layout_width="24dp" - android:layout_height="24dp" - android:layout_alignParentStart="true" - android:importantForAccessibility="no" /> - - <ImageButton - android:id="@+id/banner_dismiss_btn" - android:layout_width="wrap_content" + <RelativeLayout + android:id="@+id/top_row" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:src="@drawable/settingslib_ic_cross" - android:layout_alignParentEnd="true" - android:contentDescription="@string/accessibility_banner_message_dismiss" - style="@style/Banner.Dismiss.SettingsLib" /> - </RelativeLayout> + android:paddingBottom="8dp" + android:orientation="horizontal"> - <TextView - android:id="@+id/banner_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start" - android:textAlignment="viewStart" - android:paddingTop="0dp" - android:paddingBottom="4dp" - android:textAppearance="@style/Banner.Title.SettingsLib"/> + <ImageView + android:id="@+id/banner_icon" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_alignParentStart="true" + android:importantForAccessibility="no" /> - <TextView - android:id="@+id/banner_subtitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start" - android:textAlignment="viewStart" - android:paddingTop="0dp" - android:paddingBottom="4dp" - android:textAppearance="@style/Banner.Subtitle.SettingsLib" - android:visibility="gone"/> + <ImageButton + android:id="@+id/banner_dismiss_btn" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/settingslib_ic_cross" + android:layout_alignParentEnd="true" + android:contentDescription="@string/accessibility_banner_message_dismiss" + style="@style/Banner.Dismiss.SettingsLib" /> + </RelativeLayout> - <TextView - android:id="@+id/banner_summary" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start" - android:textAlignment="viewStart" - android:paddingTop="4dp" - android:paddingBottom="8dp" - android:textAppearance="@style/Banner.Summary.SettingsLib"/> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:minHeight="8dp" - android:gravity="end"> + <TextView + android:id="@+id/banner_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="start" + android:textAlignment="viewStart" + android:paddingTop="0dp" + android:paddingBottom="4dp" + android:textAppearance="@style/Banner.Title.SettingsLib"/> - <Button - android:id="@+id/banner_negative_btn" + <TextView + android:id="@+id/banner_subtitle" android:layout_width="wrap_content" android:layout_height="wrap_content" - style="@style/Banner.ButtonText.SettingsLib"/> + android:layout_gravity="start" + android:textAlignment="viewStart" + android:paddingTop="0dp" + android:paddingBottom="4dp" + android:textAppearance="@style/Banner.Subtitle.SettingsLib" + android:visibility="gone"/> - <Button - android:id="@+id/banner_positive_btn" + <TextView + android:id="@+id/banner_summary" android:layout_width="wrap_content" android:layout_height="wrap_content" - style="@style/Banner.ButtonText.SettingsLib"/> - </LinearLayout> -</com.android.settingslib.widget.BannerMessageView>
\ No newline at end of file + android:layout_gravity="start" + android:textAlignment="viewStart" + android:paddingTop="4dp" + android:paddingBottom="8dp" + android:textAppearance="@style/Banner.Summary.SettingsLib"/> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:minHeight="8dp" + android:gravity="end"> + + <Button + android:id="@+id/banner_negative_btn" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/Banner.ButtonText.SettingsLib"/> + + <Button + android:id="@+id/banner_positive_btn" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/Banner.ButtonText.SettingsLib"/> + </LinearLayout> + </com.android.settingslib.widget.BannerMessageView> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/layout-v35/settingslib_expressive_banner_message.xml b/packages/SettingsLib/BannerMessagePreference/res/layout-v35/settingslib_expressive_banner_message.xml new file mode 100644 index 000000000000..b10ef6e77ec7 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/layout-v35/settingslib_expressive_banner_message.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:paddingStart="?android:attr/listPreferredItemPaddingStart"> + + <com.android.settingslib.widget.BannerMessageView + android:id="@+id/banner_background" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + style="@style/Banner.Preference.SettingsLib.Expressive"> + + <RelativeLayout + android:id="@+id/top_row" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_marginEnd="@dimen/settingslib_expressive_space_medium4" + android:orientation="vertical"> + <TextView + android:id="@+id/banner_header" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/Banner.Header.SettingsLib.Expressive"/> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <ImageView + android:id="@+id/banner_icon" + android:layout_width="@dimen/settingslib_expressive_space_small3" + android:layout_height="@dimen/settingslib_expressive_space_small3" + android:layout_gravity="center_vertical" + android:importantForAccessibility="no" + android:scaleType="fitCenter" /> + + <TextView + android:id="@+id/banner_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/Banner.Title.SettingsLib.Expressive" /> + </LinearLayout> + + <TextView + android:id="@+id/banner_subtitle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/Banner.Subtitle.SettingsLib.Expressive"/> + </LinearLayout> + + <ImageButton + android:id="@+id/banner_dismiss_btn" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/Banner.Dismiss.SettingsLib.Expressive" /> + </RelativeLayout> + + <TextView + android:id="@+id/banner_summary" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/Banner.Summary.SettingsLib.Expressive"/> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/banner_buttons_frame" + android:paddingTop="@dimen/settingslib_expressive_space_extrasmall6" + android:orientation="horizontal"> + + <com.google.android.material.button.MaterialButton + android:id="@+id/banner_negative_btn" + android:layout_weight="1" + style="@style/Banner.NegativeButton.SettingsLib.Expressive"/> + <Space + android:layout_width="@dimen/settingslib_expressive_space_extrasmall4" + android:layout_height="@dimen/settingslib_expressive_space_small1"/> + <com.google.android.material.button.MaterialButton + android:id="@+id/banner_positive_btn" + android:layout_weight="1" + style="@style/Banner.PositiveButton.SettingsLib.Expressive"/> + </LinearLayout> + </com.android.settingslib.widget.BannerMessageView> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/layout/settingslib_banner_message_preference_group.xml b/packages/SettingsLib/BannerMessagePreference/res/layout/settingslib_banner_message_preference_group.xml new file mode 100644 index 000000000000..c74e39187562 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/layout/settingslib_banner_message_preference_group.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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:baselineAligned="false" + android:id="@+id/banner_group_layout" + android:importantForAccessibility="no" + android:filterTouchesWhenObscured="false" + android:orientation="horizontal"> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/values-v31/styles.xml b/packages/SettingsLib/BannerMessagePreference/res/values-v31/styles.xml index fede44feb090..5909f8e0f85e 100644 --- a/packages/SettingsLib/BannerMessagePreference/res/values-v31/styles.xml +++ b/packages/SettingsLib/BannerMessagePreference/res/values-v31/styles.xml @@ -24,9 +24,7 @@ <item name="android:paddingTop">20dp</item> <item name="android:paddingBottom">8dp</item> <item name="android:layout_marginTop">8dp</item> - <item name="android:layout_marginStart">16dp</item> <item name="android:layout_marginBottom">8dp</item> - <item name="android:layout_marginEnd">16dp</item> <item name="android:background">@drawable/settingslib_card_background</item> </style> diff --git a/packages/SettingsLib/BannerMessagePreference/res/values-v35/styles_expressive.xml b/packages/SettingsLib/BannerMessagePreference/res/values-v35/styles_expressive.xml new file mode 100644 index 000000000000..b864311bf9b7 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/res/values-v35/styles_expressive.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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="Banner.Preference.SettingsLib.Expressive"> + <item name="android:padding">@dimen/settingslib_expressive_space_small1</item> + <item name="android:background">@drawable/settingslib_expressive_card_background</item> + </style> + + <style name="Banner.Header.SettingsLib.Expressive" + parent=""> + <item name="android:textAlignment">viewStart</item> + <item name="android:paddingBottom">@dimen/settingslib_expressive_space_extrasmall4</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.LabelMedium</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + </style> + + <style name="Banner.Title.SettingsLib.Expressive" + parent=""> + <item name="android:layout_gravity">start</item> + <item name="android:layout_marginLeft">@dimen/settingslib_expressive_space_extrasmall4</item> + <item name="android:textAlignment">viewStart</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleLarge.Emphasized</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + </style> + + <style name="Banner.Subtitle.SettingsLib.Expressive" + parent=""> + <item name="android:layout_gravity">start</item> + <item name="android:textAlignment">viewStart</item> + <item name="android:paddingTop">@dimen/settingslib_expressive_space_extrasmall4</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.BodyMedium</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + </style> + + <style name="Banner.Summary.SettingsLib.Expressive" + parent=""> + <item name="android:layout_gravity">start</item> + <item name="android:textAlignment">viewStart</item> + <item name="android:paddingTop">@dimen/settingslib_expressive_space_extrasmall6</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.BodyMedium</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + </style> + + <style name="Banner.Dismiss.SettingsLib.Expressive"> + <item name="android:src">@drawable/settingslib_expressive_icon_cross</item> + <item name="android:layout_alignParentEnd">true</item> + <item name="android:contentDescription">@string/accessibility_banner_message_dismiss</item> + </style> + + <style name="Banner.PositiveButton.SettingsLib.Expressive" + parent="@style/SettingsLibButtonStyle.Expressive.Filled.Extra"> + <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> + <item name="materialSizeOverlay">@style/SizeOverlay.Material3Expressive.Button.Small</item> + </style> + + <style name="Banner.NegativeButton.SettingsLib.Expressive" + parent="@style/SettingsLibButtonStyle.Expressive.Outline.Extra"> + <item name="materialSizeOverlay">@style/SizeOverlay.Material3Expressive.Button.Small</item> + </style> +</resources> diff --git a/packages/SettingsLib/BannerMessagePreference/res/values/attrs.xml b/packages/SettingsLib/BannerMessagePreference/res/values/attrs.xml index 96634a51de56..86d5f476b0f2 100644 --- a/packages/SettingsLib/BannerMessagePreference/res/values/attrs.xml +++ b/packages/SettingsLib/BannerMessagePreference/res/values/attrs.xml @@ -21,7 +21,18 @@ <enum name="high" value="0"/> <enum name="medium" value="1"/> <enum name="low" value="2"/> + <enum name="normal" value="3"/> </attr> <attr format="string" name="subtitle" /> + <attr format="string" name="bannerHeader" /> + <attr format="integer" name="buttonOrientation" /> + </declare-styleable> + + <declare-styleable name="BannerMessagePreferenceGroup"> + <attr format="string" name="expandKey" /> + <attr format="string" name="expandTitle" /> + <attr format="string" name="collapseKey" /> + <attr format="string" name="collapseTitle" /> + <attr format="reference" name="collapseIcon" /> </declare-styleable> </resources>
\ No newline at end of file diff --git a/packages/SettingsLib/BannerMessagePreference/res/values/colors.xml b/packages/SettingsLib/BannerMessagePreference/res/values/colors.xml index 53d72d1eeff7..891def1c610a 100644 --- a/packages/SettingsLib/BannerMessagePreference/res/values/colors.xml +++ b/packages/SettingsLib/BannerMessagePreference/res/values/colors.xml @@ -19,7 +19,9 @@ <color name="banner_background_attention_high">#FFDAD5</color> <!-- red card background --> <color name="banner_background_attention_medium">#F0E3A8</color> <!-- yellow card background --> <color name="banner_background_attention_low">#CFEBC0</color> <!-- green card background --> + <color name="banner_background_attention_normal">@color/settingslib_materialColorSurfaceBright</color> <!-- normal card background --> <color name="banner_accent_attention_high">#BB3322</color> <!-- red accent color --> <color name="banner_accent_attention_medium">#895900</color> <!-- yellow accent color --> <color name="banner_accent_attention_low">#1D7233</color> <!-- green accent color --> + <color name="banner_accent_attention_normal">@color/settingslib_materialColorPrimary</color> <!-- normal accent color --> </resources> diff --git a/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreference.java b/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreference.java index 10769ecfbe42..60a9ebd6f98b 100644 --- a/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreference.java +++ b/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreference.java @@ -17,6 +17,7 @@ package com.android.settingslib.widget; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.PorterDuff; @@ -29,6 +30,7 @@ import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.ColorInt; @@ -39,6 +41,8 @@ import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import com.android.settingslib.widget.preference.banner.R; + +import com.google.android.material.button.MaterialButton; /** * Banner message is a banner displaying important information (permission request, page error etc), * and provide actions for user to address. It requires a user action to be dismissed. @@ -46,22 +50,36 @@ import com.android.settingslib.widget.preference.banner.R; public class BannerMessagePreference extends Preference implements GroupSectionDividerMixin { public enum AttentionLevel { - HIGH(0, R.color.banner_background_attention_high, R.color.banner_accent_attention_high), + HIGH(0, + R.color.banner_background_attention_high, + R.color.banner_accent_attention_high, + R.color.settingslib_banner_button_background_high), MEDIUM(1, - R.color.banner_background_attention_medium, - R.color.banner_accent_attention_medium), - LOW(2, R.color.banner_background_attention_low, R.color.banner_accent_attention_low); + R.color.banner_background_attention_medium, + R.color.banner_accent_attention_medium, + R.color.settingslib_banner_button_background_medium), + LOW(2, + R.color.banner_background_attention_low, + R.color.banner_accent_attention_low, + R.color.settingslib_banner_button_background_low), + NORMAL(3, + R.color.banner_background_attention_normal, + R.color.banner_accent_attention_normal, + R.color.settingslib_banner_button_background_normal); // Corresponds to the enum valye of R.attr.attentionLevel private final int mAttrValue; @ColorRes private final int mBackgroundColorResId; @ColorRes private final int mAccentColorResId; + @ColorRes private final int mButtonBackgroundColorResId; AttentionLevel(int attrValue, @ColorRes int backgroundColorResId, - @ColorRes int accentColorResId) { + @ColorRes int accentColorResId, + @ColorRes int buttonBackgroundColorResId) { mAttrValue = attrValue; mBackgroundColorResId = backgroundColorResId; mAccentColorResId = accentColorResId; + mButtonBackgroundColorResId = buttonBackgroundColorResId; } static AttentionLevel fromAttr(int attrValue) { @@ -80,6 +98,10 @@ public class BannerMessagePreference extends Preference implements GroupSectionD public @ColorRes int getBackgroundColorResId() { return mBackgroundColorResId; } + + public @ColorRes int getButtonBackgroundColorResId() { + return mButtonBackgroundColorResId; + } } private static final String TAG = "BannerPreference"; @@ -95,6 +117,8 @@ public class BannerMessagePreference extends Preference implements GroupSectionD // Default attention level is High. private AttentionLevel mAttentionLevel = AttentionLevel.HIGH; private String mSubtitle; + private String mHeader; + private int mButtonOrientation; public BannerMessagePreference(Context context) { super(context); @@ -119,7 +143,10 @@ public class BannerMessagePreference extends Preference implements GroupSectionD private void init(Context context, AttributeSet attrs) { setSelectable(false); - setLayoutResource(R.layout.settingslib_banner_message); + int resId = SettingsThemeHelper.isExpressiveTheme(context) + ? R.layout.settingslib_expressive_banner_message + : R.layout.settingslib_banner_message; + setLayoutResource(resId); if (IS_AT_LEAST_S) { if (attrs != null) { @@ -130,6 +157,9 @@ public class BannerMessagePreference extends Preference implements GroupSectionD a.getInt(R.styleable.BannerMessagePreference_attentionLevel, 0); mAttentionLevel = AttentionLevel.fromAttr(mAttentionLevelValue); mSubtitle = a.getString(R.styleable.BannerMessagePreference_subtitle); + mHeader = a.getString(R.styleable.BannerMessagePreference_bannerHeader); + mButtonOrientation = a.getInt(R.styleable.BannerMessagePreference_buttonOrientation, + LinearLayout.HORIZONTAL); a.recycle(); } } @@ -142,11 +172,16 @@ public class BannerMessagePreference extends Preference implements GroupSectionD final TextView titleView = (TextView) holder.findViewById(R.id.banner_title); CharSequence title = getTitle(); - titleView.setText(title); - titleView.setVisibility(title == null ? View.GONE : View.VISIBLE); + if (titleView != null) { + titleView.setText(title); + titleView.setVisibility(title == null ? View.GONE : View.VISIBLE); + } final TextView summaryView = (TextView) holder.findViewById(R.id.banner_summary); - summaryView.setText(getSummary()); + if (summaryView != null) { + summaryView.setText(getSummary()); + summaryView.setVisibility(TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE); + } mPositiveButtonInfo.mButton = (Button) holder.findViewById(R.id.banner_positive_btn); mNegativeButtonInfo.mButton = (Button) holder.findViewById(R.id.banner_negative_btn); @@ -162,8 +197,11 @@ public class BannerMessagePreference extends Preference implements GroupSectionD icon == null ? getContext().getDrawable(R.drawable.ic_warning) : icon); - iconView.setColorFilter( - new PorterDuffColorFilter(accentColor, PorterDuff.Mode.SRC_IN)); + if (mAttentionLevel != AttentionLevel.NORMAL + && !SettingsThemeHelper.isExpressiveTheme(context)) { + iconView.setColorFilter( + new PorterDuffColorFilter(accentColor, PorterDuff.Mode.SRC_IN)); + } } if (IS_AT_LEAST_S) { @@ -171,12 +209,25 @@ public class BannerMessagePreference extends Preference implements GroupSectionD context.getResources().getColor( mAttentionLevel.getBackgroundColorResId(), theme); + @ColorInt final int btnBackgroundColor = + context.getResources().getColor(mAttentionLevel.getButtonBackgroundColorResId(), + theme); + ColorStateList strokeColor = context.getResources().getColorStateList( + mAttentionLevel.getButtonBackgroundColorResId(), theme); + holder.setDividerAllowedAbove(false); holder.setDividerAllowedBelow(false); - holder.itemView.getBackground().setTint(backgroundColor); + View backgroundView = holder.findViewById(R.id.banner_background); + if (backgroundView != null && !SettingsThemeHelper.isExpressiveTheme(context)) { + backgroundView.getBackground().setTint(backgroundColor); + } mPositiveButtonInfo.mColor = accentColor; mNegativeButtonInfo.mColor = accentColor; + if (mAttentionLevel != AttentionLevel.NORMAL) { + mPositiveButtonInfo.mBackgroundColor = btnBackgroundColor; + mNegativeButtonInfo.mStrokeColor = strokeColor; + } mDismissButtonInfo.mButton = (ImageButton) holder.findViewById(R.id.banner_dismiss_btn); mDismissButtonInfo.setUpButton(); @@ -185,6 +236,13 @@ public class BannerMessagePreference extends Preference implements GroupSectionD subtitleView.setText(mSubtitle); subtitleView.setVisibility(mSubtitle == null ? View.GONE : View.VISIBLE); + TextView headerView = (TextView) holder.findViewById(R.id.banner_header); + if (headerView != null) { + headerView.setText(mHeader); + headerView.setVisibility(TextUtils.isEmpty(mHeader) ? View.GONE : View.VISIBLE); + } + + } else { holder.setDividerAllowedAbove(true); holder.setDividerAllowedBelow(true); @@ -192,6 +250,24 @@ public class BannerMessagePreference extends Preference implements GroupSectionD mPositiveButtonInfo.setUpButton(); mNegativeButtonInfo.setUpButton(); + View buttonFrame = holder.findViewById(R.id.banner_buttons_frame); + if (buttonFrame != null) { + buttonFrame.setVisibility( + mPositiveButtonInfo.shouldBeVisible() || mNegativeButtonInfo.shouldBeVisible() + ? View.VISIBLE : View.GONE); + + LinearLayout linearLayout = (LinearLayout) buttonFrame; + if (mButtonOrientation != linearLayout.getOrientation()) { + int childCount = linearLayout.getChildCount(); + //reverse the order of the buttons + for (int i = childCount - 1; i >= 0; i--) { + View child = linearLayout.getChildAt(i); + linearLayout.removeViewAt(i); + linearLayout.addView(child); + } + linearLayout.setOrientation(mButtonOrientation); + } + } } /** @@ -302,6 +378,18 @@ public class BannerMessagePreference extends Preference implements GroupSectionD } /** + * Sets button orientation. + */ + @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) + public BannerMessagePreference setButtonOrientation(int orientation) { + if (mButtonOrientation != orientation) { + mButtonOrientation = orientation; + notifyChanged(); + } + return this; + } + + /** * Sets the subtitle. */ @RequiresApi(Build.VERSION_CODES.S) @@ -322,6 +410,26 @@ public class BannerMessagePreference extends Preference implements GroupSectionD } /** + * Sets the header. + */ + @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) + public BannerMessagePreference setHeader(@StringRes int textResId) { + return setHeader(getContext().getString(textResId)); + } + + /** + * Sets the header. + */ + @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) + public BannerMessagePreference setHeader(String header) { + if (!TextUtils.equals(header, mSubtitle)) { + mHeader = header; + notifyChanged(); + } + return this; + } + + /** * Sets the attention level. This will update the color theme of the preference. */ public BannerMessagePreference setAttentionLevel(AttentionLevel attentionLevel) { @@ -342,13 +450,29 @@ public class BannerMessagePreference extends Preference implements GroupSectionD private View.OnClickListener mListener; private boolean mIsVisible = true; @ColorInt private int mColor; + @ColorInt private int mBackgroundColor; + private ColorStateList mStrokeColor; void setUpButton() { mButton.setText(mText); mButton.setOnClickListener(mListener); + MaterialButton btn = null; + if (mButton instanceof MaterialButton) { + btn = (MaterialButton) mButton; + } + if (IS_AT_LEAST_S) { - mButton.setTextColor(mColor); + if (btn != null && SettingsThemeHelper.isExpressiveTheme(btn.getContext())) { + if (mBackgroundColor != 0) { + btn.setBackgroundColor(mBackgroundColor); + } + if (mStrokeColor != null) { + btn.setStrokeColor(mStrokeColor); + } + } else { + mButton.setTextColor(mColor); + } } if (shouldBeVisible()) { diff --git a/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreferenceGroup.kt b/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreferenceGroup.kt new file mode 100644 index 000000000000..75455635fca1 --- /dev/null +++ b/packages/SettingsLib/BannerMessagePreference/src/com/android/settingslib/widget/BannerMessagePreferenceGroup.kt @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2025 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. + */ + +package com.android.settingslib.widget + +import android.content.Context +import android.graphics.drawable.Drawable +import android.util.AttributeSet +import android.view.View +import androidx.preference.Preference +import androidx.preference.PreferenceGroup +import androidx.preference.PreferenceViewHolder + +import com.android.settingslib.widget.preference.banner.R + +/** + * Custom PreferenceGroup that allows expanding and collapsing child preferences. + */ +class BannerMessagePreferenceGroup @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : PreferenceGroup(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin { + + private var isExpanded = false + private var expandPreference: NumberButtonPreference? = null + private var collapsePreference: SectionButtonPreference? = null + private val childPreferences = mutableListOf<BannerMessagePreference>() + private var expandKey: String? = null + private var expandTitle: String? = null + private var collapseKey: String? = null + private var collapseTitle: String? = null + private var collapseIcon: Drawable? = null + var expandContentDescription: Int = 0 + set(value) { + field = value + expandPreference?.btnContentDescription = expandContentDescription + } + + init { + isPersistent = false // This group doesn't store data + layoutResource = R.layout.settingslib_banner_message_preference_group + + initAttributes(context, attrs, defStyleAttr) + } + + override fun addPreference(preference: Preference): Boolean { + if (preference !is BannerMessagePreference) { + return false + } + + if (childPreferences.size >= MAX_CHILDREN) { + return false + } + + childPreferences.add(preference) + return super.addPreference(preference) + } + + override fun removePreference(preference: Preference): Boolean { + if (preference !is BannerMessagePreference) { + return false + } + childPreferences.remove(preference) + return super.removePreference(preference) + } + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + if (childPreferences.size >= MAX_CHILDREN - 1) { + if (expandPreference == null) { + expandPreference = NumberButtonPreference(context).apply { + key = expandKey + title = expandTitle + count = childPreferences.size - 1 + btnContentDescription = expandContentDescription + clickListener = View.OnClickListener { + toggleExpansion() + } + } + super.addPreference(expandPreference!!) + } + if (collapsePreference == null) { + collapsePreference = SectionButtonPreference(context) + .apply { + key = collapseKey + title = collapseTitle + icon = collapseIcon + setOnClickListener { + toggleExpansion() + } + } + super.addPreference(collapsePreference!!) + } + } + updateExpandCollapsePreference() + updateChildrenVisibility() + } + + private fun updateExpandCollapsePreference() { + expandPreference?.isVisible = !isExpanded + collapsePreference?.isVisible = isExpanded + } + + private fun updateChildrenVisibility() { + for (i in 1 until childPreferences.size) { + val child = childPreferences[i] + child.isVisible = isExpanded + } + } + + private fun toggleExpansion() { + isExpanded = !isExpanded + updateExpandCollapsePreference() + updateChildrenVisibility() + } + + private fun initAttributes(context: Context, attrs: AttributeSet?, defStyleAttr: Int) { + context.obtainStyledAttributes( + attrs, + R.styleable.BannerMessagePreferenceGroup, defStyleAttr, 0 + ).apply { + expandKey = getString(R.styleable.BannerMessagePreferenceGroup_expandKey) + expandTitle = getString(R.styleable.BannerMessagePreferenceGroup_expandTitle) + collapseKey = getString(R.styleable.BannerMessagePreferenceGroup_collapseKey) + collapseTitle = getString(R.styleable.BannerMessagePreferenceGroup_collapseTitle) + collapseIcon = getDrawable(R.styleable.BannerMessagePreferenceGroup_collapseIcon) + recycle() + } + } + + companion object { + private const val MAX_CHILDREN = 3 + } +}
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/Android.bp b/packages/SettingsLib/ButtonPreference/Android.bp index 08dd27fd25ce..a377f312ffbf 100644 --- a/packages/SettingsLib/ButtonPreference/Android.bp +++ b/packages/SettingsLib/ButtonPreference/Android.bp @@ -14,12 +14,15 @@ android_library { "SettingsLintDefaults", ], - srcs: ["src/**/*.java"], + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], resource_dirs: ["res"], static_libs: [ - "androidx.preference_preference", "SettingsLibSettingsTheme", + "androidx.preference_preference", ], sdk_version: "system_current", diff --git a/packages/SettingsLib/ButtonPreference/res/color/settingslib_section_button_background.xml b/packages/SettingsLib/ButtonPreference/res/color/settingslib_section_button_background.xml new file mode 100644 index 000000000000..0972b625d4fd --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/res/color/settingslib_section_button_background.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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"> + <item android:state_enabled="false" + android:alpha="@dimen/material_emphasis_disabled_background" android:color="@color/settingslib_materialColorSurfaceBright"/> + <item android:color="@color/settingslib_materialColorSurfaceBright" /> +</selector>
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_button_background.xml b/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_button_background.xml new file mode 100644 index 000000000000..9bf5c430e8e7 --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_button_background.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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/settingslib_materialColorSurfaceBright" /> + <corners android:radius="@dimen/settingslib_expressive_radius_extralarge2"/> +</shape>
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_count_background.xml b/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_count_background.xml new file mode 100644 index 000000000000..b993811b34f5 --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/res/drawable/settingslib_number_count_background.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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/settingslib_materialColorSecondaryContainer" /> + <corners android:radius="100dp"/> +</shape>
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/res/layout/settingslib_number_button.xml b/packages/SettingsLib/ButtonPreference/res/layout/settingslib_number_button.xml new file mode 100644 index 000000000000..fa13b4125065 --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/res/layout/settingslib_number_button.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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:orientation="vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:paddingVertical="@dimen/settingslib_expressive_space_extrasmall4"> + + <LinearLayout + android:id="@+id/settingslib_number_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingVertical="@dimen/settingslib_expressive_space_small1" + android:paddingHorizontal="@dimen/settingslib_expressive_space_small4" + android:background="@drawable/settingslib_number_button_background"> + <TextView + android:id="@+id/settingslib_number_count" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/SettingsLibNumberButtonStyle.Number"/> + <TextView + android:id="@+id/settingslib_number_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/SettingsLibNumberButtonStyle.Title"/> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/res/layout/settingslib_section_button.xml b/packages/SettingsLib/ButtonPreference/res/layout/settingslib_section_button.xml new file mode 100644 index 000000000000..e7fb572d06dc --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/res/layout/settingslib_section_button.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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:orientation="vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:paddingVertical="@dimen/settingslib_expressive_space_extrasmall4"> + + <com.google.android.material.button.MaterialButton + android:id="@+id/settingslib_section_button" + style="@style/SettingsLibSectionButtonStyle.Expressive" /> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/res/values/styles.xml b/packages/SettingsLib/ButtonPreference/res/values/styles.xml index 3963732f7ae4..5208e2004a5f 100644 --- a/packages/SettingsLib/ButtonPreference/res/values/styles.xml +++ b/packages/SettingsLib/ButtonPreference/res/values/styles.xml @@ -30,4 +30,33 @@ <item name="android:textColor">@color/settingslib_btn_colored_text_material</item> <item name="android:background">@drawable/settingslib_btn_colored_material</item> </style> + + <style name="SettingsLibSectionButtonStyle.Expressive" + parent="@style/SettingsLibButtonStyle.Expressive.Filled.Large"> + <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="backgroundTint">@color/settingslib_section_button_background</item> + <item name="iconTint">?android:attr/textColorPrimary</item> + </style> + + <style name="SettingsLibNumberButtonStyle.Number" + parent=""> + <item name="android:minWidth">@dimen/settingslib_expressive_space_small4</item> + <item name="android:minHeight">@dimen/settingslib_expressive_space_small4</item> + <item name="android:gravity">center</item> + <item name="android:background">@drawable/settingslib_number_count_background</item> + <item name="android:paddingStart">@dimen/settingslib_expressive_radius_extrasmall2</item> + <item name="android:paddingEnd">@dimen/settingslib_expressive_radius_extrasmall2</item> + <item name="android:layout_marginEnd">@dimen/settingslib_expressive_space_extrasmall4</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleMedium</item> + <item name="android:textColor">@color/settingslib_materialColorOnSecondaryContainer</item> + <item name="android:importantForAccessibility">no</item> + </style> + + <style name="SettingsLibNumberButtonStyle.Title" + parent=""> + <item name="android:gravity">center</item> + <item name="android:textAppearance">@style/TextAppearance.SettingsLib.LabelLarge</item> + <item name="android:textColor">@color/settingslib_materialColorOnSurface</item> + <item name="android:importantForAccessibility">no</item> + </style> </resources> diff --git a/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/NumberButtonPreference.kt b/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/NumberButtonPreference.kt new file mode 100644 index 000000000000..a1772d5acdf9 --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/NumberButtonPreference.kt @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2025 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. + */ + +package com.android.settingslib.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.TextView +import androidx.preference.Preference +import androidx.preference.PreferenceViewHolder + +import com.android.settingslib.widget.preference.button.R + +class NumberButtonPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin { + + var clickListener: View.OnClickListener? = null + + var count: Int = 0 + set(value) { + field = value + notifyChanged() + } + + var btnContentDescription: Int = 0 + set(value) { + field = value + notifyChanged() + } + + init { + isPersistent = false // This preference doesn't store data + order = Int.MAX_VALUE + layoutResource = R.layout.settingslib_number_button + } + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + holder.isDividerAllowedAbove = false + holder.isDividerAllowedBelow = false + + holder.findViewById(R.id.settingslib_number_button)?.apply { + setOnClickListener(clickListener) + if (btnContentDescription != 0) { + setContentDescription(context.getString(btnContentDescription, count)) + } + } + (holder.findViewById(R.id.settingslib_number_title) as? TextView)?.text = title + + (holder.findViewById(R.id.settingslib_number_count) as? TextView)?.text = "$count" + } +}
\ No newline at end of file diff --git a/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/SectionButtonPreference.kt b/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/SectionButtonPreference.kt new file mode 100644 index 000000000000..b374dea48d21 --- /dev/null +++ b/packages/SettingsLib/ButtonPreference/src/com/android/settingslib/widget/SectionButtonPreference.kt @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2025 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. + */ + +package com.android.settingslib.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import androidx.preference.Preference +import androidx.preference.PreferenceViewHolder +import com.android.settingslib.widget.preference.button.R +import com.google.android.material.button.MaterialButton + +/** + * A Preference that displays a button with an optional icon. + */ +class SectionButtonPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin { + + private var clickListener: ((View) -> Unit)? = null + set(value) { + field = value + notifyChanged() + } + private var button: MaterialButton? = null + init { + isPersistent = false // This preference doesn't store data + order = Int.MAX_VALUE + layoutResource = R.layout.settingslib_section_button + } + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + holder.isDividerAllowedAbove = false + holder.isDividerAllowedBelow = false + + button = holder.findViewById(R.id.settingslib_section_button) as? MaterialButton + button?.apply{ + text = title + isFocusable = isSelectable + isClickable = isSelectable + setOnClickListener { view -> clickListener?.let { it(view) } } + } + button?.isEnabled = isEnabled + button?.icon = icon + } + + /** + * Set a listener for button click + */ + fun setOnClickListener(listener: (View) -> Unit) { + clickListener = listener + } +}
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_chevron.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_chevron.xml index 94476538a6a5..94476538a6a5 100644 --- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_chevron.xml +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_chevron.xml diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_collapse.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_collapse.xml index 161ece73f21c..161ece73f21c 100644 --- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_collapse.xml +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_collapse.xml diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_cross.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_cross.xml new file mode 100644 index 000000000000..3ba85a2a6c79 --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_cross.xml @@ -0,0 +1,36 @@ +<!-- + Copyright (C) 2025 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> + <shape + android:shape="oval"> + <size android:width="28dp" android:height="28dp"/> + <solid android:color="@color/settingslib_materialColorSurfaceContainerHigh"/> + </shape> + </item> + <item android:gravity="center"> + <vector + android:width="16dp" + android:height="16dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@color/settingslib_materialColorOnSurface" + android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12 19,6.41z"/> + </vector> + </item> +</layer-list> diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_expand.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_expand.xml index 1b5d5182d9b2..1b5d5182d9b2 100644 --- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_expand.xml +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_expand.xml diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_high.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_high.xml new file mode 100644 index 000000000000..aa4155bc939c --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_high.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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> + <vector + android:width="20dp" + android:height="20dp" + android:viewportWidth="20" + android:viewportHeight="20"> + <path + android:pathData="M8.804,0.296C9.554,-0.099 10.446,-0.099 11.196,0.296L12.45,0.955C12.703,1.088 12.976,1.178 13.257,1.221L14.654,1.436C15.489,1.564 16.211,2.096 16.589,2.862L17.223,4.144C17.349,4.402 17.518,4.637 17.721,4.84L18.726,5.847C19.328,6.449 19.603,7.31 19.465,8.155L19.236,9.57C19.189,9.855 19.189,10.145 19.236,10.43L19.465,11.845C19.603,12.69 19.328,13.55 18.726,14.153L17.721,15.16C17.518,15.363 17.349,15.597 17.223,15.856L16.589,17.137C16.211,17.903 15.489,18.435 14.654,18.564L13.257,18.78C12.976,18.822 12.703,18.913 12.45,19.045L11.196,19.704C10.446,20.099 9.554,20.099 8.804,19.704L7.549,19.045C7.297,18.913 7.024,18.822 6.743,18.78L5.346,18.564C4.511,18.435 3.789,17.903 3.411,17.137L2.777,15.856C2.651,15.597 2.482,15.363 2.279,15.16L1.274,14.153C0.672,13.55 0.397,12.69 0.535,11.845L0.764,10.43C0.811,10.145 0.811,9.855 0.764,9.57L0.535,8.155C0.397,7.31 0.672,6.449 1.274,5.847L2.279,4.84C2.482,4.637 2.651,4.402 2.777,4.144L3.411,2.862C3.789,2.096 4.511,1.564 5.346,1.436L6.743,1.221C7.024,1.178 7.297,1.088 7.549,0.955L8.804,0.296Z" + android:fillColor="@color/settingslib_colorBackgroundLevel_high"/> + </vector> + </item> + <item android:gravity="center"> + <vector + android:width="4dp" + android:height="12dp" + android:viewportWidth="4" + android:viewportHeight="12"> + <path + android:pathData="M0.894,8.081V0.919H3.106V8.081H0.894ZM0.894,11.081V8.869H3.106V11.081H0.894Z" + android:fillColor="@color/settingslib_colorContentLevel_high"/> + </vector> + </item> +</layer-list>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_low.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_low.xml new file mode 100644 index 000000000000..9caa09516de9 --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_low.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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> + <vector + android:width="20dp" + android:height="20dp" + android:viewportWidth="20" + android:viewportHeight="20"> + <path + android:pathData="M8.804,0.296C9.554,-0.099 10.446,-0.099 11.196,0.296L12.45,0.955C12.703,1.088 12.976,1.178 13.257,1.221L14.654,1.436C15.489,1.564 16.211,2.096 16.589,2.862L17.223,4.144C17.349,4.402 17.518,4.637 17.721,4.84L18.726,5.847C19.328,6.449 19.603,7.31 19.465,8.155L19.236,9.57C19.189,9.855 19.189,10.145 19.236,10.43L19.465,11.845C19.603,12.69 19.328,13.55 18.726,14.153L17.721,15.16C17.518,15.363 17.349,15.597 17.223,15.856L16.589,17.137C16.211,17.903 15.489,18.435 14.654,18.564L13.257,18.78C12.976,18.822 12.703,18.913 12.45,19.045L11.196,19.704C10.446,20.099 9.554,20.099 8.804,19.704L7.549,19.045C7.297,18.913 7.024,18.822 6.743,18.78L5.346,18.564C4.511,18.435 3.789,17.903 3.411,17.137L2.777,15.856C2.651,15.597 2.482,15.363 2.279,15.16L1.274,14.153C0.672,13.55 0.397,12.69 0.535,11.845L0.764,10.43C0.811,10.145 0.811,9.855 0.764,9.57L0.535,8.155C0.397,7.31 0.672,6.449 1.274,5.847L2.279,4.84C2.482,4.637 2.651,4.402 2.777,4.144L3.411,2.862C3.789,2.096 4.511,1.564 5.346,1.436L6.743,1.221C7.024,1.178 7.297,1.088 7.549,0.955L8.804,0.296Z" + android:fillColor="@color/settingslib_colorBackgroundLevel_low"/> + </vector> + </item> + <item android:gravity="center"> + <vector + android:width="10dp" + android:height="9dp" + android:viewportWidth="10" + android:viewportHeight="9"> + <path + android:pathData="M3.5,8.975L0.069,5.544L1.644,3.969L3.5,5.825L8.356,0.969L9.931,2.544L3.5,8.975Z" + android:fillColor="@color/settingslib_colorContentLevel_low"/> + </vector> + </item> +</layer-list>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_medium.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_medium.xml new file mode 100644 index 000000000000..cdcb98246d56 --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_medium.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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> + <vector + android:width="20dp" + android:height="20dp" + android:viewportWidth="20" + android:viewportHeight="20"> + <path + android:pathData="M8.804,0.296C9.554,-0.099 10.446,-0.099 11.196,0.296L12.45,0.955C12.703,1.088 12.976,1.178 13.257,1.221L14.654,1.436C15.489,1.564 16.211,2.096 16.589,2.862L17.223,4.144C17.349,4.402 17.518,4.637 17.721,4.84L18.726,5.847C19.328,6.449 19.603,7.31 19.465,8.155L19.236,9.57C19.189,9.855 19.189,10.145 19.236,10.43L19.465,11.845C19.603,12.69 19.328,13.55 18.726,14.153L17.721,15.16C17.518,15.363 17.349,15.597 17.223,15.856L16.589,17.137C16.211,17.903 15.489,18.435 14.654,18.564L13.257,18.78C12.976,18.822 12.703,18.913 12.45,19.045L11.196,19.704C10.446,20.099 9.554,20.099 8.804,19.704L7.549,19.045C7.297,18.913 7.024,18.822 6.743,18.78L5.346,18.564C4.511,18.435 3.789,17.903 3.411,17.137L2.777,15.856C2.651,15.597 2.482,15.363 2.279,15.16L1.274,14.153C0.672,13.55 0.397,12.69 0.535,11.845L0.764,10.43C0.811,10.145 0.811,9.855 0.764,9.57L0.535,8.155C0.397,7.31 0.672,6.449 1.274,5.847L2.279,4.84C2.482,4.637 2.651,4.402 2.777,4.144L3.411,2.862C3.789,2.096 4.511,1.564 5.346,1.436L6.743,1.221C7.024,1.178 7.297,1.088 7.549,0.955L8.804,0.296Z" + android:fillColor="@color/settingslib_colorBackgroundLevel_medium"/> + </vector> + </item> + <item android:gravity="center"> + <vector + android:width="4dp" + android:height="12dp" + android:viewportWidth="4" + android:viewportHeight="12"> + <path + android:pathData="M0.894,8.081V0.919H3.106V8.081H0.894ZM0.894,11.081V8.869H3.106V11.081H0.894Z" + android:fillColor="@color/settingslib_colorContentLevel_medium"/> + </vector> + </item> +</layer-list>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_normal.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_normal.xml new file mode 100644 index 000000000000..448d596f05ec --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_level_normal.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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> + <vector + android:width="20dp" + android:height="20dp" + android:viewportWidth="20" + android:viewportHeight="20"> + <path + android:pathData="M8.804,0.296C9.554,-0.099 10.446,-0.099 11.196,0.296L12.45,0.955C12.703,1.088 12.976,1.178 13.257,1.221L14.654,1.436C15.489,1.564 16.211,2.096 16.589,2.862L17.223,4.144C17.349,4.402 17.518,4.637 17.721,4.84L18.726,5.847C19.328,6.449 19.603,7.31 19.465,8.155L19.236,9.57C19.189,9.855 19.189,10.145 19.236,10.43L19.465,11.845C19.603,12.69 19.328,13.55 18.726,14.153L17.721,15.16C17.518,15.363 17.349,15.597 17.223,15.856L16.589,17.137C16.211,17.903 15.489,18.435 14.654,18.564L13.257,18.78C12.976,18.822 12.703,18.913 12.45,19.045L11.196,19.704C10.446,20.099 9.554,20.099 8.804,19.704L7.549,19.045C7.297,18.913 7.024,18.822 6.743,18.78L5.346,18.564C4.511,18.435 3.789,17.903 3.411,17.137L2.777,15.856C2.651,15.597 2.482,15.363 2.279,15.16L1.274,14.153C0.672,13.55 0.397,12.69 0.535,11.845L0.764,10.43C0.811,10.145 0.811,9.855 0.764,9.57L0.535,8.155C0.397,7.31 0.672,6.449 1.274,5.847L2.279,4.84C2.482,4.637 2.651,4.402 2.777,4.144L3.411,2.862C3.789,2.096 4.511,1.564 5.346,1.436L6.743,1.221C7.024,1.178 7.297,1.088 7.549,0.955L8.804,0.296Z" + android:fillColor="@color/settingslib_materialColorOnSurface"/> + </vector> + </item> + <item android:gravity="center"> + <vector + android:width="14dp" + android:height="4dp" + android:viewportWidth="14" + android:viewportHeight="4"> + <path + android:pathData="M0.962,3.106V0.894H13.038V3.106H0.962Z" + android:fillColor="@color/settingslib_materialColorSurface"/> + </vector> + </item> +</layer-list>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_up.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_up.xml new file mode 100644 index 000000000000..c38730534f03 --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_up.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2025 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="960" + android:viewportHeight="960"> + <path + android:fillColor="@color/settingslib_materialColorOnSurface" + android:pathData="M480,432L296,616L240,560L480,320L720,560L664,616L480,432Z"/> +</vector>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference.xml b/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference.xml index 511e2bb64f1e..4ef747a99b49 100644 --- a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference.xml +++ b/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference.xml @@ -19,7 +19,7 @@ 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:minHeight="72dp" android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" diff --git a/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml index e57fe4f512fe..d677bbaa4ee8 100644 --- a/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml +++ b/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml @@ -50,4 +50,9 @@ <color name="settingslib_materialColorSurfaceContainerLow">#0E0E0E</color> <color name="settingslib_materialColorSurfaceContainerHigh">#2A2A2A</color> <color name="settingslib_materialColorSurfaceContainerHighest">#343434</color> + + <color name="settingslib_colorBackgroundLevel_high">@color/m3_ref_palette_red60</color> + <color name="settingslib_colorContentLevel_high">@color/m3_ref_palette_red10</color> + <color name="settingslib_colorBackgroundLevel_low">@color/m3_ref_palette_green70</color> + <color name="settingslib_colorContentLevel_low">@color/m3_ref_palette_green10</color> </resources>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/values/colors.xml b/packages/SettingsLib/SettingsTheme/res/values/colors.xml index c5c613b4b329..e8ab99e6bc14 100644 --- a/packages/SettingsLib/SettingsTheme/res/values/colors.xml +++ b/packages/SettingsLib/SettingsTheme/res/values/colors.xml @@ -76,4 +76,11 @@ <color name="settingslib_materialColorSurfaceContainerLowest">#FFFFFF</color> <color name="settingslib_materialColorSurfaceContainerHigh">#E8E8E8</color> <color name="settingslib_materialColorSurfaceContainerHighest">#E3E3E3</color> + + <color name="settingslib_colorBackgroundLevel_high">@color/m3_ref_palette_red50</color> + <color name="settingslib_colorContentLevel_high">@color/m3_ref_palette_red100</color> + <color name="settingslib_colorBackgroundLevel_medium">@color/m3_ref_palette_yellow80</color> + <color name="settingslib_colorContentLevel_medium">@color/m3_ref_palette_yellow10</color> + <color name="settingslib_colorBackgroundLevel_low">@color/m3_ref_palette_green50</color> + <color name="settingslib_colorContentLevel_low">@color/m3_ref_palette_green100</color> </resources>
\ No newline at end of file |