Skip to content

Commit fd15ec2

Browse files
committed
Update dependencies and tools to target API 33
1 parent 8923f46 commit fd15ec2

File tree

20 files changed

+102
-90
lines changed

20 files changed

+102
-90
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ENV ANDROID_SDK_ROOT /opt/android-sdk-linux
1717
ENV ANDROID_HOME /opt/android-sdk-linux
1818
ENV ANDROID_SDK /opt/android-sdk-linux
1919

20-
RUN echo "y\n" | cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk-linux "build-tools;30.0.0"
20+
RUN echo "y\n" | cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk-linux "build-tools;33.0.0"
2121

2222
# apktool
2323

initworkspace

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ STEPS=5
1111
[ -z "$BUILD_COMPANION" ] && BUILD_COMPANION=/opt/build-companion
1212

1313

14-
DX_PATTERN="$ANDROID_SDK_ROOT/build-tools/*/dx"
15-
DX_FILES=( $DX_PATTERN )
16-
DX=${DX_FILES[0]}
14+
D8_PATTERN="$ANDROID_SDK_ROOT/build-tools/*/d8"
15+
D8_FILES=( $D8_PATTERN )
16+
D8=${D8_FILES[0]}
1717

1818
echo "=== Verifing tools (1/$STEPS) ===" &&
1919
echo "If an errr occurs during this step make" &&
@@ -35,8 +35,8 @@ echo "" && echo "apktool:" && echo "" &&
3535
$JAVA_PATH -jar $APKTOOL_PATH --version &&
3636
echo "" && echo "uber apk signer:" && echo "" &&
3737
$JAVA_PATH -jar $UBER_APK_SIGNER_PATH --version &&
38-
echo "" && echo "dx (android sdk build tools):" && echo "" &&
39-
$DX --version &&
38+
echo "" && echo "d8 (android sdk build tools):" && echo "" &&
39+
$D8 --version &&
4040
echo "" && echo "baksmali:" && echo "" &&
4141
$JAVA_PATH -jar $BAKSMALI_PATH --version &&
4242
echo "" &&

mod/app/build.gradle

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.3"
6+
compileSdkVersion 33
7+
buildToolsVersion "33.0.0"
88

99
defaultConfig {
10-
minSdkVersion 21
11-
targetSdkVersion 30
10+
minSdkVersion 23
11+
targetSdkVersion 33
1212
versionCode 1
1313
versionName "1.0"
1414

@@ -25,21 +25,18 @@ android {
2525
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2626
}
2727
}
28-
compileOptions {
29-
sourceCompatibility JavaVersion.VERSION_1_8
30-
targetCompatibility JavaVersion.VERSION_1_8
31-
}
28+
namespace "bttv.mod"
3229
}
3330

3431
dependencies {
3532
def GLIDE_VERSION = "4.12.0"
36-
implementation 'androidx.appcompat:appcompat:1.2.0'
37-
implementation 'com.google.android.material:material:1.3.0'
33+
implementation 'androidx.appcompat:appcompat:1.6.0'
34+
implementation 'com.google.android.material:material:1.9.0'
3835
api "com.github.zjupure:webpdecoder:2.0.${GLIDE_VERSION}"
3936
api "com.caverock:androidsvg-aar:1.4"
4037
implementation project(path: ':twitch')
41-
testImplementation 'junit:junit:4.+'
38+
testImplementation 'junit:junit:4.13.2'
4239
testImplementation 'org.mockito:mockito-core:1.10.19'
43-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
44-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
40+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
4542
}

mod/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="bttv.mod">
4-
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
54
</manifest>

mod/app/src/main/java/bttv/glide/svg/SvgDecoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static com.bumptech.glide.request.target.Target.SIZE_ORIGINAL;
44

55
import android.util.Log;
6+
import android.util.TypedValue;
67

78
import androidx.annotation.NonNull;
89
import androidx.annotation.Nullable;
@@ -45,6 +46,6 @@ public Resource<SVG> decode(@NonNull InputStream source, int width, int height,
4546
}
4647

4748
private static float dpToPx(float f) {
48-
return android.util.TypedValue.applyDimension(1, f, android.content.res.Resources.getSystem().getDisplayMetrics());
49+
return android.util.TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, f, android.content.res.Resources.getSystem().getDisplayMetrics());
4950
}
5051
}

mod/app/src/main/java/bttv/highlight/Blacklist.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import bttv.Res;
66
import bttv.settings.Settings;
77

8+
import java.util.Locale;
9+
810
public class Blacklist extends StringSetUI {
911
private static final String TAG = "LBTTVBlacklist";
1012
private static Blacklist INSTANCE;
@@ -21,6 +23,6 @@ public static Blacklist getInstance() {
2123
}
2224
public static boolean shouldBlock(String word) {
2325
getInstance().loadSet();
24-
return INSTANCE.stringSet.contains(word.toLowerCase());
26+
return INSTANCE.stringSet.contains(word.toLowerCase(Locale.getDefault()));
2527
}
2628
}

mod/app/src/main/java/bttv/highlight/Highlight.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package bttv.highlight;
22

3+
import java.util.Locale;
4+
35
import android.util.Log;
46

57
import bttv.ChommentModelDelegateWrapper;
@@ -73,12 +75,12 @@ public static boolean shouldHighlight(String word) {
7375
getInstance().loadSet();
7476
if (word.startsWith("<") || word.endsWith(">"))
7577
return false;
76-
return INSTANCE.stringSet.contains(word.toLowerCase());
78+
return INSTANCE.stringSet.contains(word.toLowerCase(Locale.getDefault()));
7779
}
7880

7981
public static boolean shouldHighlightChannel(String name) {
8082
getInstance().loadSet();
81-
return INSTANCE.stringSet.contains("<" + name.toLowerCase() + ">");
83+
return INSTANCE.stringSet.contains("<" + name.toLowerCase(Locale.getDefault()) + ">");
8284
}
8385

8486
}

mod/app/src/main/java/bttv/highlight/StringSetUI.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.ArrayList;
1414
import java.util.Arrays;
1515
import java.util.Set;
16+
import java.util.Locale;
1617

1718
import bttv.Data;
1819
import bttv.Res;
@@ -41,12 +42,12 @@ void loadSet() {
4142

4243

4344
void remove(String word) {
44-
stringSet.remove(word.toLowerCase());
45+
stringSet.remove(word.toLowerCase(Locale.getDefault()));
4546
stringSetSetting.entry.set(Data.ctx, new UserPreferences.Entry.StringSetValue(stringSet));
4647
}
4748

4849
boolean add(String word) {
49-
boolean val = stringSet.add(word.toLowerCase());
50+
boolean val = stringSet.add(word.toLowerCase(Locale.getDefault()));
5051
stringSetSetting.entry.set(Data.ctx, new UserPreferences.Entry.StringSetValue(stringSet));
5152
return val;
5253
}
@@ -122,7 +123,7 @@ public void onClick(View v) {
122123

123124
boolean dialogOnAdd(TextView v, StringSetUIAdapter adapter, ArrayList<String> asList, ListView list, TextView emptyTV) {
124125
for (String w: v.getText().toString().split(" ")) {
125-
String word = w.toLowerCase();
126+
String word = w.toLowerCase(Locale.getDefault());
126127
if (word.trim().isEmpty()) {
127128
continue;
128129
}

mod/app/src/main/java/bttv/updater/UpdaterJobService.java

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
import android.content.ComponentName;
99
import android.content.Context;
1010
import android.content.Intent;
11+
import android.content.pm.PackageManager;
1112
import android.os.Build;
1213
import android.util.Log;
14+
import android.Manifest;
1315

1416
import androidx.annotation.RequiresApi;
1517
import androidx.core.app.NotificationCompat;
1618
import androidx.core.app.NotificationManagerCompat;
19+
import androidx.core.content.ContextCompat;
1720

1821
import bttv.Data;
1922

@@ -94,27 +97,32 @@ public void onUpdate(String newVersion, String body, String apkUrl, String htmlU
9497
Log.d("LBTTVUpdaterJob", "onUpdate");
9598
try {
9699
int icon = getResources().getIdentifier("ic_twitch_glitch_uv_alpha_only", "drawable", getPackageName());
97-
98-
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
99-
Notifications.createChannels(this);
100-
101-
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this, "bttv_android_updates")
102-
.setSmallIcon(icon)
103-
.setContentTitle("bttv-android update detected")
104-
.setContentText(Data.getBttvVersion(this) + " -> " + newVersion)
105-
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
106-
.setContentIntent(
107-
PendingIntent.getActivity(
108-
this,
109-
0,
110-
Updater.updateActivityIndent(this, newVersion, body, apkUrl)
111-
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK),
112-
0
113-
)
114-
)
115-
.setAutoCancel(true);
116-
117-
notificationManager.notify((int) (Math.random() * 10000), notifBuilder.build());
100+
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
101+
// Permission is granted, proceed with notification
102+
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
103+
Notifications.createChannels(this);
104+
105+
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this, "bttv_android_updates")
106+
.setSmallIcon(icon)
107+
.setContentTitle("bttv-android update detected")
108+
.setContentText(Data.getBttvVersion(this) + " -> " + newVersion)
109+
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
110+
.setContentIntent(
111+
PendingIntent.getActivity(
112+
this,
113+
0,
114+
Updater.updateActivityIndent(this, newVersion, body, apkUrl)
115+
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK),
116+
PendingIntent.FLAG_IMMUTABLE
117+
)
118+
)
119+
.setAutoCancel(true);
120+
121+
notificationManager.notify((int) (Math.random() * 10000), notifBuilder.build());
122+
} else {
123+
Log.w("NotificationsPermissionsReceiver", "Permissions are not allowed, not showing notification");
124+
//Twitch already asks on startup, we do not need to take care of this
125+
}
118126
jobFinished(params, false);
119127
} catch (Throwable e) {
120128
Log.e("LBTTVUpdaterJob", "err creating notif ", e);

mod/app/src/main/res/values-pt/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<string name="bttv_updater_notice">Se esta é a primeira vez que você utiliza o atualizador, permita instalações desta fonte quando o assistente lhe pedir.</string>
3131
<string name="bttv_updater_manual_update_start_toast">Verificando por atualizações…</string>
3232
<string name="bttv_updater_manual_update_no_update_toast">Nenhuma atualização disponível</string>
33-
<string name="bttv_updater_manual_update_update_toast">Atualização disponivel!</string>
33+
<string name="bttv_updater_manual_update_update_toast">Atualização disponível!</string>
3434
<string name="bttv_updater_manual_update_error_toast">Ocorreu um erro</string>
3535
<string name="bttv_settings_open_highlights_dia_primary">Definir Palavras-Chave de Destaque</string>
3636
<string name="bttv_settings_open_highlights_dia_secondary">Abrir Dialogo de Palavras-Chave</string>

0 commit comments

Comments
 (0)