mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-12 04:24:36 +02:00
refactor(hide-previous-next-button): rewrite the code
This commit is contained in:
parent
0079846a12
commit
37e64b6a1f
@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.shared.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ControlsOverlayStyleFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(Opcode.IGET_BOOLEAN),
|
||||
strings = listOf("supportsNextPrevious", "Missing required properties:")
|
||||
)
|
@ -1,45 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.player.nextprevbutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
|
||||
@Patch
|
||||
@Name("hide-next-prev-button")
|
||||
@Description("Hides the next prev button in the player controller.")
|
||||
@DependsOn(
|
||||
[
|
||||
PlayerButtonPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideNextPrevButtonPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: HIDE_NEXT_BUTTON",
|
||||
"SETTINGS: HIDE_PREV_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-next-prev-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package app.revanced.patches.youtube.layout.player.previousnextbutton.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.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.ControlsOverlayStyleFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
|
||||
@Patch
|
||||
@Name("hide-previous-next-button")
|
||||
@Description("Hides the previous and next button in the player controller.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HidePreviousNextButtonPatch : BytecodePatch(
|
||||
listOf(ControlsOverlayStyleFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
val controlsOverlayStyleClassDef = ControlsOverlayStyleFingerprint.result?.classDef?: return ControlsOverlayStyleFingerprint.toErrorResult()
|
||||
|
||||
val previousNextButtonVisibleFingerprint =
|
||||
object : MethodFingerprint(returnType = "V", parameters = listOf("Z"), customFingerprint = { it.name == "j" }) {}
|
||||
previousNextButtonVisibleFingerprint.resolve(context, controlsOverlayStyleClassDef)
|
||||
previousNextButtonVisibleFingerprint.result?.mutableMethod?.addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $PLAYER->hidePreviousNextButton(Z)Z
|
||||
move-result p1
|
||||
"""
|
||||
)?: return previousNextButtonVisibleFingerprint.toErrorResult()
|
||||
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-previous-next-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -404,9 +404,6 @@ Please do not report any issues you encounter while using this feature."</string
|
||||
<string name="revanced_hide_movie_shelf_summary_off">Movies shelves are shown</string>
|
||||
<string name="revanced_hide_movie_shelf_summary_on">Movies shelves are hidden</string>
|
||||
<string name="revanced_hide_movie_shelf_title">Hide movies shelf</string>
|
||||
<string name="revanced_hide_next_button_summary_off">Next button is shown</string>
|
||||
<string name="revanced_hide_next_button_summary_on">Next button is hidden</string>
|
||||
<string name="revanced_hide_next_button_title">Hide next button</string>
|
||||
<string name="revanced_hide_official_header_summary_off">Official header is shown</string>
|
||||
<string name="revanced_hide_official_header_summary_on">Official header is hidden</string>
|
||||
<string name="revanced_hide_official_header_title">Hide official header</string>
|
||||
@ -419,9 +416,9 @@ Please do not report any issues you encounter while using this feature."</string
|
||||
<string name="revanced_hide_preview_comment_off">Preview comment is shown</string>
|
||||
<string name="revanced_hide_preview_comment_on">Preview comment is hidden</string>
|
||||
<string name="revanced_hide_preview_comment_title">Hide preview comment</string>
|
||||
<string name="revanced_hide_prev_button_summary_off">Prev button is shown</string>
|
||||
<string name="revanced_hide_prev_button_summary_on">Prev button is hidden</string>
|
||||
<string name="revanced_hide_prev_button_title">Hide prev button</string>
|
||||
<string name="revanced_hide_previous_next_button_summary_off">Buttons are shown</string>
|
||||
<string name="revanced_hide_previous_next_button_summary_on">Buttons are hidden</string>
|
||||
<string name="revanced_hide_previous_next_button_title">Hide previous & next button</string>
|
||||
<string name="revanced_hide_seekbar_summary_off">Seekbar is shown</string>
|
||||
<string name="revanced_hide_seekbar_summary_on">Seekbar is hidden</string>
|
||||
<string name="revanced_hide_seekbar_title">Hide seekbar</string>
|
||||
|
@ -169,8 +169,8 @@
|
||||
<!-- SETTINGS: HIDE_NEXT_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_next_button_title" android:key="revanced_hide_next_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_next_button_summary_on" android:summaryOff="@string/revanced_hide_next_button_summary_off" />SETTINGS: HIDE_NEXT_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_PREV_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_prev_button_title" android:key="revanced_hide_prev_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_prev_button_summary_on" android:summaryOff="@string/revanced_hide_prev_button_summary_off" />SETTINGS: HIDE_PREV_BUTTON -->
|
||||
<!-- SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_previous_next_button_title" android:key="revanced_hide_previous_next_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_previous_next_button_summary_on" android:summaryOff="@string/revanced_hide_previous_next_button_summary_off" />SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_PLAYER_BUTTON_BACKGROUND
|
||||
<SwitchPreference android:title="@string/revanced_hide_player_button_background_title" android:key="revanced_hide_player_button_background" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_button_background_summary_on" android:summaryOff="@string/revanced_hide_player_button_background_summary_off" />SETTINGS: HIDE_PLAYER_BUTTON_BACKGROUND -->
|
||||
@ -466,7 +466,7 @@
|
||||
<Preference android:title="hide-cast-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-live-chat-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-captions-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-next-prev-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-previous-next-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-player-button-background" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-endscreen-cards" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-info-cards" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user