summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Liu <dswliu@google.com> 2025-03-20 21:57:33 -0700
committer David Liu <dswliu@google.com> 2025-03-20 21:57:33 -0700
commit5055c7185bfc877ccbdf3f09795f365d8442ea0c (patch)
treea822750718153ab4fd3ba6b3a4a022fad676a143
parent6b896df3fceac3de65cd07b134b5625e3e59b5de (diff)
[Settingslib] Support outlined style for SettingsSpinner
Bug: 394697569 Test: manual Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled Change-Id: I72d8ffbd85bd58c4e5ef1adf3ee041f928983af6
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_full_outlined.xml33
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_outlined.xml33
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_full_outlined.xml26
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_large_outlined.xml26
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressvie_spinner_view_outlined.xml26
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/values-v36/attr.xml2
-rw-r--r--packages/SettingsLib/SettingsSpinner/res/values-v36/styles.xml8
-rw-r--r--packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerAdapter.java8
-rw-r--r--packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java9
-rw-r--r--packages/SettingsLib/SettingsTheme/res/drawable-v36/settingslib_expressive_spinner_background_outlined.xml55
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v36/styles_expressive.xml4
11 files changed, 228 insertions, 2 deletions
diff --git a/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_full_outlined.xml b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_full_outlined.xml
new file mode 100644
index 000000000000..217d1431cd18
--- /dev/null
+++ b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_full_outlined.xml
@@ -0,0 +1,33 @@
+<?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.
+-->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:filterTouchesWhenObscured="true">
+
+ <Spinner
+ android:id="@+id/spinner"
+ style="@style/SettingslibSpinnerStyle.Expressive.Outlined"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"/>
+</RelativeLayout>
diff --git a/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_outlined.xml b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_outlined.xml
new file mode 100644
index 000000000000..3aefb887cedb
--- /dev/null
+++ b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_preference_outlined.xml
@@ -0,0 +1,33 @@
+<?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.
+-->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:filterTouchesWhenObscured="true">
+
+ <Spinner
+ android:id="@+id/spinner"
+ style="@style/SettingslibSpinnerStyle.Expressive.Outlined"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"/>
+</RelativeLayout>
diff --git a/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_full_outlined.xml b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_full_outlined.xml
new file mode 100644
index 000000000000..2c172e955a09
--- /dev/null
+++ b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_full_outlined.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_centerVertical="true"
+ android:gravity="center_vertical"
+ style="@style/SettingsSpinnerTitleBar.Expressive.Large.Outlined"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:filterTouchesWhenObscured="true"/>
diff --git a/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_large_outlined.xml b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_large_outlined.xml
new file mode 100644
index 000000000000..6601c8cd97a5
--- /dev/null
+++ b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressive_spinner_view_large_outlined.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_centerVertical="true"
+ android:gravity="center_vertical"
+ style="@style/SettingsSpinnerTitleBar.Expressive.Large.Outlined"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:filterTouchesWhenObscured="true"/>
diff --git a/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressvie_spinner_view_outlined.xml b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressvie_spinner_view_outlined.xml
new file mode 100644
index 000000000000..73e254e9bc15
--- /dev/null
+++ b/packages/SettingsLib/SettingsSpinner/res/layout-v36/settings_expressvie_spinner_view_outlined.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_centerVertical="true"
+ android:gravity="center_vertical"
+ style="@style/SettingsSpinnerTitleBar.Expressive.Outlined"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:filterTouchesWhenObscured="true"/>
diff --git a/packages/SettingsLib/SettingsSpinner/res/values-v36/attr.xml b/packages/SettingsLib/SettingsSpinner/res/values-v36/attr.xml
index d40cd565e8ce..154149acf26d 100644
--- a/packages/SettingsLib/SettingsSpinner/res/values-v36/attr.xml
+++ b/packages/SettingsLib/SettingsSpinner/res/values-v36/attr.xml
@@ -18,6 +18,8 @@
<enum name="large" value="1"/>
<enum name="full" value="2"/>
<enum name="outlined" value="3"/>
+ <enum name="large_outlined" value="4"/>
+ <enum name="full_outlined" value="5"/>
</attr>
</declare-styleable>
</resources>
diff --git a/packages/SettingsLib/SettingsSpinner/res/values-v36/styles.xml b/packages/SettingsLib/SettingsSpinner/res/values-v36/styles.xml
index 219788733eca..2cb4518af287 100644
--- a/packages/SettingsLib/SettingsSpinner/res/values-v36/styles.xml
+++ b/packages/SettingsLib/SettingsSpinner/res/values-v36/styles.xml
@@ -33,6 +33,14 @@
<item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
</style>
+ <style name="SettingsSpinnerTitleBar.Expressive.Outlined">
+ <item name="android:textColor">@color/settingslib_materialColorPrimary</item>
+ </style>
+
+ <style name="SettingsSpinnerTitleBar.Expressive.Large.Outlined">
+ <item name="android:textColor">@color/settingslib_materialColorPrimary</item>
+ </style>
+
<style name="SettingsSpinnerDropdown.Expressive">
<item name="android:background">@drawable/settings_expressive_spinner_dropdown_background</item>
<item name="android:minHeight">@dimen/spinner_dropdown_height</item>
diff --git a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerAdapter.java b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerAdapter.java
index 67bc82ccf100..2f9f7038f6f7 100644
--- a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerAdapter.java
+++ b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerAdapter.java
@@ -100,7 +100,13 @@ public class SettingsSpinnerAdapter<T> extends ArrayAdapter<T> {
return R.layout.settings_expressive_spinner_view_full;
}
case OUTLINED -> {
- return DEFAULT_RESOURCE;
+ return R.layout.settings_expressvie_spinner_view_outlined;
+ }
+ case LARGE_OUTLINED -> {
+ return R.layout.settings_expressive_spinner_view_large_outlined;
+ }
+ case FULL_OUTLINED -> {
+ return R.layout.settings_expressive_spinner_view_full_outlined;
}
default -> {
return DEFAULT_RESOURCE;
diff --git a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
index 096cec0d58a7..b357369155b6 100644
--- a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
+++ b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
@@ -87,6 +87,8 @@ public class SettingsSpinnerPreference extends Preference
LARGE,
FULL_WIDTH,
OUTLINED,
+ LARGE_OUTLINED,
+ FULL_OUTLINED,
}
private void initAttributes(
@@ -98,6 +100,9 @@ public class SettingsSpinnerPreference extends Preference
int style = a.getInteger(R.styleable.SettingsSpinnerPreference_style, 0);
switch (style) {
case 2 -> layoutRes = R.layout.settings_expressive_spinner_preference_full;
+ case 3 -> layoutRes = R.layout.settings_expressive_spinner_preference_outlined;
+ case 4 -> layoutRes = R.layout.settings_expressive_spinner_preference_outlined;
+ case 5 -> layoutRes = R.layout.settings_expressive_spinner_preference_full_outlined;
default -> layoutRes = R.layout.settings_spinner_preference;
}
}
@@ -143,7 +148,9 @@ public class SettingsSpinnerPreference extends Preference
if (spinner == null) {
return;
}
- mAdapter.setSelectedPosition(mPosition);
+ if (mAdapter != null) {
+ mAdapter.setSelectedPosition(mPosition);
+ }
spinner.setAdapter(mAdapter);
spinner.setSelection(mPosition);
spinner.setOnItemSelectedListener(mOnSelectedListener);
diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v36/settingslib_expressive_spinner_background_outlined.xml b/packages/SettingsLib/SettingsTheme/res/drawable-v36/settingslib_expressive_spinner_background_outlined.xml
new file mode 100644
index 000000000000..f32e13e7f83a
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/drawable-v36/settingslib_expressive_spinner_background_outlined.xml
@@ -0,0 +1,55 @@
+<?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.
+ -->
+
+<ripple
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+
+ <item android:id="@android:id/background">
+ <layer-list
+ android:paddingMode="stack"
+ android:paddingStart="0dp"
+ android:paddingEnd="@dimen/settingslib_expressive_space_small4">
+ <item>
+ <shape>
+ <corners android:radius="@dimen/settingslib_expressive_radius_full"/>
+ <stroke
+ android:color="@color/settingslib_materialColorOutlineVariant"
+ android:width="1dp"/>
+ <size android:height="@dimen/settingslib_expressive_space_medium3"/>
+ </shape>
+ </item>
+
+ <item
+ android:gravity="center|end"
+ android:width="@dimen/settingslib_expressive_space_small4"
+ android:height="@dimen/settingslib_expressive_space_small4"
+ android:end="@dimen/settingslib_expressive_space_small1">
+ <vector
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="@color/settingslib_materialColorPrimary">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6 -1.41,-1.41z"/>
+ </vector>
+ </item>
+ </layer-list>
+ </item>
+</ripple>
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v36/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values-v36/styles_expressive.xml
index 94cad47c4fd0..9cdbce4a4c78 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v36/styles_expressive.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v36/styles_expressive.xml
@@ -38,6 +38,10 @@
<item name="android:dropDownVerticalOffset">@dimen/settingslib_expressive_space_large3</item>
</style>
+ <style name="SettingslibSpinnerStyle.Expressive.Outlined">
+ <item name="android:background">@drawable/settingslib_expressive_spinner_background_outlined</item>
+ </style>
+
<style name="EntityHeader">
<item name="android:paddingTop">@dimen/settingslib_expressive_space_small4</item>
<item name="android:paddingBottom">@dimen/settingslib_expressive_space_small1</item>