diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-09-30 16:34:23 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-09-30 16:34:23 +0000 |
commit | 60fdb813c02f266c8c5ecaf20bfaee711372a982 (patch) | |
tree | fc128d5d4ed1607b2d529fb054ea812f487af743 /app/src/main/java | |
parent | 13bed5d234fdf7fe7335eb3cdeb3516b5dc8b205 (diff) | |
download | infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar.gz infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar.bz2 infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar.lz infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar.xz infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.tar.zst infinity-for-reddit-60fdb813c02f266c8c5ecaf20bfaee711372a982.zip |
Show a warning if nsfw is disabled and the subreddit is nsfw.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index f1799f06..a5c7b9a7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -35,6 +35,7 @@ import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.chip.Chip; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.tabs.TabLayout; @@ -167,6 +168,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Named("sort_type") SharedPreferences mSortTypeSharedPreferences; @Inject + @Named("nsfw_and_spoiler") + SharedPreferences mNsfwAndSpoilerSharedPreferences; + @Inject @Named("post_layout") SharedPreferences mPostLayoutSharedPreferences; @Inject @@ -207,6 +211,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp private int unsubscribedColor; private int subscribedColor; private SlidrInterface mSlidrInterface; + private MaterialAlertDialogBuilder nsfwWarningBuilder; @Override protected void onCreate(Bundle savedInstanceState) { @@ -416,6 +421,21 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp descriptionTextView.setVisibility(View.VISIBLE); descriptionTextView.setText(subredditData.getDescription()); } + + if (subredditData.isNSFW()) { + if (nsfwWarningBuilder == null + && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false)) { + nsfwWarningBuilder = new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.warning) + .setMessage(R.string.this_is_a_nsfw_subreddit) + .setPositiveButton(R.string.leave, (dialogInterface, i) + -> { + finish(); + }) + .setNegativeButton(R.string.dismiss, null); + nsfwWarningBuilder.show(); + } + } } }); } |