aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
4 files changed, 20 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
index 680e1e59..7e236624 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit;
import android.os.Parcel;
import android.os.Parcelable;
-import android.util.Log;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -34,7 +33,6 @@ public class PostFilter implements Parcelable {
public static boolean isPostAllowed(Post post, PostFilter postFilter) {
if (postFilter == null || post == null) {
- Log.i("asdasfd", "s " + post.getTitle());
return true;
}
if (post.isNSFW() && !postFilter.allowNSFW) {
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 defbb0a5..fd76f4f7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -196,6 +196,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mDisableImagePreview = false;
private boolean mMarkPostsAsRead;
private boolean mMarkPostsAsReadAfterVoting;
+ private boolean mHideReadPostsAutomatically;
private Drawable mCommentIcon;
private NetworkState networkState;
private ExoCreator mExoCreator;
@@ -260,6 +261,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mMarkPostsAsRead = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
mMarkPostsAsReadAfterVoting = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false);
+ mHideReadPostsAutomatically = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false);
mPostLayout = postLayout;
@@ -401,7 +403,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Post post = getItem(position);
if (post != null) {
if (post.isRead()) {
- if (position < mHideReadPostsIndex) {
+ if (mHideReadPostsAutomatically || position < mHideReadPostsIndex) {
post.hidePostInRecyclerView();
holder.itemView.setVisibility(View.GONE);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
@@ -723,7 +725,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Post post = getItem(position);
if (post != null) {
if (post.isRead()) {
- if (position < mHideReadPostsIndex) {
+ if (mHideReadPostsAutomatically || position < mHideReadPostsIndex) {
post.hidePostInRecyclerView();
holder.itemView.setVisibility(View.GONE);
ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
index eebfe17f..5d5a9e16 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java
@@ -39,6 +39,10 @@ public class PostHistoryFragment extends Fragment {
LinearLayout markPostsAsReadAfterVotingLinearLayout;
@BindView(R.id.mark_posts_as_read_after_voting_switch_post_history_fragment)
SwitchMaterial markPostsAsReadAfterVotingSwitch;
+ @BindView(R.id.hide_read_posts_automatically_linear_layout_post_history_fragment)
+ LinearLayout hideReadPostsAutomaticallyLinearLayout;
+ @BindView(R.id.hide_read_posts_automatically_switch_post_history_fragment)
+ SwitchMaterial hideReadPostsAutomaticallySwitch;
@Inject
@Named("post_history")
SharedPreferences postHistorySharedPreferences;
@@ -67,25 +71,27 @@ public class PostHistoryFragment extends Fragment {
}
markPostsAsReadSwitch.setChecked(postHistorySharedPreferences.getBoolean(
- (accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false));
+ accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false));
markPostsAsReadAfterVotingSwitch.setChecked(postHistorySharedPreferences.getBoolean(
- (accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false));
+ accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false));
+ hideReadPostsAutomaticallySwitch.setChecked(postHistorySharedPreferences.getBoolean(
+ accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
markPostsAsReadLinearLayout.setOnClickListener(view -> {
markPostsAsReadSwitch.performClick();
});
markPostsAsReadSwitch.setOnCheckedChangeListener((compoundButton, b) ->
- postHistorySharedPreferences.edit().putBoolean((accountName == null ? "" : accountName)
- + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, b).apply());
+ postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, b).apply());
- markPostsAsReadAfterVotingLinearLayout.setOnClickListener(view -> {
- markPostsAsReadAfterVotingSwitch.performClick();
- });
+ markPostsAsReadAfterVotingLinearLayout.setOnClickListener(view -> markPostsAsReadAfterVotingSwitch.performClick());
markPostsAsReadAfterVotingSwitch.setOnCheckedChangeListener((compoundButton, b) ->
- postHistorySharedPreferences.edit().putBoolean((accountName == null ? "" : accountName)
- + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply());
+ postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply());
+
+ hideReadPostsAutomaticallyLinearLayout.setOnClickListener(view -> hideReadPostsAutomaticallySwitch.performClick());
+
+ hideReadPostsAutomaticallySwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply());
return rootView;
}
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 72d85aa6..1f3fab50 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -221,6 +221,7 @@ public class SharedPreferencesUtils {
public static final String POST_HISTORY_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.post_history";
public static final String MARK_POSTS_AS_READ_BASE = "_mark_posts_as_read";
public static final String MARK_POSTS_AS_READ_AFTER_VOTING_BASE = "_mark_posts_as_read_after_voting";
+ public static final String HIDE_READ_POSTS_AUTOMATICALLY_BASE = "_hide_read_posts_automatically";
//Legacy Settings
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";