aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-09-17 07:04:37 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-09-17 07:04:37 +0000
commitee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd (patch)
tree70eef13261988a993f4324d7e2cc17ba74d8e618 /app
parent3592dc29dabe1fbc41f4af5536e395987963c810 (diff)
downloadinfinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar.gz
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar.bz2
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar.lz
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar.xz
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.tar.zst
infinity-for-reddit-ee5fc0a5fc652c9e0b83b4f82ec80f1ec81380fd.zip
Unbluring NSFW images is now an option in settings.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/Settings/MainPreferenceFragment.java95
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWBlurEvent.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWEvent.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java27
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/xml/main_preferences.xml6
11 files changed, 153 insertions, 46 deletions
diff --git a/app/src/main/java/Settings/MainPreferenceFragment.java b/app/src/main/java/Settings/MainPreferenceFragment.java
index fbe97347..11093bf6 100644
--- a/app/src/main/java/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/Settings/MainPreferenceFragment.java
@@ -1,6 +1,8 @@
package Settings;
+import android.app.Activity;
+import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
@@ -11,7 +13,11 @@ import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
+import javax.inject.Inject;
+
+import ml.docilealligator.infinityforreddit.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.ChangeNSFWEvent;
+import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SharedPreferencesUtils;
@@ -25,47 +31,74 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
*/
public class MainPreferenceFragment extends PreferenceFragmentCompat {
+ @Inject
+ SharedPreferences sharedPreferences;
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.main_preferences, rootKey);
- SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
- ListPreference listPreference = findPreference(SharedPreferencesUtils.THEME_KEY);
+ Activity activity = getActivity();
+ if(activity != null) {
+ ((Infinity) activity.getApplication()).getAppComponent().inject(this);
- if(nsfwSwitch != null) {
- nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
- EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
- return true;
- });
- }
+ SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
+ SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
+ ListPreference listPreference = findPreference(SharedPreferencesUtils.THEME_KEY);
+
+ if(nsfwSwitch != null) {
+ nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
+ if(blurNSFWSwitch != null) {
+ blurNSFWSwitch.setVisible((Boolean) newValue);
+ }
+ return true;
+ });
+ }
- boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+ if(blurNSFWSwitch != null) {
+ boolean nsfwEnabled = sharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
- if(listPreference != null) {
- if(systemDefault) {
- listPreference.setEntries(R.array.settings_theme_q);
- } else {
- listPreference.setEntries(R.array.settings_theme);
+ if(nsfwEnabled) {
+ blurNSFWSwitch.setVisible(true);
+ } else {
+ blurNSFWSwitch.setVisible(false);
+ }
+
+ blurNSFWSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeNSFWBlurEvent((Boolean) newValue));
+ return true;
+ });
}
- listPreference.setOnPreferenceChangeListener((preference, newValue) -> {
- int option = Integer.parseInt((String) newValue);
- switch (option) {
- case 0:
- AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
- break;
- case 1:
- AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
- break;
- case 2:
- if(systemDefault) {
- AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
- } else {
- AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
- }
+ boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+
+ if(listPreference != null) {
+ if(systemDefault) {
+ listPreference.setEntries(R.array.settings_theme_q);
+ } else {
+ listPreference.setEntries(R.array.settings_theme);
}
- return true;
- });
+
+ listPreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ int option = Integer.parseInt((String) newValue);
+ switch (option) {
+ case 0:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
+ break;
+ case 1:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
+ break;
+ case 2:
+ if(systemDefault) {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
+ }
+ }
+ return true;
+ });
+ }
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 0c66bcf3..2e6617f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit;
import javax.inject.Singleton;
+import Settings.MainPreferenceFragment;
import Settings.NotificationPreferenceFragment;
import dagger.Component;
@@ -41,4 +42,5 @@ public interface AppComponent {
void inject(LinkResolverActivity linkResolverActivity);
void inject(SearchActivity searchActivity);
void inject(SettingsActivity settingsActivity);
+ void inject(MainPreferenceFragment mainPreferenceFragment);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWBlurEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWBlurEvent.java
new file mode 100644
index 00000000..506c1627
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWBlurEvent.java
@@ -0,0 +1,8 @@
+package ml.docilealligator.infinityforreddit;
+
+public class ChangeNSFWBlurEvent {
+ public boolean needBlurNSFW;
+ public ChangeNSFWBlurEvent(boolean needBlurNSFW) {
+ this.needBlurNSFW = needBlurNSFW;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWEvent.java
index ee3b182b..5d4b5a5c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWEvent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ChangeNSFWEvent.java
@@ -1,7 +1,7 @@
package ml.docilealligator.infinityforreddit;
public class ChangeNSFWEvent {
- boolean nsfw;
+ public boolean nsfw;
public ChangeNSFWEvent(boolean nsfw) {
this.nsfw = nsfw;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
index 28249f40..158e48a0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
@@ -78,6 +78,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
private Locale mLocale;
private String mSingleCommentId;
private boolean mIsSingleCommentThreadMode;
+ private boolean mNeedBlurNSFW;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -94,7 +95,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
String accessToken, String accountName, Post post,
Locale locale, String singleCommentId, boolean isSingleCommentThreadMode,
- CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
+ boolean needBlurNSFW, CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity;
mRetrofit = retrofit;
mOauthRetrofit = oauthRetrofit;
@@ -127,6 +128,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
mLocale = locale;
mSingleCommentId = singleCommentId;
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
+ mNeedBlurNSFW = needBlurNSFW;
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
@@ -761,7 +763,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
}
});
- if(mPost.isNSFW()) {
+ if(mPost.isNSFW() && mNeedBlurNSFW) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 2)))
.into(holder.mImageView);
} else {
@@ -977,6 +979,10 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
}
}
+ void setBlurNSFW(boolean needBlurNSFW) {
+ mNeedBlurNSFW = needBlurNSFW;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof CommentViewHolder) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index 2bb47053..67a0b247 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -258,6 +258,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
int filter = getArguments().getInt(EXTRA_FILTER);
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
+ boolean needBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
PostViewModel.Factory factory;
@@ -266,7 +267,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String query = getArguments().getString(EXTRA_QUERY);
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, true, new PostRecyclerViewAdapter.Callback() {
+ accessToken, postType, true, needBlurNsfw, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -298,7 +299,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, displaySubredditName, new PostRecyclerViewAdapter.Callback() {
+ accessToken, postType, displaySubredditName, needBlurNsfw, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -334,7 +335,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, true, new PostRecyclerViewAdapter.Callback() {
+ accessToken, postType, true, needBlurNsfw, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -363,7 +364,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
} else {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, true, new PostRecyclerViewAdapter.Callback() {
+ accessToken, postType, true, needBlurNsfw, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -553,6 +554,29 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeNSFWBlurEvent(ChangeNSFWBlurEvent event) {
+ mAdapter.setBlurNSFW(event.needBlurNSFW);
+
+ int previousPosition = -1;
+ if(mLinearLayoutManager != null) {
+ previousPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
+ } else if(mStaggeredGridLayoutManager != null) {
+ int[] into = new int[2];
+ previousPosition = mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[0];
+ }
+
+ RecyclerView.LayoutManager layoutManager = mPostRecyclerView.getLayoutManager();
+ mPostRecyclerView.setAdapter(null);
+ mPostRecyclerView.setLayoutManager(null);
+ mPostRecyclerView.setAdapter(mAdapter);
+ mPostRecyclerView.setLayoutManager(layoutManager);
+
+ if(previousPosition > 0) {
+ mPostRecyclerView.scrollToPosition(previousPosition);
+ }
+ }
+
@Override
public void onStart() {
super.onStart();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
index 04a81c87..e671bda5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
@@ -40,7 +40,6 @@ import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import CustomView.AspectRatioGifImageView;
-import SubredditDatabase.SubredditDao;
import User.UserDao;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -59,11 +58,11 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
private String mAccessToken;
private RequestManager mGlide;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
- private SubredditDao mSubredditDao;
private UserDao mUserDao;
private boolean canStartActivity = true;
private int mPostType;
private boolean mDisplaySubredditName;
+ private boolean mNeedBlurNSFW;
private static final int VIEW_TYPE_DATA = 0;
private static final int VIEW_TYPE_ERROR = 1;
@@ -80,7 +79,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, int postType,
- boolean displaySubredditName, Callback callback) {
+ boolean displaySubredditName, boolean needBlurNSFW, Callback callback) {
super(DIFF_CALLBACK);
if(context != null) {
mContext = context;
@@ -89,9 +88,9 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
+ mNeedBlurNSFW = needBlurNSFW;
mGlide = Glide.with(mContext.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
- mSubredditDao = redditDataRoomDatabase.subredditDao();
mUserDao = redditDataRoomDatabase.userDao();
mCallback = callback;
}
@@ -652,7 +651,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
}
});
- if(post.isNSFW()) {
+ if(post.isNSFW() && mNeedBlurNSFW) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 2)))
.into(((DataViewHolder) holder).imageView);
} else {
@@ -682,6 +681,10 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
return super.getItemCount();
}
+ void setBlurNSFW(boolean needBlurNSFW) {
+ mNeedBlurNSFW = needBlurNSFW;
+ }
+
private boolean hasExtraRow() {
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
index 6c4ca027..e3103796 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
@@ -9,6 +9,7 @@ public class SharedPreferencesUtils {
public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval";
public static final String LAZY_MODE_INTERVAL_KEY = "lazy_mode_interval";
public static final String NSFW_KEY = "nsfw";
+ public static final String BLUR_NSFW_KEY = "blur_nsfw";
public static final String THEME_KEY = "theme";
public static final String ICON_FOREGROUND_KEY = "icon_foreground";
public static final String ICON_BACKGROUND_KEY = "icon_background";
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index 04e013fe..3063e0c0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -79,6 +79,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
private int orientation;
private int postListPosition = -1;
private String mSingleCommentId;
+ private boolean mNeedBlurNsfw;
@State
boolean mNullAccessToken = false;
@@ -216,6 +217,8 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
toolbar.setTitle("");
setSupportActionBar(toolbar);
+ mNeedBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
+
mGlide = Glide.with(this);
mLocale = getResources().getConfiguration().locale;
@@ -359,7 +362,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mRetrofit,
mOauthRetrofit, mRedditDataRoomDatabase, mGlide, mAccessToken, mAccountName, mPost,
- mLocale, mSingleCommentId, isSingleCommentThreadMode,
+ mLocale, mSingleCommentId, isSingleCommentThreadMode, mNeedBlurNsfw,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -471,7 +474,7 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this,
mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
- isSingleCommentThreadMode,
+ isSingleCommentThreadMode, mNeedBlurNsfw,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -902,6 +905,26 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
}
@Subscribe
+ public void onChangeNSFWBlurEvent(ChangeNSFWBlurEvent event) {
+ mAdapter.setBlurNSFW(event.needBlurNSFW);
+
+ int previousPosition = -1;
+ if(mLinearLayoutManager != null) {
+ previousPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
+ }
+
+ RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
+ mRecyclerView.setAdapter(null);
+ mRecyclerView.setLayoutManager(null);
+ mRecyclerView.setAdapter(mAdapter);
+ mRecyclerView.setLayoutManager(layoutManager);
+
+ if(previousPosition > 0) {
+ mRecyclerView.scrollToPosition(previousPosition);
+ }
+ }
+
+ @Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) {
if(!getClass().getName().equals(event.excludeActivityClassName)) {
finish();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b5b5e949..774871ce 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -273,7 +273,8 @@
<string name="settings_theme_system_default_summary">Device default</string>
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
<string name="settings_enable_nsfw_title">Enable NSFW</string>
- <string name="settings_layout_no_limits_title">Display under navigation bar and status bar</string>
+ <string name="settings_blur_nsfw_title">Blur NSFW images</string>
+ <string name="settings_layout_no_limits_title">Display Under Navigation bar and Status Bar</string>
<string name="settings_about_master_title">About</string>
<string name="settings_acknowledgement_master_title">Acknowledgement</string>
<string name="settings_credits_master_title">Credits</string>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index e8ed98d8..80df0c11 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -29,6 +29,12 @@
app:key="nsfw"
app:title="@string/settings_enable_nsfw_title" />
+ <SwitchPreference
+ app:defaultValue="true"
+ app:key="blur_nsfw"
+ app:title="@string/settings_blur_nsfw_title"
+ app:isPreferenceVisible="false" />
+
<Preference
app:title="@string/settings_about_master_title"
app:fragment="Settings.AboutPreferenceFragment" />