diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-22 17:06:58 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-22 17:06:58 +0000 |
commit | 7777a6d6756b6b2631ea24548bd69ff42bd39034 (patch) | |
tree | e3677b6eb13806e4b4c6f8ed391ec2704aa113c8 | |
parent | f14ef4a8bb8792dbf57058da329f6a74448baaa8 (diff) | |
download | infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar.gz infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar.bz2 infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar.lz infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar.xz infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.tar.zst infinity-for-reddit-7777a6d6756b6b2631ea24548bd69ff42bd39034.zip |
Start CustomizePostFilterActivity instead of FilteredPostsActivity when pressing the filter posts option.
4 files changed, 112 insertions, 87 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 0480887a..1e173b5f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java @@ -63,6 +63,7 @@ public class CustomizePostFilterActivity extends BaseActivity { public static final String EXTRA_CONTAIN_FLAIR = "ECF"; public static final String EXTRA_EXCLUDE_DOMAIN = "EED"; public static final String EXTRA_CONTAIN_DOMAIN = "ECD"; + public static final String EXTRA_START_FILTERED_POSTS_WHEN_FINISH = "ESFPWF"; public static final String RETURN_EXTRA_POST_FILTER = "REPF"; private static final String POST_FILTER_STATE = "PFS"; private static final String ORIGINAL_NAME_STATE = "ONS"; @@ -399,9 +400,16 @@ public class CustomizePostFilterActivity extends BaseActivity { } else if (item.getItemId() == R.id.action_save_customize_post_filter_activity) { try { constructPostFilter(); - Intent returnIntent = new Intent(); - returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter); - setResult(Activity.RESULT_OK, returnIntent); + if (getIntent().getBooleanExtra(EXTRA_START_FILTERED_POSTS_WHEN_FINISH, false)) { + Intent intent = new Intent(this, FilteredPostsActivity.class); + intent.putExtras(getIntent()); + intent.putExtra(FilteredPostsActivity.EXTRA_CONSTRUCTED_POST_FILTER, postFilter); + startActivity(intent); + } else { + Intent returnIntent = new Intent(); + returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter); + setResult(Activity.RESULT_OK, returnIntent); + } finish(); } catch (PatternSyntaxException e) { Toast.makeText(this, R.string.invalid_regex, Toast.LENGTH_SHORT).show(); @@ -429,9 +437,16 @@ public class CustomizePostFilterActivity extends BaseActivity { new SavePostFilter.SavePostFilterListener() { @Override public void success() { - Intent returnIntent = new Intent(); - returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter); - setResult(Activity.RESULT_OK, returnIntent); + if (getIntent().getBooleanExtra(EXTRA_START_FILTERED_POSTS_WHEN_FINISH, false)) { + Intent intent = new Intent(CustomizePostFilterActivity.this, FilteredPostsActivity.class); + intent.putExtras(getIntent()); + intent.putExtra(FilteredPostsActivity.EXTRA_CONSTRUCTED_POST_FILTER, postFilter); + startActivity(intent); + } else { + Intent returnIntent = new Intent(); + returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter); + setResult(Activity.RESULT_OK, returnIntent); + } finish(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index 8780f4b6..4a28efcb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -65,7 +65,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec public static final String EXTRA_NAME = "ESN"; public static final String EXTRA_QUERY = "EQ"; public static final String EXTRA_TRENDING_SOURCE = "ETS"; - public static final String EXTRA_FILTER = "EF"; + public static final String EXTRA_POST_TYPE_FILTER = "EPTF"; + public static final String EXTRA_CONSTRUCTED_POST_FILTER = "ECPF"; public static final String EXTRA_CONTAIN_FLAIR = "ECF"; public static final String EXTRA_POST_TYPE = "EPT"; public static final String EXTRA_USER_WHERE = "EUW"; @@ -162,66 +163,69 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec name = getIntent().getStringExtra(EXTRA_NAME); postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE); - int filter = getIntent().getIntExtra(EXTRA_FILTER, -1000); - PostFilter postFilter = new PostFilter(); - postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false); - switch (filter) { - case Post.NSFW_TYPE: - postFilter.onlyNSFW = true; - break; - case Post.TEXT_TYPE: - postFilter.containTextType = true; - postFilter.containLinkType = false; - postFilter.containImageType = false; - postFilter.containGifType = false; - postFilter.containVideoType = false; - postFilter.containGalleryType = false; - break; - case Post.LINK_TYPE: - postFilter.containTextType = false; - postFilter.containLinkType = true; - postFilter.containImageType = false; - postFilter.containGifType = false; - postFilter.containVideoType = false; - postFilter.containGalleryType = false; - break; - case Post.IMAGE_TYPE: - postFilter.containTextType = false; - postFilter.containLinkType = false; - postFilter.containImageType = true; - postFilter.containGifType = false; - postFilter.containVideoType = false; - postFilter.containGalleryType = false; - break; - case Post.GIF_TYPE: - postFilter.containTextType = false; - postFilter.containLinkType = false; - postFilter.containImageType = false; - postFilter.containGifType = true; - postFilter.containVideoType = false; - postFilter.containGalleryType = false; - break; - case Post.VIDEO_TYPE: - postFilter.containTextType = false; - postFilter.containLinkType = false; - postFilter.containImageType = false; - postFilter.containGifType = false; - postFilter.containVideoType = true; - postFilter.containGalleryType = false; - break; - case Post.GALLERY_TYPE: - postFilter.containTextType = false; - postFilter.containLinkType = false; - postFilter.containImageType = false; - postFilter.containGifType = false; - postFilter.containVideoType = false; - postFilter.containGalleryType = true; - break; - } + int filter = getIntent().getIntExtra(EXTRA_POST_TYPE_FILTER, -1000); + PostFilter postFilter = getIntent().getParcelableExtra(EXTRA_CONSTRUCTED_POST_FILTER); + if (postFilter == null) { + postFilter = new PostFilter(); + postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false); + switch (filter) { + case Post.NSFW_TYPE: + postFilter.onlyNSFW = true; + break; + case Post.TEXT_TYPE: + postFilter.containTextType = true; + postFilter.containLinkType = false; + postFilter.containImageType = false; + postFilter.containGifType = false; + postFilter.containVideoType = false; + postFilter.containGalleryType = false; + break; + case Post.LINK_TYPE: + postFilter.containTextType = false; + postFilter.containLinkType = true; + postFilter.containImageType = false; + postFilter.containGifType = false; + postFilter.containVideoType = false; + postFilter.containGalleryType = false; + break; + case Post.IMAGE_TYPE: + postFilter.containTextType = false; + postFilter.containLinkType = false; + postFilter.containImageType = true; + postFilter.containGifType = false; + postFilter.containVideoType = false; + postFilter.containGalleryType = false; + break; + case Post.GIF_TYPE: + postFilter.containTextType = false; + postFilter.containLinkType = false; + postFilter.containImageType = false; + postFilter.containGifType = true; + postFilter.containVideoType = false; + postFilter.containGalleryType = false; + break; + case Post.VIDEO_TYPE: + postFilter.containTextType = false; + postFilter.containLinkType = false; + postFilter.containImageType = false; + postFilter.containGifType = false; + postFilter.containVideoType = true; + postFilter.containGalleryType = false; + break; + case Post.GALLERY_TYPE: + postFilter.containTextType = false; + postFilter.containLinkType = false; + postFilter.containImageType = false; + postFilter.containGifType = false; + postFilter.containVideoType = false; + postFilter.containGalleryType = true; + break; + } - String flair = getIntent().getStringExtra(EXTRA_CONTAIN_FLAIR); - if (flair != null) { - postFilter.containFlairs = flair; + String flair = getIntent().getStringExtra(EXTRA_CONTAIN_FLAIR); + if (flair != null) { + postFilter.containFlairs = flair; + } } if (postType == PostPagingSource.TYPE_USER) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index d2d3d002..150ce763 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -1190,7 +1190,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler Intent intent = new Intent(mActivity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, mPost.getPostType()); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, mPost.getPostType()); mActivity.startActivity(intent); }); } else { @@ -1213,7 +1213,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler Intent intent = new Intent(mActivity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostPagingSource.TYPE_SUBREDDIT); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); mActivity.startActivity(intent); }); 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 e1949175..034f5a90 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -79,6 +79,7 @@ import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity; import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity; import ml.docilealligator.infinityforreddit.activities.BaseActivity; +import ml.docilealligator.infinityforreddit.activities.CustomizePostFilterActivity; import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.adapters.Paging3LoadingStateAdapter; @@ -471,7 +472,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query); intent.putExtra(FilteredPostsActivity.EXTRA_TRENDING_SOURCE, trendingSource); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -493,7 +494,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query); intent.putExtra(FilteredPostsActivity.EXTRA_TRENDING_SOURCE, trendingSource); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -546,7 +547,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -564,7 +565,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -617,7 +618,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -635,7 +636,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -683,7 +684,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -703,7 +704,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -742,7 +743,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void typeChipClicked(int filter) { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -758,7 +759,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void nsfwChipClicked() { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -803,7 +804,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -821,7 +822,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -859,7 +860,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void typeChipClicked(int filter) { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, filter); startActivity(intent); } @@ -875,7 +876,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void nsfwChipClicked() { Intent intent = new Intent(activity, FilteredPostsActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); - intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE); + intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE_FILTER, Post.NSFW_TYPE); startActivity(intent); } @@ -1682,32 +1683,37 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Override public void filterPosts() { if (postType == PostPagingSource.TYPE_SEARCH) { - Intent intent = new Intent(activity, FilteredPostsActivity.class); + Intent intent = new Intent(activity, CustomizePostFilterActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName); intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query); intent.putExtra(FilteredPostsActivity.EXTRA_TRENDING_SOURCE, trendingSource); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); + intent.putExtra(CustomizePostFilterActivity.EXTRA_START_FILTERED_POSTS_WHEN_FINISH, true); startActivity(intent); } else if (postType == PostPagingSource.TYPE_SUBREDDIT) { - Intent intent = new Intent(activity, FilteredPostsActivity.class); + Intent intent = new Intent(activity, CustomizePostFilterActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); + intent.putExtra(CustomizePostFilterActivity.EXTRA_START_FILTERED_POSTS_WHEN_FINISH, true); startActivity(intent); } else if (postType == PostPagingSource.TYPE_MULTI_REDDIT || postType == PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT) { - Intent intent = new Intent(activity, FilteredPostsActivity.class); + Intent intent = new Intent(activity, CustomizePostFilterActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); + intent.putExtra(CustomizePostFilterActivity.EXTRA_START_FILTERED_POSTS_WHEN_FINISH, true); startActivity(intent); } else if (postType == PostPagingSource.TYPE_USER) { - Intent intent = new Intent(activity, FilteredPostsActivity.class); + Intent intent = new Intent(activity, CustomizePostFilterActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where); + intent.putExtra(CustomizePostFilterActivity.EXTRA_START_FILTERED_POSTS_WHEN_FINISH, true); startActivity(intent); } else { - Intent intent = new Intent(activity, FilteredPostsActivity.class); + Intent intent = new Intent(activity, CustomizePostFilterActivity.class); intent.putExtra(FilteredPostsActivity.EXTRA_NAME, activity.getString(R.string.best)); intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType); + intent.putExtra(CustomizePostFilterActivity.EXTRA_START_FILTERED_POSTS_WHEN_FINISH, true); startActivity(intent); } } |