From fe658dd9e267763084775a4c27cb2aab5523ea59 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 15 Mar 2020 23:34:23 +0800 Subject: Still implementing custom themes. --- .../Activity/AccountPostsActivity.java | 5 +- .../Activity/AccountSavedThingActivity.java | 7 +- .../infinityforreddit/Activity/BaseActivity.java | 97 +++++--- .../Activity/CommentActivity.java | 13 +- .../Activity/CreateMultiRedditActivity.java | 7 +- .../Activity/EditCommentActivity.java | 7 +- .../Activity/EditPostActivity.java | 11 +- .../Activity/FilteredThingActivity.java | 5 +- .../Activity/LinkResolverActivity.java | 26 +- .../infinityforreddit/Activity/LoginActivity.java | 5 +- .../infinityforreddit/Activity/MainActivity.java | 16 +- .../Activity/MultiRedditListingActivity.java | 13 +- .../Activity/PostImageActivity.java | 83 ++++--- .../Activity/PostLinkActivity.java | 77 +++--- .../Activity/PostTextActivity.java | 77 +++--- .../Activity/PostVideoActivity.java | 83 ++++--- .../infinityforreddit/Activity/RulesActivity.java | 7 +- .../infinityforreddit/Activity/SearchActivity.java | 11 +- .../Activity/SearchResultActivity.java | 7 +- .../Activity/SearchSubredditsResultActivity.java | 5 +- .../Activity/SettingsActivity.java | 5 +- .../Activity/SubredditMultiselectionActivity.java | 7 +- .../Activity/SubredditSelectionActivity.java | 5 +- .../Activity/SubscribedThingListingActivity.java | 7 +- .../Activity/ViewMessageActivity.java | 11 +- .../Activity/ViewMultiRedditDetailActivity.java | 5 +- .../Activity/ViewPostDetailActivity.java | 13 +- .../Activity/ViewSidebarActivity.java | 11 +- .../Activity/ViewSubredditDetailActivity.java | 17 +- .../Activity/ViewUserDetailActivity.java | 29 ++- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 110 +++++---- .../CommentsListingRecyclerViewAdapter.java | 23 +- .../FlairBottomSheetRecyclerViewAdapter.java | 2 +- .../Adapter/FollowedUsersRecyclerViewAdapter.java | 5 +- .../Adapter/MessageRecyclerViewAdapter.java | 17 +- .../MultiRedditListingRecyclerViewAdapter.java | 5 +- .../NavigationDrawerRecyclerViewAdapter.java | 11 +- .../Adapter/PostRecyclerViewAdapter.java | 137 ++++++----- .../Adapter/RulesRecyclerViewAdapter.java | 5 +- .../SubredditListingRecyclerViewAdapter.java | 13 +- ...SubredditMultiselectionRecyclerViewAdapter.java | 5 +- .../SubscribedSubredditsRecyclerViewAdapter.java | 5 +- .../Adapter/UserListingRecyclerViewAdapter.java | 11 +- .../infinityforreddit/AppComponent.java | 3 + .../CustomTheme/CustomThemeWrapper.java | 273 +++++++++++---------- .../Fragment/CommentsListingFragment.java | 7 +- .../Fragment/FollowedUsersListingFragment.java | 7 +- .../infinityforreddit/Fragment/PostFragment.java | 9 +- .../Fragment/SubredditListingFragment.java | 7 +- .../SubscribedSubredditsListingFragment.java | 7 +- .../Fragment/UserListingFragment.java | 7 +- .../infinityforreddit/PullNotificationWorker.java | 2 +- .../Service/SubmitPostService.java | 2 +- .../Settings/InterfacePreferenceFragment.java | 27 +- .../Utils/CustomThemeSharedPreferencesUtils.java | 21 +- .../infinityforreddit/Utils/Utils.java | 6 - .../res/drawable/ic_outline_add_a_photo_24dp.xml | 9 + .../res/drawable/ic_outline_add_a_photo_24px.xml | 9 - .../res/drawable/ic_outline_select_photo_24dp.xml | 9 + .../res/drawable/ic_outline_select_photo_24px.xml | 9 - app/src/main/res/layout/activity_post_image.xml | 4 +- app/src/main/res/layout/activity_post_video.xml | 4 +- app/src/main/res/values/styles.xml | 2 +- 63 files changed, 756 insertions(+), 689 deletions(-) create mode 100644 app/src/main/res/drawable/ic_outline_add_a_photo_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_outline_add_a_photo_24px.xml create mode 100644 app/src/main/res/drawable/ic_outline_select_photo_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_outline_select_photo_24px.xml (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java index 721fddfb..6a8aa025 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -156,9 +156,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } private void getCurrentAccountAndInitializeFragment() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java index 0606920c..a89a451a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -155,10 +155,9 @@ public class AccountSavedThingActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyTabLayoutTheme(tabLayout); } private void getCurrentAccountAndInitializeViewPager() { 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 86a73107..7cdec427 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -4,6 +4,9 @@ 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; import android.view.View; @@ -25,6 +28,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.FontStyle; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.TitleFontStyle; +import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; @@ -34,11 +38,11 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; public abstract class BaseActivity extends AppCompatActivity { private boolean immersiveInterface; - private boolean lightStatusbar; private boolean changeStatusBarIconColor = true; private boolean transparentStatusBarAfterToolbarCollapsed; - private int systemVisibilityToolbarExpanded; - private int systemVisibilityToolbarCollapsed; + private int systemVisibilityToolbarExpanded = 0; + private int systemVisibilityToolbarCollapsed = 0; + private CustomThemeWrapper customThemeWrapper; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -49,18 +53,22 @@ public abstract class BaseActivity extends AppCompatActivity { int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2")); immersiveInterface = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true); + customThemeWrapper = getCustomThemeWrapper(); switch (systemThemeType) { case 0: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); getTheme().applyStyle(R.style.Theme_Purple, true); changeStatusBarIconColor = immersiveInterface; + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); break; case 1: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) { getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true); + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); } else { getTheme().applyStyle(R.style.Theme_Default_NormalDark, true); + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); } changeStatusBarIconColor = false; break; @@ -73,11 +81,14 @@ public abstract class BaseActivity extends AppCompatActivity { if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) { getTheme().applyStyle(R.style.Theme_Purple, true); changeStatusBarIconColor = immersiveInterface; + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); } else { if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) { getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true); + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); } else { getTheme().applyStyle(R.style.Theme_Default_NormalDark, true); + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); } changeStatusBarIconColor = false; } @@ -92,33 +103,49 @@ public abstract class BaseActivity extends AppCompatActivity { getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true); - CustomThemeWrapper customThemeWrapper = getCustomThemeWrapper(); - int themeType = customThemeWrapper.getThemeType(); Window window = getWindow(); View decorView = window.getDecorView(); - window.setStatusBarColor(customThemeWrapper.getColorPrimaryDark(themeType)); + window.setStatusBarColor(customThemeWrapper.getColorPrimaryDark()); + boolean isLightStatusbar = customThemeWrapper.isLightStatusBar(); + boolean isLightNavBar = customThemeWrapper.isLightNavBar(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - if (lightStatusbar) { - decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - if (changeStatusBarIconColor) { - systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + if (isLightStatusbar) { + if (isLightNavBar) { + systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + if (changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } else { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + } else { + systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + if (!changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } } } else { - decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; - if (changeStatusBarIconColor) { - systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + if (isLightNavBar) { + systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + if (changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + } else { + if (changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } } } - window.setNavigationBarColor(customThemeWrapper.getNavBarColor(themeType)); + decorView.setSystemUiVisibility(systemVisibilityToolbarExpanded); + window.setNavigationBarColor(customThemeWrapper.getNavBarColor()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (lightStatusbar) { + if (isLightStatusbar) { decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); systemVisibilityToolbarExpanded = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } - if (changeStatusBarIconColor) { - systemVisibilityToolbarCollapsed = 0; + if (!changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } + } else if (changeStatusBarIconColor) { + systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } } } @@ -181,20 +208,26 @@ public abstract class BaseActivity extends AppCompatActivity { this.transparentStatusBarAfterToolbarCollapsed = true; } - protected void applyTabLayoutTheme(TabLayout tabLayout, CustomThemeWrapper customThemeWrapper, int themeType) { - int toolbarAndTabBackgroundColor = customThemeWrapper.getToolbarAndTabBackgroundColor(themeType); + protected void applyToolbarTheme(Toolbar toolbar) { + toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor()); + } + + protected void applyTabLayoutTheme(TabLayout tabLayout) { + int toolbarAndTabBackgroundColor = customThemeWrapper.getToolbarAndTabBackgroundColor(); tabLayout.setBackgroundColor(toolbarAndTabBackgroundColor); - tabLayout.setSelectedTabIndicatorColor(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(themeType)); - tabLayout.setTabTextColors(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType), - customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType)); + tabLayout.setSelectedTabIndicatorColor(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator()); + tabLayout.setTabTextColors(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(), + customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor()); } - protected void applyFABTheme(FloatingActionButton fab, CustomThemeWrapper customThemeWrapper, int themeType) { - fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorPrimaryLightTheme(themeType))); - fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor(themeType))); - /*Drawable myFabSrc = getResources().getDrawable(R.drawable.ic_add_bottom_app_bar_24dp); - Drawable willBeWhite = myFabSrc.getConstantState().newDrawable(); - willBeWhite.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); - fab.setImageDrawable(willBeWhite);*/ + protected void applyFABTheme(FloatingActionButton fab, int drawableId) { + 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/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java index 27c2695e..515fe2b3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java @@ -232,13 +232,12 @@ public class CommentActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - commentParentMarkwonView.setTextColor(mCustomThemeWrapper.getCommentColor(themeType)); - divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor(themeType)); - commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor(themeType)); - markdownColor = mCustomThemeWrapper.getSecondaryTextColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + commentParentMarkwonView.setTextColor(mCustomThemeWrapper.getCommentColor()); + divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor()); + commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); + markdownColor = mCustomThemeWrapper.getSecondaryTextColor(); } private void getCurrentAccount() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java index 464e69af..1f5f39a4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java @@ -244,11 +244,10 @@ public class CreateMultiRedditActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); nameEditText.setTextColor(primaryTextColor); - int dividerColor = mCustomThemeWrapper.getDividerColor(themeType); + int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); descriptionEditText.setTextColor(primaryTextColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java index de67e642..abcc5382 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java @@ -118,10 +118,9 @@ public class EditCommentActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java index cd9ac208..a86d72ff 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java @@ -121,12 +121,11 @@ public class EditPostActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor(themeType)); - divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor(themeType)); - contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor()); + divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor()); + contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index 791fbb9c..995a3227 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -175,9 +175,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } private void getCurrentAccountAndBindView(int filter) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index 4dd5afb7..2cd62f20 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -6,12 +6,10 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; import androidx.browser.customtabs.CustomTabsIntent; import java.util.ArrayList; @@ -25,10 +23,6 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; -import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; -import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO; -import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; import static androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION; public class LinkResolverActivity extends AppCompatActivity { @@ -60,24 +54,6 @@ public class LinkResolverActivity extends AppCompatActivity { ((Infinity) getApplication()).getAppComponent().inject(this); - boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; - int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2")); - switch (themeType) { - case 0: - AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); - break; - case 1: - AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); - break; - case 2: - if (systemDefault) { - AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM); - } else { - AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY); - } - - } - Uri uri = getIntent().getData(); if (uri == null) { Toast.makeText(this, R.string.no_link_available, Toast.LENGTH_SHORT).show(); @@ -239,7 +215,7 @@ public class LinkResolverActivity extends AppCompatActivity { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); // add share action to menu list builder.addDefaultShareMenuItem(); - builder.setToolbarColor(mCustomThemeWrapper.getColorPrimary(mCustomThemeWrapper.getThemeType())); + builder.setToolbarColor(mCustomThemeWrapper.getColorPrimary()); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.intent.setPackage(resolveInfos.get(0).activityInfo.packageName); if (uri.getScheme() == null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java index a6d7eaad..e750359d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java @@ -222,9 +222,8 @@ public class LoginActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } @Override 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 5ae60914..03a489d5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.os.Build; import android.os.Bundle; import android.view.Gravity; @@ -88,6 +89,7 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; +import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; @@ -288,14 +290,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - int backgroundColor = mCustomThemeWrapper.getBackgroundColor(themeType); + int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); drawer.setBackgroundColor(backgroundColor); navigationView.setBackgroundColor(backgroundColor); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType); - bottomNavigationView.setBackgroundColor(backgroundColor); - applyFABTheme(fab, mCustomThemeWrapper, themeType); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyTabLayoutTheme(tabLayout); + bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(backgroundColor)); + applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); } private void getCurrentAccountAndBindView() { @@ -486,14 +487,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "0").apply(); AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); getTheme().applyStyle(R.style.Theme_Default, true); + mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); break; case R.string.dark_theme: mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "1").apply(); AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) { getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true); + mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); } else { getTheme().applyStyle(R.style.Theme_Default_NormalDark, true); + mCustomThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); } break; case R.string.enable_nsfw: 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 90a66e8a..8d5ce877 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java @@ -253,12 +253,11 @@ public class MultiRedditListingActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType)); - mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType)); - applyFABTheme(fab, mCustomThemeWrapper, themeType); + mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); + mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); + applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); } } 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 e37a0269..ebb0760f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java @@ -144,9 +144,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF private boolean isPosting; private Uri imageUri; private int primaryTextColor; - private int flairColor; - private int spoilerColor; - private int nsfwColor; + private int flairBackgroundColor; + private int flairTextColor; + private int spoilerBackgroundColor; + private int spoilerTextColor; + private int nsfwBackgroundColor; + private int nsfwTextColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; @@ -223,16 +226,19 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); } } else { getCurrentAccount(); @@ -292,6 +298,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -299,22 +306,26 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + spoilerTextView.setTextColor(primaryTextColor); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); isNSFW = true; } else { nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + nsfwTextView.setTextColor(primaryTextColor); isNSFW = false; } }); @@ -363,35 +374,25 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType)); - rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType))); - int dividerColor = mCustomThemeWrapper.getDividerColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor); - /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); - flairTextView.setTextColor(primaryTextColor); - int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); - spoilerTextView.setTextColor(primaryTextColor); - int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); - nsfwTextView.setTextColor(primaryTextColor);*/ - primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); - flairColor = mCustomThemeWrapper.getFlairColor(themeType); - spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); + primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); + flairTextColor = mCustomThemeWrapper.getFlairTextColor(); + spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); + spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor(); + nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); + nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); - applyFABTheme(captureFab, mCustomThemeWrapper, themeType); - applyFABTheme(selectFromLibraryFab, mCustomThemeWrapper, themeType); - selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType)); + applyFABTheme(captureFab, R.drawable.ic_outline_add_a_photo_24dp); + applyFABTheme(selectFromLibraryFab, R.drawable.ic_outline_select_photo_24dp); + selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); } private void getCurrentAccount() { @@ -572,6 +573,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF flairTextView.setVisibility(View.VISIBLE); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -602,8 +604,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java index b9d64913..91586388 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java @@ -119,9 +119,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr private boolean loadSubredditIconSuccessful = true; private boolean isPosting; private int primaryTextColor; - private int flairColor; - private int spoilerColor; - private int nsfwColor; + private int flairBackgroundColor; + private int flairTextColor; + private int spoilerBackgroundColor; + private int spoilerTextColor; + private int nsfwBackgroundColor; + private int nsfwTextColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; @@ -192,16 +195,19 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); } } else { getCurrentAccount(); @@ -262,6 +268,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -269,22 +276,26 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + spoilerTextView.setTextColor(primaryTextColor); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); isNSFW = true; } else { nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + nsfwTextView.setTextColor(primaryTextColor); isNSFW = false; } }); @@ -302,31 +313,21 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType)); - rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType))); - int dividerColor = mCustomThemeWrapper.getDividerColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor); - /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); - flairTextView.setTextColor(primaryTextColor); - int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); - spoilerTextView.setTextColor(primaryTextColor); - int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); - nsfwTextView.setTextColor(primaryTextColor);*/ - primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); - flairColor = mCustomThemeWrapper.getFlairColor(themeType); - spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); + primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); + flairTextColor = mCustomThemeWrapper.getFlairTextColor(); + spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); + spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor(); + nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); + nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); linkEditText.setTextColor(primaryTextColor); } @@ -491,6 +492,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr flairTextView.setVisibility(View.VISIBLE); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -507,8 +509,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java index 87903ab1..121cecb0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java @@ -119,9 +119,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr private boolean loadSubredditIconSuccessful = true; private boolean isPosting; private int primaryTextColor; - private int flairColor; - private int spoilerColor; - private int nsfwColor; + private int flairBackgroundColor; + private int flairTextColor; + private int spoilerBackgroundColor; + private int spoilerTextColor; + private int nsfwBackgroundColor; + private int nsfwTextColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; @@ -192,16 +195,19 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); } } else { getCurrentAccount(); @@ -266,6 +272,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -273,22 +280,26 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + spoilerTextView.setTextColor(primaryTextColor); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); isNSFW = true; } else { nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + nsfwTextView.setTextColor(primaryTextColor); isNSFW = false; } }); @@ -306,31 +317,21 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType)); - rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType))); - int dividerColor = mCustomThemeWrapper.getDividerColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor); - /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); - flairTextView.setTextColor(primaryTextColor); - int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); - spoilerTextView.setTextColor(primaryTextColor); - int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); - nsfwTextView.setTextColor(primaryTextColor);*/ - primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); - flairColor = mCustomThemeWrapper.getFlairColor(themeType); - spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); + primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); + flairTextColor = mCustomThemeWrapper.getFlairTextColor(); + spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); + spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor(); + nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); + nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); contentEditText.setTextColor(primaryTextColor); } @@ -491,6 +492,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr flairTextView.setVisibility(View.VISIBLE); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -507,8 +509,9 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } @Subscribe 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 d7853720..173ce21e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java @@ -150,9 +150,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF private boolean isPosting; private boolean wasPlaying; private int primaryTextColor; - private int flairColor; - private int spoilerColor; - private int nsfwColor; + private int flairBackgroundColor; + private int flairTextColor; + private int spoilerBackgroundColor; + private int spoilerTextColor; + private int nsfwBackgroundColor; + private int nsfwTextColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; @@ -236,16 +239,19 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); } } else { getCurrentAccount(); @@ -305,6 +311,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag()); } else { flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -312,22 +319,26 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); + spoilerTextView.setBackgroundColor(spoilerBackgroundColor); + spoilerTextView.setBorderColor(spoilerBackgroundColor); + spoilerTextView.setTextColor(spoilerTextColor); isSpoiler = true; } else { spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + spoilerTextView.setTextColor(primaryTextColor); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); + nsfwTextView.setBackgroundColor(nsfwBackgroundColor); + nsfwTextView.setBorderColor(nsfwBackgroundColor); + nsfwTextView.setTextColor(nsfwTextColor); isNSFW = true; } else { nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + nsfwTextView.setTextColor(primaryTextColor); isNSFW = false; } }); @@ -368,35 +379,25 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType)); - rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType))); - int dividerColor = mCustomThemeWrapper.getDividerColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); + rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor); - /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); - flairTextView.setTextColor(primaryTextColor); - int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - spoilerTextView.setBackgroundColor(spoilerColor); - spoilerTextView.setBorderColor(spoilerColor); - spoilerTextView.setTextColor(primaryTextColor); - int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); - nsfwTextView.setBackgroundColor(nsfwColor); - nsfwTextView.setBorderColor(nsfwColor); - nsfwTextView.setTextColor(primaryTextColor);*/ - primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); - flairColor = mCustomThemeWrapper.getFlairColor(themeType); - spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType); - nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType); + primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); + flairTextColor = mCustomThemeWrapper.getFlairTextColor(); + spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); + spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor(); + nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor(); + nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor(); titleEditText.setTextColor(primaryTextColor); - applyFABTheme(captureFab, mCustomThemeWrapper, themeType); - applyFABTheme(selectFromLibraryFab, mCustomThemeWrapper, themeType); - selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType)); + applyFABTheme(captureFab, R.drawable.ic_outline_add_a_photo_24dp); + applyFABTheme(selectFromLibraryFab, R.drawable.ic_outline_select_photo_24dp); + selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); } private void getCurrentAccount() { @@ -593,6 +594,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF flairTextView.setVisibility(View.VISIBLE); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); + flairTextView.setTextColor(primaryTextColor); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -630,8 +632,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(flairColor); - flairTextView.setBorderColor(flairColor); + flairTextView.setBackgroundColor(flairBackgroundColor); + flairTextView.setBorderColor(flairBackgroundColor); + flairTextView.setTextColor(flairTextColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java index fb337711..2fa2bff3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java @@ -129,10 +129,9 @@ public class RulesActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); } private void fetchRules() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java index d0900491..9c4e77e2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java @@ -189,12 +189,11 @@ public class SearchActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary(themeType))); - searchInTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType)); - subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary())); + searchInTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); + subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java index fb2bd7f0..9edddbca 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -171,10 +171,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyTabLayoutTheme(tabLayout); } private void getCurrentAccountAndInitializeViewPager() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java index 8801f126..95cfc840 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java @@ -120,9 +120,8 @@ public class SearchSubredditsResultActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } private void getCurrentAccountAndInitializeFragment(String query) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java index 84f6e15d..035b746c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -94,9 +94,8 @@ public class SettingsActivity extends BaseActivity implements @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java index 84db99aa..b3438e56 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java @@ -251,9 +251,8 @@ public class SubredditMultiselectionActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType)); + mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java index fe4c0b70..73314489 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java @@ -142,9 +142,8 @@ public class SubredditSelectionActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); } private void getCurrentAccountAndBindView() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java index d5d15dd0..fb80bd2f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java @@ -136,10 +136,9 @@ public class SubscribedThingListingActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyTabLayoutTheme(tabLayout); } private void getCurrentAccountAndInitializeViewPager() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java index a13eef1d..64b60fd4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java @@ -156,12 +156,11 @@ public class ViewMessageActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType)); - mFetchMessageInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType)); + mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); + mFetchMessageInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); } private void getCurrentAccountAndFetchMessage() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java index 94a40c85..b38611db 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java @@ -323,8 +323,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); } } 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 9437b2de..a56a534f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -368,13 +368,12 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType)); - mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType)); - applyFABTheme(fab, mCustomThemeWrapper, themeType); + mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); + mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); + applyFABTheme(fab, R.drawable.ic_keyboard_arrow_down_24dp); } private void getCurrentAccountAndBindView() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java index c2679877..364b257b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java @@ -228,11 +228,10 @@ public class ViewSidebarActivity extends BaseActivity { @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType)); - swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType)); - markdownColor = mCustomThemeWrapper.getSecondaryTextColor(themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); + swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); + markdownColor = mCustomThemeWrapper.getSecondaryTextColor(); } } 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 1ccea602..412c4e60 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -344,21 +344,20 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - int backgroundColor = mCustomThemeWrapper.getBackgroundColor(themeType); + int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); coordinatorLayout.setBackgroundColor(backgroundColor); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); linearLayout.setBackgroundColor(backgroundColor); - subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit(themeType)); - subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor(themeType)); - int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType); + subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit()); + subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor()); + int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); nSubscribersTextView.setTextColor(primaryTextColor); nOnlineSubscribersTextView.setTextColor(primaryTextColor); descriptionTextView.setTextColor(primaryTextColor); bottomNavigationView.setBackgroundColor(backgroundColor); - applyFABTheme(fab, mCustomThemeWrapper, themeType); - unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(themeType); - subscribedColor = mCustomThemeWrapper.getSubscribed(themeType); + applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); + unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(); + subscribedColor = mCustomThemeWrapper.getSubscribed(); } private void getCurrentAccountAndBindView() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index bc75db0a..253c38ec 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -409,21 +409,20 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override protected void applyCustomTheme() { - int themeType = mCustomThemeWrapper.getThemeType(); - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType)); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType)); - expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(themeType); - expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(themeType); - expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(themeType); - collapsedTabTextColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType); - collapsedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(themeType); - collapsedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabBackground(themeType); - unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(themeType); - subscribedColor = mCustomThemeWrapper.getSubscribed(themeType); - userNameTextView.setTextColor(mCustomThemeWrapper.getUsername(themeType)); - karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor(themeType)); - subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor(themeType)); - applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType); + coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(); + expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(); + expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(); + collapsedTabTextColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(); + collapsedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(); + collapsedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabBackground(); + unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(); + subscribedColor = mCustomThemeWrapper.getSubscribed(); + userNameTextView.setTextColor(mCustomThemeWrapper.getUsername()); + karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); + subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor()); + applyTabLayoutTheme(tabLayout); } private void getCurrentAccountAndInitializeViewPager() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index d4ff5510..1bd656b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -140,15 +140,20 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true)); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent()); } else { mSwipeRefreshLayout.setEnabled(false); } - mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType)); + mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 8fdffdd1..40b10116 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -11,7 +11,6 @@ import android.os.Build; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; -import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -72,7 +71,6 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Retrofit; @@ -731,10 +729,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Override public void applyTheme() { - int themeType = customThemeWrapper.getThemeType(); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType)); - mFetchPostInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent()); + mFetchPostInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor()); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java index 21842828..1b0f3401 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java @@ -214,9 +214,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun @Override public void applyTheme() { - int themeType = customThemeWrapper.getThemeType(); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType)); - mFetchSubredditListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent()); + mFetchSubredditListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java index d5ca7545..42477f2c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java @@ -171,10 +171,9 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra public void applyTheme() { if (mActivity instanceof SubscribedThingListingActivity) { mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true)); - int themeType = customThemeWrapper.getThemeType(); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType)); - mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent()); + mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor()); } else { mSwipeRefreshLayout.setEnabled(false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java index 311a7e56..07430235 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java @@ -194,9 +194,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato @Override public void applyTheme() { - int themeType = customThemeWrapper.getThemeType(); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType)); - mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType)); - mFetchUserListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType)); + mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground()); + mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent()); + mFetchUserListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java index 97bd4bfa..311c88c6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java @@ -63,7 +63,7 @@ public class PullNotificationWorker extends Worker { public Result doWork() { try { List accounts = mRedditDataRoomDatabase.accountDao().getAllAccounts(); - int color = mCustomThemeWrapper.getNotificationIconColor(mCustomThemeWrapper.getThemeType()); + int color = mCustomThemeWrapper.getNotificationIconColor(); for (int accountIndex = 0; accountIndex < accounts.size(); accountIndex++) { Account account = accounts.get(accountIndex); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java index 88798143..cc851e99 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java @@ -130,7 +130,7 @@ public class SubmitPostService extends Service { .setContentTitle(getString(stringResId)) .setContentText(getString(R.string.please_wait)) .setSmallIcon(R.drawable.ic_notification) - .setColor(mCustomThemeWrapper.getNotificationIconColor(mCustomThemeWrapper.getThemeType())) + .setColor(mCustomThemeWrapper.getNotificationIconColor()) .build(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java index 78634adf..5a4d0b4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java @@ -16,13 +16,18 @@ import androidx.preference.SwitchPreference; import org.greenrobot.eventbus.EventBus; +import javax.inject.Inject; + +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent; import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent; import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent; import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent; +import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; @@ -36,11 +41,15 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; public class InterfacePreferenceFragment extends PreferenceFragmentCompat { private Activity activity; + @Inject + CustomThemeWrapper customThemeWrapper; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.interface_preference, rootKey); + ((Infinity) activity.getApplication()).getAppComponent().inject(this); + ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY); SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY); SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY); @@ -53,7 +62,7 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; - if (themePreference != null) { + if (themePreference != null && amoledDarkSwitch != null) { if (systemDefault) { themePreference.setEntries(R.array.settings_theme_q); } else { @@ -65,9 +74,15 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { switch (option) { case 0: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); break; case 1: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES); + if (amoledDarkSwitch.isChecked()) { + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); + } else { + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); + } break; case 2: if (systemDefault) { @@ -75,6 +90,16 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { } else { AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY); } + + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) { + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); + } else { + if (amoledDarkSwitch.isChecked()) { + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); + } else { + customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); + } + } } return true; }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java index 6bca6a51..2bed1bb6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java @@ -4,8 +4,9 @@ public class CustomThemeSharedPreferencesUtils { public static final int NORMAL = 0; public static final int DARK = 1; public static final int AMOLED_DARK = 2; - public static final String THEME_TYPE_KEY = "theme_type"; public static final String THEME_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.theme"; + public static final String LIGHT_STATUS_BAR = "lightStatusBar"; + public static final String LIGHT_NAV_BAR = "lightNavBar"; public static final String COLOR_PRIMARY = "colorPrimary"; public static final String COLOR_PRIMARY_DARK = "colorPrimaryDark"; public static final String COLOR_ACCENT = "colorAccent"; @@ -16,9 +17,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String PRIMARY_TEXT_COLOR = "primaryTextColor"; public static final String SECONDARY_TEXT_COLOR = "secondaryTextColor"; public static final String BUTTON_TEXT_COLOR = "buttonTextColor"; - public static final String BUTTON_BACKGROUND_TINT = "buttonBackgroundTint"; public static final String BACKGROUND_COLOR = "backgroundColor"; - public static final String ROUNDED_BOTTOM_SHEET_PRIMARY_BACKGROUND = "roundedBottomSheetPrimaryBackground"; public static final String CARD_VIEW_BACKGROUND_COLOR = "cardViewBackgroundColor"; public static final String COMMENT_BACKGROUND_COLOR = "commentBackgroundColor"; public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor"; @@ -33,14 +32,18 @@ public class CustomThemeSharedPreferencesUtils { public static final String NAV_BAR_COLOR = "navBarColor"; public static final String UPVOTED = "upvoted"; public static final String DOWNVOTED = "downvoted"; - public static final String POST_TYPE = "postType"; - public static final String SPOILER_COLOR = "spoilerColor"; - public static final String NSFW_COLOR = "nsfwColor"; - public static final String FLAIR_COLOR = "flairColor"; + public static final String POST_TYPE_BACKGROUND_COLOR = "postTypeBackgroundColor"; + public static final String POST_TYPE_TEXT_COLOR = "postTypeTextColor"; + public static final String SPOILER_BACKGROUND_COLOR = "spoilerBackgroundColor"; + public static final String SPOILER_TEXT_COLOR = "spoilerTextColor"; + public static final String NSFW_BACKGROUND_COLOR = "nsfwBackgroundColor"; + public static final String NSFW_TEXT_COLOR = "nsfwTextColor"; + public static final String FLAIR_BACKGROUND_COLOR = "flairBackgroundColor"; + public static final String FLAIR_TEXT_COLOR = "flairTextColor"; public static final String ARCHIVED_TINT = "archivedTint"; public static final String LOCKED_ICON_TINT = "lockedIconTint"; - public static final String CROSSPOST = "crosspost"; - public static final String STICKIED_POST = "stickiedPost"; + public static final String CROSSPOST_ICON_TINT = "crosspostIconTint"; + public static final String STICKIED_POST_ICON_TINT = "stickiedPost"; public static final String SUBSCRIBED = "subscribed"; public static final String UNSUBSCRIBED = "unsubscribed"; public static final String USERNAME = "username"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java index 1a40911b..552f8515 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java @@ -73,10 +73,4 @@ public class Utils { return String.format(Locale.US, "%.1f", (float) votes / 1000) + "K"; } } - - /*public static int getAttributeColor(Context context, int attrId) { - TypedValue typedValue = new TypedValue(); - context.getTheme().resolveAttribute(attrId, typedValue, true); - return typedValue.data; - }*/ } diff --git a/app/src/main/res/drawable/ic_outline_add_a_photo_24dp.xml b/app/src/main/res/drawable/ic_outline_add_a_photo_24dp.xml new file mode 100644 index 00000000..98c1ac80 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_add_a_photo_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_add_a_photo_24px.xml b/app/src/main/res/drawable/ic_outline_add_a_photo_24px.xml deleted file mode 100644 index 98c1ac80..00000000 --- a/app/src/main/res/drawable/ic_outline_add_a_photo_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_outline_select_photo_24dp.xml b/app/src/main/res/drawable/ic_outline_select_photo_24dp.xml new file mode 100644 index 00000000..9551f621 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_select_photo_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_select_photo_24px.xml b/app/src/main/res/drawable/ic_outline_select_photo_24px.xml deleted file mode 100644 index 9551f621..00000000 --- a/app/src/main/res/drawable/ic_outline_select_photo_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_post_image.xml b/app/src/main/res/layout/activity_post_image.xml index e49c9179..e73a08be 100644 --- a/app/src/main/res/layout/activity_post_image.xml +++ b/app/src/main/res/layout/activity_post_image.xml @@ -171,7 +171,7 @@ android:id="@+id/capture_fab_post_image_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_outline_add_a_photo_24px" + android:src="@drawable/ic_outline_add_a_photo_24dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -184,7 +184,7 @@ android:id="@+id/select_from_library_fab_post_image_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_outline_select_photo_24px" + android:src="@drawable/ic_outline_select_photo_24dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity" diff --git a/app/src/main/res/layout/activity_post_video.xml b/app/src/main/res/layout/activity_post_video.xml index dd51f10e..2b322dcf 100644 --- a/app/src/main/res/layout/activity_post_video.xml +++ b/app/src/main/res/layout/activity_post_video.xml @@ -171,7 +171,7 @@ android:id="@+id/capture_fab_post_video_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_outline_add_a_photo_24px" + android:src="@drawable/ic_outline_add_a_photo_24dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -184,7 +184,7 @@ android:id="@+id/select_from_library_fab_post_video_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_outline_select_photo_24px" + android:src="@drawable/ic_outline_select_photo_24dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 7055c73a..053435ec 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -108,7 +108,7 @@