diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/patches/player/PlayerPatch.java b/extensions/shared/src/main/java/app/revanced/extension/music/patches/player/PlayerPatch.java index 71eed73e2..3c148524d 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/patches/player/PlayerPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/patches/player/PlayerPatch.java @@ -3,121 +3,137 @@ package app.revanced.extension.music.patches.player; import static app.revanced.extension.shared.utils.Utils.hideViewByRemovingFromParentUnderCondition; import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition; import static app.revanced.extension.shared.utils.Utils.isSDKAbove; +import static app.revanced.extension.shared.utils.Utils.runOnMainThreadDelayed; -import android.annotation.SuppressLint; import android.graphics.Color; import android.view.View; -import java.util.Arrays; +import org.apache.commons.lang3.ArrayUtils; + +import java.lang.ref.WeakReference; import app.revanced.extension.music.settings.Settings; import app.revanced.extension.music.shared.VideoType; import app.revanced.extension.music.utils.VideoUtils; -import app.revanced.extension.shared.utils.Utils; +import app.revanced.extension.shared.utils.Logger; -@SuppressWarnings({"unused"}) +@SuppressWarnings({"unused", "SpellCheckingInspection"}) public class PlayerPatch { - private static final int MUSIC_VIDEO_GREY_BACKGROUND_COLOR = -12566464; - private static final int MUSIC_VIDEO_ORIGINAL_BACKGROUND_COLOR = -16579837; + private static final boolean ADD_MINIPLAYER_NEXT_BUTTON = + Settings.ADD_MINIPLAYER_NEXT_BUTTON.get(); + private static final boolean ADD_MINIPLAYER_PREVIOUS_BUTTON = + Settings.ADD_MINIPLAYER_PREVIOUS_BUTTON.get(); + private static final boolean CHANGE_PLAYER_BACKGROUND_COLOR = + Settings.CHANGE_PLAYER_BACKGROUND_COLOR.get(); + private static final boolean DISABLE_PLAYER_GESTURE = + Settings.DISABLE_PLAYER_GESTURE.get(); + private static final boolean ENABLE_SWIPE_TO_DISMISS_MINIPLAYER = + Settings.ENABLE_SWIPE_TO_DISMISS_MINIPLAYER.get(); + private static final boolean HIDE_DOUBLE_TAP_OVERLAY_FILTER = + Settings.HIDE_DOUBLE_TAP_OVERLAY_FILTER.get(); + private static final boolean HIDE_FULLSCREEN_SHARE_BUTTON = + Settings.HIDE_FULLSCREEN_SHARE_BUTTON.get(); + private static final boolean HIDE_SONG_VIDEO_TOGGLE = + Settings.HIDE_SONG_VIDEO_TOGGLE.get(); + private static final boolean RESTORE_OLD_COMMENTS_POPUP_PANELS = + Settings.RESTORE_OLD_COMMENTS_POPUP_PANELS.get(); - @SuppressLint("StaticFieldLeak") - public static View previousButton; - @SuppressLint("StaticFieldLeak") - public static View nextButton; + private static final int MUSIC_VIDEO_GREY_BACKGROUND_COLOR = 0xFF404040; + private static final int MUSIC_VIDEO_ORIGINAL_BACKGROUND_COLOR = 0xFF030303; - public static boolean disableMiniPlayerGesture() { - return Settings.DISABLE_MINI_PLAYER_GESTURE.get(); + private static WeakReference previousButtonViewRef = new WeakReference<>(null); + private static WeakReference nextButtonViewRef = new WeakReference<>(null); + + public static boolean addMiniPlayerNextButton(boolean original) { + return !ADD_MINIPLAYER_NEXT_BUTTON && original; } - public static boolean disablePlayerGesture() { - return Settings.DISABLE_PLAYER_GESTURE.get(); + public static boolean changeMiniPlayerColor() { + return Settings.CHANGE_MINIPLAYER_COLOR.get(); } - public static boolean enableColorMatchPlayer() { - return Settings.ENABLE_COLOR_MATCH_PLAYER.get(); - } - - public static int enableBlackPlayerBackground(int originalColor) { - return Settings.ENABLE_BLACK_PLAYER_BACKGROUND.get() - && originalColor != MUSIC_VIDEO_GREY_BACKGROUND_COLOR + public static int changePlayerBackgroundColor(int originalColor) { + return CHANGE_PLAYER_BACKGROUND_COLOR && originalColor != MUSIC_VIDEO_GREY_BACKGROUND_COLOR ? Color.BLACK : originalColor; } - public static boolean enableForceMinimizedPlayer(boolean original) { - return Settings.ENABLE_FORCE_MINIMIZED_PLAYER.get() || original; + public static boolean disableMiniPlayerGesture() { + return Settings.DISABLE_MINIPLAYER_GESTURE.get(); } - public static boolean enableMiniPlayerNextButton(boolean original) { - return !Settings.ENABLE_MINI_PLAYER_NEXT_BUTTON.get() && original; + public static boolean disablePlayerGesture() { + return DISABLE_PLAYER_GESTURE; + } + + public static boolean enableForcedMiniPlayer(boolean original) { + return Settings.ENABLE_FORCED_MINIPLAYER.get() || original; } public static View[] getViewArray(View[] oldViewArray) { - if (previousButton != null) { - if (nextButton != null) { - return getViewArray(getViewArray(oldViewArray, previousButton), nextButton); - } else { - return getViewArray(oldViewArray, previousButton); + View previousButtonView = previousButtonViewRef.get(); + if (previousButtonView != null) { + oldViewArray = ArrayUtils.add(oldViewArray, previousButtonView); + View nextButtonView = nextButtonViewRef.get(); + if (nextButtonView != null) { + oldViewArray = ArrayUtils.add(oldViewArray, nextButtonView); } - } else { - return oldViewArray; + } + return oldViewArray; + } + + public static void setNextButtonView(View nextButtonView) { + nextButtonViewRef = new WeakReference<>(nextButtonView); + } + + public static void setNextButtonOnClickListener(View nextButtonView) { + if (nextButtonView != null) { + hideViewUnderCondition( + !ADD_MINIPLAYER_NEXT_BUTTON, + nextButtonView + ); + + nextButtonView.setOnClickListener(v -> nextButtonClicked(nextButtonView)); } } - private static View[] getViewArray(View[] oldViewArray, View newView) { - final int oldViewArrayLength = oldViewArray.length; - - View[] newViewArray = Arrays.copyOf(oldViewArray, oldViewArrayLength + 1); - newViewArray[oldViewArrayLength] = newView; - return newViewArray; + // rest of the implementation added by patch. + private static void nextButtonClicked(View view) { + // These instructions are ignored by patch. + Logger.printDebug(() -> "next button clicked: " + view); } - public static void setNextButton(View nextButtonView) { - if (nextButtonView == null) - return; + public static void setPreviousButtonView(View previousButtonView) { + previousButtonViewRef = new WeakReference<>(previousButtonView); + } - hideViewUnderCondition( - !Settings.ENABLE_MINI_PLAYER_NEXT_BUTTON.get(), - nextButtonView - ); + public static void setPreviousButtonOnClickListener(View previousButtonView) { + if (previousButtonView != null) { + hideViewUnderCondition( + !ADD_MINIPLAYER_PREVIOUS_BUTTON, + previousButtonView + ); - nextButtonView.setOnClickListener(PlayerPatch::setNextButtonOnClickListener); + previousButtonView.setOnClickListener(v -> previousButtonClicked(previousButtonView)); + } } // rest of the implementation added by patch. - private static void setNextButtonOnClickListener(View view) { - if (Settings.ENABLE_MINI_PLAYER_NEXT_BUTTON.get()) - view.getClass(); - } - - public static void setPreviousButton(View previousButtonView) { - if (previousButtonView == null) - return; - - hideViewUnderCondition( - !Settings.ENABLE_MINI_PLAYER_PREVIOUS_BUTTON.get(), - previousButtonView - ); - - previousButtonView.setOnClickListener(PlayerPatch::setPreviousButtonOnClickListener); - } - - // rest of the implementation added by patch. - private static void setPreviousButtonOnClickListener(View view) { - if (Settings.ENABLE_MINI_PLAYER_PREVIOUS_BUTTON.get()) - view.getClass(); + private static void previousButtonClicked(View view) { + // These instructions are ignored by patch. + Logger.printDebug(() -> "previous button clicked: " + view); } public static boolean enableSwipeToDismissMiniPlayer() { - return Settings.ENABLE_SWIPE_TO_DISMISS_MINI_PLAYER.get(); + return ENABLE_SWIPE_TO_DISMISS_MINIPLAYER; } public static boolean enableSwipeToDismissMiniPlayer(boolean original) { - return !Settings.ENABLE_SWIPE_TO_DISMISS_MINI_PLAYER.get() && original; + return !ENABLE_SWIPE_TO_DISMISS_MINIPLAYER && original; } public static Object enableSwipeToDismissMiniPlayer(Object object) { - return Settings.ENABLE_SWIPE_TO_DISMISS_MINI_PLAYER.get() ? null : object; + return ENABLE_SWIPE_TO_DISMISS_MINIPLAYER ? null : object; } public static int enableZenMode(int originalColor) { @@ -129,19 +145,20 @@ public class PlayerPatch { return originalColor; } - public static void hideAudioVideoSwitchToggle(View view, int originalVisibility) { - if (Settings.HIDE_AUDIO_VIDEO_SWITCH_TOGGLE.get()) { - originalVisibility = View.GONE; - } - view.setVisibility(originalVisibility); + public static void hideSongVideoToggle(View view, int originalVisibility) { + view.setVisibility( + HIDE_SONG_VIDEO_TOGGLE + ? View.GONE + : originalVisibility + ); } public static void hideDoubleTapOverlayFilter(View view) { - hideViewByRemovingFromParentUnderCondition(Settings.HIDE_DOUBLE_TAP_OVERLAY_FILTER, view); + hideViewByRemovingFromParentUnderCondition(HIDE_DOUBLE_TAP_OVERLAY_FILTER, view); } public static int hideFullscreenShareButton(int original) { - return Settings.HIDE_FULLSCREEN_SHARE_BUTTON.get() ? 0 : original; + return HIDE_FULLSCREEN_SHARE_BUTTON ? 0 : original; } public static void setShuffleState(Enum shuffleState) { @@ -163,7 +180,7 @@ public class PlayerPatch { return; if (needDelay) { - Utils.runOnMainThreadDelayed(VideoUtils::shuffleTracks, 1000); + runOnMainThreadDelayed(VideoUtils::shuffleTracks, 1000); } else { VideoUtils.shuffleTracks(); } @@ -185,7 +202,7 @@ public class PlayerPatch { if (!Settings.SETTINGS_INITIALIZED.get()) { return original; } - return !Settings.RESTORE_OLD_COMMENTS_POPUP_PANELS.get() && original; + return !RESTORE_OLD_COMMENTS_POPUP_PANELS && original; } public static boolean restoreOldPlayerBackground(boolean original) { diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java b/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java index 72b0337ae..b1502a416 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java @@ -130,21 +130,21 @@ public class Settings extends BaseSettings { // PreferenceScreen: Player - public static final BooleanSetting ENABLE_MINI_PLAYER_NEXT_BUTTON = new BooleanSetting("revanced_enable_mini_player_next_button", TRUE, true); - public static final BooleanSetting ENABLE_MINI_PLAYER_PREVIOUS_BUTTON = new BooleanSetting("revanced_enable_mini_player_previous_button", TRUE, true); - public static final BooleanSetting ENABLE_COLOR_MATCH_PLAYER = new BooleanSetting("revanced_enable_color_match_player", TRUE); - public static final BooleanSetting ENABLE_BLACK_PLAYER_BACKGROUND = new BooleanSetting("revanced_enable_black_player_background", FALSE, true); - public static final BooleanSetting DISABLE_MINI_PLAYER_GESTURE = new BooleanSetting("revanced_disable_mini_player_gesture", FALSE, true); + public static final BooleanSetting ADD_MINIPLAYER_NEXT_BUTTON = new BooleanSetting("revanced_add_miniplayer_next_button", TRUE, true); + public static final BooleanSetting ADD_MINIPLAYER_PREVIOUS_BUTTON = new BooleanSetting("revanced_add_miniplayer_previous_button", TRUE, true); + public static final BooleanSetting CHANGE_MINIPLAYER_COLOR = new BooleanSetting("revanced_change_miniplayer_color", TRUE); + public static final BooleanSetting CHANGE_PLAYER_BACKGROUND_COLOR = new BooleanSetting("revanced_change_player_background_color", FALSE, true); + public static final BooleanSetting DISABLE_MINIPLAYER_GESTURE = new BooleanSetting("revanced_disable_miniplayer_gesture", FALSE, true); public static final BooleanSetting DISABLE_PLAYER_GESTURE = new BooleanSetting("revanced_disable_player_gesture", FALSE, true); - public static final BooleanSetting ENABLE_FORCE_MINIMIZED_PLAYER = new BooleanSetting("revanced_enable_force_minimized_player", TRUE); - public static final BooleanSetting ENABLE_SWIPE_TO_DISMISS_MINI_PLAYER = new BooleanSetting("revanced_enable_swipe_to_dismiss_mini_player", TRUE, true); + public static final BooleanSetting ENABLE_FORCED_MINIPLAYER = new BooleanSetting("revanced_enable_forced_miniplayer", TRUE); + public static final BooleanSetting ENABLE_SWIPE_TO_DISMISS_MINIPLAYER = new BooleanSetting("revanced_enable_swipe_to_dismiss_miniplayer", TRUE, true); public static final BooleanSetting ENABLE_ZEN_MODE = new BooleanSetting("revanced_enable_zen_mode", FALSE); public static final BooleanSetting ENABLE_ZEN_MODE_PODCAST = new BooleanSetting("revanced_enable_zen_mode_podcast", FALSE); public static final BooleanSetting HIDE_COMMENT_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_comment_channel_guidelines", TRUE); public static final BooleanSetting HIDE_DOUBLE_TAP_OVERLAY_FILTER = new BooleanSetting("revanced_hide_double_tap_overlay_filter", FALSE, true); public static final BooleanSetting HIDE_COMMENT_TIMESTAMP_AND_EMOJI_BUTTONS = new BooleanSetting("revanced_hide_comment_timestamp_and_emoji_buttons", FALSE); public static final BooleanSetting HIDE_FULLSCREEN_SHARE_BUTTON = new BooleanSetting("revanced_hide_fullscreen_share_button", FALSE, true); - public static final BooleanSetting HIDE_AUDIO_VIDEO_SWITCH_TOGGLE = new BooleanSetting("revanced_hide_audio_video_switch_toggle", FALSE, true); + public static final BooleanSetting HIDE_SONG_VIDEO_TOGGLE = new BooleanSetting("revanced_hide_song_video_toggle", 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 BooleanSetting ALWAYS_SHUFFLE = new BooleanSetting("revanced_always_shuffle", FALSE); diff --git a/patches/src/main/kotlin/app/revanced/patches/music/player/components/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/music/player/components/Fingerprints.kt index 96762399f..96d619c3d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/player/components/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/player/components/Fingerprints.kt @@ -227,13 +227,17 @@ internal val nextButtonVisibilityFingerprint = legacyFingerprint( ) ) +internal const val OLD_ENGAGEMENT_PANEL_FEATURE_FLAG = 45427672L + internal val oldEngagementPanelFingerprint = legacyFingerprint( name = "oldEngagementPanelFingerprint", returnType = "Z", parameters = emptyList(), - literals = listOf(45427672L), + literals = listOf(OLD_ENGAGEMENT_PANEL_FEATURE_FLAG), ) +internal const val OLD_PLAYER_BACKGROUND_FEATURE_FLAG = 45415319L + /** * Deprecated in YouTube Music v6.34.51+ */ @@ -241,9 +245,11 @@ internal val oldPlayerBackgroundFingerprint = legacyFingerprint( name = "oldPlayerBackgroundFingerprint", returnType = "Z", parameters = emptyList(), - literals = listOf(45415319L), + literals = listOf(OLD_PLAYER_BACKGROUND_FEATURE_FLAG), ) +internal const val OLD_PLAYER_LAYOUT_FEATURE_FLAG = 45399578L + /** * Deprecated in YouTube Music v6.31.55+ */ @@ -251,7 +257,7 @@ internal val oldPlayerLayoutFingerprint = legacyFingerprint( name = "oldPlayerLayoutFingerprint", returnType = "Z", parameters = emptyList(), - literals = listOf(45399578L), + literals = listOf(OLD_PLAYER_LAYOUT_FEATURE_FLAG), ) internal val playerPatchConstructorFingerprint = legacyFingerprint( diff --git a/patches/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt index c86bf5d52..3fa1eef20 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt @@ -198,21 +198,21 @@ val playerComponentsPatch = bytecodePatch( execute { - // region patch for enable next previous button + // region patch for add next previous button - val nextButtonFieldName = "nextButton" - val previousButtonFieldName = "previousButton" + val nextButtonViewMethodName = "setNextButtonView" + val previousButtonViewMethodName = "setPreviousButtonView" val nextButtonClassFieldName = "nextButtonClass" val previousButtonClassFieldName = "previousButtonClass" - val nextButtonButtonMethodName = "setNextButton" - val previousButtonMethodName = "setPreviousButton" - val nextButtonOnClickListenerMethodName = "setNextButtonOnClickListener" - val previousButtonOnClickListenerMethodName = "setPreviousButtonOnClickListener" + val nextOnClickListenerMethodName = "setNextButtonOnClickListener" + val previousOnClickListenerMethodName = "setPreviousButtonOnClickListener" + val nextButtonClickedMethodName = "nextButtonClicked" + val previousButtonClickedMethodName = "previousButtonClicked" val nextButtonIntentString = "YTM Next" val previousButtonIntentString = "YTM Previous" - fun MutableMethod.setStaticFieldValue( - fieldName: String, + fun MutableMethod.setButtonView( + methodName: String, viewId: Long ) { val miniPlayerPlayPauseReplayButtonIndex = @@ -232,7 +232,7 @@ val playerComponentsPatch = bytecodePatch( const v$constRegister, $viewId invoke-virtual {v$findViewByIdRegister, v$constRegister}, $definingClass->findViewById(I)Landroid/view/View; move-result-object v$constRegister - sput-object v$constRegister, $PLAYER_CLASS_DESCRIPTOR->$fieldName:Landroid/view/View; + invoke-static {v$constRegister}, $PLAYER_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V """ ) } @@ -256,7 +256,7 @@ val playerComponentsPatch = bytecodePatch( ) } - fun MutableMethod.setOnClickListener( + fun MutableMethod.setIntentOnClickListener( intentString: String, methodName: String, fieldName: String @@ -302,6 +302,32 @@ val playerComponentsPatch = bytecodePatch( } } + fun MutableMethod.setOnclickListener( + methodName: String, + viewId: Long + ) { + val miniPlayerPlayPauseReplayButtonIndex = + indexOfFirstLiteralInstructionOrThrow(miniPlayerPlayPauseReplayButton) + val miniPlayerPlayPauseReplayButtonRegister = + getInstruction(miniPlayerPlayPauseReplayButtonIndex).registerA + val findViewByIdIndex = + indexOfFirstInstructionOrThrow( + miniPlayerPlayPauseReplayButtonIndex, + Opcode.INVOKE_VIRTUAL + ) + val parentViewRegister = + getInstruction(findViewByIdIndex).registerC + + addInstructions( + miniPlayerPlayPauseReplayButtonIndex, """ + const v$miniPlayerPlayPauseReplayButtonRegister, $viewId + invoke-virtual {v$parentViewRegister, v$miniPlayerPlayPauseReplayButtonRegister}, Landroid/view/View;->findViewById(I)Landroid/view/View; + move-result-object v$miniPlayerPlayPauseReplayButtonRegister + invoke-static {v$miniPlayerPlayPauseReplayButtonRegister}, $PLAYER_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V + """ + ) + } + val miniPlayerConstructorMutableMethod = miniPlayerConstructorFingerprint.methodOrThrow() @@ -320,33 +346,33 @@ val playerComponentsPatch = bytecodePatch( addInstructions( targetIndex + 1, """ - invoke-static {v$targetRegister}, $PLAYER_CLASS_DESCRIPTOR->enableMiniPlayerNextButton(Z)Z + invoke-static {v$targetRegister}, $PLAYER_CLASS_DESCRIPTOR->addMiniPlayerNextButton(Z)Z move-result v$targetRegister """ ) } } } else { - miniPlayerConstructorMutableMethod.setInstanceFieldValue( - nextButtonButtonMethodName, + miniPlayerConstructorMutableMethod.setOnclickListener( + nextOnClickListenerMethodName, topStart ) - mppWatchWhileLayoutMutableMethod.setStaticFieldValue(nextButtonFieldName, topStart) - pendingIntentReceiverMutableMethod.setOnClickListener( + mppWatchWhileLayoutMutableMethod.setButtonView(nextButtonViewMethodName, topStart) + pendingIntentReceiverMutableMethod.setIntentOnClickListener( nextButtonIntentString, - nextButtonOnClickListenerMethodName, + nextButtonClickedMethodName, nextButtonClassFieldName ) } - miniPlayerConstructorMutableMethod.setInstanceFieldValue( - previousButtonMethodName, + miniPlayerConstructorMutableMethod.setOnclickListener( + previousOnClickListenerMethodName, topEnd ) - mppWatchWhileLayoutMutableMethod.setStaticFieldValue(previousButtonFieldName, topEnd) - pendingIntentReceiverMutableMethod.setOnClickListener( + mppWatchWhileLayoutMutableMethod.setButtonView(previousButtonViewMethodName, topEnd) + pendingIntentReceiverMutableMethod.setIntentOnClickListener( previousButtonIntentString, - previousButtonOnClickListenerMethodName, + previousButtonClickedMethodName, previousButtonClassFieldName ) @@ -354,18 +380,18 @@ val playerComponentsPatch = bytecodePatch( addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_mini_player_next_button", + "revanced_add_miniplayer_next_button", "true" ) addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_mini_player_previous_button", + "revanced_add_miniplayer_previous_button", "true" ) // endregion - // region patch for enable color match player and enable black player background + // region patch for color match player and black player background val ( colorMathPlayerMethodParameter, @@ -385,9 +411,9 @@ val playerComponentsPatch = bytecodePatch( targetMethod.addInstructions( insertIndex, """ - invoke-static {p1}, $PLAYER_CLASS_DESCRIPTOR->enableBlackPlayerBackground(I)I + invoke-static {p1}, $PLAYER_CLASS_DESCRIPTOR->changePlayerBackgroundColor(I)I move-result p1 - invoke-static {p2}, $PLAYER_CLASS_DESCRIPTOR->enableBlackPlayerBackground(I)I + invoke-static {p2}, $PLAYER_CLASS_DESCRIPTOR->changePlayerBackgroundColor(I)I move-result p2 """ ) @@ -420,7 +446,7 @@ val playerComponentsPatch = bytecodePatch( addInstructionsWithLabels( invokeDirectIndex + 1, """ - invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->enableColorMatchPlayer()Z + invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->changeMiniPlayerColor()Z move-result v$freeRegister if-eqz v$freeRegister, :off invoke-virtual {p1}, $colorMathPlayerInvokeVirtualReference @@ -438,12 +464,12 @@ val playerComponentsPatch = bytecodePatch( addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_color_match_player", + "revanced_change_miniplayer_color", "true" ) addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_black_player_background", + "revanced_change_player_background_color", "false" ) @@ -487,7 +513,7 @@ val playerComponentsPatch = bytecodePatch( addSwitchPreference( CategoryType.PLAYER, - "revanced_disable_mini_player_gesture", + "revanced_disable_miniplayer_gesture", "false" ) addSwitchPreference( @@ -498,7 +524,7 @@ val playerComponentsPatch = bytecodePatch( // endregion - // region patch for enable force minimized player + // region patch for forced minimized player minimizedPlayerFingerprint.matchOrThrow().let { it.method.apply { @@ -507,7 +533,7 @@ val playerComponentsPatch = bytecodePatch( addInstructions( insertIndex, """ - invoke-static {v$insertRegister}, $PLAYER_CLASS_DESCRIPTOR->enableForceMinimizedPlayer(Z)Z + invoke-static {v$insertRegister}, $PLAYER_CLASS_DESCRIPTOR->enableForcedMiniPlayer(Z)Z move-result v$insertRegister """ ) @@ -516,13 +542,13 @@ val playerComponentsPatch = bytecodePatch( addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_force_minimized_player", + "revanced_enable_forced_miniplayer", "true" ) // endregion - // region patch for enable swipe to dismiss mini player + // region patch for enable swipe to dismiss miniplayer if (!is_6_42_or_greater) { swipeToCloseFingerprint.methodOrThrow().apply { @@ -676,7 +702,7 @@ val playerComponentsPatch = bytecodePatch( addSwitchPreference( CategoryType.PLAYER, - "revanced_enable_swipe_to_dismiss_mini_player", + "revanced_enable_swipe_to_dismiss_miniplayer", "true" ) @@ -794,7 +820,7 @@ val playerComponentsPatch = bytecodePatch( // endregion - // region patch for hide song video switch toggle + // region patch for hide song video toggle audioVideoSwitchToggleFingerprint.methodOrThrow().apply { implementation!!.instructions @@ -813,14 +839,14 @@ val playerComponentsPatch = bytecodePatch( replaceInstruction( index, "invoke-static {v${instruction.registerC}, v${instruction.registerD}}," + - "$PLAYER_CLASS_DESCRIPTOR->hideAudioVideoSwitchToggle(Landroid/view/View;I)V" + "$PLAYER_CLASS_DESCRIPTOR->hideSongVideoToggle(Landroid/view/View;I)V" ) } } addSwitchPreference( CategoryType.PLAYER, - "revanced_hide_audio_video_switch_toggle", + "revanced_hide_song_video_toggle", "false" ) @@ -997,7 +1023,7 @@ val playerComponentsPatch = bytecodePatch( if (is_6_27_or_greater && !is_7_18_or_greater) { oldEngagementPanelFingerprint.injectLiteralInstructionBooleanCall( - 45427672L, + OLD_ENGAGEMENT_PANEL_FEATURE_FLAG, "$PLAYER_CLASS_DESCRIPTOR->restoreOldCommentsPopUpPanels(Z)Z" ) restoreOldCommentsPopupPanel = true @@ -1081,7 +1107,7 @@ val playerComponentsPatch = bytecodePatch( if (oldPlayerBackgroundFingerprint.resolvable()) { oldPlayerBackgroundFingerprint.injectLiteralInstructionBooleanCall( - 45415319L, + OLD_PLAYER_BACKGROUND_FEATURE_FLAG, "$PLAYER_CLASS_DESCRIPTOR->restoreOldPlayerBackground(Z)Z" ) addSwitchPreference( @@ -1097,7 +1123,7 @@ val playerComponentsPatch = bytecodePatch( if (oldPlayerLayoutFingerprint.resolvable()) { oldPlayerLayoutFingerprint.injectLiteralInstructionBooleanCall( - 45399578L, + OLD_PLAYER_LAYOUT_FEATURE_FLAG, "$PLAYER_CLASS_DESCRIPTOR->restoreOldPlayerLayout(Z)Z" ) addSwitchPreference( @@ -1113,29 +1139,3 @@ val playerComponentsPatch = bytecodePatch( } } - -private fun MutableMethod.setInstanceFieldValue( - methodName: String, - viewId: Long -) { - val miniPlayerPlayPauseReplayButtonIndex = - indexOfFirstLiteralInstructionOrThrow(miniPlayerPlayPauseReplayButton) - val miniPlayerPlayPauseReplayButtonRegister = - getInstruction(miniPlayerPlayPauseReplayButtonIndex).registerA - val findViewByIdIndex = - indexOfFirstInstructionOrThrow( - miniPlayerPlayPauseReplayButtonIndex, - Opcode.INVOKE_VIRTUAL - ) - val parentViewRegister = - getInstruction(findViewByIdIndex).registerC - - addInstructions( - miniPlayerPlayPauseReplayButtonIndex, """ - const v$miniPlayerPlayPauseReplayButtonRegister, $viewId - invoke-virtual {v$parentViewRegister, v$miniPlayerPlayPauseReplayButtonRegister}, Landroid/view/View;->findViewById(I)Landroid/view/View; - move-result-object v$miniPlayerPlayPauseReplayButtonRegister - invoke-static {v$miniPlayerPlayPauseReplayButtonRegister}, $PLAYER_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V - """ - ) -} diff --git a/patches/src/main/resources/music/settings/host/values/strings.xml b/patches/src/main/resources/music/settings/host/values/strings.xml index e15d34f2a..3a338184f 100644 --- a/patches/src/main/resources/music/settings/host/values/strings.xml +++ b/patches/src/main/resources/music/settings/host/values/strings.xml @@ -228,22 +228,22 @@ This does not bypass the age restriction. It just accepts it automatically." Player - Add miniplayer next button - Adds a next track button to the miniplayer. - Add miniplayer previous button - Adds a previous track button to the miniplayer. - Change miniplayer color - Changes the miniplayer color to match the fullscreen player. - Change player background color - Changes the player background color to black. - Disable miniplayer gesture - Disables swipe to change tracks in the miniplayer. + Add miniplayer next button + Adds a next track button to the miniplayer. + Add miniplayer previous button + Adds a previous track button to the miniplayer. + Change miniplayer color + Changes the miniplayer color to match the fullscreen player. + Change player background color + Changes the player background color to black. + Disable miniplayer gesture + Disables swipe to change tracks in the miniplayer. Disable player gesture Disables swipe to change tracks in the player. - Enable forced miniplayer - Enables forced miniplayer when switching to a new track. - Enable swipe to dismiss miniplayer - Enables swipe down to dismiss miniplayer. + Enable forced miniplayer + Enables forced miniplayer when switching to a new track. + Enable swipe to dismiss miniplayer + Enables swipe down to dismiss miniplayer. Enable Zen mode Enables a light grey color for the player background to reduce eye strain. Enable Zen mode in podcasts @@ -256,8 +256,8 @@ This does not bypass the age restriction. It just accepts it automatically."Hides the emoji and timestamp buttons when typing comments. Hide fullscreen Share button Hides the Share button in the fullscreen player. - Hide Song / Video toggle - Hides the Song / Video toggle in the player. + Hide Song / Video toggle + Hides the Song / Video toggle in the player. Remember repeat state Remembers the state of the repeat toggle. Remember shuffle state