feat(youtube): support version 18.23.35 (#2461)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
committed by
GitHub
co-authored by
oSumAtrIX
parent
67294c76cd
commit
34514b04f1
+8
@@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.youtube.video.videoqualitymenu.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
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 OldVideoQualityMenuCompatibility
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package app.revanced.patches.youtube.video.videoqualitymenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.video.videoqualitymenu.patch.OldVideoQualityMenuResourcePatch
|
||||
import app.revanced.util.patch.LiteralValueFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object VideoQualityMenuViewInflateFingerprint : LiteralValueFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L", "L"),
|
||||
returnType = "L",
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_SUPER,
|
||||
Opcode.CONST,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST
|
||||
),
|
||||
literal = OldVideoQualityMenuResourcePatch.videoQualityBottomSheetListFragmentTitle
|
||||
)
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package app.revanced.patches.youtube.video.videoqualitymenu.patch
|
||||
|
||||
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.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.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookPatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.video.videoqualitymenu.annotations.OldVideoQualityMenuCompatibility
|
||||
import app.revanced.patches.youtube.video.videoqualitymenu.fingerprints.VideoQualityMenuViewInflateFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@DependsOn([
|
||||
IntegrationsPatch::class,
|
||||
OldVideoQualityMenuResourcePatch::class,
|
||||
LithoFilterPatch::class,
|
||||
BottomSheetHookPatch::class
|
||||
])
|
||||
@Name("old-video-quality-menu")
|
||||
@Description("Shows the old video quality with the advanced video quality options instead of the new one.")
|
||||
@OldVideoQualityMenuCompatibility
|
||||
@Version("0.0.1")
|
||||
class OldVideoQualityMenuPatch : BytecodePatch(
|
||||
listOf(VideoQualityMenuViewInflateFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// region Patch for the old type of the video quality menu.
|
||||
|
||||
VideoQualityMenuViewInflateFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val checkCastIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val listViewRegister = getInstruction<OneRegisterInstruction>(checkCastIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
checkCastIndex + 1,
|
||||
"invoke-static { v$listViewRegister }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->" +
|
||||
"showOldVideoQualityMenu(Landroid/widget/ListView;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Patch for the new type of the video quality menu.
|
||||
|
||||
BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR)
|
||||
|
||||
// Required to check if the video quality menu is currently shown in order to click on the "Advanced" item.
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
// endregion
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/integrations/patches/components/VideoQualityMenuFilterPatch;"
|
||||
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/integrations/patches/playback/quality/OldVideoQualityMenuPatch;"
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package app.revanced.patches.youtube.video.videoqualitymenu.patch
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
class OldVideoQualityMenuResourcePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.VIDEO.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_show_old_video_quality_menu",
|
||||
StringResource("revanced_show_old_video_quality_menu_title", "Show old video quality menu"),
|
||||
StringResource("revanced_show_old_video_quality_menu_summary_on", "Old video quality menu is shown"),
|
||||
StringResource("revanced_show_old_video_quality_menu_summary_off", "New video quality menu is hidden")
|
||||
)
|
||||
)
|
||||
|
||||
fun findResource(name: String) = ResourceMappingPatch.resourceMappings.find { it.name == name }?.id
|
||||
?: throw PatchResultError("Could not find resource")
|
||||
|
||||
// Used for the old type of the video quality menu.
|
||||
videoQualityBottomSheetListFragmentTitle = findResource("video_quality_bottom_sheet_list_fragment_title")
|
||||
|
||||
// Used for the new type of the video quality menu.
|
||||
bottomSheetMargins = findResource("bottom_sheet_margins")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
var videoQualityBottomSheetListFragmentTitle = -1L
|
||||
var bottomSheetMargins = -1L
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user