From 4cd07e3bb61d848590a953a37c8501962e2c0bd8 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 10 Jun 2020 12:22:19 +0800 Subject: Prepare to add different font support. --- .../infinityforreddit/Activity/BaseActivity.java | 18 ++++++++++++--- .../Activity/ThemePreviewActivity.java | 6 ++--- .../Activity/ViewGIFActivity.java | 6 ++--- .../Activity/ViewImageActivity.java | 6 ++--- .../Activity/ViewImgurMediaActivity.java | 6 ++--- .../infinityforreddit/ContentFontStyle.java | 25 -------------------- .../infinityforreddit/Font/ContentFontFamily.java | 25 ++++++++++++++++++++ .../infinityforreddit/Font/ContentFontStyle.java | 27 ++++++++++++++++++++++ .../infinityforreddit/Font/FontFamily.java | 25 ++++++++++++++++++++ .../infinityforreddit/Font/FontStyle.java | 26 +++++++++++++++++++++ .../infinityforreddit/Font/TitleFontFamily.java | 25 ++++++++++++++++++++ .../infinityforreddit/Font/TitleFontStyle.java | 26 +++++++++++++++++++++ .../infinityforreddit/FontStyle.java | 24 ------------------- .../infinityforreddit/TitleFontStyle.java | 24 ------------------- .../Utils/SharedPreferencesUtils.java | 3 +++ 15 files changed, 184 insertions(+), 88 deletions(-) delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/ContentFontStyle.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontStyle.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontStyle.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontStyle.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/FontStyle.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/TitleFontStyle.java (limited to 'app/src/main/java') 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/ContentFontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ContentFontStyle.java deleted file mode 100644 index 4eee6b53..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ContentFontStyle.java +++ /dev/null @@ -1,25 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -public enum ContentFontStyle { - Small(R.style.ContentFontStyle_Small, "Small"), - Normal(R.style.ContentFontStyle_Normal, "Normal"), - Large(R.style.ContentFontStyle_Large, "Large"), - XLarge(R.style.ContentFontStyle_XLarge, "XLarge"), - XXLarge(R.style.ContentFontStyle_XXLarge, "XXLarge"); - - private int resId; - private String title; - - ContentFontStyle(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/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/Font/ContentFontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontStyle.java new file mode 100644 index 00000000..654cff07 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontStyle.java @@ -0,0 +1,27 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum ContentFontStyle { + Small(R.style.ContentFontStyle_Small, "Small"), + Normal(R.style.ContentFontStyle_Normal, "Normal"), + Large(R.style.ContentFontStyle_Large, "Large"), + XLarge(R.style.ContentFontStyle_XLarge, "XLarge"), + XXLarge(R.style.ContentFontStyle_XXLarge, "XXLarge"); + + private int resId; + private String title; + + ContentFontStyle(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/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/Font/FontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontStyle.java new file mode 100644 index 00000000..101b17b4 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontStyle.java @@ -0,0 +1,26 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum FontStyle { + Small(R.style.FontStyle_Small, "Small"), + Normal(R.style.FontStyle_Normal, "Normal"), + Large(R.style.FontStyle_Large, "Large"), + XLarge(R.style.FontStyle_XLarge, "XLarge"); + + private int resId; + private String title; + + FontStyle(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/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/Font/TitleFontStyle.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontStyle.java new file mode 100644 index 00000000..9ac48525 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontStyle.java @@ -0,0 +1,26 @@ +package ml.docilealligator.infinityforreddit.Font; + +import ml.docilealligator.infinityforreddit.R; + +public enum TitleFontStyle { + Small(R.style.TitleFontStyle_Small, "Small"), + Normal(R.style.TitleFontStyle_Normal, "Normal"), + Large(R.style.TitleFontStyle_Large, "Large"), + XLarge(R.style.TitleFontStyle_XLarge, "XLarge"); + + private int resId; + private String title; + + TitleFontStyle(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/FontStyle.java deleted file mode 100644 index 61d4cfb8..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FontStyle.java +++ /dev/null @@ -1,24 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -public enum FontStyle { - Small(R.style.FontStyle_Small, "Small"), - Normal(R.style.FontStyle_Normal, "Normal"), - Large(R.style.FontStyle_Large, "Large"), - XLarge(R.style.FontStyle_XLarge, "XLarge"); - - private int resId; - private String title; - - FontStyle(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/TitleFontStyle.java deleted file mode 100644 index 5dc32c9d..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/TitleFontStyle.java +++ /dev/null @@ -1,24 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -public enum TitleFontStyle { - Small(R.style.TitleFontStyle_Small, "Small"), - Normal(R.style.TitleFontStyle_Normal, "Normal"), - Large(R.style.TitleFontStyle_Large, "Large"), - XLarge(R.style.TitleFontStyle_XLarge, "XLarge"); - - private int resId; - private String title; - - TitleFontStyle(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/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"; -- cgit v1.2.3