From 09a94b88b7a9ca150679f9747a1e1541c1b41b8a Mon Sep 17 00:00:00 2001 From: inotia00 Date: Wed, 20 Sep 2023 15:09:31 +0900 Subject: [PATCH] =?UTF-8?q?feat(youtube/append-time-stamps-information):?= =?UTF-8?q?=20change=20patch=20name=20`enable-time-stamps-speed`=20?= =?UTF-8?q?=E2=86=92=20`append-time-stamps-information`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patch/AppendTimeStampInformationPatch.kt} | 40 +++++++++++-------- .../youtube/settings/host/values/strings.xml | 9 +++-- .../youtube/settings/xml/revanced_prefs.xml | 10 ++--- 3 files changed, 35 insertions(+), 24 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/seekbar/{speed/patch/AppendSpeedPatch.kt => append/patch/AppendTimeStampInformationPatch.kt} (55%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/append/patch/AppendTimeStampInformationPatch.kt similarity index 55% rename from src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/append/patch/AppendTimeStampInformationPatch.kt index d67a07117..e1a0811f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/append/patch/AppendTimeStampInformationPatch.kt @@ -1,9 +1,10 @@ -package app.revanced.patches.youtube.seekbar.speed.patch +package app.revanced.patches.youtube.seekbar.append.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.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch @@ -12,6 +13,7 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fingerprints.TotalTimeFingerprint +import app.revanced.patches.youtube.utils.overridequality.patch.OverrideQualityHookPatch import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -21,43 +23,49 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c @Patch -@Name("Enable time stamps speed") -@Description("Add the current playback speed in brackets next to the current time.") +@Name("Append time stamps information") +@Description("Add the current video quality or playback speed in brackets next to the current time.") @DependsOn( [ + OverrideQualityHookPatch::class, OverrideSpeedHookPatch::class, SettingsPatch::class, SharedResourceIdPatch::class ] ) @YouTubeCompatibility -class AppendSpeedPatch : BytecodePatch( +class AppendTimeStampInformationPatch : BytecodePatch( listOf(TotalTimeFingerprint) ) { override fun execute(context: BytecodeContext) { TotalTimeFingerprint.result?.let { it.mutableMethod.apply { - var insertIndex = -1 + var setTextIndex = -1 - for ((targetIndex, targetInstruction) in implementation!!.instructions.withIndex()) { - if (targetInstruction.opcode != Opcode.INVOKE_VIRTUAL) continue + for ((textViewIndex, textViewInstruction) in implementation!!.instructions.withIndex()) { + if (textViewInstruction.opcode != Opcode.INVOKE_VIRTUAL) continue - if (getInstruction(targetIndex).reference.toString() == + if (getInstruction(textViewIndex).reference.toString() == "Landroid/widget/TextView;->getText()Ljava/lang/CharSequence;" ) { - insertIndex = targetIndex + 2 - val insertRegister = getInstruction(insertIndex).registerC + setTextIndex = textViewIndex + 2 + val setTextRegister = getInstruction(setTextIndex).registerC + val textViewRegister = getInstruction(textViewIndex).registerC addInstructions( - insertIndex, """ - invoke-static {v$insertRegister}, $SEEKBAR->enableTimeStampSpeed(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$insertRegister + setTextIndex, """ + invoke-static {v$setTextRegister}, $SEEKBAR->appendTimeStampInformation(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$setTextRegister """ ) + addInstruction( + textViewIndex, + "invoke-static {v$textViewRegister}, $SEEKBAR->setContainerClickListener(Landroid/view/View;)V" + ) break } } - if (insertIndex == -1) + if (setTextIndex == -1) throw PatchException("target Instruction not found!") } } ?: throw TotalTimeFingerprint.exception @@ -68,11 +76,11 @@ class AppendSpeedPatch : BytecodePatch( SettingsPatch.addPreference( arrayOf( "PREFERENCE: SEEKBAR_SETTINGS", - "SETTINGS: ENABLE_TIME_STAMP_SPEED" + "SETTINGS: APPEND_TIME_STAMP_INFORMATION" ) ) - SettingsPatch.updatePatchStatus("enable-timestamps-speed") + SettingsPatch.updatePatchStatus("append-timestamps-information") } } diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index b480d448e..7d9506869 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -6,6 +6,12 @@ Enable cloud messaging settings to receive notifications Open MicroG Ads + Append time stamp information is disabled + Append time stamp information is enabled + Append time stamp information + Append playback speed + Append video quality + Append information type Import ReVanced settings from file or export ReVanced settings to file Bottom player Button container @@ -137,9 +143,6 @@ Tablet navigation bar is disabled Tablet navigation bar is enabled Enable tablet navigation bar - Append time stamp speed is disabled - Append time stamp speed is enabled - Enable time stamp speed Spoof device information to enable vp9 codec Enable vp9 codec Wide search bar is disabled diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 2ed070692..b076422ba 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -368,10 +368,10 @@ + - @@ -398,7 +398,6 @@ - @@ -523,6 +522,10 @@ PREFERENCE: SEEKBAR_SETTINGS --> + + @@ -533,9 +536,6 @@ - -