refactor(youtube/remember-playback-speed): do not use other unrelated patches extension methods

This commit is contained in:
oSumAtrIX 2023-05-18 02:58:27 +02:00
parent a64f33e385
commit 19798bf31c
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 5 additions and 6 deletions

View file

@ -28,7 +28,6 @@ import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.BuilderInstruction
import org.jf.dexlib2.builder.MutableMethodImplementation
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.immutable.ImmutableMethod
@ -218,9 +217,8 @@ class VideoInformationPatch : BytecodePatch(
)
private fun getReference(instructions: List<BuilderInstruction>, offset: Int, opcode: Opcode) =
instructions[instructions.indexOfFirst { it.opcode == opcode } + offset].reference
val Instruction.reference get() = (this as ReferenceInstruction).reference.toString()
(instructions[instructions.indexOfFirst { it.opcode == opcode } + offset] as ReferenceInstruction)
.reference.toString()
private lateinit var speedSelectionInsertMethod: MutableMethod
private var speedSelectionInsertIndex = 0

View file

@ -19,9 +19,9 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch
import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch.Companion.reference
import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch
import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Name("remember-playback-speed")
@Description("Adds the ability to remember the playback speed you chose in the video playback speed flyout.")
@ -78,7 +78,8 @@ class RememberPlaybackSpeedPatch : BytecodePatch(
*/
InitializePlaybackSpeedValuesFingerprint.result?.apply {
// Infer everything necessary for calling the method setPlaybackSpeed().
val onItemClickListenerClassFieldReference = mutableMethod.instruction(0).reference
val onItemClickListenerClassFieldReference =
mutableMethod.instruction<ReferenceInstruction>(0).reference
// Registers are not used at index 0, so they can be freely used.
mutableMethod.addInstructions(