diff --git a/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/fingerprints/BrowseIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/fingerprints/BrowseIdFingerprint.kt new file mode 100644 index 000000000..5efa3d2a7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/fingerprints/BrowseIdFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.music.general.oldstylelibraryshelf.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.bytecode.isWide32LiteralExists +import com.android.tools.smali.dexlib2.AccessFlags + +object BrowseIdFingerprint : MethodFingerprint( + returnType = "L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + strings = listOf("FEmusic_offline"), + customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45358178) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/patch/OldStyleLibraryShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/patch/OldStyleLibraryShelfPatch.kt new file mode 100644 index 000000000..f559e3cc5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/general/oldstylelibraryshelf/patch/OldStyleLibraryShelfPatch.kt @@ -0,0 +1,51 @@ +package app.revanced.patches.music.general.oldstylelibraryshelf.patch + +import app.revanced.extensions.exception +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.general.oldstylelibraryshelf.fingerprints.BrowseIdFingerprint +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getStringIndex +import app.revanced.util.enum.CategoryType +import app.revanced.util.integrations.Constants.MUSIC_GENERAL +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction + +@Patch +@Name("Enable old style library shelf") +@Description("Return the library shelf to old style.") +@DependsOn([SettingsPatch::class]) +@MusicCompatibility +class OldStyleLibraryShelfPatch : BytecodePatch( + listOf(BrowseIdFingerprint) +) { + override fun execute(context: BytecodeContext) { + + BrowseIdFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = getStringIndex("FEmusic_offline") - 5 + val targetRegister = getInstruction(targetIndex).registerA + + addInstructions( + targetIndex + 1, """ + invoke-static {v$targetRegister}, $MUSIC_GENERAL->enableOldStyleLibraryShelf(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$targetRegister + """ + ) + } + } ?: throw BrowseIdFingerprint.exception + + SettingsPatch.addMusicPreference( + CategoryType.GENERAL, + "revanced_enable_old_style_library_shelf", + "false" + ) + + } +} \ No newline at end of file diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index feaaf7262..7fd1aae2a 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -30,6 +30,8 @@ Enable landscape mode Enable new player layouts. (YT Music v5.47.51+) Enable new layout + Return the library shelf to old style. (Experimental) + Enable old style library shelf Return the mini players to old style. (YT Music v5.55.53+) Enable old style mini player Enable 250/251 opus codec when playing audio.