aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-28 08:27:56 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-28 08:27:56 +0000
commit3adac8a0743a44018ce8509124a7c6506d92839c (patch)
treec36704cadf599c6e6a0991101dae2efc753cdc34 /app
parentdaa6b06617f3cc2fe189b68a427e91d830462a52 (diff)
downloadinfinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar.gz
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar.bz2
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar.lz
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar.xz
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.tar.zst
infinity-for-reddit-3adac8a0743a44018ce8509124a7c6506d92839c.zip
Show NSFW toggle in the nav drawer in anonymous mode.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java26
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml2
-rw-r--r--app/src/main/res/layout/content_view_subreddit_detail.xml10
3 files changed, 25 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
index c5fa30b2..0491c1ed 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
@@ -308,6 +308,30 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
}
break;
case 2:
+ setOnClickListener = false;
+ if (isNSFWEnabled) {
+ stringId = R.string.disable_nsfw;
+ drawableId = R.drawable.ic_nsfw_off_24dp;
+ } else {
+ stringId = R.string.enable_nsfw;
+ drawableId = R.drawable.ic_nsfw_on_24dp;
+ }
+
+ ((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> {
+ if (isNSFWEnabled) {
+ isNSFWEnabled = false;
+ ((MenuItemViewHolder) holder).menuTextView.setText(R.string.enable_nsfw);
+ ((MenuItemViewHolder) holder).imageView.setImageDrawable(context.getDrawable(R.drawable.ic_nsfw_on_24dp));
+ itemClickListener.onMenuClick(R.string.disable_nsfw);
+ } else {
+ isNSFWEnabled = true;
+ ((MenuItemViewHolder) holder).menuTextView.setText(R.string.disable_nsfw);
+ ((MenuItemViewHolder) holder).imageView.setImageDrawable(context.getDrawable(R.drawable.ic_nsfw_off_24dp));
+ itemClickListener.onMenuClick(R.string.enable_nsfw);
+ }
+ });
+ break;
+ case 3:
stringId = R.string.settings;
drawableId = R.drawable.ic_settings_24dp;
}
@@ -379,7 +403,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
}
return CURRENT_MENU_ITEMS;
} else {
- return 3;
+ return 4;
}
} else {
if (isLoggedIn) {
diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index c76ada01..837df600 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -142,8 +142,6 @@
</com.google.android.material.appbar.AppBarLayout>
- <!--<include layout="@layout/content_view_subreddit_detail" />-->
-
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottom_navigation_view_subreddit_detail_activity"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/content_view_subreddit_detail.xml b/app/src/main/res/layout/content_view_subreddit_detail.xml
deleted file mode 100644
index f5ae24e3..00000000
--- a/app/src/main/res/layout/content_view_subreddit_detail.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/frame_layout_view_subreddit_detail_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- tools:application=".ViewSubredditDetailActivity"
- tools:showIn="@layout/activity_view_subreddit_detail" />