aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java47
-rw-r--r--app/src/main/res/layout/activity_customize_post_filter.xml60
-rw-r--r--app/src/main/res/values/strings.xml2
6 files changed, 140 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
index 99c67f43..0f3b2b38 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -18,6 +18,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.checkbox.MaterialCheckBox;
+import com.google.android.material.switchmaterial.SwitchMaterial;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.r0adkll.slidr.Slidr;
@@ -76,6 +77,18 @@ public class CustomizePostFilterActivity extends BaseActivity {
TextView postTypeGalleryTextView;
@BindView(R.id.post_type_gallery_check_box_customize_post_filter_activity)
MaterialCheckBox postTypeGalleryCheckBox;
+ @BindView(R.id.only_nsfw_linear_layout_customize_post_filter_activity)
+ LinearLayout onlyNSFWLinearLayout;
+ @BindView(R.id.only_nsfw_text_view_customize_post_filter_activity)
+ TextView onlyNSFWTextView;
+ @BindView(R.id.only_nsfw_switch_customize_post_filter_activity)
+ SwitchMaterial onlyNSFWSwitch;
+ @BindView(R.id.only_spoiler_linear_layout_customize_post_filter_activity)
+ LinearLayout onlySpoilerLinearLayout;
+ @BindView(R.id.only_spoiler_text_view_customize_post_filter_activity)
+ TextView onlySpoilerTextView;
+ @BindView(R.id.only_spoiler_switch_customize_post_filter_activity)
+ SwitchMaterial onlySpoilerSwitch;
@BindView(R.id.title_excludes_strings_text_input_layout_customize_post_filter_activity)
TextInputLayout titleExcludesStringsTextInputLayout;
@BindView(R.id.title_excludes_strings_text_input_edit_text_customize_post_filter_activity)
@@ -176,6 +189,14 @@ public class CustomizePostFilterActivity extends BaseActivity {
postTypeGalleryLinearLayout.setOnClickListener(view -> {
postTypeGalleryCheckBox.performClick();
});
+
+ onlyNSFWLinearLayout.setOnClickListener(view -> {
+ onlyNSFWSwitch.performClick();
+ });
+
+ onlySpoilerLinearLayout.setOnClickListener(view -> {
+ onlySpoilerSwitch.performClick();
+ });
}
@Override
@@ -198,6 +219,8 @@ public class CustomizePostFilterActivity extends BaseActivity {
postTypeImageTextView.setTextColor(primaryTextColor);
postTypeVideoTextView.setTextColor(primaryTextColor);
postTypeGalleryTextView.setTextColor(primaryTextColor);
+ onlyNSFWTextView.setTextColor(primaryTextColor);
+ onlySpoilerTextView.setTextColor(primaryTextColor);
titleExcludesStringsTextInputLayout.setBoxStrokeColor(primaryTextColor);
titleExcludesStringsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
titleExcludesStringsTextInputEditText.setTextColor(primaryTextColor);
@@ -267,6 +290,8 @@ public class CustomizePostFilterActivity extends BaseActivity {
postFilter.containsImageType = postTypeImageCheckBox.isChecked();
postFilter.containsVideoType = postTypeVideoCheckBox.isChecked();
postFilter.containsGalleryType = postTypeGalleryCheckBox.isChecked();
+ postFilter.onlyNSFW = onlyNSFWSwitch.isChecked();
+ postFilter.onlySpoiler = onlySpoilerSwitch.isChecked();
Intent returnIntent = new Intent();
returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
index 8fa720dc..633683f3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
@@ -187,6 +187,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
}
PostFilter postFilter = new PostFilter();
switch (filter) {
+ case Post.NSFW_TYPE:
+ postFilter.onlyNSFW = true;
case Post.TEXT_TYPE:
postFilter.containsTextType = true;
break;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 0a6bd7fa..db3ee84a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1444,6 +1444,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
void typeChipClicked(int filter);
+ void nsfwChipClicked();
+
void currentlyBindItem(int position);
void delayTransition();
@@ -1668,11 +1670,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
Post post = getItem(position);
if (post != null) {
- Intent intent = new Intent(mActivity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
- mActivity.startActivity(intent);
+ mCallback.nsfwChipClicked();
}
});
typeTextView.setOnClickListener(view -> {
@@ -2658,11 +2656,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
Post post = getItem(position);
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
- Intent intent = new Intent(mActivity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
- mActivity.startActivity(intent);
+ mCallback.nsfwChipClicked();
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index c13de414..0757b5da 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -484,6 +484,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public void nsfwChipClicked() {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredThingActivity.EXTRA_QUERY, query);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ startActivity(intent);
+ }
+
+ @Override
public void currentlyBindItem(int position) {
if (maxPosition < position) {
maxPosition = position;
@@ -532,6 +542,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public void nsfwChipClicked() {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ startActivity(intent);
+ }
+
+ @Override
public void currentlyBindItem(int position) {
if (maxPosition < position) {
maxPosition = position;
@@ -582,6 +601,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public void nsfwChipClicked() {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ startActivity(intent);
+ }
+
+ @Override
public void currentlyBindItem(int position) {
if (maxPosition < position) {
maxPosition = position;
@@ -631,6 +659,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public void nsfwChipClicked() {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, username);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredThingActivity.EXTRA_USER_WHERE, where);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ startActivity(intent);
+ }
+
+ @Override
public void currentlyBindItem(int position) {
if (maxPosition < position) {
maxPosition = position;
@@ -671,6 +709,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public void nsfwChipClicked() {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ startActivity(intent);
+ }
+
+ @Override
public void currentlyBindItem(int position) {
if (maxPosition < position) {
maxPosition = position;
diff --git a/app/src/main/res/layout/activity_customize_post_filter.xml b/app/src/main/res/layout/activity_customize_post_filter.xml
index d11daee5..571f9509 100644
--- a/app/src/main/res/layout/activity_customize_post_filter.xml
+++ b/app/src/main/res/layout/activity_customize_post_filter.xml
@@ -193,6 +193,66 @@
</LinearLayout>
+ <LinearLayout
+ android:id="@+id/only_nsfw_linear_layout_customize_post_filter_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/only_nsfw_text_view_customize_post_filter_activity"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:text="@string/only_nsfw"
+ android:fontFamily="?attr/font_default"
+ android:textSize="?attr/font_default" />
+
+ <com.google.android.material.switchmaterial.SwitchMaterial
+ android:id="@+id/only_nsfw_switch_customize_post_filter_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/only_spoiler_linear_layout_customize_post_filter_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/only_spoiler_text_view_customize_post_filter_activity"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:text="@string/only_spoiler"
+ android:fontFamily="?attr/font_default"
+ android:textSize="?attr/font_default" />
+
+ <com.google.android.material.switchmaterial.SwitchMaterial
+ android:id="@+id/only_spoiler_switch_customize_post_filter_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical" />
+
+ </LinearLayout>
+
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title_excludes_strings_text_input_layout_customize_post_filter_activity"
android:layout_width="match_parent"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 02d9877a..17bb15bc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -953,6 +953,8 @@
<string name="hide_read_posts">Hide Read Posts</string>
+ <string name="only_nsfw">Only NSFW</string>
+ <string name="only_spoiler">Only Spoiler</string>
<string name="title_excludes_strings_hint">Title: excludes keywords</string>
<string name="title_excludes_regex_hint">Title: excludes regex</string>
<string name="excludes_subreddits_hint">Excludes subreddits</string>