add hide-seekbar patch

This commit is contained in:
inotia00 2023-02-22 23:36:41 +09:00
parent c297601a49
commit 07c5f92321
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,60 @@
package app.revanced.patches.youtube.layout.seekbar.seekbar.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.addInstructions
import app.revanced.patcher.extensions.instruction
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.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch
import app.revanced.util.integrations.Constants.SEEKBAR_LAYOUT
@Patch
@Name("hide-seekbar")
@Description("Hides the seekbar.")
@DependsOn(
[
HookTimebarPatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class HideSeekbarPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
val insertMethod = HookTimebarPatch.setTimebarMethod
insertMethod.addInstructions(
0, """
invoke-static {}, $SEEKBAR_LAYOUT->hideSeekbar()Z
move-result v0
if-eqz v0, :show_seekbar
return-void
""", listOf(ExternalLabel("show_seekbar", insertMethod.instruction(0)))
)
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: OTHER_LAYOUT_SETTINGS",
"PREFERENCE_HEADER: SEEKBAR",
"SETTINGS: HIDE_SEEKBAR"
)
)
SettingsPatch.updatePatchStatus("hide-seekbar")
return PatchResultSuccess()
}
}

View File

@ -284,6 +284,9 @@
<!-- SETTINGS: ENABLE_SEEKBAR_TAPPING
<SwitchPreference android:title="@string/revanced_enable_seekbar_tapping_title" android:key="revanced_enable_seekbar_tapping" android:defaultValue="true" android:summaryOn="@string/revanced_enable_seekbar_tapping_summary_on" android:summaryOff="@string/revanced_enable_seekbar_tapping_summary_off" />SETTINGS: ENABLE_SEEKBAR_TAPPING -->
<!-- SETTINGS: HIDE_SEEKBAR
<SwitchPreference android:title="@string/revanced_hide_seekbar_title" android:key="revanced_hide_seekbar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seekbar_summary_on" android:summaryOff="@string/revanced_hide_seekbar_summary_off" />SETTINGS: HIDE_SEEKBAR -->
<!-- PREFERENCE: OTHER_LAYOUT_SETTINGS
</PreferenceScreen>PREFERENCE: OTHER_LAYOUT_SETTINGS -->
@ -418,6 +421,7 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_layout_settings_seekbar" />
<Preference android:title="custom-seekbar-color" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="enable-seekbar-tapping" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-seekbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_overlay_button_title" />
<Preference android:title="overlay-buttons" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>