From 68f42fc9800210f6c4d6f8e85c0132bf0cbc06d3 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 2 May 2023 07:36:32 +0200 Subject: [PATCH] feat(youtube): `navigation-buttons` patch --- .../patches/HideCreateButtonPatch.java | 16 -------- .../patches/HideShortsButtonPatch.java | 24 ------------ .../patches/NavigationButtonsPatch.java | 38 +++++++++++++++++++ .../patches/theme/ThemePatch.java | 7 ++++ .../integrations/settings/SettingsEnum.java | 3 ++ 5 files changed, 48 insertions(+), 40 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java delete mode 100644 app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java create mode 100644 app/src/main/java/app/revanced/integrations/patches/NavigationButtonsPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java deleted file mode 100644 index c595a209..00000000 --- a/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java +++ /dev/null @@ -1,16 +0,0 @@ -package app.revanced.integrations.patches; - -import android.view.View; - -import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.LogHelper; - -public class HideCreateButtonPatch { - - //Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch - public static void hideCreateButton(View view) { - boolean hidden = SettingsEnum.HIDE_CREATE_BUTTON.getBoolean(); - LogHelper.printDebug(() -> "Create button: " + (hidden ? "hidden" : "shown")); - view.setVisibility(hidden ? View.GONE : View.VISIBLE); - } -} diff --git a/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java deleted file mode 100644 index b70c251b..00000000 --- a/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java +++ /dev/null @@ -1,24 +0,0 @@ -package app.revanced.integrations.patches; - - -import android.view.View; - -import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.LogHelper; - -public class HideShortsButtonPatch { - - // Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch - public static void hideShortsButton(View view) { - if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") { - boolean hide = SettingsEnum.HIDE_SHORTS_BUTTON.getBoolean(); - LogHelper.printDebug(() -> hide ? "Shorts button: hidden" : "Shorts button: shown"); - if (hide) { - view.setVisibility(View.GONE); - } - } - } - - //Needed for the ShortsButtonRemoverPatch - public static Enum lastPivotTab; -} diff --git a/app/src/main/java/app/revanced/integrations/patches/NavigationButtonsPatch.java b/app/src/main/java/app/revanced/integrations/patches/NavigationButtonsPatch.java new file mode 100644 index 00000000..d47f7aa0 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/NavigationButtonsPatch.java @@ -0,0 +1,38 @@ +package app.revanced.integrations.patches; + + +import android.view.View; +import app.revanced.integrations.settings.SettingsEnum; + +public final class NavigationButtonsPatch { + public static Enum lastNavigationButton; + + public static void hideCreateButton(final View view) { + view.setVisibility(SettingsEnum.HIDE_CREATE_BUTTON.getBoolean() ? View.GONE : View.VISIBLE); + } + + public static boolean switchCreateWithNotificationButton() { + return SettingsEnum.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.getBoolean(); + } + + public static void hideButton(final View buttonView) { + if (lastNavigationButton == null) return; + + for (NavigationButton button : NavigationButton.values()) + if (button.name.equals(lastNavigationButton.name())) + if (button.enabled) buttonView.setVisibility(View.GONE); + } + + private enum NavigationButton { + HOME("PIVOT_HOME", SettingsEnum.HIDE_HOME_BUTTON.getBoolean()), + SHORTS("TAB_SHORTS", SettingsEnum.HIDE_SHORTS_BUTTON.getBoolean()), + SUBSCRIPTIONS("PIVOT_SUBSCRIPTIONS", SettingsEnum.HIDE_SUBSCRIPTIONS_BUTTON.getBoolean()); + private final boolean enabled; + private final String name; + + NavigationButton(final String name, final boolean enabled) { + this.name = name; + this.enabled = enabled; + } + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java index 17cedce4..78d9f7e7 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java @@ -7,11 +7,18 @@ import app.revanced.integrations.utils.ReVancedUtils; public final class ThemePatch { public static final int DEFAULT_SEEKBAR_COLOR = 0xffff0000; + public static final int ORIGINAL_SEEKBAR_CLICKED_COLOR = -65536; + private static void resetSeekbarColor() { ReVancedUtils.showToastShort("Invalid seekbar color value. Using default value."); SettingsEnum.SEEKBAR_COLOR.saveValue("#" + Integer.toHexString(DEFAULT_SEEKBAR_COLOR)); } + public static int getSeekbarClickedColorValue(final int colorValue) { + // YouTube uses a specific color when the seekbar is clicked. Override in that case. + return colorValue == ORIGINAL_SEEKBAR_CLICKED_COLOR ? getSeekbarColorValue() : colorValue; + } + public static int getSeekbarColorValue() { try { return Color.parseColor(SettingsEnum.SEEKBAR_COLOR.getString()); diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index e46f5253..4c5db2ac 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -83,6 +83,7 @@ public enum SettingsEnum { HIDE_CAST_BUTTON("revanced_hide_cast_button", BOOLEAN, TRUE, true), HIDE_COMMENTS_SECTION("revanced_hide_comments_section", BOOLEAN, FALSE, true), HIDE_CREATE_BUTTON("revanced_hide_create_button", BOOLEAN, TRUE, true), + SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON("revanced_switch_create_with_notifications_button", BOOLEAN, TRUE, true), HIDE_CROWDFUNDING_BOX("revanced_hide_crowdfunding_box", BOOLEAN, FALSE, true), HIDE_EMAIL_ADDRESS("revanced_hide_email_address", BOOLEAN, FALSE), HIDE_ENDSCREEN_CARDS("revanced_hide_endscreen_cards", BOOLEAN, TRUE), @@ -93,7 +94,9 @@ public enum SettingsEnum { HIDE_PLAYER_BUTTONS("revanced_hide_player_buttons", BOOLEAN, FALSE), HIDE_PREVIEW_COMMENT("revanced_hide_preview_comment", BOOLEAN, FALSE, true), HIDE_SEEKBAR("revanced_hide_seekbar", BOOLEAN, FALSE), + 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), HIDE_SHORTS_COMMENTS_BUTTON("revanced_hide_shorts_comments_button", BOOLEAN, FALSE), HIDE_TIMESTAMP("revanced_hide_timestamp", BOOLEAN, FALSE), HIDE_VIDEO_WATERMARK("revanced_hide_video_watermark", BOOLEAN, TRUE),