diff options
author | Alex Ning <chineseperson5@gmail.com> | 2022-01-15 04:03:18 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2022-01-15 04:03:18 +0000 |
commit | af3447419a361071c7d0719da3c2c5dcd9bc6e68 (patch) | |
tree | 483b6c3e5d09e663e4dec66cfee0ae28da451296 /app/src/main | |
parent | 4d0b8b4672d33212cbdbee9f835d4f29f178523a (diff) | |
download | infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar.gz infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar.bz2 infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar.lz infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar.xz infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.tar.zst infinity-for-reddit-af3447419a361071c7d0719da3c2c5dcd9bc6e68.zip |
Load custom fonts.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java index a1e966de..237f3fc7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java @@ -34,6 +34,9 @@ import ml.docilealligator.infinityforreddit.broadcastreceivers.WallpaperChangeRe import ml.docilealligator.infinityforreddit.events.ChangeAppLockEvent; import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent; import ml.docilealligator.infinityforreddit.events.ToggleSecureModeEvent; +import ml.docilealligator.infinityforreddit.font.ContentFontFamily; +import ml.docilealligator.infinityforreddit.font.FontFamily; +import ml.docilealligator.infinityforreddit.font.TitleFontFamily; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -69,12 +72,18 @@ public class Infinity extends Application implements LifecycleObserver { isSecureMode = mSecuritySharedPreferences.getBoolean(SharedPreferencesUtils.SECURE_MODE, false); try { - typeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/font_family.ttf"); - titleTypeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/title_font_family.ttf"); - contentTypeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/content_font_family.ttf"); + if (mSharedPreferences.getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name()).equals(FontFamily.Custom.name())) { + typeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/font_family.ttf"); + } + if (mSharedPreferences.getString(SharedPreferencesUtils.TITLE_FONT_FAMILY_KEY, TitleFontFamily.Default.name()).equals(TitleFontFamily.Custom.name())) { + titleTypeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/title_font_family.ttf"); + } + if (mSharedPreferences.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name()).equals(ContentFontFamily.Custom.name())) { + contentTypeface = Typeface.createFromFile(getExternalFilesDir("fonts") + "/content_font_family.ttf"); + } } catch (RuntimeException e) { e.printStackTrace(); - Toast.makeText(this, "Some font files do not exist", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.unable_to_load_font, Toast.LENGTH_SHORT).show(); } registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { |