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

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into hide-suggestions-shelf
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 14, 2023
2 parents 374eac2 + 12e663c commit 0faf7d1
Show file tree
Hide file tree
Showing 29 changed files with 1,315 additions and 533 deletions.
233 changes: 233 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package app.revanced.integrations.patches;

import android.view.MotionEvent;
import android.view.VelocityTracker;
import app.revanced.integrations.settings.SettingsEnum;

public final class DisableFineScrubbingGesturePatch {
/**
* Disables the fine scrubbing gesture.
* @param tracker The velocity tracker that is used to determine the gesture.
* @param event The motion event that is used to determine the gesture.
*/
public static void disableGesture(VelocityTracker tracker, MotionEvent event) {
if (SettingsEnum.DISABLE_FINE_SCRUBBING_GESTURE.getBoolean()) return;

tracker.addMovement(event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class MinimizedPlaybackPatch {

public static boolean isPlaybackNotShort() {
return !PlayerType.getCurrent().isNoneOrHidden();
return !PlayerType.getCurrent().isNoneHiddenOrSlidingMinimized();
}

public static boolean overrideMinimizedPlaybackAvailable() {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package app.revanced.integrations.patches;

import androidx.annotation.NonNull;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.Objects;

import app.revanced.integrations.patches.playback.speed.RememberPlaybackSpeedPatch;
import app.revanced.integrations.shared.VideoState;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.Objects;

/**
* Hooking class for the current playing video.
*/
Expand All @@ -25,6 +24,10 @@ public final class VideoInformation {
private static String videoId = "";
private static long videoLength = 0;
private static long videoTime = -1;

@NonNull
private static volatile String playerResponseVideoId = "";

/**
* The current playback speed
*/
Expand Down Expand Up @@ -61,6 +64,18 @@ public static void setVideoId(@NonNull String newlyLoadedVideoId) {
}
}

/**
* Injection point. Called off the main thread.
*
* @param videoId The id of the last video loaded.
*/
public static void setPlayerResponseVideoId(@NonNull String videoId) {
if (!playerResponseVideoId.equals(videoId)) {
LogHelper.printDebug(() -> "New player response video id: " + videoId);
playerResponseVideoId = videoId;
}
}

/**
* Injection point.
* Called when user selects a playback speed.
Expand Down Expand Up @@ -141,6 +156,22 @@ public static String getVideoId() {
return videoId;
}

/**
* Differs from {@link #videoId} as this is the video id for the
* last player response received, which may not be the current video playing.
*
* If Shorts are loading the background, this commonly will be
* different from the Short that is currently on screen.
*
* For most use cases, you should instead use {@link #getVideoId()}.
*
* @return The id of the last video loaded. Empty string if not set yet.
*/
@NonNull
public static String getPlayerResponseVideoId() {
return playerResponseVideoId;
}

/**
* @return The current playback speed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ public final class LayoutComponentsFilter extends Filter {
SettingsEnum.HIDE_MIX_PLAYLISTS,
"&list="
);
private final StringFilterGroup searchResultShelfHeader;
private final StringFilterGroup inFeedSurvey;
private final StringFilterGroup notifyMe;
private final StringFilterGroup expandableMetadata;

@RequiresApi(api = Build.VERSION_CODES.N)
public LayoutComponentsFilter() {
exceptions.addPatterns(
"home_video_with_context",
"related_video_with_context",
"comment_thread", // skip filtering anything in the comments
"|comment.", // skip filtering anything in the comments replies
"comment_thread", // Whitelist comments
"|comment.", // Whitelist comment replies
"library_recent_shelf"
);

Expand Down Expand Up @@ -61,7 +65,7 @@ public LayoutComponentsFilter() {
"compact_banner"
);

final var inFeedSurvey = new StringFilterGroup(
inFeedSurvey = new StringFilterGroup(
SettingsEnum.HIDE_FEED_SURVEY,
"in_feed_survey",
"slimline_survey"
Expand Down Expand Up @@ -111,7 +115,7 @@ public LayoutComponentsFilter() {
"official_card"
);

final var expandableMetadata = new StringFilterGroup(
expandableMetadata = new StringFilterGroup(
SettingsEnum.HIDE_EXPANDABLE_CHIP,
"inline_expander"
);
Expand Down Expand Up @@ -146,53 +150,91 @@ public LayoutComponentsFilter() {
"cell_divider" // layout residue (gray line above the buttoned ad),
);

final var timedReactions = new StringFilterGroup(
SettingsEnum.HIDE_TIMED_REACTIONS,
"emoji_control_panel",
"timed_reaction"
);

searchResultShelfHeader = new StringFilterGroup(
SettingsEnum.HIDE_SEARCH_RESULT_SHELF_HEADER,
"shelf_header.eml"
);

notifyMe = new StringFilterGroup(
SettingsEnum.HIDE_NOTIFY_ME_BUTTON,
"set_reminder_button"
);

final var joinMembership = new StringFilterGroup(
SettingsEnum.HIDE_JOIN_MEMBERSHIP_BUTTON,
"compact_sponsor_button"
);

final var chipsShelf = new StringFilterGroup(
SettingsEnum.HIDE_CHIPS_SHELF,
"chips_shelf"
);

final var channelWatermark = new StringFilterGroup(
SettingsEnum.HIDE_VIDEO_CHANNEL_WATERMARK,
"featured_channel_watermark_overlay"
);

this.pathFilterGroupList.addAll(
channelBar,
communityPosts,
paidContent,
latestPosts,
chapters,
channelWatermark,
communityGuidelines,
quickActions,
expandableMetadata,
relatedVideos,
compactBanner,
inFeedSurvey,
joinMembership,
medicalPanel,
notifyMe,
infoPanel,
subscribersCommunityGuidelines,
channelGuidelines,
audioTrackButton,
artistCard,
timedReactions,
imageShelf,
subscribersCommunityGuidelines,
channelMemberShelf,
custom
);

this.identifierFilterGroupList.addAll(
graySeparator,
chipsShelf
chipsShelf,
chapters
);
}

@Override
public boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) {

// The groups are excluded from the filter due to the exceptions list below.
// Filter them separately here.
if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata)
return super.isFiltered(identifier, path, protobufBufferArray, matchedList, matchedGroup, matchedIndex);

if (matchedGroup != custom && exceptions.matches(path))
return false; // Exceptions are not filtered.

// TODO: This also hides the feed Shorts shelf header
if (matchedGroup == searchResultShelfHeader && matchedIndex != 0) return false;

return super.isFiltered(identifier, path, protobufBufferArray, matchedList, matchedGroup, matchedIndex);
}


/**
* Injection point.
*
* Called from a different place then the other filters.
*/
public static boolean filterMixPlaylists(final byte[] bytes) {
Expand All @@ -203,4 +245,8 @@ public static boolean filterMixPlaylists(final byte[] bytes) {

return isMixPlaylistFiltered;
}

public static boolean showWatermark() {
return !SettingsEnum.HIDE_VIDEO_CHANNEL_WATERMARK.getBoolean();
}
}
Loading

0 comments on commit 0faf7d1

Please sign in to comment.