diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-26 16:30:24 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-26 16:30:24 +0000 |
commit | 837e461451a877c581ea38e401863a266a1781ca (patch) | |
tree | 640ec910dde0be8c8da0559b081c0f0a407d6a3e /app/src/main/java/Settings | |
parent | 81c259edcb557e231766e17980bf7a20906ee983 (diff) | |
download | infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar.gz infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar.bz2 infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar.lz infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar.xz infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.tar.zst infinity-for-reddit-837e461451a877c581ea38e401863a266a1781ca.zip |
Add title and content font size options.
Diffstat (limited to 'app/src/main/java/Settings')
-rw-r--r-- | app/src/main/java/Settings/FontSizePreferenceFragment.java | 49 | ||||
-rw-r--r-- | app/src/main/java/Settings/MainPreferenceFragment.java | 10 |
2 files changed, 49 insertions, 10 deletions
diff --git a/app/src/main/java/Settings/FontSizePreferenceFragment.java b/app/src/main/java/Settings/FontSizePreferenceFragment.java new file mode 100644 index 00000000..41000a5a --- /dev/null +++ b/app/src/main/java/Settings/FontSizePreferenceFragment.java @@ -0,0 +1,49 @@ +package Settings; + +import android.app.Activity; +import android.os.Bundle; + +import androidx.preference.ListPreference; +import androidx.preference.PreferenceFragmentCompat; + +import org.greenrobot.eventbus.EventBus; + +import ml.docilealligator.infinityforreddit.ChangeFontSizeEvent; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SharedPreferencesUtils; + +public class FontSizePreferenceFragment extends PreferenceFragmentCompat { + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.font_size_preferences, rootKey); + + Activity activity = getActivity(); + if(activity != null) { + ListPreference fontSizePreference = findPreference(SharedPreferencesUtils.FONT_SIZE_KEY); + ListPreference titleFontSizePreference = findPreference(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY); + ListPreference contentFontSizePreference = findPreference(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY); + + if(fontSizePreference != null) { + fontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeFontSizeEvent()); + activity.recreate(); + return true; + }); + } + + if(titleFontSizePreference != null) { + titleFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeFontSizeEvent()); + return true; + }); + } + + if(contentFontSizePreference != null) { + contentFontSizePreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeFontSizeEvent()); + return true; + }); + } + } + } +} diff --git a/app/src/main/java/Settings/MainPreferenceFragment.java b/app/src/main/java/Settings/MainPreferenceFragment.java index 847112a9..af498294 100644 --- a/app/src/main/java/Settings/MainPreferenceFragment.java +++ b/app/src/main/java/Settings/MainPreferenceFragment.java @@ -15,7 +15,6 @@ 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; @@ -46,7 +45,6 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat { SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY); SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY); ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY); - ListPreference fontSizePreference = findPreference(SharedPreferencesUtils.FONT_SIZE_KEY); if(nsfwSwitch != null) { nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> { @@ -101,14 +99,6 @@ 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; - }); - } } } } |