aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/post_preferences.xml5
7 files changed, 52 insertions, 4 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 95be0ca5..4565a71c 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,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mMarkPostsAsReadOnScroll;
private boolean mHideReadPostsAutomatically;
private boolean mHidePostType;
+ private boolean mHidePostFlair;
private boolean mHideTheNumberOfAwards;
private boolean mHideSubredditAndUserPrefix;
private boolean mHideTheNumberOfVotes;
@@ -287,6 +288,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHideReadPostsAutomatically = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false);
mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, false);
+ mHidePostFlair = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_FLAIR, 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);
@@ -622,8 +624,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (flair != null && !flair.equals("")) {
- ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false);
+ if (mHidePostFlair) {
+ ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.GONE);
+ } else {
+ ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
+ Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false);
+ }
}
if (nAwards > 0 && !mHideTheNumberOfAwards) {
@@ -1123,8 +1129,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (flair != null && !flair.equals("")) {
- ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false);
+ if (mHidePostFlair) {
+ ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.GONE);
+ } else {
+ ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
+ Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false);
+ }
}
if (nAwards > 0 && !mHideTheNumberOfAwards) {
@@ -1801,6 +1811,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHidePostType = hidePostType;
}
+ public void setHidePostFlair(boolean hidePostFlair) {
+ mHidePostFlair = hidePostFlair;
+ }
+
public void setHideTheNumberOfAwards(boolean hideTheNumberOfAwards) {
mHideTheNumberOfAwards = hideTheNumberOfAwards;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java
new file mode 100644
index 00000000..f3a9a7a4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeHidePostFlairEvent {
+ public boolean hidePostFlair;
+
+ public ChangeHidePostFlairEvent(boolean hidePostFlair) {
+ this.hidePostFlair = hidePostFlair;
+ }
+}
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 7110e057..19bfaeb5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -85,6 +85,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
@@ -1826,6 +1827,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Subscribe
+ public void onChangeHidePostFlairEvent(ChangeHidePostFlairEvent event) {
+ if (mAdapter != null) {
+ mAdapter.setHidePostFlair(event.hidePostFlair);
+ refreshAdapter();
+ }
+ }
+
+ @Subscribe
public void onChangeHideTheNumberOfAwardsEvent(ChangeHideTheNumberOfAwardsEvent event) {
if (mAdapter != null) {
mAdapter.setHideTheNumberOfAwards(event.hideTheNumberOfAwards);
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 c45a2c1a..f3a4f30c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
@@ -12,6 +12,7 @@ import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
@@ -36,6 +37,7 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference longPressToHideToolbarInCompactLayoutSwitch = findPreference(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT);
SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT);
SwitchPreference hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE);
+ SwitchPreference hidePostFlairSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_FLAIR);
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);
@@ -90,6 +92,13 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
});
}
+ if (hidePostFlairSwitch != null) {
+ hidePostFlairSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeHidePostFlairEvent((Boolean) newValue));
+ return true;
+ });
+ }
+
if (hideTheNumberOfAwardsSwitch != null) {
hideTheNumberOfAwardsSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeHideTheNumberOfAwardsEvent((Boolean) newValue));
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 1125d71a..3242c63c 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,7 @@ public class SharedPreferencesUtils {
public static final String USER_DEFAULT_SORT_TIME = "user_default_sort_time";
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_FLAIR = "hide_post_flair";
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";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c3456e0e..6dd4979f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -541,6 +541,7 @@
<string name="settings_user_default_sort_time_title">User Default Sort Time</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_flair">Hide Post Flair</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>
diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml
index 7e47f86c..7ea526a5 100644
--- a/app/src/main/res/xml/post_preferences.xml
+++ b/app/src/main/res/xml/post_preferences.xml
@@ -21,6 +21,11 @@
<SwitchPreference
app:defaultValue="false"
+ app:key="hide_post_flair"
+ app:title="@string/settings_hide_post_flair" />
+
+ <SwitchPreference
+ app:defaultValue="false"
app:key="hide_the_number_of_awards"
app:title="@string/settings_hide_the_number_of_awards" />