mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 07:04:30 +02:00
add hide-autoplay-preview
patch
This commit is contained in:
parent
7cbef4e17c
commit
665c1352fd
@ -0,0 +1,94 @@
|
||||
package app.revanced.patches.youtube.layout.fullscreen.autoplaypreview.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
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.addInstructions
|
||||
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.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN_LAYOUT
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
|
||||
import org.jf.dexlib2.iface.instruction.Instruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Patch
|
||||
@Name("hide-autoplay-preview")
|
||||
@Description("Hides the autoplay preview container in the fullscreen.")
|
||||
@DependsOn(
|
||||
[
|
||||
ResourceMappingPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideAutoplayPreviewPatch : BytecodePatch(
|
||||
listOf(
|
||||
LayoutConstructorFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// resolve the offsets such as ...
|
||||
val autoNavPreviewStubId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "id" && it.name == "autonav_preview_stub"
|
||||
}.id
|
||||
|
||||
LayoutConstructorFingerprint.result?.mutableMethod?.let { method ->
|
||||
with (method.implementation!!.instructions) {
|
||||
val registerIndex = indexOfFirst {
|
||||
it.opcode == Opcode.CONST_STRING &&
|
||||
(it as BuilderInstruction21c).reference.toString() == "1.0x"
|
||||
}
|
||||
val dummyRegister = (this[registerIndex] as Instruction21c).registerA
|
||||
|
||||
// where to insert the branch instructions and ...
|
||||
val insertIndex = this.indexOfFirst {
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == autoNavPreviewStubId
|
||||
}
|
||||
|
||||
val branchIndex = this.subList(insertIndex + 1, this.size - 1).indexOfFirst {
|
||||
((it as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
|
||||
} + 1
|
||||
|
||||
val jumpInstruction = this[insertIndex + branchIndex] as Instruction
|
||||
|
||||
method.addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {}, $FULLSCREEN_LAYOUT->hideAutoPlayPreview()Z
|
||||
move-result v$dummyRegister
|
||||
if-nez v$dummyRegister, :hidden
|
||||
""", listOf(ExternalLabel("hidden", jumpInstruction))
|
||||
)
|
||||
}
|
||||
} ?: return LayoutConstructorFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: FULLSCREEN_LAYOUT_SETTINGS",
|
||||
"SETTINGS: HIDE_AUTOPLAY_PREVIEW"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-autoplay-preview")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
|
@ -265,6 +265,9 @@ Is it ready to submit?"</string>
|
||||
<string name="revanced_hide_autoplay_button_summary_off">Autoplay button is shown</string>
|
||||
<string name="revanced_hide_autoplay_button_summary_on">Autoplay button is hidden</string>
|
||||
<string name="revanced_hide_autoplay_button_title">Hide autoplay button</string>
|
||||
<string name="revanced_hide_autoplay_preview_summary_off">Autoplay preview container is shown</string>
|
||||
<string name="revanced_hide_autoplay_preview_summary_on">Autoplay preview container is hidden</string>
|
||||
<string name="revanced_hide_autoplay_preview_title">Hide autoplay preview container</string>
|
||||
<string name="revanced_hide_auto_captions_summary_off">Captions are enabled when playing a video with captioning is enforced</string>
|
||||
<string name="revanced_hide_auto_captions_summary_on">"Captions aren't enabled when playing a video with captioning is enforced"</string>
|
||||
<string name="revanced_hide_auto_captions_title">Hide auto captions</string>
|
||||
|
@ -209,6 +209,9 @@
|
||||
<!-- SETTINGS: HIDE_FULLSCREEN_BUTTON_CONTAINER
|
||||
<SwitchPreference android:title="@string/revanced_hide_fullscreen_button_container_title" android:key="revanced_hide_fullscreen_button_container" android:defaultValue="false" android:summaryOn="@string/revanced_hide_fullscreen_button_container_summary_on" android:summaryOff="@string/revanced_hide_fullscreen_button_container_summary_off" />SETTINGS: HIDE_FULLSCREEN_BUTTON_CONTAINER -->
|
||||
|
||||
<!-- SETTINGS: HIDE_AUTOPLAY_PREVIEW
|
||||
<SwitchPreference android:title="@string/revanced_hide_autoplay_preview_title" android:key="revanced_hide_autoplay_preview" android:defaultValue="false" android:summaryOn="@string/revanced_hide_autoplay_preview_summary_on" android:summaryOff="@string/revanced_hide_autoplay_preview_summary_off" />SETTINGS: HIDE_AUTOPLAY_PREVIEW -->
|
||||
|
||||
<!-- SETTINGS: HIDE_ENDSCREEN_OVERLAY
|
||||
<SwitchPreference android:title="@string/revanced_hide_endscreen_overlay_title" android:key="revanced_hide_endscreen_overlay" android:defaultValue="false" android:summaryOn="@string/revanced_hide_endscreen_overlay_summary_on" android:summaryOff="@string/revanced_hide_endscreen_overlay_summary_off" />SETTINGS: HIDE_ENDSCREEN_OVERLAY -->
|
||||
|
||||
@ -441,6 +444,7 @@
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_fullscreen_layout" />
|
||||
<Preference android:title="hide-fullscreen-panels" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-fullscreen-buttoncontainer" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-autoplay-preview" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-endscreen-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-filmstrip-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="disable-haptic-feedback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user