From 28b9eb37daf90b4a4282788ab19093e5d4a63250 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 5 Apr 2020 12:04:35 +0800 Subject: [PATCH] Add Calm Pastel theme. Fix an fab icon color issue. --- .../Activity/BaseActivity.java | 10 +-- .../Activity/MainActivity.java | 2 +- .../Activity/MultiRedditListingActivity.java | 2 +- .../Activity/PostImageActivity.java | 4 +- .../Activity/PostVideoActivity.java | 4 +- .../Activity/SelectedSubredditsActivity.java | 2 +- .../Activity/ViewPostDetailActivity.java | 2 +- .../Activity/ViewSubredditDetailActivity.java | 2 +- .../CustomTheme/CustomThemeWrapper.java | 77 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 10 files changed, 88 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 e1f87b21..c5b7f36f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -5,8 +5,6 @@ import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Color; -import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; @@ -266,14 +264,8 @@ public abstract class BaseActivity extends AppCompatActivity { customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor()); } - protected void applyFABTheme(FloatingActionButton fab, int drawableId) { + protected void applyFABTheme(FloatingActionButton fab) { fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorPrimaryLightTheme())); fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor())); - Drawable myFabSrc = getResources().getDrawable(drawableId); - if (myFabSrc.getConstantState() != null) { - Drawable willBeWhite = myFabSrc.getConstantState().newDrawable(); - willBeWhite.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); - fab.setImageDrawable(willBeWhite); - } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 0c1989c3..434eaa87 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -311,7 +311,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor())); - applyFABTheme(fab, R.drawable.ic_add_day_night_24dp); + applyFABTheme(fab); } private void getCurrentAccountAndBindView() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java index 50357ff0..9e0164b6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java @@ -258,6 +258,6 @@ public class MultiRedditListingActivity extends BaseActivity { mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); - applyFABTheme(fab, R.drawable.ic_add_day_night_24dp); + applyFABTheme(fab); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java index 043b5875..9b2f1dfd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java @@ -392,8 +392,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); - applyFABTheme(captureFab, R.drawable.ic_outline_add_a_photo_24dp); - applyFABTheme(selectFromLibraryFab, R.drawable.ic_outline_select_photo_24dp); + applyFABTheme(captureFab); + applyFABTheme(selectFromLibraryFab); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java index 5088576c..50a06878 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java @@ -397,8 +397,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); - applyFABTheme(captureFab, R.drawable.ic_outline_add_a_photo_24dp); - applyFABTheme(selectFromLibraryFab, R.drawable.ic_outline_select_photo_24dp); + applyFABTheme(captureFab); + applyFABTheme(selectFromLibraryFab); selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java index 7e136584..1f1c0f8f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SelectedSubredditsActivity.java @@ -141,6 +141,6 @@ public class SelectedSubredditsActivity extends BaseActivity { protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); - applyFABTheme(fab, R.drawable.ic_add_24dp); + applyFABTheme(fab); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 7700fcbb..a8de3b71 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -389,7 +389,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); - applyFABTheme(fab, R.drawable.ic_keyboard_arrow_down_24dp); + applyFABTheme(fab); } private void getCurrentAccountAndBindView() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index d3e3b0e3..419a5e08 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -424,7 +424,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); applyTabLayoutTheme(tabLayout); - applyFABTheme(fab, R.drawable.ic_add_day_night_24dp); + applyFABTheme(fab); unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(); subscribedColor = mCustomThemeWrapper.getSubscribed(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java index 0cd30e94..95e6d97f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -396,6 +396,8 @@ public class CustomThemeWrapper { return getRedAmoled(context); } else if (name.equals(context.getString(R.string.theme_name_dracula))) { return getDracula(context); + } else if (name.equals(context.getString(R.string.theme_name_calm_pastel))) { + return getCalmPastel(context); } else { return getIndigo(context); } @@ -413,6 +415,7 @@ public class CustomThemeWrapper { customThemes.add(getRedDark(context)); customThemes.add(getRedAmoled(context)); customThemes.add(getDracula(context)); + customThemes.add(getCalmPastel(context)); return customThemes; } @@ -1155,4 +1158,78 @@ public class CustomThemeWrapper { return customTheme; } + + public static CustomTheme getCalmPastel(Context context) { + CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_calm_pastel)); + customTheme.isLightTheme = true; + customTheme.isDarkTheme = false; + customTheme.isAmoledTheme = false; + customTheme.colorPrimary = Color.parseColor("#D48AE0"); + customTheme.colorPrimaryDark = Color.parseColor("#D476E0"); + customTheme.colorAccent = Color.parseColor("#775EFF"); + customTheme.colorPrimaryLightTheme = Color.parseColor("#D48AE0"); + customTheme.primaryTextColor = Color.parseColor("#000000"); + customTheme.secondaryTextColor = Color.parseColor("#8A000000"); + customTheme.postTitleColor = Color.parseColor("#000000"); + customTheme.postContentColor = Color.parseColor("#8A000000"); + customTheme.commentColor = Color.parseColor("#000000"); + customTheme.buttonTextColor = Color.parseColor("#FFFFFF"); + customTheme.backgroundColor = Color.parseColor("#DAD0DE"); + customTheme.cardViewBackgroundColor = Color.parseColor("#C0F0F4"); + customTheme.commentBackgroundColor = Color.parseColor("#C0F0F4"); + customTheme.bottomAppBarBackgroundColor = Color.parseColor("#C0F0F4"); + customTheme.primaryIconColor = Color.parseColor("#000000"); + customTheme.postIconAndInfoColor = Color.parseColor("#000000"); + customTheme.commentIconAndInfoColor = Color.parseColor("#000000"); + customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#3C4043"); + customTheme.toolbarSecondaryTextColor = Color.parseColor("#3C4043"); + customTheme.circularProgressBarBackground = Color.parseColor("#D48AE0"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#D48AE0"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#D48AE0"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#D48AE0"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#3C4043"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#3C4043"); + customTheme.upvoted = Color.parseColor("#E91E63"); + customTheme.downvoted = Color.parseColor("#007DDE"); + customTheme.postTypeBackgroundColor = Color.parseColor("#0D47A1"); + customTheme.postTypeTextColor = Color.parseColor("#FFFFFF"); + customTheme.spoilerBackgroundColor = Color.parseColor("#EE02EB"); + customTheme.spoilerTextColor = Color.parseColor("#FFFFFF"); + customTheme.nsfwBackgroundColor = Color.parseColor("#FF4081"); + customTheme.nsfwTextColor = Color.parseColor("#FFFFFF"); + customTheme.flairBackgroundColor = Color.parseColor("#00AA8C"); + customTheme.flairTextColor = Color.parseColor("#FFFFFF"); + customTheme.archivedTint = Color.parseColor("#B4009F"); + customTheme.lockedIconTint = Color.parseColor("#EE7302"); + customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); + customTheme.subscribed = Color.parseColor("#FF4081"); + customTheme.unsubscribed = Color.parseColor("#0D47A1"); + customTheme.username = Color.parseColor("#0D47A1"); + customTheme.subreddit = Color.parseColor("#E91E63"); + customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); + customTheme.submitter = Color.parseColor("#EE8A02"); + customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#25D5E5"); + customTheme.unreadMessageBackgroundColor = Color.parseColor("#25D5E5"); + customTheme.dividerColor = Color.parseColor("#E0E0E0"); + customTheme.noPreviewLinkBackgroundColor = Color.parseColor("#E0E0E0"); + customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#F0F0F0"); + customTheme.commentVerticalBarColor1 = Color.parseColor("#1565C0"); + customTheme.commentVerticalBarColor2 = Color.parseColor("#EE02BE"); + customTheme.commentVerticalBarColor3 = Color.parseColor("#02DFEE"); + customTheme.commentVerticalBarColor4 = Color.parseColor("#EED502"); + customTheme.commentVerticalBarColor5 = Color.parseColor("#EE0220"); + customTheme.commentVerticalBarColor6 = Color.parseColor("#02EE6E"); + customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); + customTheme.fabIconColor = Color.parseColor("#000000"); + customTheme.chipTextColor = Color.parseColor("#FFFFFF"); + customTheme.navBarColor = Color.parseColor("#D48AE0"); + customTheme.isLightStatusBar = false; + customTheme.isLightNavBar = true; + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true; + + return customTheme; + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5de9c7f4..0c78a920 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -634,6 +634,7 @@ Red Dark Red Amoled Dracula + Calm Pastel Create a Light Theme\nBase on Indigo Theme Create a Dark Theme\nBase on Indigo Dark Theme Create an Amoled Theme\nBase on Indigo Amoled Theme