diff --git a/app/src/main/java/app/revanced/integrations/twitter/Utils.java b/app/src/main/java/app/revanced/integrations/twitter/Utils.java index c2793c3cf3..99aae8b133 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/Utils.java +++ b/app/src/main/java/app/revanced/integrations/twitter/Utils.java @@ -31,6 +31,11 @@ private static String getStringPref(Setting setting) { return value; } + @SuppressWarnings("deprecation") + private static Boolean getBooleanPerf(Setting setting) { + return PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(setting.key, setting.defaultValue); + } + public static String getPublicFolder() { return getStringPref(Settings.VID_PUBLIC_FOLDER); } @@ -44,4 +49,8 @@ public static String[] addPref(String[] prefs, String pref) { bigger[prefs.length] = pref; return bigger; } + + public static boolean isChirpFontEnabled() { + return 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 8d840386b2..869082c6bb 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 @@ -1,9 +1,11 @@ package app.revanced.integrations.twitter.settings; import app.revanced.integrations.shared.settings.BaseSettings; +import app.revanced.integrations.shared.settings.BooleanSetting; import app.revanced.integrations.shared.settings.StringSetting; 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 BooleanSetting MISC_FONT = new BooleanSetting("misc_font", false); } 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 2365824dcc..e5201922f9 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 @@ -4,19 +4,13 @@ import android.app.Activity; import android.content.Context; import android.os.Bundle; -import android.preference.EditTextPreference; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; - +import android.preference.*; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; - -import com.twitter.ui.widget.LegacyTwitterPreferenceCategory; - import app.revanced.integrations.shared.Utils; +import app.revanced.integrations.shared.settings.BooleanSetting; import app.revanced.integrations.shared.settings.StringSetting; +import com.twitter.ui.widget.LegacyTwitterPreferenceCategory; @SuppressWarnings("deprecation") public class SettingsActivity extends Activity { @@ -59,6 +53,19 @@ public void onCreate(@Nullable Bundle savedInstanceState) { )); } + if (SettingsStatus.enableFontMod) { + LegacyTwitterPreferenceCategory miscPrefs = preferenceCategory("Misc", screen); + if (SettingsStatus.enableFontMod) { + miscPrefs.addPreference( + switchPreference( + "Enable Chirp Font", + "", + Settings.MISC_FONT + ) + ); + } + } + setPreferenceScreen(screen); } @@ -73,8 +80,18 @@ private Preference editTextPreference(String title, String summary, StringSettin return preference; } + private Preference switchPreference(String title, String summary, BooleanSetting setting) { + SwitchPreference preference = new SwitchPreference(context); + preference.setTitle(title); + preference.setSummary(summary); + preference.setKey(setting.key); + preference.setDefaultValue(setting.defaultValue); + + return preference; + } + private Preference listPreference(String title, String summary, StringSetting setting) { - ListPreference preference= new ListPreference(context); + ListPreference preference = new ListPreference(context); preference.setTitle(title); preference.setDialogTitle(title); preference.setSummary(summary); 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 9007b3187b..97f976a950 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,11 +2,11 @@ public class SettingsStatus { public static boolean changeDownloadEnabled = false; + public static boolean enableFontMod = false; - public static void enableDownload() { - changeDownloadEnabled = true; - } + public static void enableDownload() { changeDownloadEnabled = true; } + public static void enableFont() { enableFontMod = true; } public static void load() {} }