Set NSFW, NSFW blurring and spoiler blurring on a per-user basis. Only close the account section in the navigation drawer after dismissing if the account section is open.

This commit is contained in:
Alex Ning 2020-09-23 19:20:41 +08:00
parent d730b719b8
commit 396501e350
17 changed files with 323 additions and 99 deletions

View File

@ -176,6 +176,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Named("main_activity_tabs") @Named("main_activity_tabs")
SharedPreferences mMainActivityTabsSharedPreferences; SharedPreferences mMainActivityTabsSharedPreferences;
@Inject @Inject
@Named("nsfw_and_spoiler")
SharedPreferences mNsfwAndSpoilerSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
@ -264,8 +267,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public void onDrawerClosed(View drawerView) { public void onDrawerClosed(View drawerView) {
if (adapter != null) { if (adapter != null) {
adapter.closeAccountSectionWithoutChangeIconResource(); if (adapter.closeAccountSectionWithoutChangeIconResource(true)) {
adapter.notifyItemChanged(0); adapter.notifyItemChanged(0);
}
} }
} }
}); });
@ -480,7 +484,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
adapter = new NavigationDrawerRecyclerViewAdapter(this, mSharedPreferences, adapter = new NavigationDrawerRecyclerViewAdapter(this, mSharedPreferences,
mCustomThemeWrapper, mAccountName, mNsfwAndSpoilerSharedPreferences, mCustomThemeWrapper, mAccountName,
mProfileImageUrl, mBannerImageUrl, mKarma, mProfileImageUrl, mBannerImageUrl, mKarma,
new NavigationDrawerRecyclerViewAdapter.ItemClickListener() { new NavigationDrawerRecyclerViewAdapter.ItemClickListener() {
@Override @Override
@ -536,13 +540,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
break; break;
case R.string.enable_nsfw: case R.string.enable_nsfw:
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
mSharedPreferences.edit().putBoolean(SharedPreferencesUtils.NSFW_KEY, true).apply(); mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, true).apply();
sectionsPagerAdapter.changeNSFW(true); sectionsPagerAdapter.changeNSFW(true);
} }
break; break;
case R.string.disable_nsfw: case R.string.disable_nsfw:
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {
mSharedPreferences.edit().putBoolean(SharedPreferencesUtils.NSFW_KEY, false).apply(); mNsfwAndSpoilerSharedPreferences.edit().putBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false).apply();
sectionsPagerAdapter.changeNSFW(false); sectionsPagerAdapter.changeNSFW(false);
} }
break; break;

View File

@ -238,7 +238,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
tab.setText(R.string.posts); tab.setText(R.string.posts);
break; break;
case 1: case 1:
tab.setText(R.string.comments); tab.setText(R.string.subreddits);
break; break;
case 2: case 2:
tab.setText(R.string.users); tab.setText(R.string.users);

View File

@ -33,6 +33,7 @@ import ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.NsfwAndBlurringFragment;
public class SettingsActivity extends BaseActivity implements public class SettingsActivity extends BaseActivity implements
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback { PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
@ -159,6 +160,8 @@ public class SettingsActivity extends BaseActivity implements
pref.getFragment()); pref.getFragment());
if (fragment instanceof CustomizeMainPageTabsFragment) { if (fragment instanceof CustomizeMainPageTabsFragment) {
args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName); args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof NsfwAndBlurringFragment) {
args.putString(NsfwAndBlurringFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} }
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(caller, 0); fragment.setTargetFragment(caller, 0);

View File

@ -195,6 +195,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@Named("sort_type") @Named("sort_type")
SharedPreferences mSortTypeSharedPreferences; SharedPreferences mSortTypeSharedPreferences;
@Inject @Inject
@Named("nsfw_and_spoiler")
SharedPreferences mNsfwAndSpoilerSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
@Inject @Inject
ExoCreator mExoCreator; ExoCreator mExoCreator;
@ -623,7 +626,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide, mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mSharedPreferences, mExoCreator, isSingleCommentThreadMode, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mExoCreator,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override @Override
public void updatePost(Post post) { public void updatePost(Post post) {
@ -786,7 +789,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide, mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide,
mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, mWindowWidth, mAccessToken, mAccountName, mPost, mLocale,
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences, mExoCreator, mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
mNsfwAndSpoilerSharedPreferences, mExoCreator,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() { new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override @Override
public void updatePost(Post post) { public void updatePost(Post post) {

View File

@ -240,7 +240,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
int imageViewWidth, String accessToken, String accountName, int imageViewWidth, String accessToken, String accountName,
Post post, Locale locale, String singleCommentId, Post post, Locale locale, String singleCommentId,
boolean isSingleCommentThreadMode, boolean isSingleCommentThreadMode,
SharedPreferences sharedPreferences, ExoCreator exoCreator, SharedPreferences sharedPreferences,
SharedPreferences nsfwAndSpoilerSharedPreferences, ExoCreator exoCreator,
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) { CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity; mActivity = activity;
mRetrofit = retrofit; mRetrofit = retrofit;
@ -449,8 +450,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mSingleCommentId = singleCommentId; mSingleCommentId = singleCommentId;
mIsSingleCommentThreadMode = isSingleCommentThreadMode; mIsSingleCommentThreadMode = isSingleCommentThreadMode;
mNeedBlurNsfw = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true); mNeedBlurNsfw = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false); mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE); mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);

View File

@ -74,6 +74,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
private int primaryIconColor; private int primaryIconColor;
public NavigationDrawerRecyclerViewAdapter(AppCompatActivity appCompatActivity, SharedPreferences sharedPreferences, public NavigationDrawerRecyclerViewAdapter(AppCompatActivity appCompatActivity, SharedPreferences sharedPreferences,
SharedPreferences nsfwAndSpoilerSharedPreferences,
CustomThemeWrapper customThemeWrapper, CustomThemeWrapper customThemeWrapper,
String accountName, String userIconUrl, String accountName, String userIconUrl,
String userBannerUrl, int karma, String userBannerUrl, int karma,
@ -85,7 +86,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
this.userIconUrl = userIconUrl; this.userIconUrl = userIconUrl;
this.userBannerUrl = userBannerUrl; this.userBannerUrl = userBannerUrl;
this.karma = karma; this.karma = karma;
isNSFWEnabled = sharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false); isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false); requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
isLoggedIn = accountName != null; isLoggedIn = accountName != null;
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
@ -223,7 +224,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
} }
} else { } else {
((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_arrow_drop_down_24px, null)); ((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_arrow_drop_down_24px, null));
closeAccountSectionWithoutChangeIconResource(); closeAccountSectionWithoutChangeIconResource(false);
} }
}); });
} else if (holder instanceof MenuGroupTitleViewHolder) { } else if (holder instanceof MenuGroupTitleViewHolder) {
@ -413,18 +414,24 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
} }
} }
public void closeAccountSectionWithoutChangeIconResource() { public boolean closeAccountSectionWithoutChangeIconResource(boolean checkIsInMainPage) {
notifyItemRangeRemoved(1, getItemCount() - 1); if (!(checkIsInMainPage && isInMainPage)) {
if (isLoggedIn) { notifyItemRangeRemoved(1, getItemCount() - 1);
if (subscribedSubreddits != null) { if (isLoggedIn) {
notifyItemRangeInserted(1, subscribedSubreddits.size() + CURRENT_MENU_ITEMS - 1); if (subscribedSubreddits != null) {
notifyItemRangeInserted(1, subscribedSubreddits.size() + CURRENT_MENU_ITEMS - 1);
} else {
notifyItemRangeInserted(1, CURRENT_MENU_ITEMS - 1);
}
} else { } else {
notifyItemRangeInserted(1, CURRENT_MENU_ITEMS - 1); notifyItemRangeInserted(1, 2);
} }
} else { isInMainPage = true;
notifyItemRangeInserted(1, 2);
return true;
} }
isInMainPage = true;
return false;
} }
private void openAccountSection(ImageView dropIconImageView) { private void openAccountSection(ImageView dropIconImageView) {

View File

@ -194,8 +194,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth, CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth,
String accessToken, int postType, int postLayout, boolean displaySubredditName, String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, ExoCreator exoCreator, Callback callback) { SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences,
ExoCreator exoCreator, Callback callback) {
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
if (activity != null) { if (activity != null) {
mActivity = activity; mActivity = activity;
@ -207,8 +208,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAccessToken = accessToken; mAccessToken = accessToken;
mPostType = postType; mPostType = postType;
mDisplaySubredditName = displaySubredditName; mDisplaySubredditName = displaySubredditName;
mNeedBlurNSFW = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true); mNeedBlurNSFW = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, true);
mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false); mNeedBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE); mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);

View File

@ -66,6 +66,7 @@ import ml.docilealligator.infinityforreddit.Settings.DownloadLocationPreferenceF
import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.NsfwAndBlurringFragment;
import ml.docilealligator.infinityforreddit.Settings.SecurityPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.SecurityPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.ThemePreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.ThemePreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.VideoPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.VideoPreferenceFragment;
@ -206,4 +207,6 @@ public interface AppComponent {
void inject(SelectUserFlairActivity selectUserFlairActivity); void inject(SelectUserFlairActivity selectUserFlairActivity);
void inject(SecurityPreferenceFragment securityPreferenceFragment); void inject(SecurityPreferenceFragment securityPreferenceFragment);
void inject(NsfwAndBlurringFragment nsfwAndBlurringFragment);
} }

View File

@ -149,7 +149,6 @@ class AppModule {
.readTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS)); .connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS));
//.addInterceptor(new Okhttp3DebugInterceptor(mApplication));
return okHttpClientBuilder.build(); return okHttpClientBuilder.build();
} }
@ -211,6 +210,12 @@ class AppModule {
return mApplication.getSharedPreferences(SharedPreferencesUtils.MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE); return mApplication.getSharedPreferences(SharedPreferencesUtils.MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
} }
@Provides
@Named("nsfw_and_spoiler")
SharedPreferences provideNsfwAndSpoilerSharedPreferences() {
return mApplication.getSharedPreferences(SharedPreferencesUtils.NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
}
@Provides @Provides
@Singleton @Singleton
CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences, CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences,

View File

@ -159,6 +159,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Named("post_layout") @Named("post_layout")
SharedPreferences mPostLayoutSharedPreferences; SharedPreferences mPostLayoutSharedPreferences;
@Inject @Inject
@Named("nsfw_and_spoiler")
SharedPreferences mNsfwAndSpoilerSharedPreferences;
@Inject
CustomThemeWrapper customThemeWrapper; CustomThemeWrapper customThemeWrapper;
@Inject @Inject
ExoCreator exoCreator; ExoCreator exoCreator;
@ -396,7 +399,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
int filter = getArguments().getInt(EXTRA_FILTER); int filter = getArguments().getInt(EXTRA_FILTER);
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false); boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0")); int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false); savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true); vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
@ -414,8 +417,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
windowWidth, accessToken, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { mSharedPreferences, mNsfwAndSpoilerSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override @Override
public void retryLoadingMore() { public void retryLoadingMore() {
mPostViewModel.retryLoadingMore(); mPostViewModel.retryLoadingMore();
@ -462,8 +465,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
windowWidth, accessToken, postType, postLayout, displaySubredditName, windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { mSharedPreferences, mNsfwAndSpoilerSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override @Override
public void retryLoadingMore() { public void retryLoadingMore() {
mPostViewModel.retryLoadingMore(); mPostViewModel.retryLoadingMore();
@ -511,8 +514,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
windowWidth, accessToken, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { mSharedPreferences, mNsfwAndSpoilerSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override @Override
public void retryLoadingMore() { public void retryLoadingMore() {
mPostViewModel.retryLoadingMore(); mPostViewModel.retryLoadingMore();
@ -558,8 +561,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
windowWidth, accessToken, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { mSharedPreferences, mNsfwAndSpoilerSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override @Override
public void retryLoadingMore() { public void retryLoadingMore() {
mPostViewModel.retryLoadingMore(); mPostViewModel.retryLoadingMore();
@ -598,8 +601,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
windowWidth, accessToken, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() { mSharedPreferences, mNsfwAndSpoilerSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override @Override
public void retryLoadingMore() { public void retryLoadingMore() {
mPostViewModel.retryLoadingMore(); mPostViewModel.retryLoadingMore();

View File

@ -58,6 +58,12 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
@Inject @Inject
@Named("amoled_theme") @Named("amoled_theme")
SharedPreferences amoledThemeSharedPreferences; SharedPreferences amoledThemeSharedPreferences;
@Inject
@Named("main_activity_tabs")
SharedPreferences mainActivityTabsSharedPreferences;
@Inject
@Named("nsfw_and_spoiler")
SharedPreferences nsfwAndBlurringSharedPreferences;
private Activity activity; private Activity activity;
@Override @Override
@ -178,6 +184,9 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME_LEGACY); editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME_LEGACY);
editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME_LEGACY); editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME_LEGACY);
editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME_LEGACY); editor.remove(SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME_LEGACY);
editor.remove(SharedPreferencesUtils.NSFW_KEY_LEGACY);
editor.remove(SharedPreferencesUtils.BLUR_NSFW_KEY_LEGACY);
editor.remove(SharedPreferencesUtils.BLUR_SPOILER_KEY_LEGACY);
SharedPreferences.Editor sortTypeEditor = mSortTypeSharedPreferences.edit(); SharedPreferences.Editor sortTypeEditor = mSortTypeSharedPreferences.edit();
sortTypeEditor.remove(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY); sortTypeEditor.remove(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY);
@ -207,6 +216,9 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
.setPositiveButton(R.string.yes, (dialogInterface, i) .setPositiveButton(R.string.yes, (dialogInterface, i)
-> { -> {
mSharedPreferences.edit().clear().apply(); mSharedPreferences.edit().clear().apply();
mainActivityTabsSharedPreferences.edit().clear().apply();
nsfwAndBlurringSharedPreferences.edit().clear().apply();
Toast.makeText(activity, R.string.reset_all_settings_success, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.reset_all_settings_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new RecreateActivityEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
}) })

View File

@ -17,10 +17,7 @@ import org.greenrobot.eventbus.EventBus;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSavePostFeedScrolledPositionEvent; import ml.docilealligator.infinityforreddit.Event.ChangeSavePostFeedScrolledPositionEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
@ -47,9 +44,6 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY); Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY);
SwitchPreference savePostFeedScrolledPositionSwitch = findPreference(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION); SwitchPreference savePostFeedScrolledPositionSwitch = findPreference(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION);
SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT); SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
if (savePostFeedScrolledPositionSwitch != null) { if (savePostFeedScrolledPositionSwitch != null) {
savePostFeedScrolledPositionSwitch.setOnPreferenceChangeListener((preference, newValue) -> { savePostFeedScrolledPositionSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
@ -68,38 +62,6 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
if (blurNSFWSwitch != null) {
blurNSFWSwitch.setVisible((Boolean) newValue);
}
return true;
});
}
if (blurNSFWSwitch != null) {
boolean nsfwEnabled = sharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
if (nsfwEnabled) {
blurNSFWSwitch.setVisible(true);
} else {
blurNSFWSwitch.setVisible(false);
}
blurNSFWSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWBlurEvent((Boolean) newValue));
return true;
});
}
if (blurSpoilerSwitch != null) {
blurSpoilerSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeSpoilerBlurEvent((Boolean) newValue));
return true;
});
}
BiometricManager biometricManager = BiometricManager.from(activity); BiometricManager biometricManager = BiometricManager.from(activity);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) { if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) {
if (securityPreference != null) { if (securityPreference != null) {

View File

@ -0,0 +1,112 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.greenrobot.eventbus.EventBus;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class NsfwAndBlurringFragment extends Fragment {
public static final String EXTRA_ACCOUNT_NAME = "EAN";
@BindView(R.id.enable_nsfw_linear_layout_nsfw_and_spoiler_fragment)
LinearLayout enableNsfwLinearLayout;
@BindView(R.id.enable_nsfw_switch_nsfw_and_spoiler_fragment)
SwitchMaterial enableNsfwSwitchMaterial;
@BindView(R.id.blur_nsfw_linear_layout_nsfw_and_spoiler_fragment)
LinearLayout blurNsfwLinearLayout;
@BindView(R.id.blur_nsfw_switch_nsfw_and_spoiler_fragment)
SwitchMaterial blurNsfwSwitchMaterial;
@BindView(R.id.blur_spoiler_linear_layout_nsfw_and_spoiler_fragment)
LinearLayout blurSpoilerLinearLayout;
@BindView(R.id.blur_spoiler_switch_nsfw_and_spoiler_fragment)
SwitchMaterial blurSpoilerSwitchMaterial;
@Inject
@Named("nsfw_and_spoiler")
SharedPreferences nsfwAndBlurringSharedPreferences;
private Activity activity;
public NsfwAndBlurringFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_nsfw_and_spoiler, container, false);
((Infinity) activity.getApplication()).getAppComponent().inject(this);
ButterKnife.bind(this, rootView);
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);
boolean blurSpoiler = nsfwAndBlurringSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
if (enableNsfw) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
}
enableNsfwSwitchMaterial.setChecked(enableNsfw);
blurNsfwSwitchMaterial.setChecked(blurNsfw);
blurSpoilerSwitchMaterial.setChecked(blurSpoiler);
enableNsfwLinearLayout.setOnClickListener(view -> enableNsfwSwitchMaterial.performClick());
enableNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply();
if (b) {
blurNsfwLinearLayout.setVisibility(View.VISIBLE);
} else {
blurNsfwLinearLayout.setVisibility(View.GONE);
}
EventBus.getDefault().post(new ChangeNSFWEvent(b));
});
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));
});
blurSpoilerLinearLayout.setOnClickListener(view -> blurSpoilerSwitchMaterial.performClick());
blurSpoilerSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> {
nsfwAndBlurringSharedPreferences.edit().putBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, b).apply();
EventBus.getDefault().post(new ChangeSpoilerBlurEvent(b));
});
return rootView;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
this.activity = (AppCompatActivity) context;
}
}

View File

@ -8,9 +8,6 @@ public class SharedPreferencesUtils {
public static final String ENABLE_NOTIFICATION_KEY = "enable_notification"; public static final String ENABLE_NOTIFICATION_KEY = "enable_notification";
public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval"; public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval";
public static final String LAZY_MODE_INTERVAL_KEY = "lazy_mode_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 BLUR_SPOILER_KEY = "blur_spoiler";
public static final String THEME_KEY = "theme"; public static final String THEME_KEY = "theme";
public static final String ICON_FOREGROUND_KEY = "icon_foreground"; public static final String ICON_FOREGROUND_KEY = "icon_foreground";
public static final String ICON_BACKGROUND_KEY = "icon_background"; public static final String ICON_BACKGROUND_KEY = "icon_background";
@ -127,6 +124,11 @@ public class SharedPreferencesUtils {
public static final String LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT = "long_press_to_hide_toolbar_in_compact_layout"; public static final String LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT = "long_press_to_hide_toolbar_in_compact_layout";
public static final String POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT = "post_compact_layout_toolbar_hidden_by_default"; public static final String POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT = "post_compact_layout_toolbar_hidden_by_default";
public static final String SECURITY = "security"; public static final String SECURITY = "security";
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT = "start_autoplay_visible_area_offset_portrait";
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE = "start_autoplay_visible_area_offset_landscape";
public static final String MUTE_NSFW_VIDEO = "mute_nsfw_video";
public static final String VIDEO_PLAYER_IGNORE_NAV_BAR = "video_player_ignore_nav_bar";
public static final String SAVE_FRONT_PAGE_SCROLLED_POSITION = "save_front_page_scrolled_position";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
public static final String MAIN_PAGE_TAB_1_TITLE = "_main_page_tab_1_title"; public static final String MAIN_PAGE_TAB_1_TITLE = "_main_page_tab_1_title";
@ -145,11 +147,10 @@ public class SharedPreferencesUtils {
public static final int MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = 4; public static final int MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = 4;
public static final int MAIN_PAGE_TAB_POST_TYPE_USER = 5; public static final int MAIN_PAGE_TAB_POST_TYPE_USER = 5;
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT = "start_autoplay_visible_area_offset_portrait"; public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE = "start_autoplay_visible_area_offset_landscape"; public static final String NSFW_BASE = "_nsfw";
public static final String MUTE_NSFW_VIDEO = "mute_nsfw_video"; public static final String BLUR_NSFW_BASE = "_blur_nsfw";
public static final String VIDEO_PLAYER_IGNORE_NAV_BAR = "video_player_ignore_nav_bar"; public static final String BLUR_SPOILER_BASE = "_blur_spoiler";
public static final String SAVE_FRONT_PAGE_SCROLLED_POSITION = "save_front_page_scrolled_position";
//Legacy Settings //Legacy Settings
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title"; public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";
@ -169,4 +170,8 @@ public class SharedPreferencesUtils {
public static final String POST_LAYOUT_POPULAR_POST_LEGACY = "post_layout_popular_post"; public static final String POST_LAYOUT_POPULAR_POST_LEGACY = "post_layout_popular_post";
public static final String POST_LAYOUT_ALL_POST_LEGACY = "post_layout_all_post"; public static final String POST_LAYOUT_ALL_POST_LEGACY = "post_layout_all_post";
public static final String NSFW_KEY_LEGACY = "nsfw";
public static final String BLUR_NSFW_KEY_LEGACY = "blur_nsfw";
public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler";
} }

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".Settings.NsfwAndBlurringFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/enable_nsfw_linear_layout_nsfw_and_spoiler_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
app:drawableStartCompat="@drawable/ic_nsfw_on_24dp"
android:drawablePadding="32dp"
android:text="@string/settings_enable_nsfw_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/enable_nsfw_switch_nsfw_and_spoiler_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/blur_nsfw_linear_layout_nsfw_and_spoiler_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:visibility="gone"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:text="@string/settings_blur_nsfw_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/blur_nsfw_switch_nsfw_and_spoiler_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/blur_spoiler_linear_layout_nsfw_and_spoiler_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:text="@string/settings_blur_spoiler_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/blur_spoiler_switch_nsfw_and_spoiler_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -392,6 +392,7 @@
<string name="settings_font_size_title">Font Size</string> <string name="settings_font_size_title">Font Size</string>
<string name="settings_title_font_size_title">Title Font Size</string> <string name="settings_title_font_size_title">Title Font Size</string>
<string name="settings_content_font_size_title">Content Font Size</string> <string name="settings_content_font_size_title">Content Font Size</string>
<string name="settings_nsfw_and_spoiler_title">NSFW &amp; Spoiler</string>
<string name="settings_enable_nsfw_title">Enable NSFW</string> <string name="settings_enable_nsfw_title">Enable NSFW</string>
<string name="settings_blur_nsfw_title">Blur NSFW Images</string> <string name="settings_blur_nsfw_title">Blur NSFW Images</string>
<string name="settings_blur_spoiler_title">Blur Spoiler Images</string> <string name="settings_blur_spoiler_title">Blur Spoiler Images</string>

View File

@ -65,22 +65,10 @@
app:icon="@drawable/ic_exit_24dp" app:icon="@drawable/ic_exit_24dp"
app:title="@string/settings_confirm_to_exit" /> app:title="@string/settings_confirm_to_exit" />
<SwitchPreference <Preference
app:defaultValue="false"
app:key="nsfw"
app:icon="@drawable/ic_nsfw_on_24dp" app:icon="@drawable/ic_nsfw_on_24dp"
app:title="@string/settings_enable_nsfw_title" /> app:title="@string/settings_nsfw_and_spoiler_title"
app:fragment="ml.docilealligator.infinityforreddit.Settings.NsfwAndBlurringFragment"/>
<SwitchPreference
app:defaultValue="true"
app:key="blur_nsfw"
app:title="@string/settings_blur_nsfw_title"
app:isPreferenceVisible="false" />
<SwitchPreference
app:defaultValue="false"
app:key="blur_spoiler"
app:title="@string/settings_blur_spoiler_title" />
<Preference <Preference
app:title="@string/settings_advanced_master_title" app:title="@string/settings_advanced_master_title"