1+ < meta charset ="utf-8 ">
2+ (#) Ongoing activity icon is not white
3+
4+ !!! WARNING: Ongoing activity icon is not white
5+ This is a warning.
6+
7+ Id
8+ : `ActivityIconColor`
9+ Summary
10+ : Ongoing activity icon is not white
11+ Severity
12+ : Warning
13+ Category
14+ : Usability: Icons
15+ Platform
16+ : Android
17+ Vendor
18+ : Android Open Source Project
19+ Feedback
20+ : https://issuetracker.google.com/issues/new?component=192708
21+ Affects
22+ : Kotlin and Java files, binary resource files and resource files
23+ Editing
24+ : This check can *not* run live in the IDE editor
25+ See
26+ : https://developer.android.com/training/wearables/ongoing-activity#best-practices
27+ Implementation
28+ : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ActivityIconColorDetector.kt)
29+ Tests
30+ : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ActivityIconColorDetectorTest.kt)
31+ Copyright Year
32+ : 2022
33+
34+ The resources passed to `setAnimatedIcon` and `setStaticIcon` should be
35+ white with a transparent background, preferably a VectorDrawable or
36+ AnimatedVectorDrawable.
37+
38+ (##) Example
39+
40+ Here is an example of lint warnings produced by this check:
41+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
42+ src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:9:Warning: The
43+ animated icon for an ongoing activity should be white with a transparent
44+ background [ActivityIconColor]
45+
46+ .setAnimatedIcon(R.drawable.animated_walk)
47+ ------------------------
48+
49+
50+ src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:10:Warning: The
51+ static icon for an ongoing activity should be white with a transparent
52+ background [ActivityIconColor]
53+
54+ .setStaticIcon(R.drawable.ic_walk)
55+ ------------------
56+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57+
58+ Here is the source file referenced above:
59+
60+ `src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt`:
61+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
62+ package test.pkg;
63+
64+ import androidx.wear.ongoing.OngoingActivity
65+
66+ class ForegroundOnlyWalkingWorkoutService {
67+ private fun generateNotification(mainText: String) {
68+ val ongoingActivity =
69+ OngoingActivity.Builder()
70+ .setAnimatedIcon(R.drawable.animated_walk)
71+ .setStaticIcon(R.drawable.ic_walk)
72+ .build()
73+ }
74+ }
75+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+ You can also visit the
78+ [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ActivityIconColorDetectorTest.kt)
79+ for the unit tests for this check to see additional scenarios.
80+
81+ (##) Suppressing
82+
83+ You can suppress false positives using one of the following mechanisms:
84+
85+ * Using a suppression annotation like this on the enclosing
86+ element:
87+
88+ ```kt
89+ // Kotlin
90+ @Suppress("ActivityIconColor")
91+ fun method() {
92+ setAnimatedIcon(...)
93+ }
94+ ```
95+
96+ or
97+
98+ ```java
99+ // Java
100+ @SuppressWarnings("ActivityIconColor")
101+ void method() {
102+ setAnimatedIcon(...);
103+ }
104+ ```
105+
106+ * Using a suppression comment like this on the line above:
107+
108+ ```kt
109+ //noinspection ActivityIconColor
110+ problematicStatement()
111+ ```
112+
113+ * Adding the suppression attribute `tools:ignore="ActivityIconColor"`
114+ on the problematic XML element (or one of its enclosing elements).
115+ You may also need to add the following namespace declaration on the
116+ root element in the XML file if it's not already there:
117+ `xmlns:tools="http://schemas.android.com/tools"`.
118+
119+ * Using a special `lint.xml` file in the source tree which turns off
120+ the check in that folder and any sub folder. A simple file might look
121+ like this:
122+ ```xml
123+ <?xml version="1.0" encoding="UTF-8"?>
124+ <lint>
125+ <issue id="ActivityIconColor" severity="ignore" />
126+ </lint>
127+ ```
128+ Instead of `ignore` you can also change the severity here, for
129+ example from `error` to `warning`. You can find additional
130+ documentation on how to filter issues by path, regular expression and
131+ so on
132+ [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
133+
134+ * In Gradle projects, using the DSL syntax to configure lint. For
135+ example, you can use something like
136+ ```gradle
137+ lintOptions {
138+ disable 'ActivityIconColor'
139+ }
140+ ```
141+ In Android projects this should be nested inside an `android { }`
142+ block.
143+
144+ * For manual invocations of `lint`, using the `--ignore` flag:
145+ ```
146+ $ lint --ignore ActivityIconColor ...`
147+ ```
148+
149+ * Last, but not least, using baselines, as discussed
150+ [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
151+
152+ <!-- Markdeep: --> < style class ="fallback "> body {visibility : hidden;white-space : pre;font-family : monospace}</ style > < script src ="markdeep.min.js " charset ="utf-8 "> </ script > < script src ="https://morgan3d.github.io/markdeep/latest/markdeep.min.js " charset ="utf-8 "> </ script > < script > window . alreadyProcessedMarkdeep || ( document . body . style . visibility = "visible" ) </ script >
0 commit comments