From 509ef96cd077caa54bb8b254991aa213dddf999a Mon Sep 17 00:00:00 2001 From: Aaron Veil <70171475+anddea@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:34:46 +0300 Subject: [PATCH] fix(YouTube Music - Player components): `Remember shuffle state` setting does not remember the correct state --- .../music/patches/player/PlayerPatch.java | 11 +++++++---- .../integrations/music/settings/Settings.java | 2 +- .../revanced/integrations/music/utils/VideoUtils.java | 8 ++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/music/patches/player/PlayerPatch.java b/app/src/main/java/app/revanced/integrations/music/patches/player/PlayerPatch.java index 2e16a6b8c1..6d7137a11f 100644 --- a/app/src/main/java/app/revanced/integrations/music/patches/player/PlayerPatch.java +++ b/app/src/main/java/app/revanced/integrations/music/patches/player/PlayerPatch.java @@ -13,6 +13,7 @@ import app.revanced.integrations.music.settings.Settings; import app.revanced.integrations.music.shared.VideoType; +import app.revanced.integrations.music.utils.VideoUtils; @SuppressWarnings({"unused"}) public class PlayerPatch { @@ -145,14 +146,16 @@ public static int hideFullscreenShareButton(int original) { return Settings.HIDE_FULLSCREEN_SHARE_BUTTON.get() ? 0 : original; } - public static void setShuffleState(int buttonState) { + public static void setShuffleState(Enum shuffleState) { if (!Settings.REMEMBER_SHUFFLE_SATE.get()) return; - Settings.SHUFFLE_SATE.save(buttonState); + Settings.ALWAYS_SHUFFLE.save(shuffleState.ordinal() == 1); } - public static int getShuffleState() { - return Settings.SHUFFLE_SATE.get(); + public static void shuffleTracks() { + if (!Settings.ALWAYS_SHUFFLE.get()) + return; + VideoUtils.shuffleTracks(); } public static boolean rememberRepeatState(boolean original) { diff --git a/app/src/main/java/app/revanced/integrations/music/settings/Settings.java b/app/src/main/java/app/revanced/integrations/music/settings/Settings.java index ad4cb9ee73..66af6e3668 100644 --- a/app/src/main/java/app/revanced/integrations/music/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/music/settings/Settings.java @@ -135,7 +135,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_FULLSCREEN_SHARE_BUTTON = new BooleanSetting("revanced_hide_fullscreen_share_button", FALSE, true); public static final BooleanSetting REMEMBER_REPEAT_SATE = new BooleanSetting("revanced_remember_repeat_state", TRUE); public static final BooleanSetting REMEMBER_SHUFFLE_SATE = new BooleanSetting("revanced_remember_shuffle_state", TRUE); - public static final IntegerSetting SHUFFLE_SATE = new IntegerSetting("revanced_shuffle_state", 1); + public static final BooleanSetting ALWAYS_SHUFFLE = new BooleanSetting("revanced_always_shuffle", FALSE); public static final BooleanSetting RESTORE_OLD_COMMENTS_POPUP_PANELS = new BooleanSetting("revanced_restore_old_comments_popup_panels", FALSE, true); public static final BooleanSetting RESTORE_OLD_PLAYER_BACKGROUND = new BooleanSetting("revanced_restore_old_player_background", FALSE, true); public static final BooleanSetting RESTORE_OLD_PLAYER_LAYOUT = new BooleanSetting("revanced_restore_old_player_layout", FALSE, true); diff --git a/app/src/main/java/app/revanced/integrations/music/utils/VideoUtils.java b/app/src/main/java/app/revanced/integrations/music/utils/VideoUtils.java index 0677d6b15e..a92283ed03 100644 --- a/app/src/main/java/app/revanced/integrations/music/utils/VideoUtils.java +++ b/app/src/main/java/app/revanced/integrations/music/utils/VideoUtils.java @@ -6,6 +6,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.media.AudioManager; +import android.util.Log; import androidx.annotation.NonNull; @@ -70,6 +71,13 @@ public static void openInYouTubeMusic(@NonNull String songId) { launchView(url, context.getPackageName()); } + /** + * Rest of the implementation added by patch. + */ + public static void shuffleTracks() { + Log.d("Extended: VideoUtils", "Tracks are shuffled"); + } + /** * Rest of the implementation added by patch. */