From b4b3b48dd4b5db7792662add81e98369418c16e6 Mon Sep 17 00:00:00 2001 From: crimera Date: Sun, 31 Mar 2024 10:00:12 +0800 Subject: [PATCH] feat(Twitter): Add `Custom sharing domain` patch --- .../java/app/revanced/integrations/twitter/Pref.java | 5 +++++ .../integrations/twitter/settings/Settings.java | 2 +- .../twitter/settings/SettingsActivity.java | 10 ++++++++++ .../integrations/twitter/settings/SettingsStatus.java | 4 +++- 4 files changed, 19 insertions(+), 2 deletions(-) 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 9ba30dbed0..718ab1097e 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/Pref.java +++ b/app/src/main/java/app/revanced/integrations/twitter/Pref.java @@ -14,6 +14,11 @@ public static String getVideoFolder(String filename) { return Utils.getStringPref(Settings.VID_SUBFOLDER)+"/"+filename; } + public static String getSharingLink(String link) { + String domain = Utils.getStringPref(Settings.CUSTOM_SHARING_DOMAIN); + return link.replace("x", domain); + } + public static ArrayList hideRecommendedUsers(ArrayList users) { if (Utils.getBooleanPerf(Settings.MISC_HIDE_RECOMMENDED_USERS)) { return null; } return users; 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 809c581521..714dc71281 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 @@ -7,7 +7,7 @@ public class Settings extends BaseSettings { public static final StringSetting VID_PUBLIC_FOLDER = new StringSetting("vid_public_folder", "Movies"); public static final StringSetting VID_SUBFOLDER = new StringSetting("vid_subfolder", "Twitter"); - + public static final StringSetting CUSTOM_SHARING_DOMAIN = new StringSetting("misc_custom_sharing_domain", "fxtwitter"); public static final BooleanSetting MISC_FONT = new BooleanSetting("misc_font", false); public static final BooleanSetting MISC_HIDE_FAB = new BooleanSetting("misc_hide_fab", true); public static final BooleanSetting MISC_HIDE_RECOMMENDED_USERS = new BooleanSetting("misc_hide_recommended_users", true); diff --git a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsActivity.java b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsActivity.java index f920e944e6..7d69923de9 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsActivity.java +++ b/app/src/main/java/app/revanced/integrations/twitter/settings/SettingsActivity.java @@ -236,6 +236,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) { ) ); } + + if (SettingsStatus.customSharingDomainEnabled) { + miscPrefs.addPreference( + editTextPreference( + "Custom sharing domain", + "The domain to use when sharing tweets", + Settings.CUSTOM_SHARING_DOMAIN + ) + ); + } } if (SettingsStatus.enableTimelineSection()) { 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 7383a6d438..a307210310 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 @@ -2,6 +2,7 @@ public class SettingsStatus { public static boolean changeDownloadEnabled = false; + public static boolean customSharingDomainEnabled = false; public static boolean enableFontMod = false; public static boolean hideRecommendedUsers = false; public static boolean hidePromotedTrend = false; @@ -27,6 +28,7 @@ public class SettingsStatus { public static void enableDownloadFolder() { changeDownloadEnabled = true; } + public static void enableCustomSharingDomain() { customSharingDomainEnabled = true; } public static void enableFont() { enableFontMod = true; } public static void hideRecommendedUsers() { hideRecommendedUsers = true; } @@ -52,7 +54,7 @@ public class SettingsStatus { public static void enableAppIconNNavIcon() { enableAppIconNNavIcon = true; } public static boolean enableTimelineSection(){ return (hideLiveThreads || hideBanner || hideForyou); } - public static boolean enableMiscSection() { return (enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || hideCommunityNote); } + public static boolean enableMiscSection() { return (enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || hideCommunityNote || customSharingDomainEnabled); } public static boolean enableAdsSection() {return (hideAds|| hideGAds || hideWTF || hideCTS || hideCTJ || hideDetailedPosts || hideRBMK ||hidePromotedTrend); } public static boolean enablePremiumSection() {return (enableReaderMode || enableUndoPosts || enableAppIconNNavIcon); }