Load zen mode type icon options from the proper resources
* Move default mode icons from Settings res to core res.
* Add array resources for the icon options and their descriptions.
* As the initial version of the list, use the default mode icons.
Bug: 333901673
Test: atest IconOptionsProviderImplTest
Flag: android.app.modes_ui
Change-Id: I66669e67a9d607268c05d5ed3df6c9555e57864c
diff --git a/res/drawable/ic_zen_mode_type_bedtime.xml b/res/drawable/ic_zen_mode_type_bedtime.xml
deleted file mode 100644
index 7428a71..0000000
--- a/res/drawable/ic_zen_mode_type_bedtime.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M524,920Q440,920 366.5,888Q293,856 238.5,801.5Q184,747 152,673.5Q120,600 120,516Q120,370 213,258.5Q306,147 450,120Q432,219 461,313.5Q490,408 561,479Q632,550 726.5,579Q821,608 920,590Q894,734 782,827Q670,920 524,920ZM524,840Q612,840 687,796Q762,752 805,675Q719,667 642,631.5Q565,596 504,535Q443,474 407,397Q371,320 364,234Q287,277 243.5,352.5Q200,428 200,516Q200,651 294.5,745.5Q389,840 524,840ZM504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Q504,535 504,535Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_driving.xml b/res/drawable/ic_zen_mode_type_driving.xml
deleted file mode 100644
index 3cc0066..0000000
--- a/res/drawable/ic_zen_mode_type_driving.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M240,760L240,800Q240,817 228.5,828.5Q217,840 200,840L160,840Q143,840 131.5,828.5Q120,817 120,800L120,480L204,240Q210,222 225.5,211Q241,200 260,200L700,200Q719,200 734.5,211Q750,222 756,240L840,480L840,800Q840,817 828.5,828.5Q817,840 800,840L760,840Q743,840 731.5,828.5Q720,817 720,800L720,760L240,760ZM232,400L728,400L686,280L274,280L232,400ZM200,480L200,480L200,680L200,680L200,480ZM300,640Q325,640 342.5,622.5Q360,605 360,580Q360,555 342.5,537.5Q325,520 300,520Q275,520 257.5,537.5Q240,555 240,580Q240,605 257.5,622.5Q275,640 300,640ZM660,640Q685,640 702.5,622.5Q720,605 720,580Q720,555 702.5,537.5Q685,520 660,520Q635,520 617.5,537.5Q600,555 600,580Q600,605 617.5,622.5Q635,640 660,640ZM200,680L760,680L760,480L200,480L200,680Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_immersive.xml b/res/drawable/ic_zen_mode_type_immersive.xml
deleted file mode 100644
index 7091357..0000000
--- a/res/drawable/ic_zen_mode_type_immersive.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M440,560L520,560L520,280L440,280L440,560ZM560,500L640,500L640,320L560,320L560,500ZM320,480L400,480L400,320L320,320L320,480ZM240,880L240,708Q183,656 151.5,586.5Q120,517 120,440Q120,290 225,185Q330,80 480,80Q605,80 701.5,153.5Q798,227 827,345L879,550Q884,569 872,584.5Q860,600 840,600L760,600L760,720Q760,753 736.5,776.5Q713,800 680,800L600,800L600,880L520,880L520,720L680,720Q680,720 680,720Q680,720 680,720L680,520L788,520L750,365Q727,274 652,217Q577,160 480,160Q364,160 282,241Q200,322 200,438Q200,498 224.5,552Q249,606 294,648L320,672L320,880L240,880ZM494,520L494,520L494,520Q494,520 494,520Q494,520 494,520Q494,520 494,520Q494,520 494,520Q494,520 494,520Q494,520 494,520L494,520L494,520L494,520Q494,520 494,520Q494,520 494,520L494,520L494,520Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_managed.xml b/res/drawable/ic_zen_mode_type_managed.xml
deleted file mode 100644
index 5e224eb..0000000
--- a/res/drawable/ic_zen_mode_type_managed.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M234,684Q285,645 348,622.5Q411,600 480,600Q549,600 612,622.5Q675,645 726,684Q761,643 780.5,591Q800,539 800,480Q800,347 706.5,253.5Q613,160 480,160Q347,160 253.5,253.5Q160,347 160,480Q160,539 179.5,591Q199,643 234,684ZM480,520Q421,520 380.5,479.5Q340,439 340,380Q340,321 380.5,280.5Q421,240 480,240Q539,240 579.5,280.5Q620,321 620,380Q620,439 579.5,479.5Q539,520 480,520ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q533,800 580,784.5Q627,769 666,740Q627,711 580,695.5Q533,680 480,680Q427,680 380,695.5Q333,711 294,740Q333,769 380,784.5Q427,800 480,800ZM480,440Q506,440 523,423Q540,406 540,380Q540,354 523,337Q506,320 480,320Q454,320 437,337Q420,354 420,380Q420,406 437,423Q454,440 480,440ZM480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380Q480,380 480,380ZM480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Q480,740 480,740Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_other.xml b/res/drawable/ic_zen_mode_type_other.xml
deleted file mode 100644
index d236b0d..0000000
--- a/res/drawable/ic_zen_mode_type_other.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M354,673L480,597L606,674L573,530L684,434L538,421L480,285L422,420L276,433L387,530L354,673ZM233,840L298,559L80,370L368,345L480,80L592,345L880,370L662,559L727,840L480,691L233,840ZM480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_schedule_calendar.xml b/res/drawable/ic_zen_mode_type_schedule_calendar.xml
deleted file mode 100644
index 40004899..0000000
--- a/res/drawable/ic_zen_mode_type_schedule_calendar.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
-
- <path android:fillColor="@android:color/white"
- android:pathData="M17.0,12.0l-5.0,0.0l0.0,5.0l5.0,0.0l0.0,-5.0zM16.0,1.0l0.0,2.0L8.0,3.0L8.0,1.0L6.0,1.0l0.0,2.0L5.0,3.0c-1.11,0.0 -1.9,0.9 -1.99,2.0L3.0,19.0c0.0,1.0 0.89,2.0 2.0,2.0l14.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L21.0,5.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0l-1.0,0.0L18.0,1.0l-2.0,0.0zm3.0,18.0L5.0,19.0L5.0,8.0l14.0,0.0l0.0,11.0z"/>
-</vector>
diff --git a/res/drawable/ic_zen_mode_type_schedule_time.xml b/res/drawable/ic_zen_mode_type_schedule_time.xml
deleted file mode 100644
index 57d596a..0000000
--- a/res/drawable/ic_zen_mode_type_schedule_time.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
- ~ Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M612,668L668,612L520,464L520,280L440,280L440,496L612,668ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480ZM480,800Q613,800 706.5,706.5Q800,613 800,480Q800,347 706.5,253.5Q613,160 480,160Q347,160 253.5,253.5Q160,347 160,480Q160,613 253.5,706.5Q347,800 480,800Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_theater.xml b/res/drawable/ic_zen_mode_type_theater.xml
deleted file mode 100644
index cc66b32..0000000
--- a/res/drawable/ic_zen_mode_type_theater.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M160,840L160,120L240,120L240,200L320,200L320,120L640,120L640,200L720,200L720,120L800,120L800,840L720,840L720,760L640,760L640,840L320,840L320,760L240,760L240,840L160,840ZM240,680L320,680L320,600L240,600L240,680ZM240,520L320,520L320,440L240,440L240,520ZM240,360L320,360L320,280L240,280L240,360ZM640,680L720,680L720,600L640,600L640,680ZM640,520L720,520L720,440L640,440L640,520ZM640,360L720,360L720,280L640,280L640,360ZM400,760L560,760L560,200L400,200L400,760ZM400,200L400,200L560,200L560,200L400,200Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_zen_mode_type_unknown.xml b/res/drawable/ic_zen_mode_type_unknown.xml
deleted file mode 100644
index c1afd44..0000000
--- a/res/drawable/ic_zen_mode_type_unknown.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 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:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M480,880Q407,871 335,840.5Q263,810 206.5,753Q150,696 115,609Q80,522 80,400L80,360L120,360Q171,360 225,373Q279,386 326,412Q338,326 380.5,235.5Q423,145 480,80Q537,145 579.5,235.5Q622,326 634,412Q681,386 735,373Q789,360 840,360L880,360L880,400Q880,522 845,609Q810,696 753.5,753Q697,810 625.5,840.5Q554,871 480,880ZM478,798Q467,632 379.5,547Q292,462 162,442Q173,613 263.5,697Q354,781 478,798ZM480,544Q495,522 516.5,498.5Q538,475 558,458Q556,401 535.5,339Q515,277 480,218Q445,277 424.5,339Q404,401 402,458Q422,475 444,498.5Q466,522 480,544ZM558,780Q595,768 635,745Q675,722 709.5,682.5Q744,643 768.5,584Q793,525 798,442Q704,456 633,504.5Q562,553 524,628Q536,660 544.5,698Q553,736 558,780ZM480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544Q480,544 480,544ZM558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780Q558,780 558,780ZM478,798Q478,798 478,798Q478,798 478,798Q478,798 478,798Q478,798 478,798ZM524,628L524,628Q524,628 524,628Q524,628 524,628L524,628L524,628L524,628Q524,628 524,628Q524,628 524,628L524,628Q524,628 524,628Q524,628 524,628ZM480,880L480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880Q480,880 480,880L480,880Q480,880 480,880Q480,880 480,880L480,880Q480,880 480,880Q480,880 480,880L480,880Z" />
-</vector>
\ No newline at end of file
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 98d93a0..adaea1b 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1525,4 +1525,31 @@
<item>2</item>
</string-array>
+ <!-- TODO: b/333901673 - Get full icon list. -->
+ <array name="zen_mode_icon_options" translatable="false">
+ <item>@*android:drawable/ic_zen_mode_type_bedtime</item>
+ <item>@*android:drawable/ic_zen_mode_type_driving</item>
+ <item>@*android:drawable/ic_zen_mode_type_immersive</item>
+ <item>@*android:drawable/ic_zen_mode_type_managed</item>
+ <item>@*android:drawable/ic_zen_mode_type_other</item>
+ <item>@*android:drawable/ic_zen_mode_type_schedule_calendar</item>
+ <item>@*android:drawable/ic_zen_mode_type_schedule_time</item>
+ <item>@*android:drawable/ic_zen_mode_type_theater</item>
+ <item>@*android:drawable/ic_zen_mode_type_unknown</item>
+ </array>
+
+ <!-- TODO: b/333901673 - Complete list -->
+ <!-- Descriptions of the icons in zen_mode_icon_options. Should describe the associated image
+ [CHAR LIMIT=NONE] -->
+ <string-array name="zen_mode_icon_options_descriptions">
+ <item>Bedtime</item>
+ <item>Driving</item>
+ <item>Immersive</item>
+ <item>Managed</item>
+ <item>Star</item>
+ <item>Calendar</item>
+ <item>Time</item>
+ <item>Theater</item>
+ <item>Flower</item>
+ </string-array>
</resources>
diff --git a/src/com/android/settings/notification/modes/IconLoader.java b/src/com/android/settings/notification/modes/IconLoader.java
index 8a02093..c590285 100644
--- a/src/com/android/settings/notification/modes/IconLoader.java
+++ b/src/com/android/settings/notification/modes/IconLoader.java
@@ -36,8 +36,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.content.res.AppCompatResources;
-import com.android.settings.R;
-
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
@@ -123,17 +121,26 @@
private static Drawable getFallbackIcon(Context context, int ruleType) {
int iconResIdFromType = switch (ruleType) {
- case AutomaticZenRule.TYPE_UNKNOWN -> R.drawable.ic_zen_mode_type_unknown;
- case AutomaticZenRule.TYPE_OTHER -> R.drawable.ic_zen_mode_type_other;
- case AutomaticZenRule.TYPE_SCHEDULE_TIME -> R.drawable.ic_zen_mode_type_schedule_time;
+ case AutomaticZenRule.TYPE_UNKNOWN ->
+ com.android.internal.R.drawable.ic_zen_mode_type_unknown;
+ case AutomaticZenRule.TYPE_OTHER ->
+ com.android.internal.R.drawable.ic_zen_mode_type_other;
+ case AutomaticZenRule.TYPE_SCHEDULE_TIME ->
+ com.android.internal.R.drawable.ic_zen_mode_type_schedule_time;
case AutomaticZenRule.TYPE_SCHEDULE_CALENDAR ->
- R.drawable.ic_zen_mode_type_schedule_calendar;
- case AutomaticZenRule.TYPE_BEDTIME -> R.drawable.ic_zen_mode_type_bedtime;
- case AutomaticZenRule.TYPE_DRIVING -> R.drawable.ic_zen_mode_type_driving;
- case AutomaticZenRule.TYPE_IMMERSIVE -> R.drawable.ic_zen_mode_type_immersive;
- case AutomaticZenRule.TYPE_THEATER -> R.drawable.ic_zen_mode_type_theater;
- case AutomaticZenRule.TYPE_MANAGED -> R.drawable.ic_zen_mode_type_managed;
- default -> R.drawable.ic_zen_mode_type_unknown;
+ com.android.internal.R.drawable.ic_zen_mode_type_schedule_calendar;
+ case AutomaticZenRule.TYPE_BEDTIME ->
+ com.android.internal.R.drawable.ic_zen_mode_type_bedtime;
+ case AutomaticZenRule.TYPE_DRIVING ->
+ com.android.internal.R.drawable.ic_zen_mode_type_driving;
+ case AutomaticZenRule.TYPE_IMMERSIVE ->
+ com.android.internal.R.drawable.ic_zen_mode_type_immersive;
+ case AutomaticZenRule.TYPE_THEATER ->
+ com.android.internal.R.drawable.ic_zen_mode_type_theater;
+ case AutomaticZenRule.TYPE_MANAGED ->
+ com.android.internal.R.drawable.ic_zen_mode_type_managed;
+ default ->
+ com.android.internal.R.drawable.ic_zen_mode_type_unknown;
};
return requireNonNull(context.getDrawable(iconResIdFromType));
}
diff --git a/src/com/android/settings/notification/modes/IconOptionsProvider.java b/src/com/android/settings/notification/modes/IconOptionsProvider.java
index 288aff2..cd00664 100644
--- a/src/com/android/settings/notification/modes/IconOptionsProvider.java
+++ b/src/com/android/settings/notification/modes/IconOptionsProvider.java
@@ -17,12 +17,13 @@
package com.android.settings.notification.modes;
import androidx.annotation.DrawableRes;
+import androidx.annotation.NonNull;
import com.google.common.collect.ImmutableList;
interface IconOptionsProvider {
- ImmutableList<IconInfo> getIcons();
+ @NonNull ImmutableList<IconInfo> getIcons();
record IconInfo(@DrawableRes int resId, String description) { }
}
diff --git a/src/com/android/settings/notification/modes/IconOptionsProviderImpl.java b/src/com/android/settings/notification/modes/IconOptionsProviderImpl.java
new file mode 100644
index 0000000..f296ae1
--- /dev/null
+++ b/src/com/android/settings/notification/modes/IconOptionsProviderImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2024 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.settings.notification.modes;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.Log;
+
+import androidx.annotation.DrawableRes;
+import androidx.annotation.NonNull;
+
+import com.android.settings.R;
+
+import com.google.common.collect.ImmutableList;
+
+class IconOptionsProviderImpl implements IconOptionsProvider {
+
+ private static final String TAG = "IconOptionsProviderImpl";
+
+ private final Context mContext;
+
+ IconOptionsProviderImpl(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ @Override
+ @NonNull
+ public ImmutableList<IconInfo> getIcons() {
+ ImmutableList.Builder<IconInfo> list = ImmutableList.builder();
+ try (TypedArray icons = mContext.getResources().obtainTypedArray(
+ R.array.zen_mode_icon_options)) {
+ String[] descriptions = mContext.getResources().getStringArray(
+ R.array.zen_mode_icon_options_descriptions);
+ if (icons.length() != descriptions.length) {
+ Log.wtf(TAG, "Size mismatch between zen_mode_icon_options (" + icons.length()
+ + ") and zen_mode_icon_options_descriptions (" + descriptions.length + ")");
+ }
+
+ for (int i = 0; i < Math.min(icons.length(), descriptions.length); i++) {
+ @DrawableRes int resId = icons.getResourceId(i, 0);
+ if (resId != 0) {
+ list.add(new IconInfo(resId, descriptions[i]));
+ }
+ }
+ }
+ return list.build();
+ }
+}
diff --git a/src/com/android/settings/notification/modes/TempIconOptionsProvider.java b/src/com/android/settings/notification/modes/TempIconOptionsProvider.java
deleted file mode 100644
index 06c5c27..0000000
--- a/src/com/android/settings/notification/modes/TempIconOptionsProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2024 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.settings.notification.modes;
-
-import com.google.common.collect.ImmutableList;
-
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Objects;
-
-/** Temporary implementation of {@link IconOptionsProvider} until we have the real list. */
-class TempIconOptionsProvider implements IconOptionsProvider {
- @Override
- public ImmutableList<IconInfo> getIcons() {
- return ImmutableList.copyOf(
- Arrays.stream(com.android.internal.R.drawable.class.getFields())
- .filter(
- f -> Modifier.isStatic(f.getModifiers())
- && Modifier.isFinal(f.getModifiers())
- && f.getName().startsWith("ic_"))
- .limit(20)
- .map(f -> {
- try {
- return new IconInfo(f.getInt(null), f.getName());
- } catch (IllegalAccessException e) {
- return null;
- }
- })
- .filter(Objects::nonNull)
- .sorted(Comparator.comparing(IconInfo::resId).reversed())
- .toList());
- }
-}
diff --git a/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java b/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java
index 553d3eb..760b183 100644
--- a/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java
+++ b/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java
@@ -44,7 +44,6 @@
new ZenModeIconPickerIconPreferenceController(context, "current_icon", this,
mBackend),
new ZenModeIconPickerListPreferenceController(context, "icon_list", this,
- // TODO: b/333901673 - Replace with correct icon list.
- new TempIconOptionsProvider(), mBackend));
+ new IconOptionsProviderImpl(mContext), mBackend));
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/modes/IconOptionsProviderImplTest.java b/tests/robotests/src/com/android/settings/notification/modes/IconOptionsProviderImplTest.java
new file mode 100644
index 0000000..d5430b1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/modes/IconOptionsProviderImplTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2024 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.settings.notification.modes;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+
+import com.android.settings.R;
+
+import com.google.common.collect.ImmutableList;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class IconOptionsProviderImplTest {
+
+ private static final int EXPECTED_NUMBER_OF_ICON_OPTIONS = 9;
+
+ @Test
+ public void iconResources_correctResources() {
+ Context context = RuntimeEnvironment.getApplication();
+ String[] descriptions = context.getResources().getStringArray(
+ R.array.zen_mode_icon_options_descriptions);
+ assertThat(descriptions).hasLength(EXPECTED_NUMBER_OF_ICON_OPTIONS);
+
+ try (TypedArray icons = context.getResources().obtainTypedArray(
+ R.array.zen_mode_icon_options)) {
+ assertThat(icons.length()).isEqualTo(EXPECTED_NUMBER_OF_ICON_OPTIONS);
+ }
+ }
+
+ @Test
+ public void getIcons_returnsList() {
+ Context context = RuntimeEnvironment.getApplication();
+ IconOptionsProviderImpl provider = new IconOptionsProviderImpl(context);
+
+ ImmutableList<IconOptionsProvider.IconInfo> iconOptions = provider.getIcons();
+ assertThat(iconOptions).hasSize(EXPECTED_NUMBER_OF_ICON_OPTIONS);
+ for (int i = 0; i < iconOptions.size(); i++) {
+ assertWithMessage("Checking description of item #" + i)
+ .that(iconOptions.get(i).description()).isNotEmpty();
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java
index 5f7ffa2..ba9a6b8 100644
--- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java
@@ -27,6 +27,7 @@
import android.content.Context;
import android.net.Uri;
+import androidx.annotation.NonNull;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
@@ -95,6 +96,7 @@
private static class TestIconOptionsProvider implements IconOptionsProvider {
@Override
+ @NonNull
public ImmutableList<IconInfo> getIcons() {
return ImmutableList.of(
new IconInfo(R.drawable.ic_android, "android"),