diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-20 13:27:00 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-20 13:27:00 +0000 |
commit | 9ca494d4b5409b12b8262194f736284036858c01 (patch) | |
tree | eabfd8bda9a18cf2c8053d6916627f7ee6f06759 /app/src/main/java/Settings | |
parent | 010c323769faf9703a84144576ba33eb4410562e (diff) | |
download | infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar.gz infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar.bz2 infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar.lz infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar.xz infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.tar.zst infinity-for-reddit-9ca494d4b5409b12b8262194f736284036858c01.zip |
Changing font size is available. Delete duplicate Edit menu in comments.
Diffstat (limited to 'app/src/main/java/Settings')
-rw-r--r-- | app/src/main/java/Settings/MainPreferenceFragment.java | 20 |
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; + }); + } } } } |