feat(YouTube - Playback speed): Add option to show speed dialog button in video player (#3197)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@ -4,13 +4,19 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.video.speed.button.PlaybackSpeedButtonPatch
|
||||
import app.revanced.patches.youtube.video.speed.custom.CustomPlaybackSpeedPatch
|
||||
import app.revanced.patches.youtube.video.speed.remember.RememberPlaybackSpeedPatch
|
||||
|
||||
@Patch(
|
||||
name = "Playback speed",
|
||||
description = "Adds options to customize available playback speeds and to remember the last playback speed selected.",
|
||||
dependencies = [CustomPlaybackSpeedPatch::class, RememberPlaybackSpeedPatch::class],
|
||||
description = "Adds options to customize available playback speeds, remember the last playback speed selected " +
|
||||
"and show a speed dialog button to the video player.",
|
||||
dependencies = [
|
||||
PlaybackSpeedButtonPatch::class,
|
||||
CustomPlaybackSpeedPatch::class,
|
||||
RememberPlaybackSpeedPatch::class,
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
@ -42,4 +48,4 @@ object PlaybackSpeedPatch : BytecodePatch(emptySet()) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
// All patches this patch depends on succeed.
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package app.revanced.patches.youtube.video.speed.button
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.playercontrols.PlayerControlsBytecodePatch
|
||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.video.speed.custom.CustomPlaybackSpeedPatch
|
||||
|
||||
@Patch(
|
||||
description = "Adds the option to display playback speed dialog button in the video player.",
|
||||
dependencies = [
|
||||
PlaybackSpeedButtonResourcePatch::class,
|
||||
CustomPlaybackSpeedPatch::class,
|
||||
PlayerControlsBytecodePatch::class,
|
||||
SettingsPatch::class,
|
||||
AddResourcesPatch::class,
|
||||
],
|
||||
)
|
||||
@Suppress("unused")
|
||||
object PlaybackSpeedButtonPatch : BytecodePatch(emptySet()) {
|
||||
private const val SPEED_BUTTON_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/integrations/youtube/videoplayer/PlaybackSpeedDialogButton;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.PLAYER.addPreferences(
|
||||
SwitchPreference("revanced_playback_speed_dialog_button"),
|
||||
)
|
||||
|
||||
PlayerControlsBytecodePatch.initializeControl("$SPEED_BUTTON_CLASS_DESCRIPTOR->initializeButton(Landroid/view/View;)V")
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$SPEED_BUTTON_CLASS_DESCRIPTOR->changeVisibility(Z)V")
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package app.revanced.patches.youtube.video.speed.button
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.copyResources
|
||||
|
||||
@Patch(
|
||||
dependencies = [BottomControlsResourcePatch::class],
|
||||
)
|
||||
internal object PlaybackSpeedButtonResourcePatch : ResourcePatch() {
|
||||
override fun execute(context: ResourceContext) {
|
||||
context.copyResources(
|
||||
"speedbutton",
|
||||
ResourceGroup(
|
||||
"drawable",
|
||||
"revanced_playback_speed_dialog_button.xml",
|
||||
),
|
||||
)
|
||||
|
||||
BottomControlsResourcePatch.addControls("speedbutton")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user