mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-18 23:37:18 +02:00
feat(YouTube/Player Type Hook): add view invalidate observer
This commit is contained in:
parent
e7a00f73da
commit
1f70d702ac
@ -3,10 +3,12 @@ package app.revanced.patches.youtube.utils.fingerprints
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.youtube.player.components.PlayerComponentsPatch
|
||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FadeDurationFast
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.InsetOverlayViewLayout
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ScrimOverlay
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.SeekUndoEduOverlayStub
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.SizeAdjustableYouTubeControlsOverlay
|
||||
import app.revanced.patches.youtube.utils.sponsorblock.SponsorBlockBytecodePatch
|
||||
import app.revanced.util.containsWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
@ -19,6 +21,7 @@ import com.android.tools.smali.dexlib2.Opcode
|
||||
*
|
||||
* The patches and resourceIds that use this fingerprint are as follows:
|
||||
* - [PlayerComponentsPatch] uses [FadeDurationFast], [ScrimOverlay] and [SeekUndoEduOverlayStub].
|
||||
* - [PlayerTypeHookPatch] uses [SizeAdjustableYouTubeControlsOverlay].
|
||||
* - [SponsorBlockBytecodePatch] uses [InsetOverlayViewLayout].
|
||||
*/
|
||||
internal object YouTubeControlsOverlayFingerprint : MethodFingerprint(
|
||||
@ -30,5 +33,6 @@ internal object YouTubeControlsOverlayFingerprint : MethodFingerprint(
|
||||
&& methodDef.containsWideLiteralInstructionIndex(InsetOverlayViewLayout)
|
||||
&& methodDef.containsWideLiteralInstructionIndex(ScrimOverlay)
|
||||
&& methodDef.containsWideLiteralInstructionIndex(SeekUndoEduOverlayStub)
|
||||
&& methodDef.containsWideLiteralInstructionIndex(SizeAdjustableYouTubeControlsOverlay)
|
||||
}
|
||||
)
|
@ -6,7 +6,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
||||
@ -15,6 +17,7 @@ import app.revanced.patches.youtube.utils.playertype.fingerprint.ReelWatchPagerF
|
||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.SizeAdjustableYouTubeControlsOverlay
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
@ -24,7 +27,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Patch(dependencies = [SharedResourceIdPatch::class])
|
||||
@Patch(
|
||||
dependencies = [
|
||||
LithoFilterPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
object PlayerTypeHookPatch : BytecodePatch(
|
||||
setOf(
|
||||
ActionBarSearchResultsFingerprint,
|
||||
@ -39,6 +47,9 @@ object PlayerTypeHookPatch : BytecodePatch(
|
||||
private const val INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR =
|
||||
"$SHARED_PATH/RootView;"
|
||||
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/InvalidateStateFilter;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
PlayerTypeFingerprint.resultOrThrow().let {
|
||||
@ -67,6 +78,18 @@ object PlayerTypeHookPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
parentResult.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(SizeAdjustableYouTubeControlsOverlay)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, " +
|
||||
"$INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR->onPlayerCreate(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
ReelWatchPagerFingerprint.resultOrThrow().let {
|
||||
@ -98,5 +121,8 @@ object PlayerTypeHookPatch : BytecodePatch(
|
||||
"$INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR->searchBarResultsViewLoaded(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var ScrimOverlay = -1L
|
||||
var Scrubbing = -1L
|
||||
var SeekUndoEduOverlayStub = -1L
|
||||
var SizeAdjustableYouTubeControlsOverlay = -1L
|
||||
var SlidingDialogAnimation = -1L
|
||||
var SubtitleMenuSettingsFooterInfo = -1L
|
||||
var SuggestedAction = -1L
|
||||
@ -153,6 +154,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
ScrimOverlay = getId(ID, "scrim_overlay")
|
||||
Scrubbing = getId(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
SeekUndoEduOverlayStub = getId(ID, "seek_undo_edu_overlay_stub")
|
||||
SizeAdjustableYouTubeControlsOverlay = getId(LAYOUT, "size_adjustable_youtube_controls_overlay")
|
||||
SlidingDialogAnimation = getId(STYLE, "SlidingDialogAnimation")
|
||||
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
|
||||
SuggestedAction = getId(LAYOUT, "suggested_action")
|
||||
|
Loading…
x
Reference in New Issue
Block a user