mirror of
https://github.com/revanced/revanced-patches
synced 2025-02-19 09:16:49 +01:00
chore: merge branch dev
to main
(#418)
This commit is contained in:
commit
c4b4bf201c
@ -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));
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user