Add default icons for all mode types
Also a couple of icon-related fixes:
* Use the proper context, since we need theming (this also means it cannot be stored in IconLoader, which is a singleton, and must be supplied).
* Force apply the standard size and tint, since app-provided icons may be arbitrary.
* Fix the schedule-time icon (the viewport size was incorrect).
Bug: 308819461
Fixes: 333528437
Flag: android.app.modes_ui
Test: atest com.android.settings.notification.modes
Change-Id: Iae447c8c4a0218a8bc989c01d1d56d0c06abd8e7
diff --git a/res/drawable/ic_modes_time.xml b/res/drawable/ic_modes_time.xml
deleted file mode 100644
index dff3c43..0000000
--- a/res/drawable/ic_modes_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="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="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_bedtime.xml b/res/drawable/ic_zen_mode_type_bedtime.xml
new file mode 100644
index 0000000..7428a71
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_bedtime.xml
@@ -0,0 +1,25 @@
+<!--
+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
new file mode 100644
index 0000000..3cc0066
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_driving.xml
@@ -0,0 +1,25 @@
+<!--
+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
new file mode 100644
index 0000000..7091357
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_immersive.xml
@@ -0,0 +1,25 @@
+<!--
+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
new file mode 100644
index 0000000..5e224eb
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_managed.xml
@@ -0,0 +1,25 @@
+<!--
+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
new file mode 100644
index 0000000..d236b0d
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_other.xml
@@ -0,0 +1,25 @@
+<!--
+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_modes_event.xml b/res/drawable/ic_zen_mode_type_schedule_calendar.xml
similarity index 100%
rename from res/drawable/ic_modes_event.xml
rename to res/drawable/ic_zen_mode_type_schedule_calendar.xml
diff --git a/res/drawable/ic_zen_mode_type_schedule_time.xml b/res/drawable/ic_zen_mode_type_schedule_time.xml
new file mode 100644
index 0000000..57d596a
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_schedule_time.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ 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
new file mode 100644
index 0000000..cc66b32
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_theater.xml
@@ -0,0 +1,25 @@
+<!--
+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
new file mode 100644
index 0000000..c1afd44
--- /dev/null
+++ b/res/drawable/ic_zen_mode_type_unknown.xml
@@ -0,0 +1,25 @@
+<!--
+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/src/com/android/settings/notification/modes/IconLoader.java b/src/com/android/settings/notification/modes/IconLoader.java
index b7a6c95..8a02093 100644
--- a/src/com/android/settings/notification/modes/IconLoader.java
+++ b/src/com/android/settings/notification/modes/IconLoader.java
@@ -56,47 +56,42 @@
@Nullable // Until first usage
private static IconLoader sInstance;
- private final Context mContext;
private final LruCache<String, Drawable> mCache;
private final ListeningExecutorService mBackgroundExecutor;
- static IconLoader getInstance(Context context) {
+ static IconLoader getInstance() {
if (sInstance == null) {
- sInstance = new IconLoader(context);
+ sInstance = new IconLoader();
}
return sInstance;
}
- private IconLoader(Context context) {
- this(context, Executors.newFixedThreadPool(4));
+ private IconLoader() {
+ this(Executors.newFixedThreadPool(4));
}
@VisibleForTesting
- IconLoader(Context context, ExecutorService backgroundExecutor) {
- mContext = context.getApplicationContext();
+ IconLoader(ExecutorService backgroundExecutor) {
mCache = new LruCache<>(50);
mBackgroundExecutor =
MoreExecutors.listeningDecorator(backgroundExecutor);
}
- Context getContext() {
- return mContext;
- }
-
@NonNull
- ListenableFuture<Drawable> getIcon(@NonNull AutomaticZenRule rule) {
+ ListenableFuture<Drawable> getIcon(Context context, @NonNull AutomaticZenRule rule) {
if (rule.getIconResId() == 0) {
- return Futures.immediateFuture(getFallbackIcon(rule.getType()));
+ return Futures.immediateFuture(getFallbackIcon(context, rule.getType()));
}
- return FluentFuture.from(loadIcon(rule.getPackageName(), rule.getIconResId()))
+ return FluentFuture.from(loadIcon(context, rule.getPackageName(), rule.getIconResId()))
.transform(icon ->
- icon != null ? icon : getFallbackIcon(rule.getType()),
+ icon != null ? icon : getFallbackIcon(context, rule.getType()),
MoreExecutors.directExecutor());
}
@NonNull
- private ListenableFuture</* @Nullable */ Drawable> loadIcon(String pkg, int iconResId) {
+ private ListenableFuture</* @Nullable */ Drawable> loadIcon(Context context, String pkg,
+ int iconResId) {
String cacheKey = pkg + ":" + iconResId;
synchronized (mCache) {
Drawable cachedValue = mCache.get(cacheKey);
@@ -107,9 +102,9 @@
return FluentFuture.from(mBackgroundExecutor.submit(() -> {
if (TextUtils.isEmpty(pkg) || SystemZenRules.PACKAGE_ANDROID.equals(pkg)) {
- return mContext.getDrawable(iconResId);
+ return context.getDrawable(iconResId);
} else {
- Context appContext = mContext.createPackageContext(pkg, 0);
+ Context appContext = context.createPackageContext(pkg, 0);
Drawable appDrawable = AppCompatResources.getDrawable(appContext, iconResId);
return getMonochromeIconIfPresent(appDrawable);
}
@@ -126,21 +121,21 @@
}, MoreExecutors.directExecutor());
}
- private Drawable getFallbackIcon(int ruleType) {
+ private static Drawable getFallbackIcon(Context context, int ruleType) {
int iconResIdFromType = switch (ruleType) {
- // TODO: b/333528437 - continue replacing with proper default icons
- case AutomaticZenRule.TYPE_UNKNOWN -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_OTHER -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_SCHEDULE_TIME -> R.drawable.ic_modes_time;
- case AutomaticZenRule.TYPE_SCHEDULE_CALENDAR -> R.drawable.ic_modes_event;
- case AutomaticZenRule.TYPE_BEDTIME -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_DRIVING -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_IMMERSIVE -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_THEATER -> R.drawable.ic_do_not_disturb_on_24dp;
- case AutomaticZenRule.TYPE_MANAGED -> R.drawable.ic_do_not_disturb_on_24dp;
- default -> R.drawable.ic_do_not_disturb_on_24dp;
+ 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_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;
};
- return requireNonNull(mContext.getDrawable(iconResIdFromType));
+ return requireNonNull(context.getDrawable(iconResIdFromType));
}
private static Drawable getMonochromeIconIfPresent(Drawable icon) {
diff --git a/src/com/android/settings/notification/modes/ZenMode.java b/src/com/android/settings/notification/modes/ZenMode.java
index 058799b..1be7e5f 100644
--- a/src/com/android/settings/notification/modes/ZenMode.java
+++ b/src/com/android/settings/notification/modes/ZenMode.java
@@ -118,14 +118,14 @@
}
@NonNull
- public ListenableFuture<Drawable> getIcon(@NonNull IconLoader iconLoader) {
- Context context = iconLoader.getContext();
+ public ListenableFuture<Drawable> getIcon(@NonNull Context context,
+ @NonNull IconLoader iconLoader) {
if (mIsManualDnd) {
return Futures.immediateFuture(requireNonNull(
context.getDrawable(R.drawable.ic_do_not_disturb_on_24dp)));
}
- return iconLoader.getIcon(mRule);
+ return iconLoader.getIcon(context, mRule);
}
@NonNull
diff --git a/src/com/android/settings/notification/modes/ZenModeHeaderController.java b/src/com/android/settings/notification/modes/ZenModeHeaderController.java
index fc20710..ba6e9d9 100644
--- a/src/com/android/settings/notification/modes/ZenModeHeaderController.java
+++ b/src/com/android/settings/notification/modes/ZenModeHeaderController.java
@@ -62,7 +62,7 @@
}
FutureUtil.whenDone(
- zenMode.getIcon(IconLoader.getInstance(mContext)),
+ zenMode.getIcon(mContext, IconLoader.getInstance()),
icon -> mHeaderController.setIcon(icon)
.setLabel(zenMode.getRule().getName())
.done(false /* rebindActions */),
diff --git a/src/com/android/settings/notification/modes/ZenModeListPreference.java b/src/com/android/settings/notification/modes/ZenModeListPreference.java
index 0f4728f..c897d5b 100644
--- a/src/com/android/settings/notification/modes/ZenModeListPreference.java
+++ b/src/com/android/settings/notification/modes/ZenModeListPreference.java
@@ -24,6 +24,7 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.notification.zen.ZenModeSettings;
import com.android.settingslib.RestrictedPreference;
+import com.android.settingslib.Utils;
/**
* Preference representing a single mode item on the modes aggregator page. Clicking on this
@@ -64,10 +65,15 @@
mZenMode = zenMode;
setTitle(mZenMode.getRule().getName());
setSummary(mZenMode.getRule().getTriggerDescription());
+ setIconSize(ICON_SIZE_SMALL);
FutureUtil.whenDone(
- mZenMode.getIcon(IconLoader.getInstance(mContext)),
- icon -> setIcon(icon),
+ mZenMode.getIcon(mContext, IconLoader.getInstance()),
+ icon -> {
+ icon.setTintList(
+ Utils.getColorAttr(mContext, android.R.attr.colorControlNormal));
+ setIcon(icon);
+ },
mContext.getMainExecutor());
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/modes/IconLoaderTest.java b/tests/robotests/src/com/android/settings/notification/modes/IconLoaderTest.java
index a92e618..7d4a367 100644
--- a/tests/robotests/src/com/android/settings/notification/modes/IconLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/notification/modes/IconLoaderTest.java
@@ -21,6 +21,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.app.AutomaticZenRule;
+import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.service.notification.ZenPolicy;
@@ -37,12 +38,13 @@
@RunWith(RobolectricTestRunner.class)
public class IconLoaderTest {
+ private Context mContext;
private IconLoader mLoader;
@Before
public void setUp() {
- mLoader = new IconLoader(RuntimeEnvironment.application,
- MoreExecutors.newDirectExecutorService());
+ mContext = RuntimeEnvironment.application;
+ mLoader = new IconLoader(MoreExecutors.newDirectExecutorService());
}
@Test
@@ -52,7 +54,7 @@
.setIconResId(android.R.drawable.ic_media_play)
.build();
- ListenableFuture<Drawable> loadFuture = mLoader.getIcon(systemRule);
+ ListenableFuture<Drawable> loadFuture = mLoader.getIcon(mContext, systemRule);
assertThat(loadFuture.isDone()).isTrue();
assertThat(loadFuture.get()).isNotNull();
}
@@ -64,7 +66,7 @@
.setPackage("com.blah")
.build();
- ListenableFuture<Drawable> loadFuture = mLoader.getIcon(rule);
+ ListenableFuture<Drawable> loadFuture = mLoader.getIcon(mContext, rule);
assertThat(loadFuture.isDone()).isTrue();
assertThat(loadFuture.get()).isNotNull();
}
@@ -77,7 +79,7 @@
.setIconResId(-123456)
.build();
- ListenableFuture<Drawable> loadFuture = mLoader.getIcon(rule);
+ ListenableFuture<Drawable> loadFuture = mLoader.getIcon(mContext, rule);
assertThat(loadFuture.get()).isNotNull();
}