From 18cd14fa40c6a7d07158086310bb8b4cf5336e0d Mon Sep 17 00:00:00 2001 From: Swakshan Date: Sat, 18 May 2024 17:36:18 +0530 Subject: [PATCH] feat(Twitter): Added `Round off numbers` patch --- .../java/app/revanced/integrations/twitter/Pref.java | 7 +++++++ .../integrations/twitter/settings/Settings.java | 1 + .../twitter/settings/SettingsAboutFragment.java | 1 + .../twitter/settings/SettingsFragment.java | 10 ++++++++++ .../integrations/twitter/settings/SettingsStatus.java | 5 ++++- 5 files changed, 23 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 b6dd8b706a..de7037963e 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/Pref.java +++ b/app/src/main/java/app/revanced/integrations/twitter/Pref.java @@ -7,7 +7,14 @@ @SuppressWarnings("unused") public class Pref { + public static boolean ROUND_OFF_NUMBERS; + static{ + ROUND_OFF_NUMBERS = isRoundOffNumbersEnabled(); + } + public static boolean isRoundOffNumbersEnabled() { + return Utils.getBooleanPerf(Settings.MISC_ROUND_OFF_NUMBERS); + } public static boolean isChirpFontEnabled() { return Utils.getBooleanPerf(Settings.MISC_FONT); } 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 72fe48d543..1efd5eff02 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 @@ -19,6 +19,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting MISC_HIDE_VIEW_COUNT = new BooleanSetting("misc_hide_view_count", true); public static final BooleanSetting MISC_BROWSER_CHOOSER = new BooleanSetting("misc_browser_chooser", false); public static final StringSetting MISC_FEATURE_FLAGS = new StringSetting("misc_feature_flags", ""); + public static final BooleanSetting MISC_ROUND_OFF_NUMBERS = new BooleanSetting("misc_round_off_numbers", true); public static final BooleanSetting ADS_HIDE_PROMOTED_TRENDS = new BooleanSetting("ads_hide_promoted_trends", true); public static final BooleanSetting ADS_HIDE_PROMOTED_POSTS = new BooleanSetting("ads_hide_promoted_posts", 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 5fb4070653..20d88be8b2 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 @@ -93,6 +93,7 @@ public void onCreate(@org.jetbrains.annotations.Nullable Bundle savedInstanceSta flags.put(strRes("piko_pref_clear_tracking_params"),SettingsStatus.cleartrackingparams); flags.put(strRes("piko_pref_unshorten_link"),SettingsStatus.unshortenlink); flags.put(strRes("piko_pref_force_translate"),SettingsStatus.forceTranslate); + flags.put(strRes("piko_pref_round_off_numbers"),SettingsStatus.roundOffNumbers); 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 d3446d8113..d4cdedeeef 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 @@ -264,6 +264,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) { ); } + if (SettingsStatus.roundOffNumbers) { + miscPrefs.addPreference( + switchPreference( + strRes("piko_pref_round_off_numbers"), + strRes("piko_pref_round_off_numbers_desc"), + Settings.MISC_ROUND_OFF_NUMBERS + ) + ); + } + if (SettingsStatus.featureFlagsEnabled) { miscPrefs.addPreference( buttonPreference( 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 8531829102..a54466c2e8 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 @@ -19,6 +19,7 @@ public class SettingsStatus { public static boolean featureFlagsEnabled = false; public static boolean forceTranslate = false; public static boolean hidePromoteButton = false; + public static boolean roundOffNumbers = false; public static boolean hideAds = false; public static boolean hideGAds = false; @@ -56,6 +57,8 @@ public class SettingsStatus { public static void mediaLinkHandle() { mediaLinkHandle = true; } public static void enableCustomSharingDomain() { customSharingDomainEnabled = true; } public static void enableFont() { enableFontMod = true; } + + public static void roundOffNumbers() { roundOffNumbers = true; } public static void enableFeatureFlags() { featureFlagsEnabled = true; } public static void enableBrowserChooser() { browserChooserEnabled = true; } @@ -94,7 +97,7 @@ public class SettingsStatus { public static void navBarCustomisation() { navBarCustomisation = true; } public static boolean enableTimelineSection(){ return (navBarCustomisation || disableAutoTimelineScroll || forceTranslate || hidePromoteButton || hideCommunityNote|| hideLiveThreads || hideBanner || hideInlineBmk || showPollResultsEnabled || hideImmersivePlayer); } - public static boolean enableMiscSection() { return (enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || customSharingDomainEnabled || hideFABBtns); } + public static boolean enableMiscSection() { return (roundOffNumbers || enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || customSharingDomainEnabled || hideFABBtns); } public static boolean enableAdsSection() {return (hideAds|| hideGAds || hideWTF || hideCTS || hideCTJ || hideDetailedPosts || hideRBMK ||hidePromotedTrend); } public static boolean enableDownloadSection() {return (changeDownloadEnabled || mediaLinkHandle); }