mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-03 08:04:36 +02:00
feat(music): add remember-repeat-state
patch
This commit is contained in:
parent
6601d4539c
commit
828be15c44
@ -0,0 +1,21 @@
|
||||
package app.revanced.patches.music.player.repeat.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object RepeatTrackFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_NEZ
|
||||
),
|
||||
strings = listOf("w_st")
|
||||
)
|
@ -0,0 +1,48 @@
|
||||
package app.revanced.patches.music.player.repeat.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.player.repeat.fingerprints.RepeatTrackFingerprint
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.enum.CategoryType
|
||||
import app.revanced.util.integrations.Constants.MUSIC_PLAYER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Remember repeat state")
|
||||
@Description("Remembers the state of the repeat.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@MusicCompatibility
|
||||
class RememberRepeatPatch : BytecodePatch(
|
||||
listOf(RepeatTrackFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
RepeatTrackFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex, """
|
||||
invoke-static {v$targetRegister}, $MUSIC_PLAYER->rememberRepeatState(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw RepeatTrackFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.PLAYER,
|
||||
"revanced_remember_repeat_state",
|
||||
"true"
|
||||
)
|
||||
}
|
||||
}
|
@ -127,6 +127,8 @@
|
||||
<string name="revanced_replace_flyout_panel_dismiss_queue_continue_watch_title">Continue watching</string>
|
||||
<string name="revanced_replace_flyout_panel_dismiss_queue_summary">Replaces dismiss queue menu to watch on YouTube.</string>
|
||||
<string name="revanced_replace_flyout_panel_dismiss_queue_title">Replace dismiss queue</string>
|
||||
<string name="revanced_remember_repeat_state_summary">Remembers the state of the repeat.</string>
|
||||
<string name="revanced_remember_repeat_state_title">Remember repeat state</string>
|
||||
<string name="revanced_remember_shuffle_state_summary">Remembers the state of the shuffle.</string>
|
||||
<string name="revanced_remember_shuffle_state_title">Remember shuffle state</string>
|
||||
<string name="revanced_reset">Reset</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user