From 77e8639b71048f2795f8f32fe18d052b335e3ce4 Mon Sep 17 00:00:00 2001 From: KAZI MMT <82371061+kazimmt@users.noreply.github.com> Date: Sat, 15 Jul 2023 18:32:39 +0600 Subject: [PATCH] feat(youtube): rename `video-speed` to `playback-speed` (#2642) --- .../speed/{VideoSpeed.kt => PlaybackSpeed.kt} | 50 +++++++++---------- ...ility.kt => PlaybackSpeedCompatibility.kt} | 2 +- ....kt => GetOldPlaybackSpeedsFingerprint.kt} | 2 +- ...=> ShowOldPlaybackSpeedMenuFingerprint.kt} | 2 +- ...laybackSpeedMenuIntegrationsFingerprint.kt | 7 +++ ...ldVideoSpeedMenuIntegrationsFingerprint.kt | 7 --- ...edPatch.kt => CustomPlaybackSpeedPatch.kt} | 48 +++++++++--------- .../patch/RememberPlaybackSpeedPatch.kt | 6 +-- 8 files changed, 62 insertions(+), 62 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/{VideoSpeed.kt => PlaybackSpeed.kt} (71%) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/{VideoSpeedCompatibility.kt => PlaybackSpeedCompatibility.kt} (83%) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/{GetOldVideoSpeedsFingerprint.kt => GetOldPlaybackSpeedsFingerprint.kt} (79%) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/{ShowOldVideoSpeedMenuFingerprint.kt => ShowOldPlaybackSpeedMenuFingerprint.kt} (76%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuIntegrationsFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/{CustomVideoSpeedPatch.kt => CustomPlaybackSpeedPatch.kt} (82%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeed.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeed.kt index e71740a1d..33d6376d8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeed.kt @@ -1,25 +1,25 @@ -package app.revanced.patches.youtube.video.speed - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch -import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackSpeedPatch - -@Patch -@Name("Video speed") -@Description("Adds custom video speeds and ability to remember the playback speed you chose in the video playback speed flyout.") -@DependsOn([CustomVideoSpeedPatch::class, RememberPlaybackSpeedPatch::class]) -@VideoSpeedCompatibility -@Version("0.0.1") -class VideoSpeed : BytecodePatch() { - override fun execute(context: BytecodeContext): PatchResult { - return PatchResultSuccess() // All patches this patch depends on succeed. - } -} +package app.revanced.patches.youtube.video.speed + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.youtube.video.speed.custom.patch.CustomPlaybackSpeedPatch +import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackSpeedPatch + +@Patch +@Name("Playback speed") +@Description("Adds custom playback speeds and ability to remember the playback speed you chose in the video playback speed flyout.") +@DependsOn([CustomPlaybackSpeedPatch::class, RememberPlaybackSpeedPatch::class]) +@PlaybackSpeedCompatibility +@Version("0.0.1") +class PlaybackSpeed : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { + return PatchResultSuccess() // All patches this patch depends on succeed. + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedCompatibility.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedCompatibility.kt index 4072fa4db..2181dc918 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedCompatibility.kt @@ -5,4 +5,4 @@ import app.revanced.patcher.annotation.Package @Compatibility([Package("com.google.android.youtube", arrayOf("18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) -internal annotation class VideoSpeedCompatibility +internal annotation class PlaybackSpeedCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldPlaybackSpeedsFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldPlaybackSpeedsFingerprint.kt index 233d1d09d..e7901c5d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldPlaybackSpeedsFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.video.speed.custom.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -object GetOldVideoSpeedsFingerprint : MethodFingerprint( +object GetOldPlaybackSpeedsFingerprint : MethodFingerprint( parameters = listOf("[L", "I"), strings = listOf("menu_item_playback_speed") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuFingerprint.kt index 3844ab32d..9e7d00db4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuFingerprint.kt @@ -2,6 +2,6 @@ package app.revanced.patches.youtube.video.speed.custom.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -object ShowOldVideoSpeedMenuFingerprint : MethodFingerprint( +object ShowOldPlaybackSpeedMenuFingerprint : MethodFingerprint( strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuIntegrationsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuIntegrationsFingerprint.kt new file mode 100644 index 000000000..2d49d8182 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldPlaybackSpeedMenuIntegrationsFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.video.speed.custom.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object ShowOldPlaybackSpeedMenuIntegrationsFingerprint : MethodFingerprint( + customFingerprint = { method, _ -> method.name == "showOldPlaybackSpeedMenu" } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt deleted file mode 100644 index a672dff90..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt +++ /dev/null @@ -1,7 +0,0 @@ -package app.revanced.patches.youtube.video.speed.custom.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object ShowOldVideoSpeedMenuIntegrationsFingerprint : MethodFingerprint( - customFingerprint = { method, _ -> method.name == "showOldVideoSpeedMenu" } -) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt index cb9012501..782a61b60 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt @@ -31,16 +31,16 @@ import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.MethodReference import org.jf.dexlib2.immutable.ImmutableField -@Name("Custom video speed") -@Description("Adds custom video speed options.") +@Name("Custom playback speed") +@Description("Adds custom playback speed options.") @DependsOn([IntegrationsPatch::class, LithoFilterPatch::class, SettingsPatch::class, BottomSheetHookPatch::class]) @Version("0.0.1") -class CustomVideoSpeedPatch : BytecodePatch( +class CustomPlaybackSpeedPatch : BytecodePatch( listOf( SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint, - GetOldVideoSpeedsFingerprint, - ShowOldVideoSpeedMenuIntegrationsFingerprint + GetOldPlaybackSpeedsFingerprint, + ShowOldPlaybackSpeedMenuIntegrationsFingerprint ) ) { @@ -81,12 +81,12 @@ class CustomVideoSpeedPatch : BytecodePatch( val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA - val videoSpeedsArrayType = "$INTEGRATIONS_CLASS_DESCRIPTOR->customVideoSpeeds:[F" + val playbackSpeedsArrayType = "$INTEGRATIONS_CLASS_DESCRIPTOR->customPlaybackSpeeds:[F" arrayGenMethod.addInstructions( arrayLengthConstIndex + 1, """ - sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType + sget-object v$arrayLengthConstDestination, $playbackSpeedsArrayType array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination """ ) @@ -102,7 +102,7 @@ class CustomVideoSpeedPatch : BytecodePatch( arrayGenMethod.replaceInstruction( originalArrayFetchIndex, - "sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType" + "sget-object v$originalArrayFetchDestination, $playbackSpeedsArrayType" ) val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!! @@ -121,24 +121,24 @@ class CustomVideoSpeedPatch : BytecodePatch( // edit: alternatively this might work by overriding with fixed values such as 0.1x and 10x limiterMethod.replaceInstruction( limiterMinConstIndex, - "sget v$limiterMinConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->minVideoSpeed:F" + "sget v$limiterMinConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->minPlaybackSpeed:F" ) limiterMethod.replaceInstruction( limiterMaxConstIndex, - "sget v$limiterMaxConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->maxVideoSpeed:F" + "sget v$limiterMaxConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->maxPlaybackSpeed:F" ) // region Force old video quality menu. - // This is necessary, because there is no known way of adding custom video speeds to the new menu. + // This is necessary, because there is no known way of adding custom playback speeds to the new menu. BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR) - // Required to check if the video speed menu is currently shown. + // Required to check if the playback speed menu is currently shown. LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) - GetOldVideoSpeedsFingerprint.result?.let { result -> + GetOldPlaybackSpeedsFingerprint.result?.let { result -> // Add a static INSTANCE field to the class. - // This is later used to call "showOldVideoSpeedMenu" on the instance. + // This is later used to call "showOldPlaybackSpeedMenu" on the instance. val instanceField = ImmutableField( result.classDef.type, "INSTANCE", @@ -154,15 +154,15 @@ class CustomVideoSpeedPatch : BytecodePatch( // In order to prevent a conflict with another patch, add the instruction at index 1. result.mutableMethod.addInstruction(1, "sput-object p0, $instanceField") - // Get the "showOldVideoSpeedMenu" method. + // Get the "showOldPlaybackSpeedMenu" method. // This is later called on the field INSTANCE. - val showOldVideoSpeedMenuMethod = ShowOldVideoSpeedMenuFingerprint.also { + val showOldPlaybackSpeedMenuMethod = ShowOldPlaybackSpeedMenuFingerprint.also { if (!it.resolve(context, result.classDef)) - throw ShowOldVideoSpeedMenuFingerprint.toErrorResult() + throw ShowOldPlaybackSpeedMenuFingerprint.toErrorResult() }.result!!.method.toString() - // Insert the call to the "showOldVideoSpeedMenu" method on the field INSTANCE. - ShowOldVideoSpeedMenuIntegrationsFingerprint.result?.mutableMethod?.apply { + // Insert the call to the "showOldPlaybackSpeedMenu" method on the field INSTANCE. + ShowOldPlaybackSpeedMenuIntegrationsFingerprint.result?.mutableMethod?.apply { addInstructionsWithLabels( implementation!!.instructions.lastIndex, """ @@ -170,11 +170,11 @@ class CustomVideoSpeedPatch : BytecodePatch( if-nez v0, :not_null return-void :not_null - invoke-virtual { v0 }, $showOldVideoSpeedMenuMethod + invoke-virtual { v0 }, $showOldPlaybackSpeedMenuMethod """ ) - } ?: return ShowOldVideoSpeedMenuIntegrationsFingerprint.toErrorResult() - } ?: return GetOldVideoSpeedsFingerprint.toErrorResult() + } ?: return ShowOldPlaybackSpeedMenuIntegrationsFingerprint.toErrorResult() + } ?: return GetOldPlaybackSpeedsFingerprint.toErrorResult() // endregion @@ -183,10 +183,10 @@ class CustomVideoSpeedPatch : BytecodePatch( private companion object { private const val FILTER_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/patches/components/VideoSpeedMenuFilterPatch;" + "Lapp/revanced/integrations/patches/components/PlaybackSpeedMenuFilterPatch;" private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;" + "Lapp/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch;" } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt index b775e0e3d..67a211d60 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt @@ -19,13 +19,13 @@ 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.speed.custom.patch.CustomVideoSpeedPatch +import app.revanced.patches.youtube.video.speed.custom.patch.CustomPlaybackSpeedPatch 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.") -@DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomVideoSpeedPatch::class]) +@Description("Adds the ability to remember the playback speed you chose in the playback speed flyout.") +@DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomPlaybackSpeedPatch::class]) @Version("0.0.1") class RememberPlaybackSpeedPatch : BytecodePatch( listOf(