diff options
Diffstat (limited to 'app/src')
5 files changed, 61 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java index e64bf21e..4ed7534d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java @@ -36,6 +36,8 @@ import ml.docilealligator.infinityforreddit.postfilter.PostFilterViewModel; public class PostFilterPreferenceActivity extends BaseActivity { public static final String EXTRA_POST = "EP"; + public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + public static final String EXTRA_USER_NAME = "EUN"; @BindView(R.id.coordinator_layout_post_filter_preference_activity) CoordinatorLayout coordinatorLayout; @@ -76,26 +78,36 @@ public class PostFilterPreferenceActivity extends BaseActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); Post post = getIntent().getParcelableExtra(EXTRA_POST); + String subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); + String username = getIntent().getStringExtra(EXTRA_USER_NAME); fab.setOnClickListener(view -> { - if (post == null) { + if (post != null) { + showPostFilterOptions(post, null); + } else if (subredditName != null) { + excludeSubredditInFilter(subredditName, null); + } else if (username != null) { + excludeUserInFilter(username, null); + } else { Intent intent = new Intent(PostFilterPreferenceActivity.this, CustomizePostFilterActivity.class); intent.putExtra(CustomizePostFilterActivity.EXTRA_FROM_SETTINGS, true); startActivity(intent); - } else { - showPostFilterOptions(post, null); } }); adapter = new PostFilterRecyclerViewAdapter(postFilter -> { - if (post == null) { + if (post != null) { + showPostFilterOptions(post, postFilter); + } else if (subredditName != null) { + excludeSubredditInFilter(subredditName, postFilter); + } else if (username != null) { + excludeUserInFilter(username, postFilter); + } else { PostFilterOptionsBottomSheetFragment postFilterOptionsBottomSheetFragment = new PostFilterOptionsBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(PostFilterOptionsBottomSheetFragment.EXTRA_POST_FILTER, postFilter); postFilterOptionsBottomSheetFragment.setArguments(bundle); postFilterOptionsBottomSheetFragment.show(getSupportFragmentManager(), postFilterOptionsBottomSheetFragment.getTag()); - } else { - showPostFilterOptions(post, postFilter); } }); @@ -145,6 +157,24 @@ public class PostFilterPreferenceActivity extends BaseActivity { .show(); } + public void excludeSubredditInFilter(String subredditName, PostFilter postFilter) { + Intent intent = new Intent(this, CustomizePostFilterActivity.class); + intent.putExtra(CustomizePostFilterActivity.EXTRA_EXCLUDE_SUBREDDIT, subredditName); + if (postFilter != null) { + intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, postFilter); + } + startActivity(intent); + } + + public void excludeUserInFilter(String username, PostFilter postFilter) { + Intent intent = new Intent(this, CustomizePostFilterActivity.class); + intent.putExtra(CustomizePostFilterActivity.EXTRA_EXCLUDE_USER, username); + if (postFilter != null) { + intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, postFilter); + } + startActivity(intent); + } + public void editPostFilter(PostFilter postFilter) { Intent intent = new Intent(PostFilterPreferenceActivity.this, CustomizePostFilterActivity.class); intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, postFilter); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 8486318d..3926062d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -1114,6 +1114,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } Intent intent = new Intent(this, MultiredditSelectionActivity.class); startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE); + } else if (itemId == R.id.action_add_to_post_filter_view_subreddit_detail_activity) { + Intent intent = new Intent(this, PostFilterPreferenceActivity.class); + intent.putExtra(PostFilterPreferenceActivity.EXTRA_SUBREDDIT_NAME, subredditName); + startActivity(intent); + return true; } else if (itemId == R.id.action_share_view_subreddit_detail_activity) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index 5432c074..da2216e4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -981,6 +981,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } Intent intent = new Intent(this, MultiredditSelectionActivity.class); startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE); + } else if (itemId == R.id.action_add_to_post_filter_view_user_detail_activity) { + Intent intent = new Intent(this, PostFilterPreferenceActivity.class); + intent.putExtra(PostFilterPreferenceActivity.EXTRA_USER_NAME, username); + startActivity(intent); + return true; } else if (itemId == R.id.action_report_view_user_detail_activity) { Intent reportIntent = new Intent(this, LinkResolverActivity.class); reportIntent.setData(Uri.parse("https://www.reddithelp.com/en/categories/rules-reporting/account-and-community-restrictions/what-should-i-do-if-i-see-something-i")); diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml index 3521819a..c1631814 100644 --- a/app/src/main/res/menu/view_subreddit_detail_activity.xml +++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml @@ -48,8 +48,14 @@ app:showAsAction="never" /> <item - android:id="@+id/action_share_view_subreddit_detail_activity" + android:id="@+id/action_add_to_post_filter_view_subreddit_detail_activity" android:orderInCategory="8" + android:title="@string/action_add_to_post_filter" + app:showAsAction="never" /> + + <item + android:id="@+id/action_share_view_subreddit_detail_activity" + android:orderInCategory="9" android:title="@string/action_share" app:showAsAction="never" /> </menu> diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml index 05e4c3cb..8d89ff08 100644 --- a/app/src/main/res/menu/view_user_detail_activity.xml +++ b/app/src/main/res/menu/view_user_detail_activity.xml @@ -51,12 +51,18 @@ app:showAsAction="never" /> <item - android:id="@+id/action_report_view_user_detail_activity" + android:id="@+id/action_add_to_post_filter_view_user_detail_activity" android:orderInCategory="9" + android:title="@string/action_add_to_post_filter" + app:showAsAction="never" /> + + <item + android:id="@+id/action_report_view_user_detail_activity" + android:orderInCategory="10" android:title="@string/action_report" /> <item android:id="@+id/action_block_user_view_user_detail_activity" - android:orderInCategory="10" + android:orderInCategory="11" android:title="@string/action_block_user" /> </menu> |