Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit 136fb7b

Browse files
committed
fix: android api 23 compat
Fixes #136
1 parent ab9587d commit 136fb7b

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77

88
defaultConfig {
99
applicationId "app.revanced.integrations"
10-
minSdkVersion 24
10+
minSdkVersion 23
1111
targetSdkVersion 32
1212
versionCode 1
1313
versionName "1.0"
@@ -34,8 +34,6 @@ android {
3434
}
3535

3636
dependencies {
37-
//implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.22.1'
38-
3937
compileOnly 'androidx.annotation:annotation:1.4.0'
4038
}
4139

app/src/main/java/app/revanced/integrations/patches/GeneralBytecodeAdsPatch.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package app.revanced.integrations.patches;
22

3-
import android.os.Build;
4-
5-
import androidx.annotation.RequiresApi;
3+
import app.revanced.integrations.settings.SettingsEnum;
4+
import app.revanced.integrations.utils.LogHelper;
65

76
import java.nio.ByteBuffer;
87
import java.nio.charset.StandardCharsets;
98
import java.util.ArrayList;
109
import java.util.List;
1110

12-
import app.revanced.integrations.settings.SettingsEnum;
13-
import app.revanced.integrations.utils.LogHelper;
14-
1511
public class GeneralBytecodeAdsPatch {
1612

1713
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
@@ -59,7 +55,7 @@ private static boolean containsLithoAd(String value, ByteBuffer buffer) {
5955
bufferBlockList.add("YouTube Movies");
6056
}
6157
if (containsAny(value, "home_video_with_context", "related_video_with_context") &&
62-
bufferBlockList.stream().anyMatch(new String(buffer.array(), StandardCharsets.UTF_8)::contains)
58+
anyMatch(bufferBlockList, new String(buffer.array(), StandardCharsets.UTF_8)::contains)
6359
) return true;
6460

6561
if (SettingsEnum.ADREMOVER_COMMENTS_REMOVAL.getBoolean()) {
@@ -117,7 +113,7 @@ private static boolean containsLithoAd(String value, ByteBuffer buffer) {
117113
"-button"
118114
)) return false;
119115

120-
if (blockList.stream().anyMatch(value::contains)) {
116+
if (anyMatch(blockList, value::contains)) {
121117
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking ad: " + value);
122118
return true;
123119
}
@@ -149,4 +145,15 @@ private static String bytesToHex(byte[] bytes) {
149145
return builder.toString();
150146
}
151147

148+
private static <T> boolean anyMatch(List<T> value, APredicate<? super T> predicate) {
149+
for (T t : value) {
150+
if (predicate.test(t)) return true;
151+
}
152+
return false;
153+
}
154+
155+
@FunctionalInterface
156+
public interface APredicate<T> {
157+
boolean test(T t);
158+
}
152159
}

0 commit comments

Comments
 (0)