aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-22 15:08:33 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-22 15:08:33 +0000
commit71a7852c79f145a27b9d22a7ce56540ec2d45831 (patch)
tree022e7472f7743ef331a0e2c339fa40a81135f9ab /app/src/main/java
parentf4d061ceccf7c386321faf4093e27dab00e3e071 (diff)
downloadinfinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar.gz
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar.bz2
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar.lz
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar.xz
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.tar.zst
infinity-for-reddit-71a7852c79f145a27b9d22a7ce56540ec2d45831.zip
Add only NSFW and only Spoiler options in CustomizePostFilterActivity. Fix nsfwTextView OnClickListener in PostRecyclerViewAdapter.
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
4 files changed, 78 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;