chore: merge branch dev to main (#418)

This commit is contained in:
oSumAtrIX 2023-06-12 03:43:22 +02:00 committed by GitHub
commit 309cda8848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 149 additions and 46 deletions

View File

@ -16,28 +16,32 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.11.0
- name: Checkout
uses: actions/checkout@v3
with:
# Make sure the release step uses its own credentials:
# https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
cache: 'npm'
- name: Setup semantic-release
run: npm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
run: npm exec semantic-release
- name: Checkout
uses: actions/checkout@v3
with:
# Make sure the release step uses its own credentials:
# https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false
fetch-depth: 0
- name: Cache
uses: actions/cache@v3
with:
path: |
${{ runner.home }}/.gradle/caches
${{ runner.home }}/.gradle/wrapper
.gradle
build
node_modules
key: ${{ runner.os }}-gradle-npm-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'package-lock.json') }}
- name: Setup Java
run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
- name: Build with Gradle
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew clean --no-daemon
- name: Setup semantic-release
run: npm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
run: npm exec semantic-release

View File

@ -1,3 +1,19 @@
# [0.110.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.1-dev.1...v0.110.0-dev.1) (2023-06-12)
### Features
* **reddit:** add `hide-promoted` patch ([#419](https://github.com/revanced/revanced-integrations/issues/419)) ([7eb209d](https://github.com/revanced/revanced-integrations/commit/7eb209d8533f68cd344c331482b38bfcf4baca06))
* **youtube/hide-ads:** hide mix playlists ([aa72125](https://github.com/revanced/revanced-integrations/commit/aa721253170890a35640b860be569932b8536345))
* **youtube/swipe-controls:** add option to save and restore brightness ([b5a71a8](https://github.com/revanced/revanced-integrations/commit/b5a71a843eaecaf9f2566d0b6a3c21422b14a44f))
## [0.109.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.0...v0.109.1-dev.1) (2023-05-31)
### Bug Fixes
* **youtube/swipe-controls:** require restart if settings are changed ([#417](https://github.com/revanced/revanced-integrations/issues/417)) ([f951897](https://github.com/revanced/revanced-integrations/commit/f9518979448bf40f0a85ad88ac5971ade9343566))
# [0.109.0](https://github.com/revanced/revanced-integrations/compare/v0.108.0...v0.109.0) (2023-05-31)

View File

@ -1,7 +1,9 @@
package app.revanced.integrations.patches.components;
import android.os.Build;
import android.view.View;
import androidx.annotation.RequiresApi;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
@ -12,6 +14,13 @@ public final class AdsFilter extends Filter {
private final CustomFilterGroup custom;
// region Mix playlists
private final ByteArrayAsStringFilterGroup mixPlaylists;
private final ByteArrayAsStringFilterGroup imageHosting;
// endregion
@RequiresApi(api = Build.VERSION_CODES.N)
public AdsFilter() {
exceptions = new String[]{
"home_video_with_context",
@ -183,6 +192,21 @@ public final class AdsFilter extends Filter {
"offer_module_root"
);
// region Mix playlists
mixPlaylists = new ByteArrayAsStringFilterGroup(
SettingsEnum.HIDE_MIX_PLAYLISTS,
"&list=",
"YouTube Music"
);
imageHosting = new ByteArrayAsStringFilterGroup(
SettingsEnum.HIDE_MIX_PLAYLISTS, // Unused
"ggpht.com"
);
// endregion
this.pathFilterGroups.addAll(
generalAds,
buttonedAd,
@ -222,6 +246,18 @@ public final class AdsFilter extends Filter {
);
}
private boolean isMixPlaylistFiltered(final byte[] _protobufBufferArray) {
if (!mixPlaylists.isEnabled()) return false;
// Two checks are required to prevent false positives.
// First check if the current buffer potentially contains a mix playlist.
if (!mixPlaylists.check(_protobufBufferArray).isFiltered()) return false;
// Ensure that the buffer actually contains a mix playlist.
return imageHosting.check(_protobufBufferArray).isFiltered();
}
@Override
public boolean isFiltered(final String path, final String identifier, final byte[] _protobufBufferArray) {
FilterResult result;
@ -230,10 +266,14 @@ public final class AdsFilter extends Filter {
result = FilterResult.CUSTOM;
else if (ReVancedUtils.containsAny(path, exceptions))
result = FilterResult.EXCEPTION;
else if (pathFilterGroups.contains(path) || identifierFilterGroups.contains(identifier))
result = FilterResult.FILTERED;
else
result = FilterResult.UNFILTERED;
else {
var filtered =
pathFilterGroups.contains(path) || // Check if the path is filtered.
identifierFilterGroups.contains(identifier) || // Check if the identifier is filtered.
isMixPlaylistFiltered(_protobufBufferArray); // Check if the buffer contains a mix playlist.
result = filtered ? FilterResult.FILTERED : FilterResult.UNFILTERED;
}
LogHelper.printDebug(() -> String.format("%s (ID: %s): %s", result.message, identifier, path));

View File

@ -85,6 +85,7 @@ public enum SettingsEnum {
HIDE_WEB_SEARCH_RESULTS("revanced_hide_web_search_results", BOOLEAN, TRUE),
HIDE_QUICK_ACTIONS("revanced_hide_quick_actions", BOOLEAN, FALSE),
HIDE_RELATED_VIDEOS("revanced_hide_related_videos", BOOLEAN, FALSE),
HIDE_MIX_PLAYLISTS("revanced_hide_mix_playlists", BOOLEAN, TRUE),
// Action buttons
HIDE_LIKE_DISLIKE_BUTTON("revanced_hide_like_dislike_button", BOOLEAN, FALSE),
@ -158,15 +159,17 @@ public enum SettingsEnum {
SWIPE_VOLUME("revanced_swipe_volume", BOOLEAN, TRUE),
SWIPE_PRESS_TO_ENGAGE("revanced_swipe_press_to_engage", BOOLEAN, FALSE, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_HAPTIC_FEEDBACK("revanced_swipe_haptic_feedback", BOOLEAN, TRUE,
SWIPE_HAPTIC_FEEDBACK("revanced_swipe_haptic_feedback", BOOLEAN, TRUE, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_MAGNITUDE_THRESHOLD("revanced_swipe_threshold", INTEGER, 30,
SWIPE_MAGNITUDE_THRESHOLD("revanced_swipe_threshold", INTEGER, 30, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_OVERLAY_BACKGROUND_ALPHA("revanced_swipe_overlay_background_alpha", INTEGER, 127,
SWIPE_OVERLAY_BACKGROUND_ALPHA("revanced_swipe_overlay_background_alpha", INTEGER, 127, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_OVERLAY_TEXT_SIZE("revanced_swipe_text_overlay_size", INTEGER, 22,
SWIPE_OVERLAY_TEXT_SIZE("revanced_swipe_text_overlay_size", INTEGER, 22, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_OVERLAY_TIMEOUT("revanced_swipe_overlay_timeout", LONG, 500L,
SWIPE_OVERLAY_TIMEOUT("revanced_swipe_overlay_timeout", LONG, 500L, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_SAVE_AND_RESTORE_BRIGHTNESS("revanced_swipe_save_and_restore_brightness", BOOLEAN, TRUE, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
// Debugging

View File

@ -45,7 +45,7 @@ class SwipeControlsConfigurationProvider(
*/
val overwriteVolumeKeyControls: Boolean
get() = isFullscreenVideo && enableVolumeControls
//endregioin
//endregion
//region gesture adjustments
/**
@ -94,5 +94,15 @@ class SwipeControlsConfigurationProvider(
val overlayForegroundColor: Int
get() = Color.WHITE
//endregion
//region behaviour
/**
* should the brightness be saved and restored when exiting or entering fullscreen
*/
val shouldSaveAndRestoreBrightness: Boolean
get() = SettingsEnum.SWIPE_SAVE_AND_RESTORE_BRIGHTNESS.boolean
//endregion
}

View File

@ -168,13 +168,14 @@ class SwipeControlsHostActivity : Activity() {
* @param type the new player type
*/
private fun onPlayerTypeChanged(type: PlayerType) {
when (type) {
PlayerType.WATCH_WHILE_FULLSCREEN -> screen?.restore()
else -> {
screen?.save()
screen?.restoreDefaultBrightness()
if (config.shouldSaveAndRestoreBrightness)
when (type) {
PlayerType.WATCH_WHILE_FULLSCREEN -> screen?.restore()
else -> {
screen?.save()
screen?.restoreDefaultBrightness()
}
}
}
}
/**

View File

@ -0,0 +1,26 @@
package app.revanced.reddit.patches;
import com.reddit.domain.model.ILink;
import java.util.ArrayList;
import java.util.List;
public final class FilterPromotedLinksPatch {
/**
* Filters list from promoted links.
**/
public static List<?> filterChildren(final Iterable<?> links) {
final List<Object> filteredList = new ArrayList<>();
for (Object item : links) {
if (!(item instanceof ILink)) continue;
final var link = (ILink) item;
final var isPromotedAd = link.getPromoted();
if (!isPromotedAd) filteredList.add(item);
}
return filteredList;
}
}

View File

@ -1,4 +1,3 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
@ -7,9 +6,6 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle:8.0.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

View File

@ -0,0 +1,7 @@
package com.reddit.domain.model;
public class ILink {
public boolean getPromoted() {
throw new UnsupportedOperationException("Stub");
}
}

View File

@ -1,3 +1,3 @@
org.gradle.jvmargs = -Xmx2048m
android.useAndroidX = true
version = 0.109.0
version = 0.110.0-dev.1