diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 692097c6f..f19375610 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -13,9 +13,11 @@ 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.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint +import app.revanced.patches.youtube.utils.alertdialog.patch.NewLayoutAlertDialogPatch import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.FLYOUT_PANEL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -24,6 +26,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Description("Enables the original quality flyout menu.") @DependsOn( [ + NewLayoutAlertDialogPatch::class, SettingsPatch::class, SharedResourceIdPatch::class ] @@ -47,6 +50,8 @@ class OldQualityLayoutPatch : BytecodePatch( } } ?: return QualityMenuViewInflateFingerprint.toErrorResult() + context.updatePatchStatus("OldQualityLayout") + /** * Add settings */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/fingerprints/BottomSheetRecyclerViewBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/fingerprints/BottomSheetRecyclerViewBuilderFingerprint.kt new file mode 100644 index 000000000..96739977c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/fingerprints/BottomSheetRecyclerViewBuilderFingerprint.kt @@ -0,0 +1,26 @@ +package app.revanced.patches.youtube.utils.alertdialog.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomSheetRecyclerView +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object BottomSheetRecyclerViewBuilderFingerprint : MethodFingerprint( + returnType = "L", + accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, + parameters = listOf(), + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET_OBJECT, + Opcode.IF_NEZ, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.RETURN_OBJECT, + Opcode.IGET_OBJECT, + Opcode.IF_EQZ + ), + customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(BottomSheetRecyclerView) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/patch/NewLayoutAlertDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/patch/NewLayoutAlertDialogPatch.kt new file mode 100644 index 000000000..995505922 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/alertdialog/patch/NewLayoutAlertDialogPatch.kt @@ -0,0 +1,49 @@ +package app.revanced.patches.youtube.utils.alertdialog.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +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.patches.youtube.misc.spoofappversion.patch.SpoofAppVersionPatch +import app.revanced.patches.youtube.utils.alertdialog.fingerprints.BottomSheetRecyclerViewBuilderFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.util.integrations.Constants.UTILS_PATH +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Name("new-layout-alert-dialog") +@DependsOn( + [ + SharedResourceIdPatch::class, + SpoofAppVersionPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class NewLayoutAlertDialogPatch : BytecodePatch( + listOf(BottomSheetRecyclerViewBuilderFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + BottomSheetRecyclerViewBuilderFingerprint.result?.let { + it.mutableMethod.apply { + val contextIndex = it.scanResult.patternScanResult!!.startIndex + 3 + val contextRegister = getInstruction(contextIndex).registerA + + val insertIndex = it.scanResult.patternScanResult!!.endIndex + + addInstruction( + insertIndex, + "invoke-static {v$contextRegister}, $UTILS_PATH/NewPlayerFlyoutPanelsDetectPatch;->showAlertDialog(Landroid/content/Context;)V" + ) + } + } ?: return BottomSheetRecyclerViewBuilderFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt index 9ee901da0..45fe3bc6d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -36,6 +36,7 @@ class SharedResourceIdPatch : ResourcePatch { var BackgroundCategory: Long = -1 var BarContainerHeight: Long = -1 var BottomPanelOverlayText: Long = -1 + var BottomSheetRecyclerView: Long = -1 var BottomUiContainerStub: Long = -1 var ChannelListSubMenu: Long = -1 var CompactLink: Long = -1 @@ -104,6 +105,7 @@ class SharedResourceIdPatch : ResourcePatch { BackgroundCategory = find(STRING, "pref_background_and_offline_category") BarContainerHeight = find(DIMEN, "bar_container_height") BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text") + BottomSheetRecyclerView = find(LAYOUT, "bottom_sheet_recycler_view") BottomUiContainerStub = find(ID, "bottom_ui_container_stub") ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu") CompactLink = find(LAYOUT, "compact_link") diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt index af1525ea6..ba23c4814 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt @@ -13,10 +13,12 @@ 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.utils.alertdialog.patch.NewLayoutAlertDialogPatch import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedArrayGeneratorFingerprint import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFingerprint +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction @@ -28,7 +30,12 @@ import org.jf.dexlib2.iface.reference.MethodReference @Patch @Name("custom-video-speed") @Description("Adds more video speed options.") -@DependsOn([SettingsPatch::class]) +@DependsOn( + [ + NewLayoutAlertDialogPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") class CustomVideoSpeedPatch : BytecodePatch( @@ -114,6 +121,8 @@ class CustomVideoSpeedPatch : BytecodePatch( } } ?: return SpeedLimiterFingerprint.toErrorResult() + context.updatePatchStatus("CustomVideoSpeed") + /** * Add settings */ diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 73cc99821..dc3cd43dd 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -492,6 +492,9 @@ Only available on YouTube v18.24.37+" Layout Miscellaneous Navigation + There is no valid resolution for this issue yet\nOnly spoofing the client version to %s can temporarily fix this issue\n\nSpoofing the client version to %s?" + The following settings do not work in the new player flyout panel : + New player flyout panel detected Library is not opened at app startup Library is opened at app startup Open library on app startup