From 3dc2d9fee215449c7730bade75781c044565a138 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 17 Mar 2020 20:03:15 +0800 Subject: Continue implementing custom themes. --- .../infinityforreddit/Activity/MainActivity.java | 7 +- .../Activity/ViewSubredditDetailActivity.java | 7 +- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 153 ++++++++++++--------- .../CommentsListingRecyclerViewAdapter.java | 39 ++++-- .../NavigationDrawerRecyclerViewAdapter.java | 17 ++- .../Adapter/PostRecyclerViewAdapter.java | 82 +++++++---- .../CustomTheme/CustomThemeWrapper.java | 27 +++- .../infinityforreddit/PullNotificationWorker.java | 2 +- .../Service/SubmitPostService.java | 2 +- .../Utils/CustomThemeSharedPreferencesUtils.java | 5 +- .../main/res/layout/item_nav_drawer_menu_item.xml | 26 +++- 11 files changed, 233 insertions(+), 134 deletions(-) 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 b03e04d6..9bc49a1a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -296,10 +296,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); drawer.setBackgroundColor(backgroundColor); drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark()); + int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor(); + subscriptionsBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); navigationView.setBackgroundColor(backgroundColor); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyTabLayoutTheme(tabLayout); - bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(backgroundColor)); + bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor())); applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); } 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 039c07dd..d34b133b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -354,7 +354,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp nSubscribersTextView.setTextColor(primaryTextColor); nOnlineSubscribersTextView.setTextColor(primaryTextColor); descriptionTextView.setTextColor(primaryTextColor); - bottomNavigationView.setBackgroundColor(backgroundColor); + bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(backgroundColor)); + int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor(); + subscriptionsBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp); unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(); subscribedColor = mCustomThemeWrapper.getSubscribed(); 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 1bd656b4..5d7e2b79 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -27,6 +27,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; +import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -170,7 +171,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { + ((PostDetailViewHolder) holder).mSaveButton.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show(); return; } if (mPost.isSaved()) { - ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostDetailViewHolder) holder).mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(), new SaveThing.SaveThingListener() { @Override public void success() { mPost.setSaved(false); - ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); + ((PostDetailViewHolder) holder).mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show(); mCommentRecyclerViewAdapterCallback.updatePost(mPost); } @@ -752,19 +763,19 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { + ((CommentViewHolder) holder).upvoteButton.setOnClickListener(view -> { if (mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -966,20 +977,20 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { + ((CommentViewHolder) holder).downvoteButton.setOnClickListener(view -> { if (mPost.isArchived()) { Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show(); return; @@ -1023,20 +1034,20 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter itemClickListener.onMenuClick(finalStringId)); @@ -461,12 +460,16 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter accounts = mRedditDataRoomDatabase.accountDao().getAllAccounts(); - int color = mCustomThemeWrapper.getNotificationIconColor(); + int color = mCustomThemeWrapper.getColorPrimaryLightTheme(); 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 cc851e99..cfce40c8 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()) + .setColor(mCustomThemeWrapper.getColorPrimaryLightTheme()) .build(); } 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 a3f3695a..92d1a984 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java @@ -21,6 +21,10 @@ public class CustomThemeSharedPreferencesUtils { public static final String BACKGROUND_COLOR = "backgroundColor"; public static final String CARD_VIEW_BACKGROUND_COLOR = "cardViewBackgroundColor"; public static final String COMMENT_BACKGROUND_COLOR = "commentBackgroundColor"; + public static final String BOTTOM_APP_BAR_BACKGROUND_COLOR = "bottomAppBarBackgroundColor"; + public static final String PRIMARY_ICON_COLOR = "primaryIconColor"; + public static final String POST_ICON_AND_INFO_COLOR = "postIconAndInfoColor"; + public static final String COMMENT_ICON_AND_INFO_COLOR = "commentIconAndInfoColor"; public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor"; public static final String TOOLBAR_AND_TAB_BACKGROUND_COLOR = "toolbarAndTabBackgroundColor"; public static final String CIRCULAR_PROGRESS_BAR_BACKGROUND = "circularProgressBarBackground"; @@ -52,7 +56,6 @@ public class CustomThemeSharedPreferencesUtils { public static final String AUTHOR_FLAIR_TEXT_COLOR = "authorFlairTextColor"; public static final String SUBMITTER = "submitter"; public static final String MODERATOR = "moderator"; - public static final String NOTIFICATION_ICON_COLOR = "notificationIconColor"; public static final String SINGLE_COMMENT_THREAD_BACKGROUND = "singleCommentThreadBackgroundColor"; public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor"; public static final String DIVIDER_COLOR = "dividerColor"; diff --git a/app/src/main/res/layout/item_nav_drawer_menu_item.xml b/app/src/main/res/layout/item_nav_drawer_menu_item.xml index 4e3cdf5b..6fcd0b35 100644 --- a/app/src/main/res/layout/item_nav_drawer_menu_item.xml +++ b/app/src/main/res/layout/item_nav_drawer_menu_item.xml @@ -1,12 +1,24 @@ - \ No newline at end of file + android:background="?attr/selectableItemBackground"> + + + + + + \ No newline at end of file -- cgit v1.2.3