From 71a7852c79f145a27b9d22a7ce56540ec2d45831 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 22 Dec 2020 23:08:33 +0800 Subject: Add only NSFW and only Spoiler options in CustomizePostFilterActivity. Fix nsfwTextView OnClickListener in PostRecyclerViewAdapter. --- .../activities/CustomizePostFilterActivity.java | 25 +++++++++ .../activities/FilteredThingActivity.java | 2 + .../adapters/PostRecyclerViewAdapter.java | 14 ++--- .../infinityforreddit/fragments/PostFragment.java | 47 +++++++++++++++++ .../res/layout/activity_customize_post_filter.xml | 60 ++++++++++++++++++++++ app/src/main/res/values/strings.xml | 2 + 6 files changed, 140 insertions(+), 10 deletions(-) (limited to 'app/src/main') 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 { @@ -2658,11 +2656,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter + + + + + + + + + + + + + + + + Hide Read Posts + Only NSFW + Only Spoiler Title: excludes keywords Title: excludes regex Excludes subreddits -- cgit v1.2.3