mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Add to post filter menu option available in ViewSubredditActivity and ViewUserActivity.
This commit is contained in:
parent
eaa24b4858
commit
3eb608888b
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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"));
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user