aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
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>