diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-06-10 04:22:19 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-06-10 04:22:19 +0000 |
commit | 4cd07e3bb61d848590a953a37c8501962e2c0bd8 (patch) | |
tree | cf4878e6ccea7a7f58d117fef57233a5cd48c6c8 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | 9a47a3d9d20c061e38161293498622e3a6aaf8b5 (diff) | |
download | infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar.gz infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar.bz2 infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar.lz infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar.xz infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.tar.zst infinity-for-reddit-4cd07e3bb61d848590a953a37c8501962e2c0bd8.zip |
Prepare to add different font support.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
12 files changed, 114 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java index 1eb8aa0a..883d0ce8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -27,11 +27,14 @@ import com.google.android.material.tabs.TabLayout; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; -import ml.docilealligator.infinityforreddit.ContentFontStyle; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.FontStyle; +import ml.docilealligator.infinityforreddit.Font.ContentFontFamily; +import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; +import ml.docilealligator.infinityforreddit.Font.FontFamily; +import ml.docilealligator.infinityforreddit.Font.FontStyle; +import ml.docilealligator.infinityforreddit.Font.TitleFontFamily; +import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.TitleFontStyle; import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -113,6 +116,15 @@ public abstract class BaseActivity extends AppCompatActivity { getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true); + getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true); + + getTheme().applyStyle(TitleFontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.TITLE_FONT_FAMILY_KEY, TitleFontFamily.Default.name())).getResId(), true); + + getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences + .getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true); + Window window = getWindow(); View decorView = window.getDecorView(); if (!hasDrawerLayout) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java index c9a08f48..015f0a37 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java @@ -41,15 +41,15 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; -import ml.docilealligator.infinityforreddit.ContentFontStyle; +import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem; -import ml.docilealligator.infinityforreddit.FontStyle; +import ml.docilealligator.infinityforreddit.Font.FontStyle; import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewCommentsFragment; import ml.docilealligator.infinityforreddit.Fragment.ThemePreviewPostsFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.TitleFontStyle; +import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java index 8bdc82fe..59521940 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java @@ -47,11 +47,11 @@ import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.AsyncTask.SaveGIFToFileAsyncTask; import ml.docilealligator.infinityforreddit.BuildConfig; -import ml.docilealligator.infinityforreddit.ContentFontStyle; -import ml.docilealligator.infinityforreddit.FontStyle; +import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; +import ml.docilealligator.infinityforreddit.Font.FontStyle; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.TitleFontStyle; +import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import pl.droidsonroids.gif.GifImageView; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java index 779d7fe7..6db185e0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java @@ -49,11 +49,11 @@ import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.AsyncTask.SaveImageToFileAsyncTask; import ml.docilealligator.infinityforreddit.BuildConfig; -import ml.docilealligator.infinityforreddit.ContentFontStyle; -import ml.docilealligator.infinityforreddit.FontStyle; +import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; +import ml.docilealligator.infinityforreddit.Font.FontStyle; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.TitleFontStyle; +import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; public class ViewImageActivity extends AppCompatActivity { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java index 9e0b95e7..7d776ed6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java @@ -33,14 +33,14 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.API.ImgurAPI; -import ml.docilealligator.infinityforreddit.ContentFontStyle; -import ml.docilealligator.infinityforreddit.FontStyle; +import ml.docilealligator.infinityforreddit.Font.ContentFontStyle; +import ml.docilealligator.infinityforreddit.Font.FontStyle; import ml.docilealligator.infinityforreddit.Fragment.ViewImgurImageFragment; import ml.docilealligator.infinityforreddit.Fragment.ViewImgurVideoFragment; import ml.docilealligator.infinityforreddit.ImgurMedia; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.TitleFontStyle; +import ml.docilealligator.infinityforreddit.Font.TitleFontStyle; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java new file mode 100644 index 00000000..1ef28bbe --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java @@ -0,0 +1,25 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum ContentFontFamily { + Default(R.style.ContentFontFamily, "Default"), + BalsamiqSans(R.style.ContentFontFamily_BalsamiqSans, "BalsamiqSans"), + NotoSans(R.style.ContentFontFamily_NotoSans, "NotoSans"); + + private int resId; + private String title; + + ContentFontFamily(int resId, String title) { + this.resId = resId; + this.title = title; + } + + public int getResId() { + return resId; + } + + public String getTitle() { + return title; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ContentFontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontStyle.java index 4eee6b53..654cff07 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ContentFontStyle.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontStyle.java @@ -1,4 +1,6 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; public enum ContentFontStyle { Small(R.style.ContentFontStyle_Small, "Small"), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java new file mode 100644 index 00000000..f33873b2 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java @@ -0,0 +1,25 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum FontFamily { + Default(R.style.FontFamily, "Default"), + BalsamiqSans(R.style.FontFamily_BalsamiqSans, "BalsamiqSans"), + NotoSans(R.style.FontFamily_NotoSans, "NotoSans"); + + private int resId; + private String title; + + FontFamily(int resId, String title) { + this.resId = resId; + this.title = title; + } + + public int getResId() { + return resId; + } + + public String getTitle() { + return title; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontStyle.java index 61d4cfb8..101b17b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FontStyle.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontStyle.java @@ -1,4 +1,6 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; public enum FontStyle { Small(R.style.FontStyle_Small, "Small"), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java new file mode 100644 index 00000000..2b9a73b0 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java @@ -0,0 +1,25 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum TitleFontFamily { + Default(R.style.TitleFontFamily, "Default"), + BalsamiqSans(R.style.TitleFontFamily_BalsamiqSans, "BalsamiqSans"), + NotoSans(R.style.TitleFontFamily_NotoSans, "NotoSans"); + + private int resId; + private String title; + + TitleFontFamily(int resId, String title) { + this.resId = resId; + this.title = title; + } + + public int getResId() { + return resId; + } + + public String getTitle() { + return title; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/TitleFontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontStyle.java index 5dc32c9d..9ac48525 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/TitleFontStyle.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontStyle.java @@ -1,4 +1,6 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; public enum TitleFontStyle { Small(R.style.TitleFontStyle_Small, "Small"), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java index a51c9e0b..b29ff3ed 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -29,6 +29,9 @@ public class SharedPreferencesUtils { public static final String FONT_SIZE_KEY = "font_size"; public static final String TITLE_FONT_SIZE_KEY = "title_font_size"; public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; + public static final String FONT_FAMILY_KEY = "font_family"; + public static final String TITLE_FONT_FAMILY_KEY = "title_font_family"; + public static final String CONTENT_FONT_FAMILY_KEY = "content_font_family"; public static final String AMOLED_DARK_KEY = "amoled_dark"; public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface"; public static final String IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY = "immersive_interface_ignore_nav_bar"; |