diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/playback/speed/CustomPlaybackSpeedPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/playback/speed/CustomPlaybackSpeedPatch.java index 59d63bcb..2ca56ed3 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/playback/speed/CustomPlaybackSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/playback/speed/CustomPlaybackSpeedPatch.java @@ -159,7 +159,7 @@ public class CustomPlaybackSpeedPatch { }); } - private static void showOldPlaybackSpeedMenu() { + public static void showOldPlaybackSpeedMenu() { // This method is sometimes used multiple times. // To prevent this, ignore method reuse within 1 second. final long now = System.currentTimeMillis(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index 359aa774..dd5eec20 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -127,6 +127,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_PLAYER_BUTTONS = new BooleanSetting("revanced_hide_player_buttons", FALSE); public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE); public static final BooleanSetting COPY_VIDEO_URL_TIMESTAMP = new BooleanSetting("revanced_copy_video_url_timestamp", TRUE); + public static final BooleanSetting PLAYBACK_SPEED_DIALOG_BUTTON = new BooleanSetting("revanced_playback_speed_dialog_button", FALSE); // External downloader public static final BooleanSetting EXTERNAL_DOWNLOADER = new BooleanSetting("revanced_external_downloader", FALSE); diff --git a/app/src/main/java/app/revanced/integrations/youtube/videoplayer/PlaybackSpeedDialogButton.java b/app/src/main/java/app/revanced/integrations/youtube/videoplayer/PlaybackSpeedDialogButton.java new file mode 100644 index 00000000..0acf184a --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/youtube/videoplayer/PlaybackSpeedDialogButton.java @@ -0,0 +1,43 @@ +package app.revanced.integrations.youtube.videoplayer; + +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.Nullable; + +import app.revanced.integrations.youtube.patches.playback.speed.CustomPlaybackSpeedPatch; +import app.revanced.integrations.youtube.settings.Settings; +import app.revanced.integrations.shared.Logger; + +public class PlaybackSpeedDialogButton extends BottomControlButton { + @Nullable + private static PlaybackSpeedDialogButton instance; + + public PlaybackSpeedDialogButton(ViewGroup viewGroup) { + super( + viewGroup, + "revanced_playback_speed_dialog_button", + Settings.PLAYBACK_SPEED_DIALOG_BUTTON, + view -> CustomPlaybackSpeedPatch.showOldPlaybackSpeedMenu(), + null + ); + } + + /** + * Injection point. + */ + public static void initializeButton(View view) { + try { + instance = new PlaybackSpeedDialogButton((ViewGroup) view); + } catch (Exception ex) { + Logger.printException(() -> "initializeButton failure", ex); + } + } + + /** + * Injection point. + */ + public static void changeVisibility(boolean showing) { + if (instance != null) instance.setVisibility(showing); + } +} \ No newline at end of file