aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeNSFWBlurEvent.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndBlurringFragment.java)31
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
12 files changed, 90 insertions, 29 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 8fa5d081..4af5a6c7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -80,7 +80,7 @@ import ml.docilealligator.infinityforreddit.settings.GesturesAndButtonsPreferenc
import ml.docilealligator.infinityforreddit.settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.MiscellaneousPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.NotificationPreferenceFragment;
-import ml.docilealligator.infinityforreddit.settings.NsfwAndBlurringFragment;
+import ml.docilealligator.infinityforreddit.settings.NsfwAndSpoilerFragment;
import ml.docilealligator.infinityforreddit.settings.PostHistoryFragment;
import ml.docilealligator.infinityforreddit.settings.SecurityPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.ThemePreferenceFragment;
@@ -224,7 +224,7 @@ public interface AppComponent {
void inject(SecurityPreferenceFragment securityPreferenceFragment);
- void inject(NsfwAndBlurringFragment nsfwAndBlurringFragment);
+ void inject(NsfwAndSpoilerFragment nsfwAndSpoilerFragment);
void inject(CustomizeBottomAppBarFragment customizeBottomAppBarFragment);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
index 5e536223..0ba911c8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
@@ -32,6 +32,7 @@ public class LinkResolverActivity extends AppCompatActivity {
public static final String EXTRA_IS_NSFW = "EIN";
private static final String POST_PATTERN = "/r/\\w+/comments/\\w+/?\\w+/?";
+ private static final String POST_PATTERN_2 = "/(u|U|user)/\\w+/comments/\\w+/?\\w+/?";
private static final String COMMENT_PATTERN = "/(r|u|U|user)/\\w+/comments/\\w+/?\\w+/\\w+/?";
private static final String SUBREDDIT_PATTERN = "/[rR]/[\\w-]+/?";
private static final String USER_PATTERN = "/(u|U|user)/[\\w-]+/?";
@@ -125,7 +126,7 @@ public class LinkResolverActivity extends AppCompatActivity {
} else if (path.isEmpty()) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
- } else if (path.matches(POST_PATTERN)) {
+ } else if (path.matches(POST_PATTERN) || path.matches(POST_PATTERN_2)) {
int commentsIndex = segments.lastIndexOf("comments");
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
index e19b5fa9..c1183636 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
@@ -33,7 +33,7 @@ import ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.GesturesAndButtonsPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.InterfacePreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.MainPreferenceFragment;
-import ml.docilealligator.infinityforreddit.settings.NsfwAndBlurringFragment;
+import ml.docilealligator.infinityforreddit.settings.NsfwAndSpoilerFragment;
import ml.docilealligator.infinityforreddit.settings.PostHistoryFragment;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -155,8 +155,8 @@ public class SettingsActivity extends BaseActivity implements
pref.getFragment());
if (fragment instanceof CustomizeMainPageTabsFragment) {
args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName);
- } else if (fragment instanceof NsfwAndBlurringFragment) {
- args.putString(NsfwAndBlurringFragment.EXTRA_ACCOUNT_NAME, mAccountName);
+ } else if (fragment instanceof NsfwAndSpoilerFragment) {
+ args.putString(NsfwAndSpoilerFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof CustomizeBottomAppBarFragment) {
args.putString(CustomizeBottomAppBarFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof PostHistoryFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index 078d782f..4577cb96 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -69,6 +69,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
public static final String EXTRA_MESSAGE_FULLNAME = "ENI";
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
public static final String EXTRA_POST_FRAGMENT_ID = "EPFI";
+ public static final String EXTRA_IS_NSFW_SUBREDDIT = "EINS";
public static final int EDIT_COMMENT_REQUEST_CODE = 3;
public static final int GIVE_AWARD_REQUEST_CODE = 100;
@State
@@ -108,6 +109,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private int postListPosition = -1;
private int orientation;
private boolean mVolumeKeysNavigateComments;
+ private boolean isNsfwSubreddit;
@Override
@@ -163,6 +165,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
EventBus.getDefault().post(new NeedForPostListFromPostFragmentEvent(postFragmentId));
}
+ isNsfwSubreddit = getIntent().getBooleanExtra(EXTRA_IS_NSFW_SUBREDDIT, false);
+
fragmentManager = getSupportFragmentManager();
if (savedInstanceState == null) {
@@ -258,6 +262,10 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
}
+ public boolean isNsfwSubreddit() {
+ return isNsfwSubreddit;
+ }
+
private void editComment(String commentAuthor, String commentContentMarkdown, int position) {
if (sectionsPagerAdapter != null) {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 15c0071d..e0a9ab7a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -201,6 +201,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private String subredditName;
private boolean mFetchSubredditInfoSuccess = false;
private int mNCurrentOnlineSubscribers = 0;
+ private boolean isNsfwSubreddit = false;
private boolean subscriptionReady = false;
private boolean isInLazyMode = false;
private boolean showToast = false;
@@ -364,6 +365,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
.get(SubredditViewModel.class);
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
if (subredditData != null) {
+ isNsfwSubreddit = subredditData.isNSFW();
+
if (subredditData.getBannerUrl().equals("")) {
iconGifImageView.setOnClickListener(view -> {
//Do nothing as it has no image
@@ -1111,6 +1114,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
EventBus.getDefault().unregister(this);
}
+ public boolean isNsfwSubreddit() {
+ return isNsfwSubreddit;
+ }
+
private void makeSnackbar(int resId, boolean retry) {
if (showToast) {
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
index bfa2e0b1..8b779730 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
@@ -164,6 +164,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private String mSingleCommentId;
private boolean mIsSingleCommentThreadMode;
private boolean mNeedBlurNsfw;
+ private boolean mDoNotBlurNsfwInNsfwSubreddits;
private boolean mNeedBlurSpoiler;
private boolean mVoteButtonsOnTheRight;
private boolean mShowElapsedTime;
@@ -476,6 +477,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
mNeedBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ mDoNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
@@ -1540,7 +1542,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
});
- if ((mPost.isNSFW() && mNeedBlurNsfw && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
+ if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else {
if (mImageViewWidth > preview.getPreviewWidth()) {
@@ -1571,7 +1573,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
});
- if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
+ if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} else {
@@ -1603,7 +1605,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
});
- if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
+ if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostDetailLinkViewHolder) holder).mImageView);
} else {
@@ -1635,7 +1637,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
});
- if ((mPost.isNSFW() && mNeedBlurNsfw && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
+ if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailGalleryViewHolder) holder).mImageView);
} else {
if (mImageViewWidth > preview.getPreviewWidth()) {
@@ -1870,8 +1872,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
}
- public void setBlurNSFW(boolean needBlurNSFW) {
- mNeedBlurNsfw = needBlurNSFW;
+ public void setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(boolean needBlurNsfw, boolean doNotBlurNsfwInNsfwSubreddits) {
+ mNeedBlurNsfw = needBlurNsfw;
+ mDoNotBlurNsfwInNsfwSubreddits = doNotBlurNsfwInNsfwSubreddits;
}
public void setBlurSpoiler(boolean needBlurSpoiler) {
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 ab431025..99df68d9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -186,7 +186,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private float mScale;
private boolean mDisplaySubredditName;
private boolean mVoteButtonsOnTheRight;
- private boolean mNeedBlurNSFW;
+ private boolean mNeedBlurNsfw;
+ private boolean mDoNotBlurNsfwInNsfwSubreddits;
private boolean mNeedBlurSpoiler;
private boolean mShowElapsedTime;
private String mTimeFormatPattern;
@@ -240,7 +241,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
- mNeedBlurNSFW = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ mNeedBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ mDoNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
@@ -1501,7 +1503,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
});
- if ((post.isNSFW() && mNeedBlurNSFW && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
+ if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else {
@@ -1535,7 +1537,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
return false;
}
});
- if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
+ if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder
.transform(new BlurTransformation(50, 2)).into(((PostCompactBaseViewHolder) holder).imageView);
} else {
@@ -1570,7 +1572,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
});
- if ((post.isNSFW() && mNeedBlurNSFW && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
+ if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostGalleryViewHolder) holder).imageView);
} else {
@@ -1608,7 +1610,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
});
- if ((post.isNSFW() && mNeedBlurNSFW && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
+ if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostCard2WithPreviewViewHolder) holder).imageView);
} else {
@@ -1668,8 +1670,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mPostLayout = postLayout;
}
- public void setBlurNSFW(boolean needBlurNSFW) {
- mNeedBlurNSFW = needBlurNSFW;
+ public void setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(boolean needBlurNsfw, boolean doNotBlurNsfwInNsfwSubreddits) {
+ mNeedBlurNsfw = needBlurNsfw;
+ mDoNotBlurNsfwInNsfwSubreddits = doNotBlurNsfwInNsfwSubreddits;
}
public void setBlurSpoiler(boolean needBlurSpoiler) {
@@ -2023,6 +2026,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_FRAGMENT_ID, mFragment.getPostFragmentId());
+ intent.putExtra(ViewPostDetailActivity.EXTRA_IS_NSFW_SUBREDDIT, mFragment.getIsNsfwSubreddit());
mActivity.startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeNSFWBlurEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeNSFWBlurEvent.java
index cc4f5987..4087be05 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeNSFWBlurEvent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeNSFWBlurEvent.java
@@ -2,8 +2,10 @@ package ml.docilealligator.infinityforreddit.events;
public class ChangeNSFWBlurEvent {
public boolean needBlurNSFW;
+ public boolean doNotBlurNsfwInNsfwSubreddits;
- public ChangeNSFWBlurEvent(boolean needBlurNSFW) {
+ public ChangeNSFWBlurEvent(boolean needBlurNSFW, boolean doNotBlurNsfwInNsfwSubreddits) {
this.needBlurNSFW = needBlurNSFW;
+ this.doNotBlurNsfwInNsfwSubreddits = doNotBlurNsfwInNsfwSubreddits;
}
}
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 cc7b9bfc..8400985b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -75,6 +75,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
+import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.adapters.PostRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.CustomToroContainer;
@@ -1476,6 +1477,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ public boolean getIsNsfwSubreddit() {
+ if (activity instanceof ViewSubredditDetailActivity) {
+ return ((ViewSubredditDetailActivity) activity).isNsfwSubreddit();
+ } else {
+ return false;
+ }
+ }
+
@Subscribe
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
PagedList<Post> posts = mAdapter.getCurrentList();
@@ -1522,7 +1531,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Subscribe
public void onChangeNSFWBlurEvent(ChangeNSFWBlurEvent event) {
if (mAdapter != null) {
- mAdapter.setBlurNSFW(event.needBlurNSFW);
+ mAdapter.setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(event.needBlurNSFW, event.doNotBlurNsfwInNsfwSubreddits);
refreshAdapter();
}
}
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 97d55b66..e9fb018c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java
@@ -1664,6 +1664,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
});
}
+ public boolean getIsNsfwSubreddit() {
+ if (activity != null) {
+ return activity.isNsfwSubreddit();
+ }
+ return false;
+ }
+
@Subscribe
public void onPostUpdateEvent(PostUpdateEventToDetailActivity event) {
if (mPost.getId().equals(event.post.getId())) {
@@ -1682,7 +1689,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
@Subscribe
public void onChangeNSFWBlurEvent(ChangeNSFWBlurEvent event) {
- mAdapter.setBlurNSFW(event.needBlurNSFW);
+ mAdapter.setBlurNsfwAndDoNotBlurNsfwInNsfwSubreddits(event.needBlurNSFW, event.doNotBlurNsfwInNsfwSubreddits);
refreshAdapter();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndBlurringFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
index a4373a70..99affad3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndBlurringFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java
@@ -22,14 +22,14 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.events.ChangeSpoilerBlurEvent;
-import ml.docilealligator.infinityforreddit.Infinity;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-public class NsfwAndBlurringFragment extends Fragment {
+public class NsfwAndSpoilerFragment extends Fragment {
public static final String EXTRA_ACCOUNT_NAME = "EAN";
@@ -41,6 +41,10 @@ public class NsfwAndBlurringFragment extends Fragment {
LinearLayout blurNsfwLinearLayout;
@BindView(R.id.blur_nsfw_switch_nsfw_and_spoiler_fragment)
SwitchMaterial blurNsfwSwitchMaterial;
+ @BindView(R.id.do_not_blur_nsfw_in_nsfw_subreddits_linear_layout_nsfw_and_spoiler_fragment)
+ LinearLayout doNotBlurNsfwInNsfwSubredditsLinearLayout;
+ @BindView(R.id.do_not_blur_nsfw_in_nsfw_subreddits_switch_nsfw_and_spoiler_fragment)
+ SwitchMaterial doNotBlurNsfwInNsfwSubredditsSwitch;
@BindView(R.id.blur_spoiler_linear_layout_nsfw_and_spoiler_fragment)
LinearLayout blurSpoilerLinearLayout;
@BindView(R.id.blur_spoiler_switch_nsfw_and_spoiler_fragment)
@@ -50,8 +54,10 @@ public class NsfwAndBlurringFragment extends Fragment {
SharedPreferences nsfwAndBlurringSharedPreferences;
private Activity activity;
+ private boolean blurNsfw;
+ private boolean doNotBlurNsfwInNsfwSubreddits;
- public NsfwAndBlurringFragment() {
+ public NsfwAndSpoilerFragment() {
// Required empty public constructor
}
@@ -68,15 +74,18 @@ public class NsfwAndBlurringFragment extends Fragment {
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
boolean enableNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
- boolean blurNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ blurNsfw = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
+ doNotBlurNsfwInNsfwSubreddits = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
boolean blurSpoiler = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
if (enableNsfw) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
+ doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE);
}
enableNsfwSwitchMaterial.setChecked(enableNsfw);
blurNsfwSwitchMaterial.setChecked(blurNsfw);
+ doNotBlurNsfwInNsfwSubredditsSwitch.setChecked(doNotBlurNsfwInNsfwSubreddits);
blurSpoilerSwitchMaterial.setChecked(blurSpoiler);
enableNsfwLinearLayout.setOnClickListener(view -> enableNsfwSwitchMaterial.performClick());
@@ -84,8 +93,10 @@ public class NsfwAndBlurringFragment extends Fragment {
nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
if (b) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
+ doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE);
} else {
blurNsfwLinearLayout.setVisibility(View.GONE);
+ doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.GONE);
}
EventBus.getDefault().post(new ChangeNSFWEvent(b));
});
@@ -93,7 +104,15 @@ public class NsfwAndBlurringFragment extends Fragment {
blurNsfwLinearLayout.setOnClickListener(view -> blurNsfwSwitchMaterial.performClick());
blurNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply();
- EventBus.getDefault().post(new ChangeNSFWBlurEvent(b));
+ EventBus.getDefault().post(new ChangeNSFWBlurEvent(b, doNotBlurNsfwInNsfwSubreddits));
+ });
+
+ doNotBlurNsfwInNsfwSubredditsLinearLayout.setOnClickListener(view -> {
+ doNotBlurNsfwInNsfwSubredditsSwitch.performClick();
+ });
+ doNotBlurNsfwInNsfwSubredditsSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
+ nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, b).apply();
+ EventBus.getDefault().post(new ChangeNSFWBlurEvent(blurNsfw, b));
});
blurSpoilerLinearLayout.setOnClickListener(view -> blurSpoilerSwitchMaterial.performClick());
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 e1089706..1d2ba964 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -274,6 +274,7 @@ public class SharedPreferencesUtils {
public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
public static final String NSFW_BASE = "_nsfw";
public static final String BLUR_NSFW_BASE = "_blur_nsfw";
+ public static final String DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS = "do_not_blur_nsfw_in_nsfw_subreddits";
public static final String BLUR_SPOILER_BASE = "_blur_spoiler";
public static final String POST_HISTORY_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.post_history";