From 3b474d3503e619ab9cfb6a95497df7992c17f83a Mon Sep 17 00:00:00 2001 From: Swakshan Date: Mon, 20 May 2024 19:00:16 +0530 Subject: [PATCH 1/2] feat(Twitter): Added `Hide Buy Premium Banner` patch --- .../java/app/revanced/integrations/twitter/Pref.java | 5 +++++ .../integrations/twitter/patches/TimelineEntry.java | 6 +++++- .../integrations/twitter/settings/Settings.java | 1 + .../twitter/settings/SettingsAboutFragment.java | 1 + .../twitter/settings/SettingsFragment.java | 10 ++++++++++ .../integrations/twitter/settings/SettingsStatus.java | 2 ++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/twitter/Pref.java b/app/src/main/java/app/revanced/integrations/twitter/Pref.java index 72ffd22a7c..c666a18528 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/Pref.java +++ b/app/src/main/java/app/revanced/integrations/twitter/Pref.java @@ -200,6 +200,10 @@ public static boolean hideDetailedPosts() { return Utils.getBooleanPerf(Settings.ADS_HIDE_DETAILED_POSTS); } + public static boolean hidePremiumPrompt() { + return Utils.getBooleanPerf(Settings.ADS_HIDE_PREMIUM_PROMPT); + } + public static boolean enableReaderMode() { return Utils.getBooleanPerf(Settings.PREMIUM_READER_MODE); } @@ -207,6 +211,7 @@ public static boolean enableReaderMode() { public static boolean enableUndoPosts() { return Utils.getBooleanPerf(Settings.PREMIUM_UNDO_POSTS); } + public static boolean enableDebugMenu() { return Utils.getBooleanPerf(Settings.MISC_DEBUG_MENU); } diff --git a/app/src/main/java/app/revanced/integrations/twitter/patches/TimelineEntry.java b/app/src/main/java/app/revanced/integrations/twitter/patches/TimelineEntry.java index 88a3b6cf24..e55c7bc68c 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/patches/TimelineEntry.java +++ b/app/src/main/java/app/revanced/integrations/twitter/patches/TimelineEntry.java @@ -6,7 +6,7 @@ import app.revanced.integrations.twitter.settings.SettingsStatus; public class TimelineEntry { - private static final boolean hideAds,hideGAds,hideWTF,hideCTS,hideCTJ,hideDetailedPosts,hideRBMK,hidePinnedPosts; + private static final boolean hideAds,hideGAds,hideWTF,hideCTS,hideCTJ,hideDetailedPosts,hideRBMK,hidePinnedPosts,hidePremiumPrompt; static { hideAds = (Pref.hideAds() && SettingsStatus.hideAds); hideGAds = (Pref.hideGoogleAds() && SettingsStatus.hideGAds); @@ -16,6 +16,7 @@ public class TimelineEntry { hideDetailedPosts = (Pref.hideDetailedPosts() && SettingsStatus.hideDetailedPosts); hideRBMK = (Pref.hideRBMK() && SettingsStatus.hideRBMK); hidePinnedPosts = (Pref.hideRPinnedPosts() && SettingsStatus.hideRPinnedPosts); + hidePremiumPrompt = (Pref.hidePremiumPrompt() && SettingsStatus.hidePremiumPrompt); } @@ -48,6 +49,9 @@ private static boolean isEntryIdRemove(String entryId) { if (entryId.startsWith("pinned-tweets") && hidePinnedPosts) { return true; } + if (entryId.startsWith("messageprompt-premium") && hidePremiumPrompt) { + return true; + } } return false; } diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java b/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java index e8d7522097..0c01b88a71 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java @@ -31,6 +31,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting ADS_HIDE_REVISIT_BMK = new BooleanSetting("ads_hide_revisit_bookmark", true); public static final BooleanSetting ADS_HIDE_REVISIT_PINNED_POSTS = new BooleanSetting("ads_hide_revisit_pinned_posts", true); public static final BooleanSetting ADS_HIDE_DETAILED_POSTS = new BooleanSetting("ads_hide_detailed_posts", true); + public static final BooleanSetting ADS_HIDE_PREMIUM_PROMPT = new BooleanSetting("ads_hide_premium_prompt", true); public static final BooleanSetting TIMELINE_DISABLE_AUTO_SCROLL = new BooleanSetting("timeline_disable_auto_scroll", true); public static final BooleanSetting TIMELINE_HIDE_LIVETHREADS = new BooleanSetting("timeline_hide_livethreads", true); diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java index 2bfd2f3d6f..3ebb15c789 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java @@ -96,6 +96,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta flags.put(strRes("piko_pref_round_off_numbers"),SettingsStatus.roundOffNumbers); flags.put(strRes("piko_pref_customisation_inlinetabs"),SettingsStatus.inlineBarCustomisation); flags.put(strRes("piko_pref_debug_menu"),SettingsStatus.enableDebugMenu); + flags.put(strRes("piko_pref_hide_premium_prompt"),SettingsStatus.hidePremiumPrompt); LegacyTwitterPreferenceCategory patPref = preferenceCategory(strRes("piko_pref_patches"), screen); diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java index 8515bbcc23..2787e24c17 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java @@ -190,6 +190,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) { ); } + if (SettingsStatus.hidePremiumPrompt) { + adsPrefs.addPreference( + switchPreference( + strRes("piko_pref_hide_premium_prompt"), + "", + Settings.ADS_HIDE_PREMIUM_PROMPT + ) + ); + } + } diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java index b53b47fb1a..ccb7f2477a 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java @@ -30,6 +30,7 @@ public class SettingsStatus { public static boolean hideDetailedPosts = false; public static boolean hideRBMK = false; public static boolean hideRPinnedPosts = false; + public static boolean hidePremiumPrompt = false; public static boolean enableReaderMode = false; public static boolean enableUndoPosts = false; @@ -73,6 +74,7 @@ public class SettingsStatus { public static void disableAutoTimelineScroll() { disableAutoTimelineScroll = true; } public static void hideLiveThreads() { hideLiveThreads = true; } public static void hideBanner() { hideBanner = true; } + public static void hidePremiumPrompt(){ hidePremiumPrompt = true; } public static void enableShowPollResults() { showPollResultsEnabled = true; } public static void forceTranslate() { forceTranslate = true; } public static void hidePromoteButton() { hidePromoteButton = true; } From 9b9dd0dd6d1eab7ede235d29ae5dc2153a01f8cb Mon Sep 17 00:00:00 2001 From: Swakshan Date: Mon, 20 May 2024 23:42:53 +0530 Subject: [PATCH 2/2] feat(Twitter): Added `Hide hidden replies` patch --- .../java/app/revanced/integrations/twitter/Pref.java | 7 +++++++ .../revanced/integrations/twitter/settings/Settings.java | 1 + .../twitter/settings/SettingsAboutFragment.java | 1 + .../integrations/twitter/settings/SettingsFragment.java | 9 +++++++++ .../integrations/twitter/settings/SettingsStatus.java | 2 ++ 5 files changed, 20 insertions(+) diff --git a/app/src/main/java/app/revanced/integrations/twitter/Pref.java b/app/src/main/java/app/revanced/integrations/twitter/Pref.java index c666a18528..ec841618f5 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/Pref.java +++ b/app/src/main/java/app/revanced/integrations/twitter/Pref.java @@ -161,6 +161,13 @@ public static boolean hideImmersivePlayer() { return !Utils.getBooleanPerf(Settings.TIMELINE_HIDE_IMMERSIVE_PLAYER); } + public static boolean hideHiddenReplies(boolean bool){ + if(Utils.getBooleanPerf(Settings.TIMELINE_HIDE_HIDDEN_REPLIES)){ + return false; + } + return bool; + } + public static boolean hidePromotedTrend(Object data) { if (data != null && Utils.getBooleanPerf(Settings.ADS_HIDE_PROMOTED_TRENDS)) { return true; diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java b/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java index 0c01b88a71..bf0319c1ff 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/Settings.java @@ -41,6 +41,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting TIMELINE_HIDE_IMMERSIVE_PLAYER = new BooleanSetting("timeline_hide_immersive_player", false); public static final BooleanSetting TIMELINE_HIDE_PROMOTE_BUTTON = new BooleanSetting("timeline_hide_promote_button", false); public static final BooleanSetting TIMELINE_HIDE_FORCE_TRANSLATE = new BooleanSetting("timeline_force_translate", false); + public static final BooleanSetting TIMELINE_HIDE_HIDDEN_REPLIES = new BooleanSetting("timeline_hide_hidden_replies", false); public static final BooleanSetting PREMIUM_READER_MODE = new BooleanSetting("premium_reader_mode", false); public static final BooleanSetting PREMIUM_UNDO_POSTS = new BooleanSetting("premium_undo_posts", false); diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java index 3ebb15c789..7f6ac32b34 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsAboutFragment.java @@ -97,6 +97,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta flags.put(strRes("piko_pref_customisation_inlinetabs"),SettingsStatus.inlineBarCustomisation); flags.put(strRes("piko_pref_debug_menu"),SettingsStatus.enableDebugMenu); flags.put(strRes("piko_pref_hide_premium_prompt"),SettingsStatus.hidePremiumPrompt); + flags.put(strRes("piko_pref_hide_hidden_replies"),SettingsStatus.hideHiddenReplies); LegacyTwitterPreferenceCategory patPref = preferenceCategory(strRes("piko_pref_patches"), screen); diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java index 2787e24c17..977f4d159a 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsFragment.java @@ -447,6 +447,15 @@ public void onCreate(@Nullable Bundle savedInstanceState) { ); } + if (SettingsStatus.hideHiddenReplies) { + timelinePrefs.addPreference( + switchPreference( + strRes("piko_pref_hide_hidden_replies"), + "", + Settings.TIMELINE_HIDE_HIDDEN_REPLIES + ) + ); + } } diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java index ccb7f2477a..25ec250e94 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsStatus.java @@ -31,6 +31,7 @@ public class SettingsStatus { public static boolean hideRBMK = false; public static boolean hideRPinnedPosts = false; public static boolean hidePremiumPrompt = false; + public static boolean hideHiddenReplies = false; public static boolean enableReaderMode = false; public static boolean enableUndoPosts = false; @@ -77,6 +78,7 @@ public class SettingsStatus { public static void hidePremiumPrompt(){ hidePremiumPrompt = true; } public static void enableShowPollResults() { showPollResultsEnabled = true; } public static void forceTranslate() { forceTranslate = true; } + public static void hideHiddenReplies() { hideHiddenReplies = true; } public static void hidePromoteButton() { hidePromoteButton = true; } public static void enableDebugMenu() { enableDebugMenu = true; }