diff options
Diffstat (limited to '')
8 files changed, 148 insertions, 43 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 3b62cd49..6bb41682 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -754,6 +754,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } else if (stringId == R.string.multi_reddit) { intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true); + } else if (stringId == R.string.rpan) { + intent = new Intent(MainActivity.this, RPANActivity.class); + } else if (stringId == R.string.trending) { + } else if (stringId == R.string.upvoted) { intent = new Intent(MainActivity.this, AccountPostsActivity.class); intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_UPVOTED); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java index 863b2da3..664f2689 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java @@ -56,8 +56,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re private static final int VIEW_TYPE_FAVORITE_SUBSCRIBED_SUBREDDIT = 4; private static final int VIEW_TYPE_SUBSCRIBED_SUBREDDIT = 5; private static final int VIEW_TYPE_ACCOUNT = 6; - private static final int CURRENT_MENU_ITEMS = 17; + private static final int CURRENT_MENU_ITEMS = 20; private static final int ACCOUNT_SECTION_ITEMS = 4; + private static final int REDDIT_SECTION_ITEMS = 2; private static final int POST_SECTION_ITEMS = 5; private static final int PREFERENCES_SECTION_ITEMS = 3; @@ -76,6 +77,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re private boolean isLoggedIn; private boolean isInMainPage = true; private boolean collapseAccountSection; + private boolean collapseRedditSection; private boolean collapsePostSection; private boolean collapsePreferencesSection; private boolean collapseFavoriteSubredditsSection; @@ -105,6 +107,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false); isLoggedIn = accountName != null; collapseAccountSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_ACCOUNT_SECTION, false); + collapseRedditSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_REDDIT_SECTION, false); collapsePostSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_POST_SECTION, false); collapsePreferencesSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_PREFERENCES_SECTION, false); collapseFavoriteSubredditsSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_FAVORITE_SUBREDDITS_SECTION, false); @@ -127,21 +130,25 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re if (isInMainPage) { if (isLoggedIn) { if (position == CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) { return VIEW_TYPE_MENU_GROUP_TITLE; } else if (!hideFavoriteSubredditsSection && !favoriteSubscribedSubreddits.isEmpty() && position == CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0) + (collapseFavoriteSubredditsSection ? 0 : favoriteSubscribedSubreddits.size()) + 1) { return VIEW_TYPE_MENU_GROUP_TITLE; } else if (position > CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) { if (!favoriteSubscribedSubreddits.isEmpty() && !hideFavoriteSubredditsSection && !collapseFavoriteSubredditsSection && position <= CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0) + favoriteSubscribedSubreddits.size()) { @@ -152,11 +159,17 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } else if (position == 0) { return VIEW_TYPE_NAV_HEADER; } else if (position == 1 - || position == 6 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) - || position == 12 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + || position == (ACCOUNT_SECTION_ITEMS + 2) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + || position == (ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + 3) + - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) + || position == (ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + POST_SECTION_ITEMS + 4) + - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0)) { return VIEW_TYPE_MENU_GROUP_TITLE; - } else if (position == 16 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + } else if (position == (CURRENT_MENU_ITEMS - 1) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) { return VIEW_TYPE_DIVIDER; @@ -217,15 +230,13 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof NavHeaderViewHolder) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ((NavHeaderViewHolder) holder).profileImageView.getLayoutParams(); if (showAvatarOnTheRightInTheNavigationDrawer) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ((NavHeaderViewHolder) holder).profileImageView.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_END); - ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params); } else { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ((NavHeaderViewHolder) holder).profileImageView.getLayoutParams(); params.removeRule(RelativeLayout.ALIGN_PARENT_END); - ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params); } + ((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params); if (isLoggedIn) { ((NavHeaderViewHolder) holder).karmaTextView.setText(appCompatActivity.getString(R.string.karma_info, karma)); ((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName); @@ -258,7 +269,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re ((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px)); } - ((NavHeaderViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { if (isInMainPage) { if (requireAuthToAccountSection) { BiometricManager biometricManager = BiometricManager.from(appCompatActivity); @@ -301,15 +312,27 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); } type = 0; - } else if (position == 6 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0)) { + } else if (position == (ACCOUNT_SECTION_ITEMS + 2) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0)) { + ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_reddit); + if (collapseRedditSection) { + ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_up_24px); + } else { + ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); + } + type = 1; + } else if (position == (ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + 3) + - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0)) { ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_post); if (collapsePostSection) { ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_up_24px); } else { ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); } - type = 1; - } else if (position == 12 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + type = 2; + } else if (position == (ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + POST_SECTION_ITEMS + 4) + - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0)) { ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.label_preferences); if (collapsePreferencesSection) { @@ -317,10 +340,11 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } else { ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); } - type = 2; + type = 3; } else { if (!hideFavoriteSubredditsSection && !favoriteSubscribedSubreddits.isEmpty() && position == CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) { ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.favorites); @@ -329,7 +353,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } else { ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); } - type = 3; + type = 4; } else { ((MenuGroupTitleViewHolder) holder).titleTextView.setText(R.string.subscriptions); if (collapseSubscribedSubredditsSection) { @@ -337,11 +361,11 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } else { ((MenuGroupTitleViewHolder) holder).collapseIndicatorImageView.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24px); } - type = 4; + type = 5; } } - ((MenuGroupTitleViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { switch (type) { case 0: if (collapseAccountSection) { @@ -353,6 +377,15 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } break; case 1: + if (collapseRedditSection) { + collapseRedditSection = !collapseRedditSection; + notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS); + } else { + collapseRedditSection = !collapseRedditSection; + notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS); + } + break; + case 2: if (collapsePostSection) { collapsePostSection = !collapsePostSection; notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, POST_SECTION_ITEMS); @@ -361,7 +394,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, POST_SECTION_ITEMS); } break; - case 2: + case 3: if (collapsePreferencesSection) { collapsePreferencesSection = !collapsePreferencesSection; notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, PREFERENCES_SECTION_ITEMS); @@ -370,7 +403,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, PREFERENCES_SECTION_ITEMS); } break; - case 3: + case 4: if (collapseFavoriteSubredditsSection) { collapseFavoriteSubredditsSection = !collapseFavoriteSubredditsSection; notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, favoriteSubscribedSubreddits.size()); @@ -379,7 +412,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, favoriteSubscribedSubreddits.size()); } break; - case 4: + case 5: if (collapseSubscribedSubredditsSection) { collapseSubscribedSubredditsSection = !collapseSubscribedSubredditsSection; notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, subscribedSubreddits.size()); @@ -399,14 +432,26 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re if (isInMainPage) { if (isLoggedIn) { int pseudoPosition = position; - if (collapseAccountSection && collapsePostSection) { - pseudoPosition += ACCOUNT_SECTION_ITEMS + POST_SECTION_ITEMS; - } else if (collapseAccountSection && collapsePreferencesSection) { - pseudoPosition += ACCOUNT_SECTION_ITEMS; + if (collapseAccountSection && collapseRedditSection && collapsePostSection) { + pseudoPosition += ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + POST_SECTION_ITEMS; + } else if (collapseAccountSection && collapseRedditSection) { + pseudoPosition += ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS; + } else if (collapseAccountSection && collapsePostSection) { + if (position > REDDIT_SECTION_ITEMS + 2) { + pseudoPosition += ACCOUNT_SECTION_ITEMS + POST_SECTION_ITEMS; + } + } else if (collapseRedditSection && collapsePostSection) { + if (position > ACCOUNT_SECTION_ITEMS + 1) { + pseudoPosition += REDDIT_SECTION_ITEMS + POST_SECTION_ITEMS; + } } else if (collapseAccountSection) { pseudoPosition += ACCOUNT_SECTION_ITEMS; - } else if (collapsePostSection) { + } else if (collapseRedditSection) { if (position > ACCOUNT_SECTION_ITEMS + 1) { + pseudoPosition += REDDIT_SECTION_ITEMS; + } + } else if (collapsePostSection) { + if (position > ACCOUNT_SECTION_ITEMS + REDDIT_SECTION_ITEMS + 2) { pseudoPosition += POST_SECTION_ITEMS; } } @@ -431,32 +476,40 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re ((MenuItemViewHolder) holder).menuTextView.setText(R.string.inbox); } ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_inbox_24dp)); - ((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { Intent intent = new Intent(appCompatActivity, InboxActivity.class); appCompatActivity.startActivity(intent); }); break; case 7: + stringId = R.string.rpan; + drawableId = R.drawable.ic_rpan_24dp; + break; + case 8: + stringId = R.string.trending; + drawableId = R.drawable.ic_trending_24dp; + break; + case 10: stringId = R.string.upvoted; drawableId = R.drawable.ic_arrow_upward_black_24dp; break; - case 8: + case 11: stringId = R.string.downvoted; drawableId = R.drawable.ic_arrow_downward_black_24dp; break; - case 9: + case 12: stringId = R.string.hidden; drawableId = R.drawable.ic_outline_lock_24dp; break; - case 10: + case 13: stringId = R.string.account_saved_thing_activity_label; drawableId = R.drawable.ic_outline_bookmarks_24dp; break; - case 11: + case 14: stringId = R.string.gilded; drawableId = R.drawable.ic_star_border_24dp; break; - case 13: + case 16: if ((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { stringId = R.string.dark_theme; drawableId = R.drawable.ic_dark_theme_24dp; @@ -465,7 +518,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re drawableId = R.drawable.ic_light_theme_24dp; } break; - case 14: + case 17: setOnClickListener = false; if (isNSFWEnabled) { stringId = R.string.disable_nsfw; @@ -475,21 +528,21 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re drawableId = R.drawable.ic_nsfw_on_24dp; } - ((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { if (isNSFWEnabled) { isNSFWEnabled = false; ((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw); - ((MenuItemViewHolder) holder).imageView.setImageDrawable(appCompatActivity.getDrawable(R.drawable.ic_nsfw_on_24dp)); + ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_on_24dp)); itemClickListener.onMenuClick(R.string.disable_nsfw); } else { isNSFWEnabled = true; ((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw); - ((MenuItemViewHolder) holder).imageView.setImageDrawable(appCompatActivity.getDrawable(R.drawable.ic_nsfw_off_24dp)); + ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_off_24dp)); itemClickListener.onMenuClick(R.string.enable_nsfw); } }); break; - case 15: + case 18: stringId = R.string.settings; drawableId = R.drawable.ic_settings_24dp; } @@ -518,16 +571,16 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re drawableId = R.drawable.ic_nsfw_on_24dp; } - ((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { if (isNSFWEnabled) { isNSFWEnabled = false; ((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw); - ((MenuItemViewHolder) holder).imageView.setImageDrawable(appCompatActivity.getDrawable(R.drawable.ic_nsfw_on_24dp)); + ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_on_24dp)); itemClickListener.onMenuClick(R.string.disable_nsfw); } else { isNSFWEnabled = true; ((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw); - ((MenuItemViewHolder) holder).imageView.setImageDrawable(appCompatActivity.getDrawable(R.drawable.ic_nsfw_off_24dp)); + ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, R.drawable.ic_nsfw_off_24dp)); itemClickListener.onMenuClick(R.string.enable_nsfw); } }); @@ -558,15 +611,16 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re if (stringId != 0) { ((MenuItemViewHolder) holder).menuTextView.setText(stringId); - ((MenuItemViewHolder) holder).imageView.setImageDrawable(appCompatActivity.getDrawable(drawableId)); + ((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(appCompatActivity, drawableId)); if (setOnClickListener) { int finalStringId = stringId; - ((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId)); + holder.itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId)); } } } else if (holder instanceof FavoriteSubscribedThingViewHolder) { SubscribedSubredditData subreddit = favoriteSubscribedSubreddits.get(position - (CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) - 1); @@ -585,17 +639,19 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re .into(((FavoriteSubscribedThingViewHolder) holder).iconGifImageView); } - ((FavoriteSubscribedThingViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { itemClickListener.onSubscribedSubredditClick(subredditName); }); } else if (holder instanceof SubscribedThingViewHolder) { SubscribedSubredditData subreddit = favoriteSubscribedSubreddits.isEmpty() || hideFavoriteSubredditsSection ? subscribedSubreddits.get(position - (CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) - 1) : subscribedSubreddits.get(position - (CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0)) - (collapseFavoriteSubredditsSection ? 0 : favoriteSubscribedSubreddits.size()) @@ -615,7 +671,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re .into(((SubscribedThingViewHolder) holder).iconGifImageView); } - ((SubscribedThingViewHolder) holder).itemView.setOnClickListener(view -> { + holder.itemView.setOnClickListener(view -> { itemClickListener.onSubscribedSubredditClick(subredditName); }); } else if (holder instanceof AccountViewHolder) { @@ -624,7 +680,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0))) .into(((AccountViewHolder) holder).profileImageGifImageView); ((AccountViewHolder) holder).usernameTextView.setText(accounts.get(position - 1).getAccountName()); - ((AccountViewHolder) holder).itemView.setOnClickListener(view -> + holder.itemView.setOnClickListener(view -> itemClickListener.onAccountClick(accounts.get(position - 1).getAccountName())); } } @@ -669,18 +725,21 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re if (hideFavoriteSubredditsSection && hideSubscribedSubredditsSection) { return CURRENT_MENU_ITEMS - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0); } else if (hideFavoriteSubredditsSection) { return CURRENT_MENU_ITEMS + (subscribedSubreddits.isEmpty() ? 0 : subscribedSubreddits.size() + 1) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0) - (collapseSubscribedSubredditsSection ? subscribedSubreddits.size() : 0); } else if (hideSubscribedSubredditsSection) { return CURRENT_MENU_ITEMS + (favoriteSubscribedSubreddits.isEmpty() ? 0 : favoriteSubscribedSubreddits.size() + 1) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0) - (collapseFavoriteSubredditsSection ? favoriteSubscribedSubreddits.size() : 0); @@ -688,6 +747,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re return CURRENT_MENU_ITEMS + (favoriteSubscribedSubreddits.isEmpty() ? 0 : favoriteSubscribedSubreddits.size() + 1) + (subscribedSubreddits.isEmpty() ? 0 : subscribedSubreddits.size() + 1) - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0) - (collapseFavoriteSubredditsSection ? favoriteSubscribedSubreddits.size() : 0) @@ -695,6 +755,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } return CURRENT_MENU_ITEMS - 1 - (collapseAccountSection ? ACCOUNT_SECTION_ITEMS : 0) + - (collapseRedditSection ? REDDIT_SECTION_ITEMS : 0) - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 82343e4f..7f43ff5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -308,6 +308,7 @@ public class SharedPreferencesUtils { public static final String NAVIGATION_DRAWER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.navigation_drawer"; public static final String COLLAPSE_ACCOUNT_SECTION = "collapse_account_section"; + public static final String COLLAPSE_REDDIT_SECTION = "collapse_reddit_section"; public static final String COLLAPSE_POST_SECTION = "collapse_post_section"; public static final String COLLAPSE_PREFERENCES_SECTION = "collapse_preferences_section"; public static final String COLLAPSE_FAVORITE_SUBREDDITS_SECTION = "collapse_favorite_subreddits_section"; diff --git a/app/src/main/res/drawable-night/ic_rpan_24dp.xml b/app/src/main/res/drawable-night/ic_rpan_24dp.xml new file mode 100644 index 00000000..1c8156c1 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_rpan_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M21,6h-7.59l3.29,-3.29L16,2l-4,4 -4,-4 -0.71,0.71L10.59,6L3,6c-1.1,0 -2,0.89 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.11 -0.9,-2 -2,-2zM21,20L3,20L3,8h18v12zM9,10v8l7,-4z"/> +</vector> diff --git a/app/src/main/res/drawable-night/ic_trending_24dp.xml b/app/src/main/res/drawable-night/ic_trending_24dp.xml new file mode 100644 index 00000000..d441a7f7 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_trending_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M16,6l2.29,2.29 -4.88,4.88 -4,-4L2,16.59 3.41,18l6,-6 4,4 6.3,-6.29L22,12V6z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_rpan_24dp.xml b/app/src/main/res/drawable/ic_rpan_24dp.xml new file mode 100644 index 00000000..bb61e6ff --- /dev/null +++ b/app/src/main/res/drawable/ic_rpan_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/black" + android:pathData="M21,6h-7.59l3.29,-3.29L16,2l-4,4 -4,-4 -0.71,0.71L10.59,6L3,6c-1.1,0 -2,0.89 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.11 -0.9,-2 -2,-2zM21,20L3,20L3,8h18v12zM9,10v8l7,-4z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_trending_24dp.xml b/app/src/main/res/drawable/ic_trending_24dp.xml new file mode 100644 index 00000000..b237138b --- /dev/null +++ b/app/src/main/res/drawable/ic_trending_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/black" + android:pathData="M16,6l2.29,2.29 -4.88,4.88 -4,-4L2,16.59 3.41,18l6,-6 4,4 6.3,-6.29L22,12V6z"/> +</vector> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d57ac76e..3f2d4621 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -128,6 +128,8 @@ <string name="multi_reddit">Multireddit</string> <string name="inbox">Inbox</string> <string name="inbox_with_count">Inbox (%1$d)</string> + <string name="rpan">RPAN</string> + <string name="trending">Trending</string> <string name="upvoted">Upvoted</string> <string name="downvoted">Downvoted</string> <string name="hidden">Hidden</string> @@ -344,6 +346,7 @@ <string name="notification_new_messages">%1$d New Messages</string> <string name="label_account">Account</string> + <string name="label_reddit">Reddit</string> <string name="label_post">Post</string> <string name="label_preferences">Preferences</string> |