mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
New option: Hide the number of comments.
This commit is contained in:
parent
8768e71a91
commit
f4bfa4fc40
@ -212,6 +212,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
private boolean mHideTheNumberOfAwards;
|
||||
private boolean mHideSubredditAndUserPrefix;
|
||||
private boolean mHideTheNumberOfVotes;
|
||||
private boolean mHideTheNumberOfComments;
|
||||
private Drawable mCommentIcon;
|
||||
private NetworkState networkState;
|
||||
private ExoCreator mExoCreator;
|
||||
@ -287,6 +288,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
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);
|
||||
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
|
||||
|
||||
mPostLayout = postLayout;
|
||||
|
||||
@ -662,7 +664,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
((PostBaseViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
((PostBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
|
||||
if (!mHideTheNumberOfComments) {
|
||||
((PostBaseViewHolder) holder).commentsCountTextView.setVisibility(View.VISIBLE);
|
||||
((PostBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
|
||||
} else {
|
||||
((PostBaseViewHolder) holder).commentsCountTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (post.isSaved()) {
|
||||
((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
@ -1241,7 +1248,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
break;
|
||||
}
|
||||
|
||||
((PostCompactBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
|
||||
if (!mHideTheNumberOfComments) {
|
||||
((PostCompactBaseViewHolder) holder).commentsCountTextView.setVisibility(View.VISIBLE);
|
||||
((PostCompactBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
|
||||
} else {
|
||||
((PostCompactBaseViewHolder) holder).commentsCountTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (post.isSaved()) {
|
||||
((PostCompactBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
@ -1798,6 +1810,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
mHideTheNumberOfVotes = hideTheNumberOfVotes;
|
||||
}
|
||||
|
||||
public void setHideTheNumberOfComments(boolean hideTheNumberOfComments) {
|
||||
mHideTheNumberOfComments = hideTheNumberOfComments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
super.onViewRecycled(holder);
|
||||
|
@ -0,0 +1,9 @@
|
||||
package ml.docilealligator.infinityforreddit.events;
|
||||
|
||||
public class ChangeHideTheNumberOfCommentsEvent {
|
||||
public boolean hideTheNumberOfComments;
|
||||
|
||||
public ChangeHideTheNumberOfCommentsEvent(boolean hideTheNumberOfComments) {
|
||||
this.hideTheNumberOfComments = hideTheNumberOfComments;
|
||||
}
|
||||
}
|
@ -87,6 +87,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitch
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfCommentsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEvent;
|
||||
@ -1675,6 +1676,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeHideTheNumberOfCommentsEvent(ChangeHideTheNumberOfCommentsEvent event) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setHideTheNumberOfComments(event.hideTheNumberOfComments);
|
||||
refreshAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshAdapter() {
|
||||
int previousPosition = -1;
|
||||
if (mLinearLayoutManager != null) {
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.settings;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@ -14,6 +15,7 @@ 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.ChangeHideTheNumberOfCommentsEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
|
||||
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||
@ -37,6 +39,7 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
|
||||
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);
|
||||
SwitchPreference hideTheNumberOfCommentsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS);
|
||||
|
||||
if (defaultPostLayoutList != null) {
|
||||
defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
@ -107,5 +110,15 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (hideTheNumberOfCommentsSwitch != null) {
|
||||
hideTheNumberOfCommentsSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
EventBus.getDefault().post(new ChangeHideTheNumberOfCommentsEvent((Boolean) newValue));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -167,6 +167,7 @@ public class SharedPreferencesUtils {
|
||||
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 HIDE_THE_NUMBER_OF_COMMENTS = "hide_the_number_of_comments";
|
||||
|
||||
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";
|
||||
|
@ -539,6 +539,7 @@
|
||||
<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="settings_hide_the_number_of_comments">Hide the Number of Comments</string>
|
||||
|
||||
<string name="no_link_available">Cannot get the link</string>
|
||||
|
||||
|
@ -34,6 +34,11 @@
|
||||
app:key="hide_the_number_of_votes"
|
||||
app:title="@string/settings_hide_the_number_of_votes" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="hide_the_number_of_comments"
|
||||
app:title="@string/settings_hide_the_number_of_comments" />
|
||||
|
||||
<PreferenceCategory
|
||||
app:title="@string/post_layout_compact" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user