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 fix/yt-shorts-pip
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 21, 2024
2 parents 1a11e49 + 14fb894 commit 9715866
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 12 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
## [1.16.1-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v1.16.0...v1.16.1-dev.1) (2024-10-20)


### Bug Fixes

* **YouTube - Hide layout components:** Hide new kind of community post ([#711](https://github.com/ReVanced/revanced-integrations/issues/711)) ([9ffdfc3](https://github.com/ReVanced/revanced-integrations/commit/9ffdfc37630288eb1383446e38c5bf0d9317bc12))
* **YouTube - Hide seekbar:** Hide 19.34+ gradient seekbar ([e3975cf](https://github.com/ReVanced/revanced-integrations/commit/e3975cfc3ac703eb972f68528a99c92457276815))

# [1.16.0](https://github.com/ReVanced/revanced-integrations/compare/v1.15.0...v1.16.0) (2024-10-20)


### Bug Fixes

* **YouTube - Hide layout components:** Adjust settings text ([#713](https://github.com/ReVanced/revanced-integrations/issues/713)) ([119c416](https://github.com/ReVanced/revanced-integrations/commit/119c416bc5c24f2455bfe70adccd51234b165d25))
* **YouTube - Hide layout components:** Hide new type of Playable ([1a58a40](https://github.com/ReVanced/revanced-integrations/commit/1a58a406db76e4deaea070d077a31714f270e479))
* **YouTube - Spoof video streams:** Fix playback for Android VR by removing invalid body as well ([#716](https://github.com/ReVanced/revanced-integrations/issues/716)) ([8ad3f78](https://github.com/ReVanced/revanced-integrations/commit/8ad3f78865836fbe38a832ef6395c6eb8d0edbf2))
* **YouTube - Spoof video streams:** Handle app left open for a long time ([#709](https://github.com/ReVanced/revanced-integrations/issues/709)) ([ea4b073](https://github.com/ReVanced/revanced-integrations/commit/ea4b073f5c21b0fea4e3922488e8bbf69cfcb421))


### Features

* **Sync for Reddit:** Add `Fix video downloads` patch ([#710](https://github.com/ReVanced/revanced-integrations/issues/710)) ([888de49](https://github.com/ReVanced/revanced-integrations/commit/888de49edd39913116028ac1d173f2b6e0feab09))
* **Twitter:** Add `Change link sharing domain` patch ([#715](https://github.com/ReVanced/revanced-integrations/issues/715)) ([c673951](https://github.com/ReVanced/revanced-integrations/commit/c6739517f179bf8e811e869640a24f433d729f42))
* **YouTube - Hide layout components:** Add option to hide Yoodles (YouTube Doodles) ([#712](https://github.com/ReVanced/revanced-integrations/issues/712)) ([4b5f3de](https://github.com/ReVanced/revanced-integrations/commit/4b5f3deef9c3a8c700e23a0f4d9ce999013ec9d4))
* **YouTube - Hide Shorts components:** Add option to hide like fountain ([#708](https://github.com/ReVanced/revanced-integrations/issues/708)) ([16c3ef7](https://github.com/ReVanced/revanced-integrations/commit/16c3ef7ee5a32ec22db6da876dcf19fc02bc9aac))
* **YouTube - Hide Shorts components:** Add options to hide `Use template`, `Upcoming`, `Green screen` buttons ([#714](https://github.com/ReVanced/revanced-integrations/issues/714)) ([faad754](https://github.com/ReVanced/revanced-integrations/commit/faad7548df2091c24d41dad98a589745ce8a6b73))
* **YouTube - Hide Shorts components:** Hide `Hashtag` button ([#717](https://github.com/ReVanced/revanced-integrations/issues/717)) ([1c9a966](https://github.com/ReVanced/revanced-integrations/commit/1c9a966354243dd1a106e1fc767227c1b025125e))
* **YouTube:** Support versions `19.25` and `19.34` ([#689](https://github.com/ReVanced/revanced-integrations/issues/689)) ([61569ba](https://github.com/ReVanced/revanced-integrations/commit/61569ba111af82aaff60d11863bc57221a295fe8))

# [1.16.0-dev.11](https://github.com/ReVanced/revanced-integrations/compare/v1.16.0-dev.10...v1.16.0-dev.11) (2024-10-19)


### Features

* **YouTube - Hide Shorts components:** Hide `Hashtag` button ([#717](https://github.com/ReVanced/revanced-integrations/issues/717)) ([1c9a966](https://github.com/ReVanced/revanced-integrations/commit/1c9a966354243dd1a106e1fc767227c1b025125e))

# [1.16.0-dev.10](https://github.com/ReVanced/revanced-integrations/compare/v1.16.0-dev.9...v1.16.0-dev.10) (2024-10-19)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package app.revanced.integrations.youtube.patches;

import android.app.Activity;
import android.os.Build;

import androidx.annotation.RequiresApi;

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

import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings("unused")
public class ShortsAutoplayPatch {

private enum ShortsLoopBehavior {
UNKNOWN,
/**
* Repeat the same Short forever!
*/
REPEAT,
/**
* Play once, then advanced to the next Short.
*/
SINGLE_PLAY,
/**
* Pause playback after 1 play.
*/
END_SCREEN;

static void setYTEnumValue(Enum<?> ytBehavior) {
for (ShortsLoopBehavior rvBehavior : values()) {
if (ytBehavior.name().endsWith(rvBehavior.name())) {
rvBehavior.ytEnumValue = ytBehavior;

Logger.printDebug(() -> rvBehavior + " set to YT enum: " + ytBehavior.name());
return;
}
}

Logger.printException(() -> "Unknown Shorts loop behavior: " + ytBehavior.name());
}

/**
* YouTube enum value of the obfuscated enum type.
*/
private Enum<?> ytEnumValue;
}

private static WeakReference<Activity> mainActivityRef = new WeakReference<>(null);


public static void setMainActivity(Activity activity) {
mainActivityRef = new WeakReference<>(activity);
}

/**
* @return If the app is currently in background PiP mode.
*/
@RequiresApi(api = Build.VERSION_CODES.N)
private static boolean isAppInBackgroundPiPMode() {
Activity activity = mainActivityRef.get();
return activity != null && activity.isInPictureInPictureMode();
}

/**
* Injection point.
*/
public static void setYTShortsRepeatEnum(Enum<?> ytEnum) {
try {
for (Enum<?> ytBehavior : Objects.requireNonNull(ytEnum.getClass().getEnumConstants())) {
ShortsLoopBehavior.setYTEnumValue(ytBehavior);
}
} catch (Exception ex) {
Logger.printException(() -> "setYTShortsRepeatEnum failure", ex);
}
}

/**
* Injection point.
*/
@RequiresApi(api = Build.VERSION_CODES.N)
public static Enum<?> changeShortsRepeatBehavior(Enum<?> original) {
try {
final boolean autoplay;

if (isAppInBackgroundPiPMode()) {
if (!VersionCheckPatch.IS_19_34_OR_GREATER) {
// 19.34+ is required to set background play behavior.
Logger.printDebug(() -> "PiP Shorts not supported, using original repeat behavior");

return original;
}

autoplay = Settings.SHORTS_AUTOPLAY_BACKGROUND.get();
} else {
autoplay = Settings.SHORTS_AUTOPLAY.get();
}

final ShortsLoopBehavior behavior = autoplay
? ShortsLoopBehavior.SINGLE_PLAY
: ShortsLoopBehavior.REPEAT;

if (behavior.ytEnumValue != null) {
Logger.printDebug(() -> behavior.ytEnumValue == original
? "Changing Shorts repeat behavior from: " + original.name() + " to: " + behavior.ytEnumValue
: "Behavior setting is same as original. Using original: " + original.name()
);

return behavior.ytEnumValue;
}
} catch (Exception ex) {
Logger.printException(() -> "changeShortsRepeatState failure", ex);
}

return original;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public class VersionCheckPatch {
public static final boolean IS_19_21_OR_GREATER = Utils.getAppVersionName().compareTo("19.21.00") >= 0;
public static final boolean IS_19_26_OR_GREATER = Utils.getAppVersionName().compareTo("19.26.00") >= 0;
public static final boolean IS_19_29_OR_GREATER = Utils.getAppVersionName().compareTo("19.29.00") >= 0;
public static final boolean IS_19_34_OR_GREATER = Utils.getAppVersionName().compareTo("19.34.00") >= 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public LayoutComponentsFilter() {
"text_post_root.eml",
"images_post_root.eml",
"images_post_slim.eml",
"images_post_root_slim.eml",
"text_post_root_slim.eml",
"post_base_wrapper_slim.eml"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,24 @@ public ShortsFilter() {
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_GREEN_SCREEN_BUTTON,
"greenscreen_temp"
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_HASHTAG_BUTTON,
"yt_outline_hashtag_"
)
);
}

private boolean isEverySuggestedActionFilterEnabled() {
for (ByteArrayFilterGroup group : suggestedActionsGroupList) {
if (!group.isEnabled()) {
return false;
}
}

return true;
}

@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
Expand Down Expand Up @@ -279,7 +293,13 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
}

if (matchedGroup == suggestedAction) {
// Suggested actions can be at the start or in the middle of a path.
// Skip searching the buffer if all suggested actions are set to hidden.
// This has a secondary effect of hiding all new un-identified actions
// under the assumption that the user wants all actions hidden.
if (isEverySuggestedActionFilterEnabled()) {
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
}

if (suggestedActionsGroupList.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ public static int getSeekbarColor() {
}

public static boolean playerSeekbarGradientEnabled(boolean original) {
if (original) {
Logger.printDebug(() -> "playerSeekbarGradientEnabled original: " + true);
if (SEEKBAR_CUSTOM_COLOR_ENABLED) return false;
}
if (SEEKBAR_CUSTOM_COLOR_ENABLED) return false;

return original;
}
Expand Down Expand Up @@ -104,12 +101,14 @@ public static int getLithoColor(int colorValue) {
* Injection point.
*/
public static void setLinearGradient(int[] colors, float[] positions) {
if (SEEKBAR_CUSTOM_COLOR_ENABLED) {
final boolean hideSeekbar = Settings.HIDE_SEEKBAR_THUMBNAIL.get();

if (SEEKBAR_CUSTOM_COLOR_ENABLED || hideSeekbar) {
// Most litho usage of linear gradients is hooked here,
// so must only change if the values are those for the seekbar.
if (Arrays.equals(ORIGINAL_SEEKBAR_GRADIENT_COLORS, colors)
&& Arrays.equals(ORIGINAL_SEEKBAR_GRADIENT_POSITIONS, positions)) {
Arrays.fill(colors, Settings.HIDE_SEEKBAR_THUMBNAIL.get()
Arrays.fill(colors, hideSeekbar
? 0x00000000
: seekbarColor);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SHORTS_USE_TEMPLATE_BUTTON = new BooleanSetting("revanced_hide_shorts_use_template_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_UPCOMING_BUTTON = new BooleanSetting("revanced_hide_shorts_upcoming_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_GREEN_SCREEN_BUTTON = new BooleanSetting("revanced_hide_shorts_green_screen_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_HASHTAG_BUTTON = new BooleanSetting("revanced_hide_shorts_hashtag_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_SEARCH_SUGGESTIONS = new BooleanSetting("revanced_hide_shorts_search_suggestions", FALSE);
public static final BooleanSetting HIDE_SHORTS_STICKERS = new BooleanSetting("revanced_hide_shorts_stickers", TRUE);
public static final BooleanSetting HIDE_SHORTS_SUPER_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_super_thanks_button", TRUE);
Expand All @@ -247,6 +248,8 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SHORTS_SOUND_METADATA_LABEL = new BooleanSetting("revanced_hide_shorts_sound_metadata_label", FALSE);
public static final BooleanSetting HIDE_SHORTS_FULL_VIDEO_LINK_LABEL = new BooleanSetting("revanced_hide_shorts_full_video_link_label", FALSE);
public static final BooleanSetting HIDE_SHORTS_NAVIGATION_BAR = new BooleanSetting("revanced_hide_shorts_navigation_bar", FALSE, true);
public static final BooleanSetting SHORTS_AUTOPLAY = new BooleanSetting("revanced_shorts_autoplay", FALSE);
public static final BooleanSetting SHORTS_AUTOPLAY_BACKGROUND = new BooleanSetting("revanced_shorts_autoplay_background", TRUE);

// Seekbar
public static final BooleanSetting DISABLE_PRECISE_SEEKING_GESTURE = new BooleanSetting("revanced_disable_precise_seeking_gesture", TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,7 @@ private static void setSponsorBarAbsoluteRight(Rect rect) {
*/
@SuppressWarnings("unused")
public static void setSponsorBarThickness(int thickness) {
if (sponsorBarThickness != thickness) {
Logger.printDebug(() -> "setSponsorBarThickness: " + thickness);
sponsorBarThickness = thickness;
}
sponsorBarThickness = thickness;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
android.useAndroidX = true
version = 1.16.0-dev.10
version = 1.16.1-dev.1

0 comments on commit 9715866

Please sign in to comment.