Skip to content

Commit d5a3b7a

Browse files
committed
Fix lint issues
1 parent 5309275 commit d5a3b7a

127 files changed

Lines changed: 1064 additions & 741 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎app/build.gradle.kts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,30 @@ android {
4848
namespace = "org.thunderdog.challegram"
4949

5050
lint {
51-
disable += "MissingTranslation"
51+
disable += arrayOf(
52+
"MissingTranslation",
53+
"RtlHardcoded",
54+
"ClickableViewAccessibility",
55+
"ViewConstructor",
56+
"VectorPath",
57+
"LocaleFolder",
58+
"StringFormatCount",
59+
"IconDuplicates",
60+
61+
"MissingPermission",
62+
"ScopedStorage",
63+
"SelectedPhotoAccess",
64+
65+
"AppCompatCustomView",
66+
"AppCompatResource",
67+
"UseCompatLoadingForDrawables",
68+
69+
// FIXME
70+
"UnusedResources",
71+
"ThreadConstraint",
72+
"SwitchIntDef",
73+
"WrongConstant"
74+
)
5275
checkDependencies = true
5376
}
5477

@@ -249,6 +272,12 @@ android {
249272
proguardFile("proguard-r8-bug-android-4.x-workaround.pro")
250273
}
251274

275+
if (selectedMinSdk > Sdk.VARIANTS[Sdk.LEGACY]!!.minSdk) {
276+
lint {
277+
disable += "ObsoleteSdkInt"
278+
}
279+
}
280+
252281
val flags = listOf(
253282
"-w",
254283
"-Werror=return-type",

‎app/lint-baseline.xml‎

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 9.3.1" type="baseline" client="gradle" dependencies="true" name="AGP (9.3.1)" variant="all" version="9.3.1">
3+
4+
<issue
5+
id="WakelockTimeout"
6+
message="Provide a timeout when requesting a wakelock with `PowerManager.Wakelock.acquire(long timeout)`. This will ensure the OS will cleanup any wakelocks that last longer than you intend, and will save your user&apos;s battery."
7+
errorLine1=" wakeLock.acquire();"
8+
errorLine2=" ~~~~~~~~~~~~~~~~~~">
9+
<location
10+
file="src/main/java/org/thunderdog/challegram/component/chat/RaiseHelper.java"
11+
line="459"
12+
column="13"/>
13+
</issue>
14+
15+
<issue
16+
id="WakelockTimeout"
17+
message="Provide a timeout when requesting a wakelock with `PowerManager.Wakelock.acquire(long timeout)`. This will ensure the OS will cleanup any wakelocks that last longer than you intend, and will save your user&apos;s battery."
18+
errorLine1=" cpuWakelock.acquire();"
19+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
20+
<location
21+
file="src/main/java/org/thunderdog/challegram/service/TGCallService.java"
22+
line="302"
23+
column="9"/>
24+
</issue>
25+
26+
<issue
27+
id="WakelockTimeout"
28+
message="Provide a timeout when requesting a wakelock with `PowerManager.Wakelock.acquire(long timeout)`. This will ensure the OS will cleanup any wakelocks that last longer than you intend, and will save your user&apos;s battery."
29+
errorLine1=" proximityWakelock.acquire();"
30+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
31+
<location
32+
file="src/main/java/org/thunderdog/challegram/service/TGCallService.java"
33+
line="760"
34+
column="13"/>
35+
</issue>
36+
37+
<issue
38+
id="NotifyDataSetChanged"
39+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
40+
errorLine1=" notifyDataSetChanged();"
41+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
42+
<location
43+
file="src/main/java/org/thunderdog/challegram/ui/ContactsController.java"
44+
line="1171"
45+
column="7"/>
46+
</issue>
47+
48+
<issue
49+
id="NotifyDataSetChanged"
50+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
51+
errorLine1=" notifyDataSetChanged();"
52+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
53+
<location
54+
file="src/main/java/org/thunderdog/challegram/ui/ContactsController.java"
55+
line="1179"
56+
column="7"/>
57+
</issue>
58+
59+
<issue
60+
id="NotifyDataSetChanged"
61+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
62+
errorLine1=" notifyDataSetChanged();"
63+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
64+
<location
65+
file="src/main/java/org/thunderdog/challegram/ui/ContactsController.java"
66+
line="1190"
67+
column="7"/>
68+
</issue>
69+
70+
<issue
71+
id="NotifyDataSetChanged"
72+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
73+
errorLine1=" adapter.notifyDataSetChanged();"
74+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
75+
<location
76+
file="src/main/java/org/thunderdog/challegram/ui/CreateGroupController.java"
77+
line="486"
78+
column="7"/>
79+
</issue>
80+
81+
<issue
82+
id="NotifyDataSetChanged"
83+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
84+
errorLine1=" trendingAdapter.notifyDataSetChanged();"
85+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
86+
<location
87+
file="src/main/java/org/thunderdog/challegram/ui/EmojiListController.java"
88+
line="115"
89+
column="7"/>
90+
</issue>
91+
92+
<issue
93+
id="NotifyDataSetChanged"
94+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
95+
errorLine1=" trendingAdapter.notifyDataSetChanged();"
96+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
97+
<location
98+
file="src/main/java/org/thunderdog/challegram/ui/EmojiMediaListController.java"
99+
line="319"
100+
column="7"/>
101+
</issue>
102+
103+
<issue
104+
id="NotifyDataSetChanged"
105+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
106+
errorLine1=" customRecyclerView.getAdapter().notifyDataSetChanged();"
107+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
108+
<location
109+
file="src/main/java/org/thunderdog/challegram/ui/EmojiStatusSelectorEmojiPage.java"
110+
line="170"
111+
column="9"/>
112+
</issue>
113+
114+
<issue
115+
id="NotifyDataSetChanged"
116+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
117+
errorLine1=" notifyDataSetChanged();"
118+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
119+
<location
120+
file="src/main/java/org/thunderdog/challegram/component/chat/InlineResultsAdapter.java"
121+
line="81"
122+
column="5"/>
123+
</issue>
124+
125+
<issue
126+
id="NotifyDataSetChanged"
127+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
128+
errorLine1=" notifyDataSetChanged();// FIXME"
129+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
130+
<location
131+
file="src/main/java/org/thunderdog/challegram/component/emoji/MediaGifsAdapter.java"
132+
line="91"
133+
column="5"/>
134+
</issue>
135+
136+
<issue
137+
id="NotifyDataSetChanged"
138+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
139+
errorLine1=" notifyDataSetChanged(); // FIXME"
140+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
141+
<location
142+
file="src/main/java/org/thunderdog/challegram/component/emoji/MediaGifsAdapter.java"
143+
line="109"
144+
column="9"/>
145+
</issue>
146+
147+
<issue
148+
id="NotifyDataSetChanged"
149+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
150+
errorLine1=" mediaAdapter.notifyDataSetChanged();"
151+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
152+
<location
153+
file="src/main/java/org/thunderdog/challegram/widget/emoji/header/MediaHeaderView.java"
154+
line="113"
155+
column="5"/>
156+
</issue>
157+
158+
<issue
159+
id="NotifyDataSetChanged"
160+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
161+
errorLine1=" notifyDataSetChanged();"
162+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
163+
<location
164+
file="src/main/java/org/thunderdog/challegram/ui/SettingsAdapter.java"
165+
line="2304"
166+
column="9"/>
167+
</issue>
168+
169+
<issue
170+
id="NotifyDataSetChanged"
171+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
172+
errorLine1=" adapter.notifyDataSetChanged();"
173+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
174+
<location
175+
file="src/main/java/org/thunderdog/challegram/ui/StickersTrendingController.java"
176+
line="137"
177+
column="7"/>
178+
</issue>
179+
180+
<issue
181+
id="NotifyDataSetChanged"
182+
message="It will always be more efficient to use more specific change events if you can. Rely on `notifyDataSetChanged` as a last resort."
183+
errorLine1=" ((RecyclerViewController&lt;?>) c).getRecyclerView().getAdapter().notifyDataSetChanged();"
184+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
185+
<location
186+
file="src/main/java/org/thunderdog/challegram/ui/ThemeController.java"
187+
line="317"
188+
column="17"/>
189+
</issue>
190+
191+
</issues>

‎app/src/main/AndroidManifest.xml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@
8686
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
8787
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
8888

89-
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
90-
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
91-
92-
<uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE" />
93-
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
94-
9589
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
9690
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />
9791
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />

‎app/src/main/java/org/thunderdog/challegram/U.java‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,27 @@ public static boolean isScreenshotFolder (String str) {
292292
if (StringUtils.isEmpty(str)) {
293293
return false;
294294
}
295-
str = str.toLowerCase();
295+
str = str.toLowerCase(Locale.ROOT);
296296
return str.contains("screencapture") || str.contains("screenshot") || str.contains("экран");
297297
}
298298

299+
public static boolean isDownloadsFolder (String str) {
300+
if (StringUtils.isEmpty(str)) {
301+
return false;
302+
}
303+
str = str.toLowerCase(Locale.ROOT);
304+
return str.contains("download") || str.contains("загрузки");
305+
}
306+
307+
@SuppressWarnings("SpellCheckingInspection")
308+
public static boolean isCameraFolder (String str) {
309+
if (StringUtils.isEmpty(str)) {
310+
return false;
311+
}
312+
str = str.toLowerCase(Locale.ROOT);
313+
return str.contains("camera") || str.contains("dcim") || str.contains("камера");
314+
}
315+
299316
public static float maxWidth (Layout layout) {
300317
if (layout == null)
301318
return 0;
@@ -307,6 +324,7 @@ public static float maxWidth (Layout layout) {
307324
}
308325

309326
public static boolean isLocalhost (String server) {
327+
server = server.toLowerCase(Locale.ROOT);
310328
return switch (server) {
311329
case "127.0.0.1",
312330
"::1",
@@ -392,14 +410,16 @@ public static float distanceBetween (double latitude1, double longitude1, double
392410
//Below few lines is to remove paths which may not be external memory card, like OTG (feel free to comment them out)
393411
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
394412
for (int i = 0; i < results.size(); i++) {
395-
if (!results.get(i).toLowerCase().matches(".*[0-9a-f]{4}[-][0-9a-f]{4}")) {
413+
String lowercase = results.get(i).toLowerCase(Locale.ROOT);
414+
if (!lowercase.matches(".*[0-9a-f]{4}[-][0-9a-f]{4}")) {
396415
// Log.d(LOG_TAG, results.get(i) + " might not be extSDcard");
397416
results.remove(i--);
398417
}
399418
}
400419
} else {
401420
for (int i = 0; i < results.size(); i++) {
402-
if (!results.get(i).toLowerCase().contains("ext") && !results.get(i).toLowerCase().contains("sdcard")) {
421+
String lowercase = results.get(i).toLowerCase(Locale.ROOT);
422+
if (!lowercase.contains("ext") && !lowercase.contains("sdcard")) {
403423
// Log.d(LOG_TAG, results.get(i)+" might not be extSDcard");
404424
results.remove(i--);
405425
}
@@ -448,7 +468,7 @@ public static String toHexString (String str) {
448468
int len = str.length();
449469
for (int i = 0; i < len; i++) {
450470
char c = str.charAt(i);
451-
b.append("\\u").append(Integer.toString(c, 16).toUpperCase());
471+
b.append("\\u").append(Integer.toString(c, 16).toUpperCase(Locale.ROOT));
452472
}
453473
return b.toString();
454474
}
@@ -2067,7 +2087,7 @@ public static float measureEmojiText (@Nullable CharSequence in, @NonNull Paint
20672087
}
20682088

20692089
public static String hexWithZero (int color) {
2070-
String part = Integer.toHexString(color).toUpperCase();
2090+
String part = Integer.toHexString(color).toUpperCase(Locale.ROOT);
20712091
if (part.length() == 1)
20722092
return "0" + part;
20732093
return part;

‎app/src/main/java/org/thunderdog/challegram/charts/data/ChartData.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.regex.Matcher;
1717
import java.util.regex.Pattern;
1818

19+
@SuppressWarnings("SimpleDateFormat")
1920
public class ChartData {
2021

2122
public long[] x;
@@ -77,7 +78,7 @@ public ChartData(JSONObject jsonObject) throws JSONException {
7778
if (matcher.matches()) {
7879
String key = matcher.group(1);
7980
if (key != null) {
80-
line.colorKey = "statisticChartLine_" + matcher.group(1).toLowerCase();
81+
line.colorKey = "statisticChartLine_" + matcher.group(1).toLowerCase(Locale.ROOT);
8182
}
8283

8384
line.color = Color.parseColor(matcher.group(2));

‎app/src/main/java/org/thunderdog/challegram/charts/view_data/LegendSignatureView.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Date;
3333
import java.util.Locale;
3434

35+
@SuppressWarnings("SimpleDateFormat")
3536
public class LegendSignatureView extends FrameLayout {
3637

3738
public boolean isTopHourChart;
@@ -208,13 +209,13 @@ public String formatWholeNumber(int v) {
208209
float num_ = v;
209210
int count = 0;
210211
if (v < 10_000) {
211-
return String.format("%d", v);
212+
return String.format(Locale.ROOT, "%d", v);
212213
}
213214
while (num_ >= 10_000 && count < ChartHorizontalLinesData.s.length - 1) {
214215
num_ /= 1000;
215216
count++;
216217
}
217-
return String.format("%.2f", num_) + ChartHorizontalLinesData.s[count];
218+
return String.format(Locale.ROOT, "%.2f", num_) + ChartHorizontalLinesData.s[count];
218219
}
219220

220221

‎app/src/main/java/org/thunderdog/challegram/charts/view_data/PieLegendView.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void recolor() {
4040
}
4141

4242

43+
@SuppressWarnings("SetTextI18n")
4344
public void setData(String name, int value, int color) {
4445
signature.setText(name);
4546
this.value.setText(Integer.toString(value));

‎app/src/main/java/org/thunderdog/challegram/component/attach/AvatarPickerManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public int getCameraButtonOffset () {
190190
TextView button = Views.newTextView(context.context(), 16, Theme.getColor(customButtonColorId), Gravity.CENTER, Views.TEXT_FLAG_BOLD | Views.TEXT_FLAG_HORIZONTAL_PADDING);
191191
context.addThemeTextColorListener(button, customButtonColorId);
192192

193-
button.setText(customButtonText.toUpperCase());
193+
button.setText(Lang.uppercase(customButtonText));
194194
button.setOnClickListener(v -> customButtonCallback.run());
195195

196196
RippleSupport.setSimpleWhiteBackground(button, context);

0 commit comments

Comments
 (0)