From 40def9e036129e9f70549db5fd219f18618e931d Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 27 May 2023 11:51:50 +0400 Subject: [PATCH] feat(youtube/hide-seekbar): more fine grained hiding of seekbar (#409) --- .../patches/theme/ProgressBarDrawable.java | 2 +- .../patches/theme/SeekbarColorPatch.java | 41 ++++++++++++++----- .../integrations/settings/SettingsEnum.java | 1 + 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/ProgressBarDrawable.java b/app/src/main/java/app/revanced/integrations/patches/theme/ProgressBarDrawable.java index 890fc44c..6050b514 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/ProgressBarDrawable.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/ProgressBarDrawable.java @@ -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()); diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java index 1505732d..efedb5f4 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java @@ -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); 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 b65e5aea..9d95783d 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -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),