diff --git a/CHANGELOG.md b/CHANGELOG.md index 0494f4fb..099ec339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +# [0.107.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.107.0-dev.2...v0.107.0-dev.3) (2023-05-02) + + +### Features + +* **youtube:** `navigation-buttons` patch ([68f42fc](https://github.com/revanced/revanced-integrations/commit/68f42fc9800210f6c4d6f8e85c0132bf0cbc06d3)) + +# [0.107.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.107.0-dev.1...v0.107.0-dev.2) (2023-05-02) + + +### Bug Fixes + +* **youtube/theme:** set correct default seekbar color ([a91b036](https://github.com/revanced/revanced-integrations/commit/a91b0363a8aca4e195c9da4e48e2c332c1b1a7a6)) + +# [0.107.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.106.0...v0.107.0-dev.1) (2023-05-02) + + +### Features + +* **youtube/theme:** change seekbar color via preference ([1185cee](https://github.com/revanced/revanced-integrations/commit/1185ceedf7fdb40759261ae8560e79604c8cb743)) + # [0.106.0](https://github.com/revanced/revanced-integrations/compare/v0.105.0...v0.106.0) (2023-05-01) 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/LithoThemePatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/ThemeLithoComponentsPatch.java similarity index 93% rename from app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java rename to app/src/main/java/app/revanced/integrations/patches/theme/ThemeLithoComponentsPatch.java index f544970b..da9f3963 100644 --- a/app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/ThemeLithoComponentsPatch.java @@ -1,9 +1,9 @@ -package app.revanced.integrations.patches; +package app.revanced.integrations.patches.theme; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.ThemeHelper; -public class LithoThemePatch { +public class ThemeLithoComponentsPatch { // color constants used in relation with litho components private static final int[] WHITE_VALUES = { -1, // comments chip background @@ -31,7 +31,7 @@ public class LithoThemePatch { * @param originalValue The original color value. * @return The new or original color value */ - public static int applyLithoTheme(int originalValue) { + public static int getValue(int originalValue) { if (ThemeHelper.isDarkTheme()) { if (anyEquals(originalValue, DARK_VALUES)) return getBlackColor(); } else { 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 new file mode 100644 index 00000000..78d9f7e7 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java @@ -0,0 +1,30 @@ +package app.revanced.integrations.patches.theme; + +import android.graphics.Color; +import app.revanced.integrations.settings.SettingsEnum; +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()); + } catch (IllegalArgumentException exception) { + resetSeekbarColor(); + return DEFAULT_SEEKBAR_COLOR; + } + } +} 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 c5a21902..4c5db2ac 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -1,21 +1,17 @@ package app.revanced.integrations.settings; -import static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; -import static app.revanced.integrations.settings.SettingsEnum.ReturnType.BOOLEAN; -import static app.revanced.integrations.settings.SettingsEnum.ReturnType.FLOAT; -import static app.revanced.integrations.settings.SettingsEnum.ReturnType.INTEGER; -import static app.revanced.integrations.settings.SettingsEnum.ReturnType.LONG; -import static app.revanced.integrations.settings.SettingsEnum.ReturnType.STRING; -import static app.revanced.integrations.settings.SharedPrefCategory.RETURN_YOUTUBE_DISLIKE; -import static app.revanced.integrations.settings.SharedPrefCategory.SPONSOR_BLOCK; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import app.revanced.integrations.utils.StringRef; +import app.revanced.integrations.patches.theme.ThemePatch; import java.util.Objects; -import app.revanced.integrations.utils.StringRef; +import static app.revanced.integrations.settings.SettingsEnum.ReturnType.*; +import static app.revanced.integrations.settings.SharedPrefCategory.RETURN_YOUTUBE_DISLIKE; +import static app.revanced.integrations.settings.SharedPrefCategory.SPONSOR_BLOCK; +import static java.lang.Boolean.FALSE; +import static java.lang.Boolean.TRUE; public enum SettingsEnum { //Download Settings @@ -87,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), @@ -97,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), @@ -107,6 +106,7 @@ public enum SettingsEnum { SPOOF_APP_VERSION_TARGET("revanced_spoof_app_version_target", STRING, "17.30.35", true, parents(SPOOF_APP_VERSION)), USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", BOOLEAN, FALSE, true), WIDE_SEARCHBAR("revanced_wide_searchbar", BOOLEAN, FALSE, true), + SEEKBAR_COLOR("revanced_seekbar_color", STRING, Integer.toHexString(ThemePatch.DEFAULT_SEEKBAR_COLOR), true), // Misc. Settings SIGNATURE_SPOOFING("revanced_spoof_signature_verification", BOOLEAN, TRUE, "revanced_spoof_signature_verification_user_dialog_message"), diff --git a/gradle.properties b/gradle.properties index ad8862f3..72ed6a43 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.106.0 +version = 0.107.0-dev.3