Skip to content

Commit

Permalink
feat: Add settings for Disable chirp font patch
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Mar 16, 2024
1 parent 10d1e2c commit 8600093
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ private static String getStringPref(Setting<String> setting) {
return value;
}

@SuppressWarnings("deprecation")
private static Boolean getBooleanPerf(Setting<Boolean> setting) {
return PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(setting.key, setting.defaultValue);
}

public static String getPublicFolder() {
return getStringPref(Settings.VID_PUBLIC_FOLDER);
}
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}

0 comments on commit 8600093

Please sign in to comment.