aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-09-30 16:34:23 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-09-30 16:34:23 +0000
commit60fdb813c02f266c8c5ecaf20bfaee711372a982 (patch)
treefc128d5d4ed1607b2d529fb054ea812f487af743 /app
parent13bed5d234fdf7fe7335eb3cdeb3516b5dc8b205 (diff)
downloadinfinity-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 '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java20
-rw-r--r--app/src/main/res/values/strings.xml6
2 files changed, 26 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();
+ }
+ }
}
});
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5b85708a..ad5871fe 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -914,4 +914,10 @@
<string name="recent_searches">Recent searches</string>
+ <string name="warning">Warning</string>
+ <string name="this_is_a_nsfw_subreddit">This is a NSFW subreddit.</string>
+ <string name="this_user_has_nsfw_content">This user has NSFW content</string>
+ <string name="dismiss">Dismiss</string>
+ <string name="leave">Leave</string>
+
</resources>