1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-27 11:13:38 +01:00

feat(youtube/hide-seekbar): more fine grained hiding of seekbar (#409)

This commit is contained in:
LisoUseInAIKyrios 2023-05-27 11:51:50 +04:00 committed by GitHub
parent 8ff9ebc592
commit 40def9e036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 11 deletions

View File

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

View File

@ -51,12 +51,31 @@ public final class SeekbarColorPatch {
return customSeekbarColor; return customSeekbarColor;
} }
/** /**
* Injection point. * 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 return colorValue == ORIGINAL_SEEKBAR_COLOR
? getSeekbarColorValue(ORIGINAL_SEEKBAR_COLOR) ? getSeekbarColorValue(ORIGINAL_SEEKBAR_COLOR)
: colorValue; : colorValue;
@ -65,18 +84,20 @@ public final class SeekbarColorPatch {
/** /**
* Injection point. * Injection point.
* *
* If {@link SettingsEnum#HIDE_SEEKBAR} is enabled, this returns a fully transparent color. * Overrides color used for the video player seekbar.
* */
* Otherwise the original color is changed to the custom seekbar color, while retaining 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. * 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 { try {
if (SettingsEnum.HIDE_SEEKBAR.getBoolean()) {
return 0x00000000;
}
if (customSeekbarColor == ORIGINAL_SEEKBAR_COLOR) { 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); final int alphaDifference = Color.alpha(originalColor) - Color.alpha(ORIGINAL_SEEKBAR_COLOR);

View File

@ -116,6 +116,7 @@ public enum SettingsEnum {
HIDE_PLAYER_OVERLAY("revanced_hide_player_overlay", BOOLEAN, FALSE, true), HIDE_PLAYER_OVERLAY("revanced_hide_player_overlay", BOOLEAN, FALSE, true),
HIDE_PREVIEW_COMMENT("revanced_hide_preview_comment", BOOLEAN, FALSE, true), HIDE_PREVIEW_COMMENT("revanced_hide_preview_comment", BOOLEAN, FALSE, true),
HIDE_SEEKBAR("revanced_hide_seekbar", 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_HOME_BUTTON("revanced_hide_home_button", BOOLEAN, FALSE, true),
HIDE_SHORTS_BUTTON("revanced_hide_shorts_button", BOOLEAN, TRUE, true), HIDE_SHORTS_BUTTON("revanced_hide_shorts_button", BOOLEAN, TRUE, true),
HIDE_SUBSCRIPTIONS_BUTTON("revanced_hide_subscriptions_button", BOOLEAN, FALSE, true), HIDE_SUBSCRIPTIONS_BUTTON("revanced_hide_subscriptions_button", BOOLEAN, FALSE, true),