aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTextPostContent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java19
-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
8 files changed, 48 insertions, 9 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 82ccc212..df842ad4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -207,6 +207,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mHideTheNumberOfComments;
private boolean mLegacyAutoplayVideoControllerUI;
private boolean mFixedHeightPreviewInCard;
+ private boolean mHideTextPostContent;
private Drawable mCommentIcon;
private ExoCreator mExoCreator;
private Callback mCallback;
@@ -284,6 +285,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
mFixedHeightPreviewInCard = sharedPreferences.getBoolean(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD, false);
+ mHideTextPostContent = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_TEXT_POST_CONTENT, false);
mPostLayout = postLayout;
mDefaultLinkPostLayout = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.DEFAULT_LINK_POST_LAYOUT_KEY, "-1"));
@@ -825,7 +827,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
} else if (holder instanceof PostTextTypeViewHolder) {
- if (!post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
+ if (!mHideTextPostContent && !post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
if (post.isRead()) {
((PostTextTypeViewHolder) holder).contentTextView.setTextColor(mReadPostContentColor);
@@ -980,7 +982,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
} else if (holder instanceof PostCard2TextTypeViewHolder) {
- if (!post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
+ if (!mHideTextPostContent && !post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
((PostCard2TextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
if (post.isRead()) {
((PostCard2TextTypeViewHolder) holder).contentTextView.setTextColor(mReadPostContentColor);
@@ -1737,6 +1739,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mFixedHeightPreviewInCard = fixedHeightPreviewInCard;
}
+ public void setHideTextPostContent(boolean hideTextPostContent) {
+ mHideTextPostContent = hideTextPostContent;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTextPostContent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTextPostContent.java
new file mode 100644
index 00000000..0bda8641
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTextPostContent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeHideTextPostContent {
+ public boolean hideTextPostContent;
+
+ public ChangeHideTextPostContent(boolean hideTextPostContent) {
+ this.hideTextPostContent = hideTextPostContent;
+ }
+}
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 3638190c..aaafe2e2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -99,6 +99,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeFixedHeightPreviewInCar
import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideTextPostContent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfCommentsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
@@ -1728,6 +1729,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
post.setTitle(event.post.getTitle());
post.setVoteType(event.post.getVoteType());
post.setScore(event.post.getScore());
+ post.setNComments(event.post.getNComments());
post.setNSFW(event.post.isNSFW());
post.setHidden(event.post.isHidden());
post.setSpoiler(event.post.isSpoiler());
@@ -2074,6 +2076,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeHideTextPostContentEvent(ChangeHideTextPostContent event) {
+ if (mAdapter != null) {
+ mAdapter.setHideTextPostContent(event.hideTextPostContent);
+ refreshAdapter();
+ }
+ }
+
private void refreshAdapter() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
index a7b4a15b..a465dc8c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -706,6 +706,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mPostAdapter != null) {
mPostAdapter.addOneComment();
}
+ EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
public void addChildComment(Comment comment, String parentFullname, int parentPosition) {
@@ -715,6 +716,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mPostAdapter != null) {
mPostAdapter.addOneComment();
}
+ EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
public void editComment(String commentAuthor, String commentContentMarkdown, int position) {
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 d4785cc7..cacdf83b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
@@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.settings;
import android.os.Bundle;
import androidx.preference.ListPreference;
-import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
@@ -17,6 +16,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeFixedHeightPreviewInCar
import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHideTextPostContent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfCommentsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfVotesEvent;
@@ -49,6 +49,7 @@ public class PostPreferenceFragment extends CustomFontPreferenceFragmentCompat {
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);
+ SwitchPreference hideTextPostContentSwitch = findPreference(SharedPreferencesUtils.HIDE_TEXT_POST_CONTENT);
SwitchPreference fixedHeightPreviewInCardSwitch = findPreference(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD);
if (defaultPostLayoutList != null) {
@@ -136,12 +137,16 @@ public class PostPreferenceFragment extends CustomFontPreferenceFragmentCompat {
}
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;
- }
+ hideTheNumberOfCommentsSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeHideTheNumberOfCommentsEvent((Boolean) newValue));
+ return true;
+ });
+ }
+
+ if (hideTextPostContentSwitch != null) {
+ hideTextPostContentSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeHideTextPostContent((Boolean) newValue));
+ return true;
});
}
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 e5713e4f..74dc9a7f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -201,6 +201,7 @@ public class SharedPreferencesUtils {
public static final String LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI = "legacy_autoplay_video_controller_ui";
public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video";
public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card";
+ public static final String HIDE_TEXT_POST_CONTENT = "hide_text_post_content";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 733343bf..8751ce69 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -625,6 +625,7 @@
<string name="settings_custom_title_font_family_title">Custom Title Font Family</string>
<string name="settings_custom_content_font_family_title">Custom Content Font Family</string>
<string name="settings_fixed_height_preview_in_card_title">Fixed Height in Card</string>
+ <string name="settings_hide_text_post_content">Hide Text Post Content</string>
<string name="no_link_available">Cannot get the link</string>
diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml
index 3bc09d0f..d07b5edd 100644
--- a/app/src/main/res/xml/post_preferences.xml
+++ b/app/src/main/res/xml/post_preferences.xml
@@ -54,6 +54,11 @@
<ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
app:defaultValue="false"
+ app:key="hide_text_post_content"
+ app:title="@string/settings_hide_text_post_content" />
+
+ <ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
+ app:defaultValue="false"
app:key="fixed_height_preview_in_card"
app:title="@string/settings_fixed_height_preview_in_card_title" />