chore: merge branch dev to main (#413)

This commit is contained in:
oSumAtrIX 2023-05-31 10:33:38 +02:00 committed by GitHub
commit 2dcb66ea3e
8 changed files with 102 additions and 30 deletions

View File

@ -0,0 +1,21 @@
package app.revanced.all.screencapture.removerestriction;
import android.media.AudioAttributes;
import android.os.Build;
import androidx.annotation.RequiresApi;
public final class RemoveScreencaptureRestrictionPatch {
// Member of AudioAttributes.Builder
@RequiresApi(api = Build.VERSION_CODES.Q)
public static AudioAttributes.Builder setAllowedCapturePolicy(final AudioAttributes.Builder builder, final int capturePolicy) {
builder.setAllowedCapturePolicy(AudioAttributes.ALLOW_CAPTURE_BY_ALL);
return builder;
}
// Member of AudioManager static class
public static void setAllowedCapturePolicy(final int capturePolicy) {
// Ignore request
}
}

View File

@ -1,11 +1,16 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public final class HidePlayerButtonsPatch {
public static boolean hideButtons() {
return SettingsEnum.HIDE_PLAYER_BUTTONS.getBoolean();
/**
* Injection point.
*/
public static boolean previousOrNextButtonIsVisible(boolean previousOrNextButtonVisible) {
if (SettingsEnum.HIDE_PLAYER_BUTTONS.getBoolean()) {
return false;
}
return previousOrNextButtonVisible;
}
}

View File

@ -168,6 +168,7 @@ public final class AdsFilter extends Filter {
"text_image_button_layout",
"primetime_promo",
"product_details",
"carousel_headered_layout",
"full_width_portrait_image_layout",
"brand_video_shelf"
);

View File

@ -20,6 +20,11 @@ public final class ShortsFilter extends Filter {
"reel_channel_bar"
);
private final StringFilterGroup infoPanel = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_INFO_PANEL,
"shorts_info_panel_overview"
);
public ShortsFilter() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
@ -38,23 +43,38 @@ public final class ShortsFilter extends Filter {
"sponsor_button"
);
final var soundButton = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_SOUND_BUTTON,
"reel_pivot_button"
);
final var channelBar = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_CHANNEL_BAR,
"reel_channel_bar"
);
final var shorts = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS,
"shorts_shelf",
"inline_shorts",
"shorts_grid"
"shorts_grid",
"shorts_video_cell"
);
this.pathFilterGroups.addAll(joinButton, subscribeButton);
this.pathFilterGroups.addAll(joinButton, subscribeButton, soundButton, channelBar);
this.identifierFilterGroups.addAll(shorts, thanksButton);
}
@Override
boolean isFiltered(final String path, final String identifier, final byte[] protobufBufferArray) {
boolean isFiltered(final String path, final String identifier,
final byte[] protobufBufferArray) {
// Filter the path only when reelChannelBar is visible.
if (reelChannelBar.check(path).isFiltered())
if (this.pathFilterGroups.contains(path)) return true;
// Shorts info panel path appears outside of reelChannelBar path.
if (infoPanel.isEnabled() && infoPanel.check(path).isFiltered()) return true;
return this.identifierFilterGroups.contains(identifier);
}

View File

@ -22,7 +22,7 @@ public class ProgressBarDrawable extends Drawable {
@Override
public void draw(@NonNull Canvas canvas) {
if (SettingsEnum.HIDE_SEEKBAR.getBoolean()) {
if (SettingsEnum.HIDE_SEEKBAR_THUMBNAIL.getBoolean()) {
return;
}
paint.setColor(SeekbarColorPatch.getCustomSeekbarColor());

View File

@ -51,12 +51,31 @@ public final class SeekbarColorPatch {
return customSeekbarColor;
}
/**
* Injection point.
*
* Overrides color when seekbar is clicked, and all Litho components that use the YouTube seekbar color.
* Overrides all Litho components that use the YouTube seekbar color.
* Used only for the video thumbnails seekbar.
*
* If {@link SettingsEnum#HIDE_SEEKBAR_THUMBNAIL} is enabled, this returns a fully transparent color.
*/
public static int getSeekbarColorOverride(int colorValue) {
public static int getLithoColor(int colorValue) {
if (colorValue == ORIGINAL_SEEKBAR_COLOR) {
if (SettingsEnum.HIDE_SEEKBAR_THUMBNAIL.getBoolean()) {
return 0x00000000;
}
return getSeekbarColorValue(ORIGINAL_SEEKBAR_COLOR);
}
return colorValue;
}
/**
* Injection point.
*
* Overrides color when video player seekbar is clicked.
*/
public static int getVideoPlayerSeekbarClickedColor(int colorValue) {
return colorValue == ORIGINAL_SEEKBAR_COLOR
? getSeekbarColorValue(ORIGINAL_SEEKBAR_COLOR)
: colorValue;
@ -65,18 +84,20 @@ public final class SeekbarColorPatch {
/**
* Injection point.
*
* If {@link SettingsEnum#HIDE_SEEKBAR} is enabled, this returns a fully transparent color.
*
* Otherwise the original color is changed to the custom seekbar color, while retaining
* Overrides color used for the video player seekbar.
*/
public static int getVideoPlayerSeekbarColor(int originalColor) {
return getSeekbarColorValue(originalColor);
}
/**
* Color parameter is changed to the custom seekbar color, while retaining
* the brightness and alpha changes of the parameter value compared to the original seekbar color.
*/
public static int getSeekbarColorValue(int originalColor) {
private static int getSeekbarColorValue(int originalColor) {
try {
if (SettingsEnum.HIDE_SEEKBAR.getBoolean()) {
return 0x00000000;
}
if (customSeekbarColor == ORIGINAL_SEEKBAR_COLOR) {
return originalColor; // Nothing to do
return originalColor; // nothing to do
}
final int alphaDifference = Color.alpha(originalColor) - Color.alpha(ORIGINAL_SEEKBAR_COLOR);

View File

@ -32,7 +32,7 @@ import java.util.Objects;
public enum SettingsEnum {
// External downloader
EXTERNAL_DOWNLOADER("revanced_external_downloader", BOOLEAN, TRUE),
EXTERNAL_DOWNLOADER("revanced_external_downloader", BOOLEAN, FALSE),
EXTERNAL_DOWNLOADER_PACKAGE_NAME("revanced_external_downloader_name", STRING,
"org.schabi.newpipe" /* NewPipe */, parents(EXTERNAL_DOWNLOADER)),
@ -116,6 +116,7 @@ public enum SettingsEnum {
HIDE_PLAYER_OVERLAY("revanced_hide_player_overlay", BOOLEAN, FALSE, true),
HIDE_PREVIEW_COMMENT("revanced_hide_preview_comment", BOOLEAN, FALSE, true),
HIDE_SEEKBAR("revanced_hide_seekbar", BOOLEAN, FALSE, true),
HIDE_SEEKBAR_THUMBNAIL("revanced_hide_seekbar_thumbnail", BOOLEAN, FALSE, true),
HIDE_HOME_BUTTON("revanced_hide_home_button", BOOLEAN, FALSE, true),
HIDE_SHORTS_BUTTON("revanced_hide_shorts_button", BOOLEAN, TRUE, true),
HIDE_SUBSCRIPTIONS_BUTTON("revanced_hide_subscriptions_button", BOOLEAN, FALSE, true),
@ -132,12 +133,15 @@ public enum SettingsEnum {
HIDE_FILTER_BAR_FEED_IN_FEED("revanced_hide_filter_bar_feed_in_feed", BOOLEAN, FALSE, true),
HIDE_FILTER_BAR_FEED_IN_SEARCH("revanced_hide_filter_bar_feed_in_search", BOOLEAN, FALSE, true),
HIDE_FILTER_BAR_FEED_IN_RELATED_VIDEOS("revanced_hide_filter_bar_feed_in_related_videos", BOOLEAN, FALSE, true),
HIDE_SHORTS_JOIN_BUTTON("revanced_hide_shorts_join_button", BOOLEAN, FALSE),
HIDE_SHORTS_JOIN_BUTTON("revanced_hide_shorts_join_button", BOOLEAN, TRUE),
HIDE_SHORTS_SUBSCRIBE_BUTTON("revanced_hide_shorts_subscribe_button", BOOLEAN, FALSE),
HIDE_SHORTS_THANKS_BUTTON("revanced_hide_shorts_thanks_button", BOOLEAN, FALSE),
HIDE_SHORTS_THANKS_BUTTON("revanced_hide_shorts_thanks_button", BOOLEAN, TRUE),
HIDE_SHORTS_COMMENTS_BUTTON("revanced_hide_shorts_comments_button", BOOLEAN, FALSE),
HIDE_SHORTS_REMIX_BUTTON("revanced_hide_shorts_remix_button", BOOLEAN, FALSE),
HIDE_SHORTS_REMIX_BUTTON("revanced_hide_shorts_remix_button", BOOLEAN, TRUE),
HIDE_SHORTS_SHARE_BUTTON("revanced_hide_shorts_share_button", BOOLEAN, FALSE),
HIDE_SHORTS_INFO_PANEL("revanced_hide_shorts_info_panel", BOOLEAN, TRUE),
HIDE_SHORTS_SOUND_BUTTON("revanced_hide_shorts_sound_button", BOOLEAN, FALSE),
HIDE_SHORTS_CHANNEL_BAR("revanced_hide_shorts_channel_bar", BOOLEAN, FALSE),
HIDE_SHORTS_NAVIGATION_BAR("revanced_hide_shorts_navigation_bar", BOOLEAN, TRUE, true),
HIDE_SHORTS("revanced_hide_shorts", BOOLEAN, FALSE, true),

View File

@ -13,16 +13,16 @@ import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.StringRef;
public class DownloadButton extends BottomControlButton {
public class ExternalDownloadButton extends BottomControlButton {
@Nullable
private static DownloadButton instance;
private static ExternalDownloadButton instance;
public DownloadButton(ViewGroup viewGroup) {
public ExternalDownloadButton(ViewGroup viewGroup) {
super(
viewGroup,
"download_button",
"external_download_button",
SettingsEnum.EXTERNAL_DOWNLOADER,
DownloadButton::onDownloadClick,
ExternalDownloadButton::onDownloadClick,
null
);
}
@ -32,7 +32,7 @@ public class DownloadButton extends BottomControlButton {
*/
public static void initializeButton(View view) {
try {
instance = new DownloadButton((ViewGroup) view);
instance = new ExternalDownloadButton((ViewGroup) view);
} catch (Exception ex) {
LogHelper.printException(() -> "initializeButton failure", ex);
}
@ -46,7 +46,7 @@ public class DownloadButton extends BottomControlButton {
}
private static void onDownloadClick(View view) {
LogHelper.printDebug(() -> "Download button clicked");
LogHelper.printDebug(() -> "External download button clicked");
final var context = view.getContext();
var downloaderPackageName = SettingsEnum.EXTERNAL_DOWNLOADER_PACKAGE_NAME.getString();
@ -55,12 +55,12 @@ public class DownloadButton extends BottomControlButton {
try {
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
} catch (PackageManager.NameNotFoundException error) {
LogHelper.printDebug(() -> "Downloader could not be found: " + error);
LogHelper.printDebug(() -> "External downloader could not be found: " + error);
}
// If the package is not installed, show the toast
if (!packageEnabled) {
ReVancedUtils.showToastLong(downloaderPackageName + " " + StringRef.str("downloader_not_installed_warning"));
ReVancedUtils.showToastLong(downloaderPackageName + " " + StringRef.str("external_downloader_not_installed_warning"));
return;
}