From 870976068d9a759e6fc62d3cc3283c3de727bedb Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 16 Mar 2020 16:53:29 +0800 Subject: Apply theme to toolbars. --- .../Activity/AccountPostsActivity.java | 3 +- .../Activity/AccountSavedThingActivity.java | 3 +- .../infinityforreddit/Activity/BaseActivity.java | 65 +++++++++++++++++----- .../Activity/CommentActivity.java | 3 +- .../Activity/CreateMultiRedditActivity.java | 3 +- .../Activity/EditCommentActivity.java | 3 +- .../Activity/EditPostActivity.java | 3 +- .../Activity/FilteredThingActivity.java | 3 +- .../infinityforreddit/Activity/LoginActivity.java | 2 +- .../infinityforreddit/Activity/MainActivity.java | 7 +-- .../Activity/MultiRedditListingActivity.java | 2 +- .../Activity/PostImageActivity.java | 5 +- .../Activity/PostLinkActivity.java | 5 +- .../Activity/PostTextActivity.java | 5 +- .../Activity/PostVideoActivity.java | 5 +- .../infinityforreddit/Activity/RulesActivity.java | 2 +- .../infinityforreddit/Activity/SearchActivity.java | 2 +- .../Activity/SearchResultActivity.java | 3 +- .../Activity/SearchSubredditsResultActivity.java | 2 +- .../Activity/SettingsActivity.java | 4 +- .../Activity/SubredditMultiselectionActivity.java | 3 +- .../Activity/SubredditSelectionActivity.java | 3 +- .../Activity/SubscribedThingListingActivity.java | 2 +- .../Activity/ViewGIFActivity.java | 2 +- .../Activity/ViewImageActivity.java | 2 +- .../Activity/ViewMessageActivity.java | 11 ++-- .../Activity/ViewMultiRedditDetailActivity.java | 3 +- .../Activity/ViewPostDetailActivity.java | 60 ++++++++++++-------- .../Activity/ViewSidebarActivity.java | 3 +- .../Activity/ViewSubredditDetailActivity.java | 3 +- .../Activity/ViewUserDetailActivity.java | 3 +- .../Activity/ViewVideoActivity.java | 2 +- .../CustomTheme/CustomThemeWrapper.java | 8 ++- .../Utils/CustomThemeSharedPreferencesUtils.java | 1 + 34 files changed, 162 insertions(+), 74 deletions(-) (limited to 'app/src/main/java/ml') 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 6a8aa025..29b49d24 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -157,7 +157,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } private void getCurrentAccountAndInitializeFragment() { @@ -187,6 +187,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.account_posts_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity); if (isInLazyMode) { 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 a89a451a..d95a1735 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -156,7 +156,7 @@ public class AccountSavedThingActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); } @@ -205,6 +205,7 @@ public class AccountSavedThingActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.account_saved_thing_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity); if (isInLazyMode) { 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 61beaee0..60abf067 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -1,5 +1,6 @@ package ml.docilealligator.infinityforreddit.Activity; +import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.content.res.Configuration; @@ -9,6 +10,8 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -16,7 +19,9 @@ import android.view.Window; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.view.menu.MenuItemImpl; import androidx.appcompat.widget.Toolbar; +import androidx.core.graphics.drawable.DrawableCompat; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -38,9 +43,10 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; public abstract class BaseActivity extends AppCompatActivity { private boolean immersiveInterface; - private boolean changeStatusBarIconColor = true; + private boolean changeStatusBarIconColor; private boolean transparentStatusBarAfterToolbarCollapsed; private boolean hasDrawerLayout = false; + private boolean isImmersiveInterfaceApplicable = true; private int systemVisibilityToolbarExpanded = 0; private int systemVisibilityToolbarCollapsed = 0; private CustomThemeWrapper customThemeWrapper; @@ -48,30 +54,28 @@ public abstract class BaseActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + customThemeWrapper = getCustomThemeWrapper(); SharedPreferences mSharedPreferences = getSharedPreferences(); boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; 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; + getTheme().applyStyle(R.style.Theme_Normal, true); 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); + getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true); customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); } else { - getTheme().applyStyle(R.style.Theme_Default_NormalDark, true); + getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true); customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); } - changeStatusBarIconColor = false; break; case 2: if (systemDefault) { @@ -80,21 +84,27 @@ public abstract class BaseActivity extends AppCompatActivity { AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY); } if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) { - getTheme().applyStyle(R.style.Theme_Purple, true); - changeStatusBarIconColor = immersiveInterface; + getTheme().applyStyle(R.style.Theme_Normal, true); customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.NORMAL); } else { if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) { - getTheme().applyStyle(R.style.Theme_Default_AmoledDark, true); + getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true); customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED_DARK); } else { - getTheme().applyStyle(R.style.Theme_Default_NormalDark, true); + getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true); customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK); } - changeStatusBarIconColor = false; } } + boolean userDefinedChangeSatusBarIconColorInImmersiveInterface = + customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface(); + if (immersiveInterface && isImmersiveInterfaceApplicable) { + changeStatusBarIconColor = userDefinedChangeSatusBarIconColorInImmersiveInterface; + } else { + changeStatusBarIconColor = false; + } + getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true); @@ -215,8 +225,37 @@ public abstract class BaseActivity extends AppCompatActivity { hasDrawerLayout = true; } - protected void applyToolbarTheme(Toolbar toolbar) { + public void setImmersiveModeNotApplicable() { + isImmersiveInterfaceApplicable = false; + } + + protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { + appBarLayout.setBackgroundColor(customThemeWrapper.getToolbarAndTabBackgroundColor()); toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor()); + if (toolbar.getNavigationIcon() != null) { + toolbar.getNavigationIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); + } + if (toolbar.getOverflowIcon() != null) { + toolbar.getOverflowIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); + } + } + + @SuppressLint("RestrictedApi") + protected boolean applyMenuItemTheme(Menu menu) { + if (customThemeWrapper != null) { + int size = Math.min(menu.size(), 2); + for (int i = 0; i < size; i++) { + MenuItem item = menu.getItem(i); + if (((MenuItemImpl) item).requestsActionButton()) { + Drawable drawable = item.getIcon(); + if (drawable != null) { + DrawableCompat.setTint(drawable, customThemeWrapper.getToolbarPrimaryTextAndIconColor()); + item.setIcon(drawable); + } + } + } + } + return true; } protected void applyTabLayoutTheme(TabLayout tabLayout) { 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 515fe2b3..072b5163 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java @@ -233,7 +233,7 @@ public class CommentActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); commentParentMarkwonView.setTextColor(mCustomThemeWrapper.getCommentColor()); divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor()); commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); @@ -262,6 +262,7 @@ public class CommentActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.comment_activity, menu); + applyMenuItemTheme(menu); return true; } 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 1f5f39a4..3ce4ce2f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java @@ -148,6 +148,7 @@ public class CreateMultiRedditActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.create_multi_reddit_activity, menu); + applyMenuItemTheme(menu); return true; } @@ -244,7 +245,7 @@ public class CreateMultiRedditActivity extends BaseActivity { @Override protected void applyCustomTheme() { - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); nameEditText.setTextColor(primaryTextColor); int dividerColor = mCustomThemeWrapper.getDividerColor(); 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 abcc5382..fac5af22 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java @@ -119,7 +119,7 @@ public class EditCommentActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor()); } @@ -135,6 +135,7 @@ public class EditCommentActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.edit_comment_activity, menu); + applyMenuItemTheme(menu); return true; } 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 a86d72ff..bdc92af4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java @@ -122,7 +122,7 @@ public class EditPostActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor()); divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor()); contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor()); @@ -140,6 +140,7 @@ public class EditPostActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.edit_post_activity, menu); + applyMenuItemTheme(menu); return true; } 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 995a3227..545bce1d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -176,7 +176,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } private void getCurrentAccountAndBindView(int filter) { @@ -295,6 +295,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.filtered_posts_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity); if (isInLazyMode) { 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 e750359d..78e67281 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java @@ -223,7 +223,7 @@ public class LoginActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } @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 315b81ed..b03e04d6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -245,6 +245,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + toggle.getDrawerArrowDrawable().setColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); drawer.addDrawerListener(toggle); toggle.syncState(); @@ -296,7 +297,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb drawer.setBackgroundColor(backgroundColor); drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark()); navigationView.setBackgroundColor(backgroundColor); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(backgroundColor)); applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); @@ -489,17 +490,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb case R.string.light_theme: 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; @@ -707,6 +705,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity); 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 8d5ce877..e5069e16 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java @@ -254,7 +254,7 @@ public class MultiRedditListingActivity extends BaseActivity { @Override protected void applyCustomTheme() { mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar); mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); 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 ebb0760f..043b5875 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java @@ -163,6 +163,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_post_image); @@ -375,7 +377,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); int dividerColor = mCustomThemeWrapper.getDividerColor(); @@ -448,6 +450,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.post_image_activity, menu); + applyMenuItemTheme(menu); mMemu = menu; if (isPosting) { mMemu.findItem(R.id.action_send_post_image_activity).setEnabled(false); 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 91586388..eafc4a67 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java @@ -138,6 +138,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_post_link); @@ -314,7 +316,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); int dividerColor = mCustomThemeWrapper.getDividerColor(); @@ -376,6 +378,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.post_link_activity, menu); + applyMenuItemTheme(menu); mMemu = menu; if (isPosting) { mMemu.findItem(R.id.action_send_post_link_activity).setEnabled(false); 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 121cecb0..1ff0a84c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java @@ -138,6 +138,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_post_text); @@ -318,7 +320,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); int dividerColor = mCustomThemeWrapper.getDividerColor(); @@ -381,6 +383,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.post_text_activity, menu); + applyMenuItemTheme(menu); mMemu = menu; if (isPosting) { mMemu.findItem(R.id.action_send_post_text_activity).setEnabled(false); 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 173ce21e..5088576c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java @@ -171,6 +171,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_post_video); @@ -380,7 +382,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); int dividerColor = mCustomThemeWrapper.getDividerColor(); @@ -454,6 +456,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.post_video_activity, menu); + applyMenuItemTheme(menu); mMemu = menu; if (isPosting) { mMemu.findItem(R.id.action_send_post_video_activity).setEnabled(false); 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 2fa2bff3..99027e23 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java @@ -130,7 +130,7 @@ public class RulesActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); } 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 9c4e77e2..2fab7727 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java @@ -190,7 +190,7 @@ public class SearchActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary())); searchInTextView.setTextColor(mCustomThemeWrapper.getColorAccent()); subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); 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 9edddbca..359d408b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -172,7 +172,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); } @@ -198,6 +198,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search_result_activity, menu); + applyMenuItemTheme(menu); return true; } 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 95cfc840..1548362c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java @@ -121,7 +121,7 @@ public class SearchSubredditsResultActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } 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 035b746c..1a678afe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -48,6 +48,8 @@ public class SettingsActivity extends BaseActivity implements protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + setImmersiveModeNotApplicable(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); @@ -95,7 +97,7 @@ public class SettingsActivity extends BaseActivity implements @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } @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 b3438e56..800a8320 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java @@ -188,6 +188,7 @@ public class SubredditMultiselectionActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.subreddit_multiselection_activity, menu); + applyMenuItemTheme(menu); return true; } @@ -252,7 +253,7 @@ public class SubredditMultiselectionActivity extends BaseActivity { @Override protected void applyCustomTheme() { mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar); 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 73314489..efc50700 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java @@ -143,7 +143,7 @@ public class SubredditSelectionActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } private void getCurrentAccountAndBindView() { @@ -207,6 +207,7 @@ public class SubredditSelectionActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.subreddit_selection_activity, menu); + applyMenuItemTheme(menu); return true; } 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 fb80bd2f..48568085 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java @@ -137,7 +137,7 @@ public class SubscribedThingListingActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java index 72cef5a5..a2efbda0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java @@ -94,7 +94,7 @@ public class ViewGIFActivity extends AppCompatActivity { super.onCreate(savedInstanceState); ((Infinity) getApplication()).getAppComponent().inject(this); - getTheme().applyStyle(R.style.Theme_Default, true); + getTheme().applyStyle(R.style.Theme_Normal, true); getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java index 0697c5e1..40ffb2eb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java @@ -99,7 +99,7 @@ public class ViewImageActivity extends AppCompatActivity { ((Infinity) getApplication()).getAppComponent().inject(this); - getTheme().applyStyle(R.style.Theme_Default, true); + getTheme().applyStyle(R.style.Theme_Normal, true); getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences .getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true); 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 64b60fd4..e8fe5334 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java @@ -63,7 +63,7 @@ public class ViewMessageActivity extends BaseActivity { @BindView(R.id.appbar_layout_view_message_activity) AppBarLayout mAppBarLayout; @BindView(R.id.toolbar_view_message_activity) - Toolbar toolbar; + Toolbar mToolbar; @BindView(R.id.swipe_refresh_layout_view_message_activity) SwipeRefreshLayout mSwipeRefreshLayout; @BindView(R.id.recycler_view_view_message_activity) @@ -116,7 +116,7 @@ public class ViewMessageActivity extends BaseActivity { if (isImmersiveInterface()) { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - adjustToolbar(toolbar); + adjustToolbar(mToolbar); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { @@ -125,8 +125,8 @@ public class ViewMessageActivity extends BaseActivity { } } - toolbar.setTitle(R.string.inbox); - setSupportActionBar(toolbar); + mToolbar.setTitle(R.string.inbox); + setSupportActionBar(mToolbar); if (savedInstanceState != null) { mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); @@ -157,7 +157,7 @@ public class ViewMessageActivity extends BaseActivity { @Override protected void applyCustomTheme() { mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar); mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); mFetchMessageInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); @@ -255,6 +255,7 @@ public class ViewMessageActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_message_activity, menu); + applyMenuItemTheme(menu); return true; } 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 b38611db..9e7e7039 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java @@ -183,6 +183,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_multi_reddit_detail_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity); if (isInLazyMode) { @@ -324,6 +325,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } } 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 a56a534f..152b71ad 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; @@ -19,6 +20,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearSmoothScroller; import androidx.recyclerview.widget.RecyclerView; @@ -132,7 +134,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @BindView(R.id.appbar_layout_view_post_detail_activity) AppBarLayout mAppBarLayout; @BindView(R.id.toolbar_view_post_detail_activity) - Toolbar toolbar; + Toolbar mToolbar; @BindView(R.id.swipe_refresh_layout_view_post_detail_activity) SwipeRefreshLayout mSwipeRefreshLayout; @BindView(R.id.recycler_view_view_post_detail) @@ -182,6 +184,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS private RecyclerView.SmoothScroller mSmoothScroller; private PostCommentSortTypeBottomSheetFragment mPostCommentSortTypeBottomSheetFragment; private SlidrInterface mSlidrInterface; + private Drawable mSavedIcon; + private Drawable mUnsavedIcon; @Override protected void onCreate(Bundle savedInstanceState) { @@ -199,6 +203,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS applyCustomTheme(); + mSavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_toolbar_24dp); + mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) { mSlidrInterface = Slidr.attach(this); } @@ -212,7 +219,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS if (isImmersiveInterface()) { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - adjustToolbar(toolbar); + adjustToolbar(mToolbar); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { @@ -225,8 +232,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS } } - toolbar.setTitle(""); - setSupportActionBar(toolbar); + mToolbar.setTitle(""); + setSupportActionBar(mToolbar); mNeedBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true); mNeedBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false); @@ -369,7 +376,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override protected void applyCustomTheme() { mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar); mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground()); mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent()); mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor()); @@ -444,10 +451,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS if (mAccessToken != null) { if (mPost.isSaved()) { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + saveItem.setIcon(mSavedIcon); } else { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + saveItem.setIcon(mUnsavedIcon); } if (mPost.isHidden()) { @@ -537,6 +544,14 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS fab.setOnClickListener(view -> scrollToNextParentComment()); } + private Drawable getMenuItemIcon(int drawableId) { + Drawable icon = getDrawable(drawableId); + if (icon != null) { + DrawableCompat.setTint(icon, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + } + + return icon; + } private void fetchPostAndCommentsById(String subredditId) { mFetchPostInfoLinearLayout.setVisibility(View.GONE); @@ -585,10 +600,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS if (mAccessToken != null) { if (post.isSaved()) { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + saveItem.setIcon(mSavedIcon); } else { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + saveItem.setIcon(mUnsavedIcon); } if (post.isHidden()) { @@ -895,10 +910,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS if (mAccessToken != null) { if (post.isSaved()) { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + saveItem.setIcon(mSavedIcon); } else { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + saveItem.setIcon(mUnsavedIcon); } if (post.isHidden()) { @@ -1164,11 +1179,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS mPost.setSaved(event.post.isSaved()); if (mMenu != null) { if (event.post.isSaved()) { - mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(getResources() - .getDrawable(R.drawable.ic_bookmark_toolbar_24dp)); + mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(mSavedIcon); } else { - mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(getResources() - .getDrawable(R.drawable.ic_bookmark_border_toolbar_24dp)); + mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(mUnsavedIcon); } } mAdapter.updatePost(mPost); @@ -1214,6 +1227,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_post_detail_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; if (mPost != null) { MenuItem saveItem = mMenu.findItem(R.id.action_save_view_post_detail_activity); @@ -1225,10 +1239,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS if (mAccessToken != null) { if (mPost.isSaved()) { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + saveItem.setIcon(mSavedIcon); } else { saveItem.setVisible(true); - saveItem.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + saveItem.setIcon(mUnsavedIcon); } if (mPost.isHidden()) { @@ -1308,13 +1322,13 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS case R.id.action_save_view_post_detail_activity: if (mPost != null && mAccessToken != null) { if (mPost.isSaved()) { - item.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + item.setIcon(mUnsavedIcon); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { mPost.setSaved(false); - item.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + item.setIcon(mUnsavedIcon); showMessage(R.string.post_unsaved_success); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } @@ -1322,19 +1336,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void failed() { mPost.setSaved(true); - item.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + item.setIcon(mSavedIcon); showMessage(R.string.post_unsaved_failed); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } }); } else { - item.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + item.setIcon(mSavedIcon); SaveThing.saveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { mPost.setSaved(true); - item.setIcon(R.drawable.ic_bookmark_toolbar_24dp); + item.setIcon(mSavedIcon); showMessage(R.string.post_saved_success); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } @@ -1342,7 +1356,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS @Override public void failed() { mPost.setSaved(false); - item.setIcon(R.drawable.ic_bookmark_border_toolbar_24dp); + item.setIcon(mUnsavedIcon); showMessage(R.string.post_saved_failed); EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)); } 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 364b257b..6568cd2e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java @@ -199,6 +199,7 @@ public class ViewSidebarActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_sidebar_activity, menu); + applyMenuItemTheme(menu); return true; } @@ -229,7 +230,7 @@ public class ViewSidebarActivity extends BaseActivity { @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); 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 412c4e60..039c07dd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -346,7 +346,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp protected void applyCustomTheme() { int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); coordinatorLayout.setBackgroundColor(backgroundColor); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); linearLayout.setBackgroundColor(backgroundColor); subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit()); subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor()); @@ -547,6 +547,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu); + applyMenuItemTheme(menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity); if (isInLazyMode) { 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 253c38ec..8e90f20b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -410,7 +410,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor()); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(); expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(); expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(); @@ -546,6 +546,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.view_user_detail_activity, menu); + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity); if (isInLazyMode) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java index 7e873010..a3694352 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java @@ -98,7 +98,7 @@ public class ViewVideoActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getTheme().applyStyle(R.style.Theme_Default, true); + getTheme().applyStyle(R.style.Theme_Normal, true); setContentView(R.layout.activity_view_video); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java index 853ea446..835a7db2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -39,6 +39,12 @@ public class CustomThemeWrapper { return themeSharedPreferences.getBoolean(CustomThemeSharedPreferencesUtils.LIGHT_NAV_BAR, false); } + public boolean isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface() { + return themeSharedPreferences.getBoolean( + CustomThemeSharedPreferencesUtils.CHANGE_STATUS_BAR_ICON_COLOR_AFTER_TOOLBAR_COLLAPSED_IN_IMMERSIVE_INTERFACE, + true); + } + public int getColorPrimary() { return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY, getDefaultColor("#1565C0", "#242424", "#000000")); @@ -106,7 +112,7 @@ public class CustomThemeWrapper { public int getToolbarPrimaryTextAndIconColor() { return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR, - getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); + getDefaultColor("#000000", "#FFFFFF", "#FFFFFF")); } public int getToolbarAndTabBackgroundColor() { 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 2bed1bb6..a3f3695a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java @@ -7,6 +7,7 @@ public class CustomThemeSharedPreferencesUtils { 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 CHANGE_STATUS_BAR_ICON_COLOR_AFTER_TOOLBAR_COLLAPSED_IN_IMMERSIVE_INTERFACE = "changeStatusBarIconColorImmersive"; public static final String COLOR_PRIMARY = "colorPrimary"; public static final String COLOR_PRIMARY_DARK = "colorPrimaryDark"; public static final String COLOR_ACCENT = "colorAccent"; -- cgit v1.2.3