aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Settings
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/Settings')
-rw-r--r--app/src/main/java/Settings/MainPreferenceFragment.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/src/main/java/Settings/MainPreferenceFragment.java b/app/src/main/java/Settings/MainPreferenceFragment.java
index 11093bf6..847112a9 100644
--- a/app/src/main/java/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/Settings/MainPreferenceFragment.java
@@ -15,6 +15,7 @@ import org.greenrobot.eventbus.EventBus;
import javax.inject.Inject;
+import ml.docilealligator.infinityforreddit.ChangeFontSizeEvent;
import ml.docilealligator.infinityforreddit.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -44,7 +45,8 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
- ListPreference listPreference = findPreference(SharedPreferencesUtils.THEME_KEY);
+ ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY);
+ ListPreference fontSizePreference = findPreference(SharedPreferencesUtils.FONT_SIZE_KEY);
if(nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -73,14 +75,14 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
- if(listPreference != null) {
+ if(themePreference != null) {
if(systemDefault) {
- listPreference.setEntries(R.array.settings_theme_q);
+ themePreference.setEntries(R.array.settings_theme_q);
} else {
- listPreference.setEntries(R.array.settings_theme);
+ themePreference.setEntries(R.array.settings_theme);
}
- listPreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ themePreference.setOnPreferenceChangeListener((preference, newValue) -> {
int option = Integer.parseInt((String) newValue);
switch (option) {
case 0:
@@ -99,6 +101,14 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ if(fontSizePreference != null) {
+ fontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeFontSizeEvent((String) newValue));
+ activity.recreate();
+ return true;
+ });
+ }
}
}
}