From 6f3f88264e736b80f88103e795534f86f053c8d1 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 27 Dec 2023 05:39:23 +0100 Subject: [PATCH] feat(YouTube): Add `Remove viewer discretion dialog` patch --- .../RemoveViewerDiscretionDialogPatch.java | 18 ++++++++++++++++++ .../integrations/settings/SettingsEnum.java | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/RemoveViewerDiscretionDialogPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/RemoveViewerDiscretionDialogPatch.java b/app/src/main/java/app/revanced/integrations/patches/RemoveViewerDiscretionDialogPatch.java new file mode 100644 index 00000000..c0d013e5 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/RemoveViewerDiscretionDialogPatch.java @@ -0,0 +1,18 @@ +package app.revanced.integrations.patches; + +import android.app.AlertDialog; +import app.revanced.integrations.settings.SettingsEnum; + +public class RemoveViewerDiscretionDialogPatch { + public static void confirmDialog(AlertDialog dialog) { + if (!SettingsEnum.REMOVE_VIEWER_DISCRETION_DIALOG.getBoolean()) { + // Since the patch replaces the AlertDialog#show() method, we need to call the original method here. + dialog.show(); + return; + } + + final var button = dialog.getButton(AlertDialog.BUTTON_POSITIVE); + button.setSoundEffectsEnabled(false); + button.performClick(); + } +} diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index cd154686..ef628fc6 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -209,6 +209,8 @@ public enum SettingsEnum { ANNOUNCEMENT_CONSUMER("revanced_announcement_consumer", STRING, ""), ANNOUNCEMENT_LAST_HASH("revanced_announcement_last_hash", STRING, ""), REMOVE_TRACKING_QUERY_PARAMETER("revanced_remove_tracking_query_parameter", BOOLEAN, TRUE), + REMOVE_VIEWER_DISCRETION_DIALOG("revanced_remove_viewer_discretion_dialog", BOOLEAN, FALSE, + "revanced_remove_viewer_discretion_dialog_user_dialog_message"), // Swipe controls SWIPE_BRIGHTNESS("revanced_swipe_brightness", BOOLEAN, TRUE),