aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-02-24 04:54:45 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-02-24 04:54:45 +0000
commit8768e71a910284a74824a26db3041c339a3af325 (patch)
treecc9e320f49c313d2cead0d4696e8b6d8257bfe6f /app/src/main/java
parent07e2e1e746164eb39c20a1bacbb53bdfc3f8d2c8 (diff)
downloadinfinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar.gz
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar.bz2
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar.lz
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar.xz
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.tar.zst
infinity-for-reddit-8768e71a910284a74824a26db3041c339a3af325.zip
New options: Hide subreddit and user prefix and hide the number of votes.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java93
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideSubredditAndUserPrefixEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTheNumberOfVotesEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java2
7 files changed, 133 insertions, 20 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 87025e50..46f3f7d9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -210,6 +210,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mHideReadPostsAutomatically;
private boolean mHidePostType;
private boolean mHideTheNumberOfAwards;
+ private boolean mHideSubredditAndUserPrefix;
+ private boolean mHideTheNumberOfVotes;
private Drawable mCommentIcon;
private NetworkState networkState;
private ExoCreator mExoCreator;
@@ -283,6 +285,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, 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;
@@ -475,8 +479,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
String flair = post.getFlair();
int nAwards = post.getNAwards();
- ((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed);
- ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
+ if (mHideSubredditAndUserPrefix) {
+ ((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 (authorPrefixed.equals(subredditNamePrefixed)) {
@@ -590,7 +599,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
((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()) {
((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.setText(subredditNamePrefixed);
+ if (mHideSubredditAndUserPrefix) {
+ ((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditName);
+ } else {
+ ((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditNamePrefixed);
+ }
} else {
if (post.getAuthorIconUrl() == null) {
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.setText(authorPrefixed);
+ if (mHideSubredditAndUserPrefix) {
+ ((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getAuthor());
+ } else {
+ ((PostCompactBaseViewHolder) holder).nameTextView.setText(authorPrefixed);
+ }
}
if (mShowElapsedTime) {
@@ -1074,7 +1095,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
((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()) {
((PostCompactBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
@@ -1765,6 +1790,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHideTheNumberOfAwards = hideTheNumberOfAwards;
}
+ public void setHideSubredditAndUserPrefix(boolean hideSubredditAndUserPrefix) {
+ mHideSubredditAndUserPrefix = hideSubredditAndUserPrefix;
+ }
+
+ public void setHideTheNumberOfVotes(boolean hideTheNumberOfVotes) {
+ mHideTheNumberOfVotes = hideTheNumberOfVotes;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
@@ -2298,7 +2331,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
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() {
@Override
@@ -2320,7 +2355,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) {
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));
@@ -2331,7 +2368,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) {
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ if (!mHideTheNumberOfVotes) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ }
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor);
@@ -2388,7 +2427,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
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() {
@Override
@@ -2410,7 +2451,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) {
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));
@@ -2421,7 +2464,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) {
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ if (!mHideTheNumberOfVotes) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ }
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor);
@@ -3253,7 +3298,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
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() {
@Override
@@ -3275,7 +3322,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) {
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));
@@ -3286,7 +3335,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) {
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ if (!mHideTheNumberOfVotes) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ }
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor);
@@ -3343,7 +3394,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
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() {
@Override
@@ -3366,7 +3419,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (currentPosition == position) {
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));
@@ -3377,7 +3432,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
post.setVoteType(previousVoteType);
if (getBindingAdapterPosition() == position) {
- scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ if (!mHideTheNumberOfVotes) {
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ }
upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
scoreTextView.setTextColor(previousScoreTextViewColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
index b2babae7..df1bf5e9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
@@ -26,12 +26,12 @@ public class PostLayoutBottomSheetFragment extends RoundedBottomSheetDialogFragm
@BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment)
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)
TextView compactLayoutTextView;
@BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment)
TextView galleryLayoutTextView;
- @BindView(R.id.card_layout_2_text_view_post_layout_bottom_sheet_fragment)
- TextView cardLayout2TextView;
private Activity activity;
public PostLayoutBottomSheetFragment() {
// Required empty public constructor
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideSubredditAndUserPrefixEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideSubredditAndUserPrefixEvent.java
new file mode 100644
index 00000000..d6981747
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideSubredditAndUserPrefixEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeHideSubredditAndUserPrefixEvent {
+ public boolean hideSubredditAndUserPrefix;
+
+ public ChangeHideSubredditAndUserPrefixEvent(boolean hideSubredditAndUserPrefix) {
+ this.hideSubredditAndUserPrefix = hideSubredditAndUserPrefix;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTheNumberOfVotesEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTheNumberOfVotesEvent.java
new file mode 100644
index 00000000..ed4273b6
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTheNumberOfVotesEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeHideTheNumberOfVotesEvent {
+ public boolean hideTheNumberOfVotes;
+
+ public ChangeHideTheNumberOfVotesEvent(boolean hideTheNumberOfVotes) {
+ this.hideTheNumberOfVotes = hideTheNumberOfVotes;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 7841efc2..60fd460d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -85,7 +85,9 @@ import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEvent;
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() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
index f04c205a..b7d0f205 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
@@ -12,7 +12,9 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
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 hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE);
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) {
defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -89,5 +93,19 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
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;
+ });
+ }
}
} \ No newline at end of file
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 965f8145..abef106a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -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 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_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_TAB_COUNT = "_main_page_tab_count";