New options: Hide subreddit and user prefix and hide the number of votes.

This commit is contained in:
Alex Ning 2021-02-24 12:54:45 +08:00
parent 07e2e1e746
commit 8768e71a91
10 changed files with 163 additions and 38 deletions

View File

@ -210,6 +210,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mHideReadPostsAutomatically; private boolean mHideReadPostsAutomatically;
private boolean mHidePostType; private boolean mHidePostType;
private boolean mHideTheNumberOfAwards; private boolean mHideTheNumberOfAwards;
private boolean mHideSubredditAndUserPrefix;
private boolean mHideTheNumberOfVotes;
private Drawable mCommentIcon; private Drawable mCommentIcon;
private NetworkState networkState; private NetworkState networkState;
private ExoCreator mExoCreator; private ExoCreator mExoCreator;
@ -283,6 +285,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, false); mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, false);
mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false); mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mPostLayout = postLayout; mPostLayout = postLayout;
@ -475,8 +479,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
String flair = post.getFlair(); String flair = post.getFlair();
int nAwards = post.getNAwards(); int nAwards = post.getNAwards();
((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed); if (mHideSubredditAndUserPrefix) {
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); ((PostBaseViewHolder) holder).subredditTextView.setText(subredditName);
((PostBaseViewHolder) holder).userTextView.setText(post.getAuthor());
} else {
((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed);
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
}
if (mDisplaySubredditName) { if (mDisplaySubredditName) {
if (authorPrefixed.equals(subredditNamePrefixed)) { if (authorPrefixed.equals(subredditNamePrefixed)) {
@ -590,7 +599,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle()); ((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle());
((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} else {
((PostBaseViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
}
if (post.isLocked()) { if (post.isLocked()) {
((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); ((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
@ -1011,7 +1024,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mSubredditColor); ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mSubredditColor);
((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditNamePrefixed); if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditName);
} else {
((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditNamePrefixed);
}
} else { } else {
if (post.getAuthorIconUrl() == null) { if (post.getAuthorIconUrl() == null) {
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor(); String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor();
@ -1047,7 +1064,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor); ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mUsernameColor);
((PostCompactBaseViewHolder) holder).nameTextView.setText(authorPrefixed); if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
} else {
((PostCompactBaseViewHolder) holder).nameTextView.setText(authorPrefixed);
}
} }
if (mShowElapsedTime) { if (mShowElapsedTime) {
@ -1074,7 +1095,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
((PostCompactBaseViewHolder) holder).titleTextView.setText(title); ((PostCompactBaseViewHolder) holder).titleTextView.setText(title);
((PostCompactBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
((PostCompactBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} else {
((PostCompactBaseViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
}
if (post.isLocked()) { if (post.isLocked()) {
((PostCompactBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE); ((PostCompactBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
@ -1765,6 +1790,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHideTheNumberOfAwards = hideTheNumberOfAwards; mHideTheNumberOfAwards = hideTheNumberOfAwards;
} }
public void setHideSubredditAndUserPrefix(boolean hideSubredditAndUserPrefix) {
mHideSubredditAndUserPrefix = hideSubredditAndUserPrefix;
}
public void setHideTheNumberOfVotes(boolean hideTheNumberOfVotes) {
mHideTheNumberOfVotes = hideTheNumberOfVotes;
}
@Override @Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder); super.onViewRecycled(holder);
@ -2298,7 +2331,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
scoreTextView.setTextColor(mPostIconAndInfoColor); scoreTextView.setTextColor(mPostIconAndInfoColor);
} }
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
@ -2320,7 +2355,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) { if (currentPosition == position) {
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
} }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
@ -2331,7 +2368,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType); post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) { if (getBindingAdapterPosition() == position) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
}
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor); scoreTextView.setTextColor(previousScoreTextViewColor);
@ -2388,7 +2427,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
scoreTextView.setTextColor(mPostIconAndInfoColor); scoreTextView.setTextColor(mPostIconAndInfoColor);
} }
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
@ -2410,7 +2451,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) { if (currentPosition == position) {
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
} }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
@ -2421,7 +2464,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType); post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) { if (getBindingAdapterPosition() == position) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
}
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor); scoreTextView.setTextColor(previousScoreTextViewColor);
@ -3253,7 +3298,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
scoreTextView.setTextColor(mPostIconAndInfoColor); scoreTextView.setTextColor(mPostIconAndInfoColor);
} }
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
@ -3275,7 +3322,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) { if (currentPosition == position) {
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
} }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
@ -3286,7 +3335,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType); post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) { if (getBindingAdapterPosition() == position) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
}
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor); scoreTextView.setTextColor(previousScoreTextViewColor);
@ -3343,7 +3394,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
scoreTextView.setTextColor(mPostIconAndInfoColor); scoreTextView.setTextColor(mPostIconAndInfoColor);
} }
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
@ -3366,7 +3419,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) { if (currentPosition == position) {
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
} }
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post)); EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
@ -3377,7 +3432,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType); post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) { if (getBindingAdapterPosition() == position) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType)); if (!mHideTheNumberOfVotes) {
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
}
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter); downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor); scoreTextView.setTextColor(previousScoreTextViewColor);

View File

@ -26,12 +26,12 @@ public class PostLayoutBottomSheetFragment extends RoundedBottomSheetDialogFragm
@BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment) @BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment)
TextView cardLayoutTextView; TextView cardLayoutTextView;
@BindView(R.id.card_layout_2_text_view_post_layout_bottom_sheet_fragment)
TextView cardLayout2TextView;
@BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment) @BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment)
TextView compactLayoutTextView; TextView compactLayoutTextView;
@BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment) @BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment)
TextView galleryLayoutTextView; TextView galleryLayoutTextView;
@BindView(R.id.card_layout_2_text_view_post_layout_bottom_sheet_fragment)
TextView cardLayout2TextView;
private Activity activity; private Activity activity;
public PostLayoutBottomSheetFragment() { public PostLayoutBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor

View File

@ -0,0 +1,9 @@
package ml.docilealligator.infinityforreddit.events;
public class ChangeHideSubredditAndUserPrefixEvent {
public boolean hideSubredditAndUserPrefix;
public ChangeHideSubredditAndUserPrefixEvent(boolean hideSubredditAndUserPrefix) {
this.hideSubredditAndUserPrefix = hideSubredditAndUserPrefix;
}
}

View File

@ -0,0 +1,9 @@
package ml.docilealligator.infinityforreddit.events;
public class ChangeHideTheNumberOfVotesEvent {
public boolean hideTheNumberOfVotes;
public ChangeHideTheNumberOfVotesEvent(boolean hideTheNumberOfVotes) {
this.hideTheNumberOfVotes = hideTheNumberOfVotes;
}
}

View File

@ -85,7 +85,9 @@ import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent; import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent; import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent; import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEvent; import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEvent;
import ml.docilealligator.infinityforreddit.events.ChangeMuteNSFWVideoEvent; import ml.docilealligator.infinityforreddit.events.ChangeMuteNSFWVideoEvent;
@ -1657,6 +1659,22 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
} }
@Subscribe
public void onChangeHideSubredditAndUserEvent(ChangeHideSubredditAndUserPrefixEvent event) {
if (mAdapter != null) {
mAdapter.setHideSubredditAndUserPrefix(event.hideSubredditAndUserPrefix);
refreshAdapter();
}
}
@Subscribe
public void onChangeHideTheNumberOfVotesEvent(ChangeHideTheNumberOfVotesEvent event) {
if (mAdapter != null) {
mAdapter.setHideTheNumberOfVotes(event.hideTheNumberOfVotes);
refreshAdapter();
}
}
private void refreshAdapter() { private void refreshAdapter() {
int previousPosition = -1; int previousPosition = -1;
if (mLinearLayoutManager != null) { if (mLinearLayoutManager != null) {

View File

@ -12,7 +12,9 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent; import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent; import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent; import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent; import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent;
@ -33,6 +35,8 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT); SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT);
SwitchPreference hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE); SwitchPreference hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE);
SwitchPreference hideTheNumberOfAwardsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS); SwitchPreference hideTheNumberOfAwardsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS);
SwitchPreference hideSubredditAndUserPrefixSwitch = findPreference(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX);
SwitchPreference hideTheNumberOfVotesSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES);
if (defaultPostLayoutList != null) { if (defaultPostLayoutList != null) {
defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> { defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> {
@ -89,5 +93,19 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
return true; return true;
}); });
} }
if (hideSubredditAndUserPrefixSwitch != null) {
hideSubredditAndUserPrefixSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeHideSubredditAndUserPrefixEvent((Boolean) newValue));
return true;
});
}
if (hideTheNumberOfVotesSwitch != null) {
hideTheNumberOfVotesSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeHideTheNumberOfVotesEvent((Boolean) newValue));
return true;
});
}
} }
} }

View File

@ -165,6 +165,8 @@ public class SharedPreferencesUtils {
public static final String CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT = "click_to_show_media_in_gallery_layout"; public static final String CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT = "click_to_show_media_in_gallery_layout";
public static final String HIDE_POST_TYPE = "hide_post_type"; public static final String HIDE_POST_TYPE = "hide_post_type";
public static final String HIDE_THE_NUMBER_OF_AWARDS = "hide_the_number_of_awards"; public static final String HIDE_THE_NUMBER_OF_AWARDS = "hide_the_number_of_awards";
public static final String HIDE_SUBREDDIT_AND_USER_PREFIX = "hide_subreddit_and_user_prefix";
public static final String HIDE_THE_NUMBER_OF_VOTES = "hide_the_number_of_votes";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count"; public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";

View File

@ -28,6 +28,22 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" /> android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/card_layout_2_text_view_post_layout_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/post_layout_card_2"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<TextView <TextView
android:id="@+id/compact_layout_text_view_post_layout_bottom_sheet_fragment" android:id="@+id/compact_layout_text_view_post_layout_bottom_sheet_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -60,22 +76,6 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" /> android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/card_layout_2_text_view_post_layout_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/post_layout_card_2"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -537,6 +537,8 @@
<string name="settings_click_to_show_media_in_gallery_layout">Click to Show Media in Gallery Layout</string> <string name="settings_click_to_show_media_in_gallery_layout">Click to Show Media in Gallery Layout</string>
<string name="settings_hide_post_type">Hide Post Type</string> <string name="settings_hide_post_type">Hide Post Type</string>
<string name="settings_hide_the_number_of_awards">Hide the Number of Awards</string> <string name="settings_hide_the_number_of_awards">Hide the Number of Awards</string>
<string name="settings_hide_subreddit_and_user_prefix">Hide Subreddit and User Prefix</string>
<string name="settings_hide_the_number_of_votes">Hide the Number of Votes</string>
<string name="no_link_available">Cannot get the link</string> <string name="no_link_available">Cannot get the link</string>
@ -1024,7 +1026,7 @@
<string name="have_trouble_login_title">Having Trouble Login</string> <string name="have_trouble_login_title">Having Trouble Login</string>
<string name="have_trouble_login_message">Do you want to try another way to login?</string> <string name="have_trouble_login_message">Do you want to try another way to login?</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="vote">Vote</string>
</resources> </resources>

View File

@ -24,6 +24,16 @@
app:key="hide_the_number_of_awards" app:key="hide_the_number_of_awards"
app:title="@string/settings_hide_the_number_of_awards" /> app:title="@string/settings_hide_the_number_of_awards" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_subreddit_and_user_prefix"
app:title="@string/settings_hide_subreddit_and_user_prefix" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_the_number_of_votes"
app:title="@string/settings_hide_the_number_of_votes" />
<PreferenceCategory <PreferenceCategory
app:title="@string/post_layout_compact" /> app:title="@string/post_layout_compact" />