Skip to content

Commit

Permalink
chore: Merge branch dev to main (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed May 21, 2024
2 parents 4e64b69 + e3994d3 commit 9147842
Show file tree
Hide file tree
Showing 27 changed files with 2,835 additions and 681 deletions.
111 changes: 111 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,114 @@
# [1.9.0-dev.15](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.14...v1.9.0-dev.15) (2024-05-21)


### Bug Fixes

* **YouTube - Client spoof:** Spoof client to fix playback ([#637](https://github.com/ReVanced/revanced-integrations/issues/637)) ([4c1f82a](https://github.com/ReVanced/revanced-integrations/commit/4c1f82aa228239b041c7d3657f1117abd7516991))

# [1.9.0-dev.14](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.13...v1.9.0-dev.14) (2024-05-18)


### Features

* **YouTube - Navigation buttons:** Add option to hide navigation button labels ([#635](https://github.com/ReVanced/revanced-integrations/issues/635)) ([6bd0ac2](https://github.com/ReVanced/revanced-integrations/commit/6bd0ac20dcfc76bfd044fb9f2f03ce98d6efc535))

# [1.9.0-dev.13](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.12...v1.9.0-dev.13) (2024-05-16)


### Features

* **YouTube - Hide Shorts components:** Hide 'Buy super thanks' button ([#633](https://github.com/ReVanced/revanced-integrations/issues/633)) ([303754c](https://github.com/ReVanced/revanced-integrations/commit/303754c46f6d3471405d67b7911065fc3a87f721))

# [1.9.0-dev.12](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.11...v1.9.0-dev.12) (2024-05-15)


### Bug Fixes

* **YouTube - Hide Shorts components:** Hide old layout like/dislike buttons without leaving empty space ([9782338](https://github.com/ReVanced/revanced-integrations/commit/978233843d2dcf9a8a0ddf9c9517d25c973e8689))
* **YouTube - Restore old video quality menu:** Do not make click sounds when opening Shorts quality menu ([578a27d](https://github.com/ReVanced/revanced-integrations/commit/578a27dea546f572c3fd270d001fd6024f59dd1a))

# [1.9.0-dev.11](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.10...v1.9.0-dev.11) (2024-05-15)


### Bug Fixes

* **YouTube - Hide video action buttons:** Updated path filter ([b74e544](https://github.com/ReVanced/revanced-integrations/commit/b74e54481ad4040d7742bb4f9a6a20351bb9ef71))

# [1.9.0-dev.10](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.9...v1.9.0-dev.10) (2024-05-11)


### Bug Fixes

* **YouTube - Restore old video quality menu:** Show advanced quality menu in Shorts quality flyout ([#632](https://github.com/ReVanced/revanced-integrations/issues/632)) ([77c9825](https://github.com/ReVanced/revanced-integrations/commit/77c9825b824f95ff6e2c2d5776f4c1d231e6fd0c))

# [1.9.0-dev.9](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.8...v1.9.0-dev.9) (2024-05-08)


### Bug Fixes

* **YouTube - SponsorBlock:** Show correct segment times if video is over 24 hours in length ([#630](https://github.com/ReVanced/revanced-integrations/issues/630)) ([81251f9](https://github.com/ReVanced/revanced-integrations/commit/81251f9a34ef9f252ce69b01b40e29480a5add9f))

# [1.9.0-dev.8](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.7...v1.9.0-dev.8) (2024-05-06)


### Bug Fixes

* **YouTube - Player flyout menu:** Remove obsolete `Hide report menu` ([9e9d969](https://github.com/ReVanced/revanced-integrations/commit/9e9d96910c27568013f2a0744687eb8fba685175))

# [1.9.0-dev.7](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.6...v1.9.0-dev.7) (2024-05-02)


### Bug Fixes

* Use Java instead of Kotlin Regex to improve reliability ([#628](https://github.com/ReVanced/revanced-integrations/issues/628)) ([44c3cc4](https://github.com/ReVanced/revanced-integrations/commit/44c3cc46367520f780537716236e0bed3b9537e6))

# [1.9.0-dev.6](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.5...v1.9.0-dev.6) (2024-04-29)


### Bug Fixes

* **YouTube - Hide keyword content:** Filter Shorts found in horizontal shelves ([75fa579](https://github.com/ReVanced/revanced-integrations/commit/75fa5797f70123f68d4676201503cf35dcef46dc))

# [1.9.0-dev.5](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.4...v1.9.0-dev.5) (2024-04-28)


### Bug Fixes

* **YouTube - Hide Shorts components:** Hide Shorts in search result horizontal shelves ([#625](https://github.com/ReVanced/revanced-integrations/issues/625)) ([656ca17](https://github.com/ReVanced/revanced-integrations/commit/656ca17ffc67cae7012436e5cddd7112b73fc450))

# [1.9.0-dev.4](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.3...v1.9.0-dev.4) (2024-04-23)


### Bug Fixes

* **YouTube - Settings:** Use same background color for about screen if Theme patch is not included ([4164ed3](https://github.com/ReVanced/revanced-integrations/commit/4164ed3486330add8ff158f5b6765fa26587154d))

# [1.9.0-dev.3](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.2...v1.9.0-dev.3) (2024-04-23)


### Features

* **YouTube - Hide ads:** Add option to hide the 'Visit store' button on channel pages ([#622](https://github.com/ReVanced/revanced-integrations/issues/622)) ([9de566c](https://github.com/ReVanced/revanced-integrations/commit/9de566ca02398ab9c628565091ed02316c5e1ed0))

# [1.9.0-dev.2](https://github.com/ReVanced/revanced-integrations/compare/v1.9.0-dev.1...v1.9.0-dev.2) (2024-04-23)


### Features

* **YouTube - Comments:** Add option to hide timestamp and emoji buttons ([#621](https://github.com/ReVanced/revanced-integrations/issues/621)) ([6e9e122](https://github.com/ReVanced/revanced-integrations/commit/6e9e12235a69a1f3759180abd48e65b151b62e9a))

# [1.9.0-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v1.8.0...v1.9.0-dev.1) (2024-04-21)


### Bug Fixes

* **YouTube - Hide video action buttons:** Remove obsolete `hide Shop button` ([#618](https://github.com/ReVanced/revanced-integrations/issues/618)) ([a78c3ff](https://github.com/ReVanced/revanced-integrations/commit/a78c3ff09e81b1d1e0fe863135ad19e699b702c8))


### Features

* **YouTube - Hide Shorts components:** Hide like / dislike button in video ads ([#619](https://github.com/ReVanced/revanced-integrations/issues/619)) ([b2b6b8c](https://github.com/ReVanced/revanced-integrations/commit/b2b6b8c3d7d3c706552ffe70f3ed0314fe5284b6))

# [1.8.0](https://github.com/ReVanced/revanced-integrations/compare/v1.7.0...v1.8.0) (2024-04-21)


Expand Down
35 changes: 24 additions & 11 deletions app/src/main/java/app/revanced/integrations/shared/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.preference.PreferenceScreen;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
Expand All @@ -28,6 +29,7 @@

import java.text.Bidi;
import java.util.*;
import java.util.regex.Pattern;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
Expand All @@ -36,7 +38,6 @@

import app.revanced.integrations.shared.settings.BooleanSetting;
import app.revanced.integrations.shared.settings.preference.ReVancedAboutPreference;
import kotlin.text.Regex;

public class Utils {

Expand Down Expand Up @@ -94,7 +95,7 @@ public static String getAppVersionName() {
* @param condition The setting to check for hiding the view.
* @param view The view to hide.
*/
public static void hideViewBy1dpUnderCondition(BooleanSetting condition, View view) {
public static void hideViewBy0dpUnderCondition(BooleanSetting condition, View view) {
if (!condition.get()) return;

Logger.printDebug(() -> "Hiding view with setting: " + condition);
Expand All @@ -116,6 +117,15 @@ public static void hideViewUnderCondition(BooleanSetting condition, View view) {
view.setVisibility(View.GONE);
}

public static void removeViewFromParentUnderConditions(BooleanSetting setting, View view) {
if (setting.get()) {
ViewParent parent = view.getParent();
if (parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(view);
}
}
}

/**
* General purpose pool for network calls and other background tasks.
* All tasks run at max thread priority.
Expand Down Expand Up @@ -412,27 +422,30 @@ public static NetworkType getNetworkType() {
}

/**
* Hide a view by setting its layout params to 1x1
* Hide a view by setting its layout params to 0x0
* @param view The view to hide.
*/
public static void hideViewByLayoutParams(View view) {
if (view instanceof LinearLayout) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, 0);
view.setLayoutParams(layoutParams);
} else if (view instanceof FrameLayout) {
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(0, 0);
view.setLayoutParams(layoutParams2);
} else if (view instanceof RelativeLayout) {
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(0, 0);
view.setLayoutParams(layoutParams3);
} else if (view instanceof Toolbar) {
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(0, 0);
view.setLayoutParams(layoutParams4);
} else if (view instanceof ViewGroup) {
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(0, 0);
view.setLayoutParams(layoutParams5);
} else {
Logger.printDebug(() -> "Hidden view with id " + view.getId());
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = 0;
params.height = 0;
view.setLayoutParams(params);
}
}

Expand Down Expand Up @@ -474,14 +487,14 @@ static Sort fromKey(@Nullable String key, @NonNull Sort defaultSort) {
}
}

private static final Regex punctuationRegex = new Regex("\\p{P}+");
private static final Pattern punctuationPattern = Pattern.compile("\\p{P}+");

/**
* Strips all punctuation and converts to lower case. A null parameter returns an empty string.
*/
public static String removePunctuationConvertToLowercase(@Nullable CharSequence original) {
if (original == null) return "";
return punctuationRegex.replace(original, "").toLowerCase();
return punctuationPattern.matcher(original).replaceAll("").toLowerCase();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ThemeHelper {
/**
* Injection point.
*/
@SuppressWarnings("unused")
public static void setTheme(Enum<?> value) {
final int newOrdinalValue = value.ordinal();
if (themeValue != newOrdinalValue) {
Expand All @@ -40,12 +41,12 @@ public static void setActivityTheme(Activity activity) {
*/
private static String darkThemeResourceName() {
// Value is changed by Theme patch, if included.
return "@android:color/black";
return "@color/yt_black3";
}

/**
* @return The dark theme color as specified by the Theme patch (if included),
* or the Android color of black.
* or the dark mode background color unpatched YT uses.
*/
public static int getDarkThemeColor() {
if (darkThemeColor == null) {
Expand All @@ -59,12 +60,12 @@ public static int getDarkThemeColor() {
*/
private static String lightThemeResourceName() {
// Value is changed by Theme patch, if included.
return "@android:color/white";
return "@color/yt_white1";
}

/**
* @return The light theme color as specified by the Theme patch (if included),
* or the Android color of white.
* or the non dark mode background color unpatched YT uses.
*/
public static int getLightThemeColor() {
if (lightThemeColor == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

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

/**
* Patch is obsolete and will be deleted in a future release
*/
@SuppressWarnings("unused")
@Deprecated()
public class HideEmailAddressPatch {
//Used by app.revanced.patches.youtube.layout.personalinformation.patch.HideEmailAddressPatch
public static int hideEmailAddress(int originalValue) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package app.revanced.integrations.youtube.patches;

import static app.revanced.integrations.shared.Utils.hideViewUnderCondition;
import static app.revanced.integrations.youtube.shared.NavigationBar.NavigationButton;

import android.view.View;

import java.util.EnumMap;
import java.util.Map;

import app.revanced.integrations.shared.Logger;
import android.widget.TextView;
import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -40,4 +41,11 @@ public static void navigationTabCreated(NavigationButton button, View tabView) {
tabView.setVisibility(View.GONE);
}
}

/**
* Injection point.
*/
public static void hideNavigationButtonLabels(TextView navigationLabelsView) {
hideViewUnderCondition(Settings.HIDE_NAVIGATION_BUTTON_LABELS, navigationLabelsView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static CharSequence onLithoTextLoaded(@NonNull Object conversionContext,
true, isRollingNumber);
} else if (!isRollingNumber && conversionContextString.contains("|shorts_dislike_button.eml|")) {
// Litho Shorts player.
if (!Settings.RYD_SHORTS.get()) {
if (!Settings.RYD_SHORTS.get() || Settings.HIDE_SHORTS_DISLIKE_BUTTON.get()) {
// Must clear the current video here, otherwise if the user opens a regular video
// then opens a litho short (while keeping the regular video on screen), then closes the short,
// the original video may show the incorrect dislike value.
Expand Down Expand Up @@ -451,7 +451,7 @@ public static boolean setShortsDislikes(@NonNull View likeDislikeView) {
if (!Settings.RYD_ENABLED.get()) {
return false;
}
if (!Settings.RYD_SHORTS.get()) {
if (!Settings.RYD_SHORTS.get() || Settings.HIDE_SHORTS_DISLIKE_BUTTON.get()) {
// Must clear the data here, in case a new video was loaded while PlayerType
// suggested the video was not a short (can happen when spoofing to an old app version).
clearData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static boolean playerParametersAreShort(@NonNull String parameters) {
/**
* Injection point.
*/
public static String newPlayerResponseSignature(@NonNull String signature, boolean isShortAndOpeningOrPlaying) {
public static String newPlayerResponseSignature(@NonNull String signature, String videoId, boolean isShortAndOpeningOrPlaying) {
final boolean isShort = playerParametersAreShort(signature);
playerResponseVideoIdIsShort = isShort;
if (!isShort || isShortAndOpeningOrPlaying) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public final class AdsFilter extends Filter {
// endregion

private final StringTrieSearch exceptions = new StringTrieSearch();

private final StringFilterGroup channelProfile;
private final ByteArrayFilterGroup visitStoreButton;

private final StringFilterGroup shoppingLinks;

public AdsFilter() {
Expand Down Expand Up @@ -100,6 +104,16 @@ public AdsFilter() {
"expandable_list"
);

channelProfile = new StringFilterGroup(
null,
"channel_profile.eml"
);

visitStoreButton = new ByteArrayFilterGroup(
Settings.HIDE_VISIT_STORE_BUTTON,
"header_store_button"
);

final var webLinkPanel = new StringFilterGroup(
Settings.HIDE_WEB_SEARCH_RESULTS,
"web_link_panel"
Expand All @@ -122,6 +136,7 @@ public AdsFilter() {
viewProducts,
selfSponsor,
fullscreenAd,
channelProfile,
webLinkPanel,
shoppingLinks,
movieAds
Expand All @@ -140,6 +155,13 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
return false; // Do not actually filter the fullscreen ad otherwise it will leave a dimmed screen.
}

if (matchedGroup == channelProfile) {
if (visitStoreButton.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
return false;
}

// Check for the index because of likelihood of false positives.
if (matchedGroup == shoppingLinks && contentIndex != 0)
return false;
Expand All @@ -153,7 +175,7 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
* @param view The view, which shows ads.
*/
public static void hideAdAttributionView(View view) {
Utils.hideViewBy1dpUnderCondition(Settings.HIDE_GENERAL_ADS, view);
Utils.hideViewBy0dpUnderCondition(Settings.HIDE_GENERAL_ADS, view);
}

/**
Expand Down
Loading

0 comments on commit 9147842

Please sign in to comment.