From b8d86d8352f44a1271628cc2980c11bcd83c2d33 Mon Sep 17 00:00:00 2001 From: Zerwin <46265592+Zerwin@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:28:08 +0200 Subject: [PATCH] Update dependencies and tools to target API 33 --- Dockerfile | 2 +- initworkspace | 10 ++-- mod/app/build.gradle | 23 ++++----- mod/app/src/main/AndroidManifest.xml | 5 +- .../main/java/bttv/glide/svg/SvgDecoder.java | 3 +- .../main/java/bttv/highlight/Blacklist.java | 4 +- .../main/java/bttv/highlight/Highlight.java | 6 ++- .../main/java/bttv/highlight/StringSetUI.java | 7 +-- .../java/bttv/updater/UpdaterJobService.java | 50 +++++++++++-------- mod/app/src/main/res/values-pt/strings.xml | 2 +- .../src/test/java/bttv/mod/TokenizerTest.java | 2 +- mod/build.gradle | 2 +- mod/consumer/build.gradle | 23 ++++----- mod/consumer/src/main/AndroidManifest.xml | 7 +-- .../src/main/res/values-night/themes.xml | 2 +- mod/consumer/src/main/res/values/themes.xml | 2 +- mod/gradle/wrapper/gradle-wrapper.properties | 2 +- mod/twitch/build.gradle | 29 +++++------ mod/twitch/src/main/AndroidManifest.xml | 3 +- .../chat/pub/model/messages/MessageToken.java | 8 +++ 20 files changed, 102 insertions(+), 90 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce702419..3b12b0c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ ENV ANDROID_SDK_ROOT /opt/android-sdk-linux ENV ANDROID_HOME /opt/android-sdk-linux ENV ANDROID_SDK /opt/android-sdk-linux -RUN echo "y\n" | cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk-linux "build-tools;30.0.0" +RUN echo "y\n" | cmdline-tools/bin/sdkmanager --sdk_root=/opt/android-sdk-linux "build-tools;33.0.0" # apktool diff --git a/initworkspace b/initworkspace index c2ac95a4..8e62bbc3 100755 --- a/initworkspace +++ b/initworkspace @@ -11,9 +11,9 @@ STEPS=5 [ -z "$BUILD_COMPANION" ] && BUILD_COMPANION=/opt/build-companion -DX_PATTERN="$ANDROID_SDK_ROOT/build-tools/*/dx" -DX_FILES=( $DX_PATTERN ) -DX=${DX_FILES[0]} +D8_PATTERN="$ANDROID_SDK_ROOT/build-tools/*/d8" +D8_FILES=( $D8_PATTERN ) +D8=${D8_FILES[0]} echo "=== Verifing tools (1/$STEPS) ===" && echo "If an errr occurs during this step make" && @@ -35,8 +35,8 @@ echo "" && echo "apktool:" && echo "" && $JAVA_PATH -jar $APKTOOL_PATH --version && echo "" && echo "uber apk signer:" && echo "" && $JAVA_PATH -jar $UBER_APK_SIGNER_PATH --version && -echo "" && echo "dx (android sdk build tools):" && echo "" && -$DX --version && +echo "" && echo "d8 (android sdk build tools):" && echo "" && +$D8 --version && echo "" && echo "baksmali:" && echo "" && $JAVA_PATH -jar $BAKSMALI_PATH --version && echo "" && diff --git a/mod/app/build.gradle b/mod/app/build.gradle index 97a56672..565ab1eb 100644 --- a/mod/app/build.gradle +++ b/mod/app/build.gradle @@ -3,12 +3,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 33 + buildToolsVersion "33.0.0" defaultConfig { - minSdkVersion 21 - targetSdkVersion 30 + minSdkVersion 23 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -25,21 +25,18 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace "bttv.mod" } dependencies { def GLIDE_VERSION = "4.12.0" - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.9.0' api "com.github.zjupure:webpdecoder:2.0.${GLIDE_VERSION}" api "com.caverock:androidsvg-aar:1.4" implementation project(path: ':twitch') - testImplementation 'junit:junit:4.+' + testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:1.10.19' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } diff --git a/mod/app/src/main/AndroidManifest.xml b/mod/app/src/main/AndroidManifest.xml index 77c5d54c..ffb7f703 100644 --- a/mod/app/src/main/AndroidManifest.xml +++ b/mod/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - - + + \ No newline at end of file diff --git a/mod/app/src/main/java/bttv/glide/svg/SvgDecoder.java b/mod/app/src/main/java/bttv/glide/svg/SvgDecoder.java index 7c88fe6c..b270dfdd 100644 --- a/mod/app/src/main/java/bttv/glide/svg/SvgDecoder.java +++ b/mod/app/src/main/java/bttv/glide/svg/SvgDecoder.java @@ -3,6 +3,7 @@ import static com.bumptech.glide.request.target.Target.SIZE_ORIGINAL; import android.util.Log; +import android.util.TypedValue; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -45,6 +46,6 @@ public Resource decode(@NonNull InputStream source, int width, int height, } private static float dpToPx(float f) { - return android.util.TypedValue.applyDimension(1, f, android.content.res.Resources.getSystem().getDisplayMetrics()); + return android.util.TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, f, android.content.res.Resources.getSystem().getDisplayMetrics()); } } diff --git a/mod/app/src/main/java/bttv/highlight/Blacklist.java b/mod/app/src/main/java/bttv/highlight/Blacklist.java index 3f27f87d..3ca944c7 100644 --- a/mod/app/src/main/java/bttv/highlight/Blacklist.java +++ b/mod/app/src/main/java/bttv/highlight/Blacklist.java @@ -5,6 +5,8 @@ import bttv.Res; import bttv.settings.Settings; +import java.util.Locale; + public class Blacklist extends StringSetUI { private static final String TAG = "LBTTVBlacklist"; private static Blacklist INSTANCE; @@ -21,6 +23,6 @@ public static Blacklist getInstance() { } public static boolean shouldBlock(String word) { getInstance().loadSet(); - return INSTANCE.stringSet.contains(word.toLowerCase()); + return INSTANCE.stringSet.contains(word.toLowerCase(Locale.getDefault())); } } diff --git a/mod/app/src/main/java/bttv/highlight/Highlight.java b/mod/app/src/main/java/bttv/highlight/Highlight.java index 8ebb6916..54905a27 100644 --- a/mod/app/src/main/java/bttv/highlight/Highlight.java +++ b/mod/app/src/main/java/bttv/highlight/Highlight.java @@ -1,5 +1,7 @@ package bttv.highlight; +import java.util.Locale; + import android.util.Log; import bttv.ChommentModelDelegateWrapper; @@ -73,12 +75,12 @@ public static boolean shouldHighlight(String word) { getInstance().loadSet(); if (word.startsWith("<") || word.endsWith(">")) return false; - return INSTANCE.stringSet.contains(word.toLowerCase()); + return INSTANCE.stringSet.contains(word.toLowerCase(Locale.getDefault())); } public static boolean shouldHighlightChannel(String name) { getInstance().loadSet(); - return INSTANCE.stringSet.contains("<" + name.toLowerCase() + ">"); + return INSTANCE.stringSet.contains("<" + name.toLowerCase(Locale.getDefault()) + ">"); } } diff --git a/mod/app/src/main/java/bttv/highlight/StringSetUI.java b/mod/app/src/main/java/bttv/highlight/StringSetUI.java index 165a54f0..867e95b7 100644 --- a/mod/app/src/main/java/bttv/highlight/StringSetUI.java +++ b/mod/app/src/main/java/bttv/highlight/StringSetUI.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Set; +import java.util.Locale; import bttv.Data; import bttv.Res; @@ -41,12 +42,12 @@ void loadSet() { void remove(String word) { - stringSet.remove(word.toLowerCase()); + stringSet.remove(word.toLowerCase(Locale.getDefault())); stringSetSetting.entry.set(Data.ctx, new UserPreferences.Entry.StringSetValue(stringSet)); } boolean add(String word) { - boolean val = stringSet.add(word.toLowerCase()); + boolean val = stringSet.add(word.toLowerCase(Locale.getDefault())); stringSetSetting.entry.set(Data.ctx, new UserPreferences.Entry.StringSetValue(stringSet)); return val; } @@ -122,7 +123,7 @@ public void onClick(View v) { boolean dialogOnAdd(TextView v, StringSetUIAdapter adapter, ArrayList asList, ListView list, TextView emptyTV) { for (String w: v.getText().toString().split(" ")) { - String word = w.toLowerCase(); + String word = w.toLowerCase(Locale.getDefault()); if (word.trim().isEmpty()) { continue; } diff --git a/mod/app/src/main/java/bttv/updater/UpdaterJobService.java b/mod/app/src/main/java/bttv/updater/UpdaterJobService.java index 4f25e780..2a66499b 100644 --- a/mod/app/src/main/java/bttv/updater/UpdaterJobService.java +++ b/mod/app/src/main/java/bttv/updater/UpdaterJobService.java @@ -8,12 +8,15 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Build; import android.util.Log; +import android.Manifest; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; +import androidx.core.content.ContextCompat; import bttv.Data; @@ -94,27 +97,32 @@ public void onUpdate(String newVersion, String body, String apkUrl, String htmlU Log.d("LBTTVUpdaterJob", "onUpdate"); try { int icon = getResources().getIdentifier("ic_twitch_glitch_uv_alpha_only", "drawable", getPackageName()); - - NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); - Notifications.createChannels(this); - - NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this, "bttv_android_updates") - .setSmallIcon(icon) - .setContentTitle("bttv-android update detected") - .setContentText(Data.getBttvVersion(this) + " -> " + newVersion) - .setPriority(NotificationCompat.PRIORITY_DEFAULT) - .setContentIntent( - PendingIntent.getActivity( - this, - 0, - Updater.updateActivityIndent(this, newVersion, body, apkUrl) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK), - 0 - ) - ) - .setAutoCancel(true); - - notificationManager.notify((int) (Math.random() * 10000), notifBuilder.build()); + if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { + // Permission is granted, proceed with notification + NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); + Notifications.createChannels(this); + + NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this, "bttv_android_updates") + .setSmallIcon(icon) + .setContentTitle("bttv-android update detected") + .setContentText(Data.getBttvVersion(this) + " -> " + newVersion) + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + .setContentIntent( + PendingIntent.getActivity( + this, + 0, + Updater.updateActivityIndent(this, newVersion, body, apkUrl) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK), + PendingIntent.FLAG_IMMUTABLE + ) + ) + .setAutoCancel(true); + + notificationManager.notify((int) (Math.random() * 10000), notifBuilder.build()); + } else { + Log.w("NotificationsPermissionsReceiver", "Permissions are not allowed, not showing notification"); + //Twitch already asks on startup, we do not need to take care of this + } jobFinished(params, false); } catch (Throwable e) { Log.e("LBTTVUpdaterJob", "err creating notif ", e); diff --git a/mod/app/src/main/res/values-pt/strings.xml b/mod/app/src/main/res/values-pt/strings.xml index 45b46af1..d64a59e8 100644 --- a/mod/app/src/main/res/values-pt/strings.xml +++ b/mod/app/src/main/res/values-pt/strings.xml @@ -30,7 +30,7 @@ Se esta é a primeira vez que você utiliza o atualizador, permita instalações desta fonte quando o assistente lhe pedir. Verificando por atualizações… Nenhuma atualização disponível - Atualização disponivel! + Atualização disponível! Ocorreu um erro Definir Palavras-Chave de Destaque Abrir Dialogo de Palavras-Chave diff --git a/mod/app/src/test/java/bttv/mod/TokenizerTest.java b/mod/app/src/test/java/bttv/mod/TokenizerTest.java index d0607f5f..9b4e67b1 100644 --- a/mod/app/src/test/java/bttv/mod/TokenizerTest.java +++ b/mod/app/src/test/java/bttv/mod/TokenizerTest.java @@ -21,8 +21,8 @@ import bttv.Tokenizer; import bttv.emote.Emote; import bttv.emote.Emotes; -import tv.twitch.android.models.chat.AutoModMessageFlags; import tv.twitch.android.shared.chat.pub.model.messages.MessageToken; +import tv.twitch.android.shared.chat.pub.model.messages.AutoModMessageFlags; import static org.junit.Assert.*; import static org.mockito.Mockito.when; diff --git a/mod/build.gradle b/mod/build.gradle index 18615e1a..5b097b38 100644 --- a/mod/build.gradle +++ b/mod/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.1.3" + classpath "com.android.tools.build:gradle:7.4.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/mod/consumer/build.gradle b/mod/consumer/build.gradle index 0c2a18a6..3de57a61 100644 --- a/mod/consumer/build.gradle +++ b/mod/consumer/build.gradle @@ -3,13 +3,13 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 33 + buildToolsVersion "33.0.0" defaultConfig { applicationId "app.consumer" - minSdkVersion 21 - targetSdkVersion 30 + minSdkVersion 23 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -22,10 +22,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace "app.consumer" } dependencies { @@ -33,10 +30,10 @@ dependencies { // glide 4.10.0+ implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}" annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}" - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.9.0' implementation project(path: ':app') - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } diff --git a/mod/consumer/src/main/AndroidManifest.xml b/mod/consumer/src/main/AndroidManifest.xml index bba6e721..1cc28ade 100644 --- a/mod/consumer/src/main/AndroidManifest.xml +++ b/mod/consumer/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + - + diff --git a/mod/consumer/src/main/res/values-night/themes.xml b/mod/consumer/src/main/res/values-night/themes.xml index 0c371fc4..42c5b7e2 100644 --- a/mod/consumer/src/main/res/values-night/themes.xml +++ b/mod/consumer/src/main/res/values-night/themes.xml @@ -10,7 +10,7 @@ @color/teal_200 @color/black - ?attr/colorPrimaryVariant + ?attr/colorPrimaryVariant \ No newline at end of file diff --git a/mod/consumer/src/main/res/values/themes.xml b/mod/consumer/src/main/res/values/themes.xml index fde2538e..b56356de 100644 --- a/mod/consumer/src/main/res/values/themes.xml +++ b/mod/consumer/src/main/res/values/themes.xml @@ -10,7 +10,7 @@ @color/teal_700 @color/black - ?attr/colorPrimaryVariant + ?attr/colorPrimaryVariant \ No newline at end of file diff --git a/mod/gradle/wrapper/gradle-wrapper.properties b/mod/gradle/wrapper/gradle-wrapper.properties index ffed3a25..8049c684 100644 --- a/mod/gradle/wrapper/gradle-wrapper.properties +++ b/mod/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/mod/twitch/build.gradle b/mod/twitch/build.gradle index 0124b394..133a032c 100644 --- a/mod/twitch/build.gradle +++ b/mod/twitch/build.gradle @@ -3,12 +3,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 33 + buildToolsVersion "33.0.0" defaultConfig { - minSdkVersion 21 - targetSdkVersion 30 + minSdkVersion 23 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -22,24 +22,21 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace "tv.twitch" } dependencies { def GLIDE_VERSION = "4.12.0" - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' - api 'com.google.dagger:dagger-android:2.35.1' - annotationProcessor 'com.google.dagger:dagger-android-processor:2.35.1' - annotationProcessor 'com.google.dagger:dagger-compiler:2.35.1' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.9.0' + api 'com.google.dagger:dagger-android:2.51.1' + annotationProcessor 'com.google.dagger:dagger-android-processor:2.51.1' + annotationProcessor 'com.google.dagger:dagger-compiler:2.51.1' api 'com.squareup.okhttp3:okhttp:4.0.1' api 'io.reactivex.rxjava2:rxandroid:2.1.1' api 'ru.noties:markwon:2.0.2' api "com.github.bumptech.glide:glide:${GLIDE_VERSION}" - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } diff --git a/mod/twitch/src/main/AndroidManifest.xml b/mod/twitch/src/main/AndroidManifest.xml index 5d701ebd..a5918e68 100644 --- a/mod/twitch/src/main/AndroidManifest.xml +++ b/mod/twitch/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + \ No newline at end of file diff --git a/mod/twitch/src/main/java/tv/twitch/android/shared/chat/pub/model/messages/MessageToken.java b/mod/twitch/src/main/java/tv/twitch/android/shared/chat/pub/model/messages/MessageToken.java index 4e527011..5d627ff5 100644 --- a/mod/twitch/src/main/java/tv/twitch/android/shared/chat/pub/model/messages/MessageToken.java +++ b/mod/twitch/src/main/java/tv/twitch/android/shared/chat/pub/model/messages/MessageToken.java @@ -21,6 +21,14 @@ public EmoticonToken(String text, String id) { this.id = id; } + public final String component1() { + return this.text; + } + public final String component2() { + return this.id; + } + + } public static final class TextToken extends MessageToken {