mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-05 21:39:50 +02:00
Hiding post fliar in PostFragment is now available.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package ml.docilealligator.infinityforreddit.events;
|
||||
|
||||
public class ChangeHidePostFlairEvent {
|
||||
public boolean hidePostFlair;
|
||||
|
||||
public ChangeHidePostFlairEvent(boolean hidePostFlair) {
|
||||
this.hidePostFlair = hidePostFlair;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
@@ -1825,6 +1826,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) {
|
||||
|
@@ -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));
|
||||
|
@@ -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";
|
||||
|
@@ -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>
|
||||
|
@@ -19,6 +19,11 @@
|
||||
app:key="hide_post_type"
|
||||
app:title="@string/settings_hide_post_type" />
|
||||
|
||||
<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"
|
||||
|
Reference in New Issue
Block a user