fix(YouTube/Description components): Expand video description setting does not work in certain languages

This commit is contained in:
inotia00 2024-05-02 23:58:31 +09:00
parent 3dcde2ede4
commit cccd2298dc
5 changed files with 29 additions and 32 deletions

View File

@ -5,18 +5,17 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelTitleFingerprint import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelSubHeaderFingerprint
import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelTitleParentFingerprint
import app.revanced.patches.youtube.player.descriptions.fingerprints.TextViewComponentFingerprint import app.revanced.patches.youtube.player.descriptions.fingerprints.TextViewComponentFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithMethodReferenceName import app.revanced.util.getTargetIndexWithMethodReferenceName
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
@ -30,11 +29,13 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
dependencies = setOf( dependencies = setOf(
BottomSheetRecyclerViewPatch::class, BottomSheetRecyclerViewPatch::class,
LithoFilterPatch::class, LithoFilterPatch::class,
SettingsPatch::class PlayerTypeHookPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
), ),
compatiblePackages = COMPATIBLE_PACKAGE, compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf( fingerprints = setOf(
EngagementPanelTitleParentFingerprint, EngagementPanelSubHeaderFingerprint,
TextViewComponentFingerprint TextViewComponentFingerprint
) )
) { ) {
@ -59,18 +60,14 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
} }
} }
EngagementPanelTitleFingerprint.resolve( EngagementPanelSubHeaderFingerprint.resultOrThrow().mutableMethod.apply {
context, val instructionIndex = getTargetIndexReversed(Opcode.INVOKE_INTERFACE) + 1
EngagementPanelTitleParentFingerprint.resultOrThrow().classDef val viewRegister = getInstruction<OneRegisterInstruction>(instructionIndex).registerA
)
EngagementPanelTitleFingerprint.resultOrThrow().mutableMethod.apply {
val contentDescriptionIndex = getTargetIndexWithMethodReferenceName("setContentDescription")
val contentDescriptionRegister = getInstruction<FiveRegisterInstruction>(contentDescriptionIndex).registerD
addInstruction( addInstruction(
contentDescriptionIndex, instructionIndex + 1,
"invoke-static {v$contentDescriptionRegister}," + "invoke-static { v$viewRegister }, " +
"$PLAYER_CLASS_DESCRIPTOR->setContentDescription(Ljava/lang/String;)V" "$PLAYER_CLASS_DESCRIPTOR->engagementPanelSubHeaderViewLoaded(Landroid/view/View;)V"
) )
} }

View File

@ -0,0 +1,13 @@
package app.revanced.patches.youtube.player.descriptions.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.PanelSubHeader
import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
internal object EngagementPanelSubHeaderFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
returnType = "V",
parameters = listOf("Landroid/view/ViewGroup;", "L"),
literalSupplier = { PanelSubHeader }
)

View File

@ -1,8 +0,0 @@
package app.revanced.patches.youtube.player.descriptions.fingerprints
import app.revanced.util.fingerprint.MethodReferenceNameFingerprint
internal object EngagementPanelTitleFingerprint : MethodReferenceNameFingerprint(
strings = listOf(". "),
reference = { "setContentDescription" }
)

View File

@ -1,7 +0,0 @@
package app.revanced.patches.youtube.player.descriptions.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object EngagementPanelTitleParentFingerprint : MethodFingerprint(
strings = listOf("[EngagementPanelTitleHeader] Cannot remove action buttons from header as the child count is out of sync. Buttons to remove exceed current header child count.")
)

View File

@ -67,6 +67,7 @@ object SharedResourceIdPatch : ResourcePatch() {
var ModernMiniPlayerRewindButton = -1L var ModernMiniPlayerRewindButton = -1L
var MusicAppDeeplinkButtonView = -1L var MusicAppDeeplinkButtonView = -1L
var NotificationBigPictureIconWidth = -1L var NotificationBigPictureIconWidth = -1L
var PanelSubHeader = -1L
var PlayerCollapseButton = -1L var PlayerCollapseButton = -1L
var PosterArtWidthDefault = -1L var PosterArtWidthDefault = -1L
var QualityAuto = -1L var QualityAuto = -1L
@ -156,6 +157,7 @@ object SharedResourceIdPatch : ResourcePatch() {
ModernMiniPlayerRewindButton = getId(ID, "modern_miniplayer_rewind_button") ModernMiniPlayerRewindButton = getId(ID, "modern_miniplayer_rewind_button")
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view") MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
NotificationBigPictureIconWidth = getId(DIMEN, "notification_big_picture_icon_width") NotificationBigPictureIconWidth = getId(DIMEN, "notification_big_picture_icon_width")
PanelSubHeader = getId(ID, "panel_subheader")
PlayerCollapseButton = getId(ID, "player_collapse_button") PlayerCollapseButton = getId(ID, "player_collapse_button")
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default") PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")
QualityAuto = getId(STRING, "quality_auto") QualityAuto = getId(STRING, "quality_auto")