diff options
21 files changed, 307 insertions, 168 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java index 3fb00c2a..29675703 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java @@ -38,4 +38,7 @@ public interface FragmentCommunicator { default void hideReadPosts() { } + + default void changePostFilter(PostFilter postFilter) { + } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java index 990dc775..d6842991 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java @@ -2,6 +2,12 @@ package ml.docilealligator.infinityforreddit; import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import ml.docilealligator.infinityforreddit.post.Post; public class PostFilter implements Parcelable { public int maxVote = -1; @@ -13,16 +19,115 @@ public class PostFilter implements Parcelable { public boolean allowNSFW; public boolean onlyNSFW; public boolean onlySpoiler; - public String postTitleRegex; + public String postTitleExcludesRegex; public String postTitleExcludesStrings; public String excludesSubreddits; public String excludesUsers; public String containsFlairs; public String excludesFlairs; - public boolean containsTextType; - public boolean containsLinkType; - public boolean containsImageType; - public boolean containsVideoType; + public boolean containsTextType = true; + public boolean containsLinkType = true; + public boolean containsImageType = true; + public boolean containsVideoType = true; + public boolean containsGalleryType = true; + + public static boolean isPostAllowed(Post post, PostFilter postFilter) { + if (postFilter == null || post == null) { + Log.i("asdasfd", "s " + post.getTitle()); + return true; + } + if (post.isNSFW() && !postFilter.allowNSFW) { + return false; + } + if (postFilter.maxVote > 0 && post.getVoteType() + post.getScore() > postFilter.maxVote) { + return false; + } + if (postFilter.minVote > 0 && post.getVoteType() + post.getScore() < postFilter.minVote) { + return false; + } + if (postFilter.maxComments > 0 && post.getNComments() > postFilter.maxComments) { + return false; + } + if (postFilter.minComments > 0 && post.getNComments() < postFilter.minComments) { + return false; + } + if (postFilter.maxAwards > 0 && post.getNAwards() > postFilter.maxAwards) { + return false; + } + if (postFilter.minAwards > 0 && post.getNAwards() < postFilter.minAwards) { + return false; + } + if (postFilter.onlyNSFW && !post.isNSFW()) { + return false; + } + if (postFilter.onlySpoiler && !post.isSpoiler()) { + return false; + } + if (!postFilter.containsTextType && post.getPostType() == Post.TEXT_TYPE) { + return false; + } + if (!postFilter.containsLinkType && (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE)) { + return false; + } + if (!postFilter.containsImageType && post.getPostType() == Post.IMAGE_TYPE) { + return false; + } + if (!postFilter.containsVideoType && post.getPostType() == Post.VIDEO_TYPE) { + return false; + } + if (!postFilter.containsGalleryType && post.getPostType() == Post.GALLERY_TYPE) { + return false; + } + if (postFilter.postTitleExcludesRegex != null && !postFilter.postTitleExcludesRegex.equals("")) { + Pattern spoilerPattern = Pattern.compile(postFilter.postTitleExcludesRegex); + Matcher matcher = spoilerPattern.matcher(postFilter.postTitleExcludesRegex); + if (matcher.find()) { + return false; + } + } + if (postFilter.postTitleExcludesStrings != null && !postFilter.postTitleExcludesStrings.equals("")) { + String[] titles = postFilter.postTitleExcludesStrings.split(",", 0); + for (String t : titles) { + if (post.getTitle().contains(t)) { + return false; + } + } + } + if (postFilter.excludesSubreddits != null && !postFilter.excludesSubreddits.equals("")) { + String[] subreddits = postFilter.excludesSubreddits.split(",", 0); + for (String s : subreddits) { + if (post.getSubredditName().equals(s)) { + return false; + } + } + } + if (postFilter.excludesUsers != null && !postFilter.excludesUsers.equals("")) { + String[] users = postFilter.excludesUsers.split(",", 0); + for (String u : users) { + if (post.getAuthor().equals(u)) { + return false; + } + } + } + if (postFilter.excludesFlairs != null && !postFilter.excludesFlairs.equals("")) { + String[] flairs = postFilter.excludesFlairs.split(",", 0); + for (String f : flairs) { + if (post.getFlair().equals(f)) { + return false; + } + } + } + if (postFilter.containsFlairs != null && !postFilter.containsFlairs.equals("")) { + String[] flairs = postFilter.containsFlairs.split(",", 0); + for (String f : flairs) { + if (post.getFlair().equals(f)) { + return false; + } + } + } + + return true; + } public PostFilter() { @@ -38,7 +143,7 @@ public class PostFilter implements Parcelable { allowNSFW = in.readByte() != 0; onlyNSFW = in.readByte() != 0; onlySpoiler = in.readByte() != 0; - postTitleRegex = in.readString(); + postTitleExcludesRegex = in.readString(); postTitleExcludesStrings = in.readString(); excludesSubreddits = in.readString(); excludesUsers = in.readString(); @@ -48,6 +153,7 @@ public class PostFilter implements Parcelable { containsLinkType = in.readByte() != 0; containsImageType = in.readByte() != 0; containsVideoType = in.readByte() != 0; + containsGalleryType = in.readByte() != 0; } public static final Creator<PostFilter> CREATOR = new Creator<PostFilter>() { @@ -78,7 +184,7 @@ public class PostFilter implements Parcelable { parcel.writeByte((byte) (allowNSFW ? 1 : 0)); parcel.writeByte((byte) (onlyNSFW ? 1 : 0)); parcel.writeByte((byte) (onlySpoiler ? 1 : 0)); - parcel.writeString(postTitleRegex); + parcel.writeString(postTitleExcludesRegex); parcel.writeString(postTitleExcludesStrings); parcel.writeString(excludesSubreddits); parcel.writeString(excludesUsers); @@ -88,5 +194,6 @@ public class PostFilter implements Parcelable { parcel.writeByte((byte) (containsLinkType ? 1 : 0)); parcel.writeByte((byte) (containsImageType ? 1 : 0)); parcel.writeByte((byte) (containsVideoType ? 1 : 0)); + parcel.writeByte((byte) (containsGalleryType ? 1 : 0)); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java index 8c340208..06628e3e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java @@ -198,7 +198,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName); bundle.putString(PostFragment.EXTRA_USER_WHERE, mUserWhere); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java index 5069d2e4..c33104ac 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java @@ -358,7 +358,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName); bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_SAVED); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); bundle.putBoolean(PostFragment.EXTRA_DISABLE_READ_POSTS, true); 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 3fb67298..c9e34f61 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java @@ -70,6 +70,12 @@ public class CustomizePostFilterActivity extends BaseActivity { TextView postTypeVideoTextView; @BindView(R.id.post_type_video_check_box_customize_post_filter_activity) MaterialCheckBox postTypeVideoCheckBox; + @BindView(R.id.post_type_gallery_linear_layout_customize_post_filter_activity) + LinearLayout postTypeGalleryLinearLayout; + @BindView(R.id.post_type_gallery_text_view_customize_post_filter_activity) + TextView postTypeGalleryTextView; + @BindView(R.id.post_type_gallery_check_box_customize_post_filter_activity) + MaterialCheckBox postTypeGalleryCheckBox; @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) @@ -187,6 +193,7 @@ public class CustomizePostFilterActivity extends BaseActivity { postTypeLinkTextView.setTextColor(primaryTextColor); postTypeImageTextView.setTextColor(primaryTextColor); postTypeVideoTextView.setTextColor(primaryTextColor); + postTypeGalleryTextView.setTextColor(primaryTextColor); titleExcludesStringsTextInputLayout.setBoxStrokeColor(primaryTextColor); titleExcludesStringsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor)); titleExcludesStringsTextInputEditText.setTextColor(primaryTextColor); @@ -239,13 +246,13 @@ public class CustomizePostFilterActivity extends BaseActivity { return true; } else if (item.getItemId() == R.id.action_save_customize_post_filter_activity) { PostFilter postFilter = new PostFilter(); - postFilter.maxVote = maxVoteTextInputEditText.getText() == null ? -1 : Integer.parseInt(maxVoteTextInputEditText.getText().toString()); - postFilter.minVote = minVoteTextInputEditText.getText() == null ? -1 : Integer.parseInt(minVoteTextInputEditText.getText().toString()); - postFilter.maxComments = maxCommentsTextInputEditText.getText() == null ? -1 : Integer.parseInt(maxCommentsTextInputEditText.getText().toString()); - postFilter.minComments = minCommentsTextInputEditText.getText() == null ? -1 : Integer.parseInt(minCommentsTextInputEditText.getText().toString()); - postFilter.maxAwards = maxAwardsTextInputEditText.getText() == null ? -1 : Integer.parseInt(maxAwardsTextInputEditText.getText().toString()); - postFilter.minAwards = minAwardsTextInputEditText.getText() == null ? -1 : Integer.parseInt(minAwardsTextInputEditText.getText().toString()); - postFilter.postTitleRegex = titleExcludesRegexTextInputEditText.getText().toString(); + postFilter.maxVote = maxVoteTextInputEditText.getText() == null || maxVoteTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxVoteTextInputEditText.getText().toString()); + postFilter.minVote = minVoteTextInputEditText.getText() == null || minVoteTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minVoteTextInputEditText.getText().toString()); + postFilter.maxComments = maxCommentsTextInputEditText.getText() == null || maxCommentsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxCommentsTextInputEditText.getText().toString()); + postFilter.minComments = minCommentsTextInputEditText.getText() == null || minCommentsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minCommentsTextInputEditText.getText().toString()); + postFilter.maxAwards = maxAwardsTextInputEditText.getText() == null || maxAwardsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxAwardsTextInputEditText.getText().toString()); + postFilter.minAwards = minAwardsTextInputEditText.getText() == null || minAwardsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minAwardsTextInputEditText.getText().toString()); + postFilter.postTitleExcludesRegex = titleExcludesRegexTextInputEditText.getText().toString(); postFilter.postTitleExcludesStrings = titleExcludesStringsTextInputEditText.getText().toString(); postFilter.excludesSubreddits = excludesSubredditsTextInputEditText.getText().toString(); postFilter.excludesUsers = excludesUsersTextInputEditText.getText().toString(); @@ -255,6 +262,7 @@ public class CustomizePostFilterActivity extends BaseActivity { postFilter.containsLinkType = postTypeLinkCheckBox.isChecked(); postFilter.containsImageType = postTypeImageCheckBox.isChecked(); postFilter.containsVideoType = postTypeVideoCheckBox.isChecked(); + postFilter.containsGalleryType = postTypeGalleryCheckBox.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 a8775ea7..8fa720dc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java @@ -12,6 +12,7 @@ import android.view.Window; import android.view.WindowManager; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; @@ -32,6 +33,7 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface; +import ml.docilealligator.infinityforreddit.PostFilter; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; @@ -66,6 +68,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec private static final String ACCESS_TOKEN_STATE = "ATS"; private static final String ACCOUNT_NAME_STATE = "ANS"; private static final String FRAGMENT_OUT_STATE = "FOS"; + private static final int CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE = 1000; @BindView(R.id.coordinator_layout_filtered_thing_activity) CoordinatorLayout coordinatorLayout; @@ -159,6 +162,47 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec name = getIntent().getStringExtra(EXTRA_NAME); postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE); int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE); + switch (filter) { + case Post.NSFW_TYPE: + toolbar.setSubtitle(R.string.nsfw); + break; + case Post.TEXT_TYPE: + toolbar.setSubtitle(R.string.text); + break; + case Post.LINK_TYPE: + case Post.NO_PREVIEW_LINK_TYPE: + toolbar.setSubtitle(R.string.link); + break; + case Post.IMAGE_TYPE: + toolbar.setSubtitle(R.string.image); + break; + case Post.VIDEO_TYPE: + toolbar.setSubtitle(R.string.video); + break; + case Post.GIF_TYPE: + toolbar.setSubtitle(R.string.gif); + break; + case Post.GALLERY_TYPE: + toolbar.setSubtitle(R.string.gallery); + } + PostFilter postFilter = new PostFilter(); + switch (filter) { + case Post.TEXT_TYPE: + postFilter.containsTextType = true; + break; + case Post.LINK_TYPE: + postFilter.containsLinkType = true; + break; + case Post.IMAGE_TYPE: + postFilter.containsImageType = true; + break; + case Post.VIDEO_TYPE: + postFilter.containsVideoType = true; + break; + case Post.GALLERY_TYPE: + postFilter.containsGalleryType = true; + break; + } if (postType == PostDataSource.TYPE_USER) { userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE); @@ -174,14 +218,14 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); if (!mNullAccessToken && mAccessToken == null) { - getCurrentAccountAndBindView(filter); + getCurrentAccountAndBindView(postFilter); } else { mFragment = (PostFragment) getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit(); - bindView(filter, false); + bindView(postFilter, false); } } else { - getCurrentAccountAndBindView(filter); + getCurrentAccountAndBindView(postFilter); } postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); @@ -213,7 +257,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec applyFABTheme(fab); } - private void getCurrentAccountAndBindView(int filter) { + private void getCurrentAccountAndBindView(PostFilter postFilter) { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { if (account == null) { mNullAccessToken = true; @@ -221,11 +265,11 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec mAccessToken = account.getAccessToken(); mAccountName = account.getUsername(); } - bindView(filter, true); + bindView(postFilter, true); }).execute(); } - private void bindView(int filter, boolean initializeFragment) { + private void bindView(PostFilter postFilter, boolean initializeFragment) { switch (postType) { case PostDataSource.TYPE_FRONT_PAGE: getSupportActionBar().setTitle(name); @@ -285,35 +329,11 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment(); - switch (filter) { - case Post.NSFW_TYPE: - toolbar.setSubtitle(R.string.nsfw); - break; - case Post.TEXT_TYPE: - toolbar.setSubtitle(R.string.text); - break; - case Post.LINK_TYPE: - case Post.NO_PREVIEW_LINK_TYPE: - toolbar.setSubtitle(R.string.link); - break; - case Post.IMAGE_TYPE: - toolbar.setSubtitle(R.string.image); - break; - case Post.VIDEO_TYPE: - toolbar.setSubtitle(R.string.video); - break; - case Post.GIF_TYPE: - toolbar.setSubtitle(R.string.gif); - break; - case Post.GALLERY_TYPE: - toolbar.setSubtitle(R.string.gallery); - } - if (initializeFragment) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType); - bundle.putInt(PostFragment.EXTRA_FILTER, filter); + bundle.putParcelable(PostFragment.EXTRA_FILTER, postFilter); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); if (postType == PostDataSource.TYPE_USER) { @@ -331,7 +351,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec fab.setOnClickListener(view -> { Intent intent = new Intent(this, CustomizePostFilterActivity.class); - startActivity(intent); + startActivityForResult(intent, CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE); }); if (mAccessToken != null) { @@ -427,6 +447,16 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec } @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) { + if (mFragment != null) { + ((PostFragment) mFragment).changePostFilter(data.getParcelableExtra(CustomizePostFilterActivity.RETURN_EXTRA_POST_FILTER)); + } + } + } + + @Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 0fbf9f4f..15de5a52 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1317,7 +1317,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); bundle.putString(PostFragment.EXTRA_NAME, "popular"); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1327,7 +1326,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); bundle.putString(PostFragment.EXTRA_NAME, "all"); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1379,7 +1377,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1389,7 +1386,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); bundle.putString(PostFragment.EXTRA_NAME, "all"); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1399,7 +1395,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); bundle.putString(PostFragment.EXTRA_NAME, name); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1409,7 +1404,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putString(PostFragment.EXTRA_NAME, name); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_MULTI_REDDIT); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1420,7 +1414,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); bundle.putString(PostFragment.EXTRA_USER_NAME, name); bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_SUBMITTED); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); @@ -1430,7 +1423,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); bundle.putString(PostFragment.EXTRA_NAME, "popular"); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index 1330c0ee..b605aedb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -395,7 +395,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SEARCH); bundle.putString(PostFragment.EXTRA_NAME, mSubredditName); bundle.putString(PostFragment.EXTRA_QUERY, mQuery); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); mFragment.setArguments(bundle); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index b0032263..bcb0a40d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -200,7 +200,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT Bundle bundle = new Bundle(); bundle.putString(PostFragment.EXTRA_NAME, multiPath); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_MULTI_REDDIT); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); mFragment.setArguments(bundle); 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 de7b793d..70cea4fb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -1230,7 +1230,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp Bundle bundle = new Bundle(); bundle.putString(PostFragment.EXTRA_NAME, subredditName); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); 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 d5fb3823..c871f8e7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -1306,7 +1306,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); bundle.putString(PostFragment.EXTRA_USER_NAME, username); bundle.putString(PostFragment.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_SUBMITTED); - bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); 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 dd0ac7c8..0a6bd7fa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -412,7 +412,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView String subredditName = subredditNamePrefixed.substring(2); String authorPrefixed = "u/" + post.getAuthor(); String flair = post.getFlair(); - int nAwards = post.getnAwards(); + int nAwards = post.getNAwards(); ((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed); ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); @@ -736,7 +736,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView boolean nsfw = post.isNSFW(); boolean spoiler = post.isSpoiler(); String flair = post.getFlair(); - int nAwards = post.getnAwards(); + int nAwards = post.getNAwards(); boolean isArchived = post.isArchived(); if (mDisplaySubredditName) { 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 2824e8bb..bad67e8e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -129,7 +129,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public static final String EXTRA_QUERY = "EQ"; public static final String EXTRA_POST_TYPE = "EPT"; public static final String EXTRA_FILTER = "EF"; - public static final int EXTRA_NO_FILTER = -2; public static final String EXTRA_ACCESS_TOKEN = "EAT"; public static final String EXTRA_ACCOUNT_NAME = "EAN"; public static final String EXTRA_DISABLE_READ_POSTS = "EDRP"; @@ -444,9 +443,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator { postType = getArguments().getInt(EXTRA_POST_TYPE); //TODO: Initialize PostFilter - postFilter = new PostFilter(); + postFilter = getArguments().getParcelable(EXTRA_FILTER); + if (postFilter == null) { + postFilter = new PostFilter(); + } - int filter = getArguments().getInt(EXTRA_FILTER); String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN); accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false); @@ -692,7 +693,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (accountName != null && !accountName.equals("")) { if (readPosts == null) { if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) { - initializeAndBindPostViewModel(accessToken, locale, filter); + initializeAndBindPostViewModel(accessToken, locale); } else { FetchReadPosts.fetchReadPosts(mRedditDataRoomDatabase, accountName, postType == PostDataSource.TYPE_SUBREDDIT && subredditName != null && (subredditName.equals("all") || subredditName.equals("popular")), @@ -700,15 +701,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { this.readPosts = readPosts; this.subredditFilterList = subredditFilters; - initializeAndBindPostViewModel(accessToken, locale, filter); + initializeAndBindPostViewModel(accessToken, locale); } }); } } else { - initializeAndBindPostViewModel(accessToken, locale, filter); + initializeAndBindPostViewModel(accessToken, locale); } } else { - initializeAndBindPostViewModelForAnonymous(accessToken, locale, filter); + initializeAndBindPostViewModelForAnonymous(accessToken, locale); } vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true); @@ -820,57 +821,57 @@ public class PostFragment extends Fragment implements FragmentCommunicator { return rootView; } - private void initializeAndBindPostViewModel(String accessToken, Locale locale, int filter) { + private void initializeAndBindPostViewModel(String accessToken, Locale locale) { if (postType == PostDataSource.TYPE_SEARCH) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, - postFilter, filter, readPosts)).get(PostViewModel.class); + postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_SUBREDDIT) { if (subredditName.equals("all") || subredditName.equals("popular")) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, - postFilter, filter, readPosts, subredditFilterList)).get(PostViewModel.class); + postFilter, readPosts, subredditFilterList)).get(PostViewModel.class); } else { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, - postFilter, filter, readPosts)).get(PostViewModel.class); + postFilter, readPosts)).get(PostViewModel.class); } } else if (postType == PostDataSource.TYPE_MULTI_REDDIT) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, - postFilter, filter, readPosts)).get(PostViewModel.class); + postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_USER) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter, - where, filter, readPosts)).get(PostViewModel.class); + where, readPosts)).get(PostViewModel.class); } else { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, - postType, sortType, postFilter, filter, readPosts)).get(PostViewModel.class); + postType, sortType, postFilter, readPosts)).get(PostViewModel.class); } bindPostViewModel(); } - private void initializeAndBindPostViewModelForAnonymous(String accessToken, Locale locale, int filter) { + private void initializeAndBindPostViewModelForAnonymous(String accessToken, Locale locale) { //For anonymous user if (postType == PostDataSource.TYPE_SEARCH) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, - postFilter, filter, readPosts)).get(PostViewModel.class); + postFilter, readPosts)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_SUBREDDIT) { if (subredditName.equals("all") || subredditName.equals("popular")) { if (subredditFilterList != null) { mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, - postFilter, filter, readPosts, subredditFilterList)).get(PostViewModel.class); + postFilter, readPosts, subredditFilterList)).get(PostViewModel.class); } else { FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> { if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { @@ -878,7 +879,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, - sortType, postFilter, filter, readPosts, subredditFilterList)).get(PostViewModel.class); + sortType, postFilter, readPosts, subredditFilterList)).get(PostViewModel.class); bindPostViewModel(); } @@ -888,22 +889,22 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, postFilter, - filter, readPosts)).get(PostViewModel.class); + readPosts)).get(PostViewModel.class); } } else if (postType == PostDataSource.TYPE_MULTI_REDDIT) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, postFilter, - filter, readPosts)).get(PostViewModel.class); + readPosts)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_USER) { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter, - where, filter, readPosts)).get(PostViewModel.class); + where, readPosts)).get(PostViewModel.class); } else { mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken, accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, - postType, sortType, postFilter, filter, readPosts)).get(PostViewModel.class); + postType, sortType, postFilter, readPosts)).get(PostViewModel.class); } if (mPostViewModel != null) { @@ -1202,6 +1203,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } + @Override + public void changePostFilter(PostFilter postFilter) { + if (mPostViewModel != null) { + mPostViewModel.changePostFilter(postFilter); + } + } + @Subscribe public void onPostUpdateEvent(PostUpdateEventToPostList event) { PagedList<Post> posts = mAdapter.getCurrentList(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index a67f2ed8..96b0ef7b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -14,7 +14,6 @@ import java.util.LinkedHashSet; import java.util.List; import ml.docilealligator.infinityforreddit.PostFilter; -import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.readpost.ReadPost; import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter; import ml.docilealligator.infinityforreddit.utils.JSONUtils; @@ -25,14 +24,14 @@ import ml.docilealligator.infinityforreddit.utils.Utils; */ public class ParsePost { - public static void parsePosts(String response, int nPosts, int filter, PostFilter postFilter, List<ReadPost> readPostList, + public static void parsePosts(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList, ParsePostsListingListener parsePostsListingListener) { - new ParsePostDataAsyncTask(response, nPosts, filter, postFilter, readPostList, parsePostsListingListener).execute(); + new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, parsePostsListingListener).execute(); } - public static void parsePosts(String response, int nPosts, int filter, PostFilter postFilter, List<ReadPost> readPostList, + public static void parsePosts(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList, ParsePostsListingListener parsePostsListingListener) { - new ParsePostDataAsyncTask(response, nPosts, filter, postFilter, readPostList, subredditFilterList, parsePostsListingListener).execute(); + new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, subredditFilterList, parsePostsListingListener).execute(); } public static void parsePost(String response, ParsePostListener parsePostListener) { @@ -493,7 +492,6 @@ public class ParsePost { private static class ParsePostDataAsyncTask extends AsyncTask<Void, Void, Void> { private JSONArray allData; private int nPosts; - private int filter; private PostFilter postFilter; private List<ReadPost> readPostList; private List<SubredditFilter> subredditFilterList; @@ -504,7 +502,7 @@ public class ParsePost { private String lastItem; private boolean parseFailed; - ParsePostDataAsyncTask(String response, int nPosts, int filter, PostFilter postFilter, List<ReadPost> readPostList, + ParsePostDataAsyncTask(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList, ParsePostsListingListener parsePostsListingListener) { this.parsePostsListingListener = parsePostsListingListener; try { @@ -512,7 +510,6 @@ public class ParsePost { allData = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); lastItem = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY); this.nPosts = nPosts; - this.filter = filter; this.postFilter = postFilter; this.readPostList = readPostList; newPosts = new LinkedHashSet<>(); @@ -523,9 +520,9 @@ public class ParsePost { } } - ParsePostDataAsyncTask(String response, int nPosts, int filter, PostFilter postFilter, List<ReadPost> readPostList, + ParsePostDataAsyncTask(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList, ParsePostsListingListener parsePostsListingListener) { - this(response, nPosts, filter, postFilter, readPostList, parsePostsListingListener); + this(response, nPosts, postFilter, readPostList, parsePostsListingListener); this.subredditFilterList = subredditFilterList; } @@ -592,16 +589,8 @@ public class ParsePost { } } } - if (availablePost && !(!postFilter.allowNSFW && post.isNSFW())) { - if (filter == PostFragment.EXTRA_NO_FILTER) { - newPosts.add(post); - } else if (filter == post.getPostType()) { - newPosts.add(post); - } else if (filter == Post.LINK_TYPE && post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) { - newPosts.add(post); - } else if (filter == Post.NSFW_TYPE && post.isNSFW()) { - newPosts.add(post); - } + if (availablePost && PostFilter.isPostAllowed(post, postFilter)) { + newPosts.add(post); } } } catch (JSONException e) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index c96c325a..9449b050 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -359,7 +359,7 @@ public class Post implements Parcelable { awards += newAwardsHTML; } - public int getnAwards() { + public int getNAwards() { return nAwards; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java index c2fff1e6..1f6f5671 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java @@ -49,7 +49,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { private int postType; private SortType sortType; private PostFilter postFilter; - private int filter; private List<ReadPost> readPostList; private List<SubredditFilter> subredditFilterList; private String userWhere; @@ -66,7 +65,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { PostDataSource(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, int postType, - SortType sortType, PostFilter postFilter, int filter, List<ReadPost> readPostList) { + SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -79,14 +78,13 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { this.postType = postType; this.sortType = sortType == null ? new SortType(SortType.Type.BEST) : sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; postLinkedHashSet = new LinkedHashSet<>(); } PostDataSource(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, - String path, int postType, SortType sortType, PostFilter postFilter, int filter, + String path, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) { this.retrofit = retrofit; this.accessToken = accessToken; @@ -121,7 +119,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { this.sortType = sortType; } this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; this.subredditFilterList = subredditFilterList; postLinkedHashSet = new LinkedHashSet<>(); @@ -130,7 +127,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { PostDataSource(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter, - String where, int filter, List<ReadPost> readPostList) { + String where, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -145,7 +142,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { this.sortType = sortType == null ? new SortType(SortType.Type.NEW) : sortType; this.postFilter = postFilter; userWhere = where; - this.filter = filter; this.readPostList = readPostList; postLinkedHashSet = new LinkedHashSet<>(); } @@ -153,7 +149,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { PostDataSource(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditOrUserName, String query, int postType, SortType sortType, PostFilter postFilter, - int filter, List<ReadPost> readPostList) { + List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -168,7 +164,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { this.postType = postType; this.sortType = sortType == null ? new SortType(SortType.Type.RELEVANCE) : sortType; this.postFilter = postFilter; - this.filter = filter; postLinkedHashSet = new LinkedHashSet<>(); this.readPostList = readPostList; } @@ -261,7 +256,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -324,7 +319,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -384,7 +379,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, subredditFilterList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, subredditFilterList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -458,7 +453,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, subredditFilterList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, subredditFilterList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -519,7 +514,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -590,7 +585,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -673,7 +668,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -764,7 +759,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -824,7 +819,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { @@ -895,7 +890,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - ParsePost.parsePosts(response.body(), -1, filter, postFilter, readPostList, + ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, new ParsePost.ParsePostsListingListener() { @Override public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSourceFactory.java index c0bdc023..c31619af 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSourceFactory.java @@ -28,7 +28,6 @@ class PostDataSourceFactory extends DataSource.Factory { private SortType sortType; private PostFilter postFilter; private String userWhere; - private int filter; private List<ReadPost> readPostList; private List<SubredditFilter> subredditFilterList; @@ -38,7 +37,7 @@ class PostDataSourceFactory extends DataSource.Factory { PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, int postType, - SortType sortType, PostFilter postFilter, int filter, List<ReadPost> readPostList) { + SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -49,14 +48,13 @@ class PostDataSourceFactory extends DataSource.Factory { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; } PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, int postType, SortType sortType, PostFilter postFilter, - int filter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) { + List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -68,7 +66,6 @@ class PostDataSourceFactory extends DataSource.Factory { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; this.subredditFilterList = subredditFilterList; } @@ -76,7 +73,7 @@ class PostDataSourceFactory extends DataSource.Factory { PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, int postType, SortType sortType, PostFilter postFilter, - String where, int filter, List<ReadPost> readPostList) { + String where, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -89,14 +86,13 @@ class PostDataSourceFactory extends DataSource.Factory { this.sortType = sortType; this.postFilter = postFilter; userWhere = where; - this.filter = filter; this.readPostList = readPostList; } PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, String query, int postType, SortType sortType, PostFilter postFilter, - int filter, List<ReadPost> readPostList) { + List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -109,7 +105,6 @@ class PostDataSourceFactory extends DataSource.Factory { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; } @@ -119,19 +114,19 @@ class PostDataSourceFactory extends DataSource.Factory { if (postType == PostDataSource.TYPE_FRONT_PAGE) { postDataSource = new PostDataSource(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType, - postFilter, filter, readPostList); + postFilter, readPostList); } else if (postType == PostDataSource.TYPE_SEARCH) { postDataSource = new PostDataSource(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, query, - postType, sortType, postFilter, filter, readPostList); + postType, sortType, postFilter, readPostList); } else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) { postDataSource = new PostDataSource(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, - sortType, postFilter, filter, readPostList, subredditFilterList); + sortType, postFilter, readPostList, subredditFilterList); } else { postDataSource = new PostDataSource(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, - sortType, postFilter, userWhere, filter, readPostList); + sortType, postFilter, userWhere, readPostList); } postDataSourceLiveData.postValue(postDataSource); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java index 4a805ccc..189f0264 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java @@ -35,9 +35,9 @@ public class PostViewModel extends ViewModel { public PostViewModel(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences cache, int postType, - SortType sortType, PostFilter postFilter, int filter, List<ReadPost> readPostList) { + SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, locale, - sharedPreferences, cache, postType, sortType, postFilter, filter, readPostList); + sharedPreferences, cache, postType, sortType, postFilter, readPostList); initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), PostDataSource::getInitialLoadStateLiveData); @@ -68,10 +68,10 @@ public class PostViewModel extends ViewModel { public PostViewModel(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName, - int postType, SortType sortType, PostFilter postFilter, int filter, + int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) { postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, locale, - sharedPreferences, cache, subredditName, postType, sortType, postFilter, filter, + sharedPreferences, cache, subredditName, postType, sortType, postFilter, readPostList, subredditFilterList); initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), @@ -103,11 +103,10 @@ public class PostViewModel extends ViewModel { public PostViewModel(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName, - int postType, SortType sortType, PostFilter postFilter, String where, int filter, + int postType, SortType sortType, PostFilter postFilter, String where, List<ReadPost> readPostList) { postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, locale, - sharedPreferences, cache, subredditName, postType, sortType, postFilter, where, filter, - readPostList); + sharedPreferences, cache, subredditName, postType, sortType, postFilter, where, readPostList); initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), PostDataSource::getInitialLoadStateLiveData); @@ -138,10 +137,9 @@ public class PostViewModel extends ViewModel { public PostViewModel(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName, - String query, int postType, SortType sortType, PostFilter postFilter, int filter, - List<ReadPost> readPostList) { + String query, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName, locale, - sharedPreferences, cache, subredditName, query, postType, sortType, postFilter, filter, + sharedPreferences, cache, subredditName, query, postType, sortType, postFilter, readPostList); initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(), @@ -216,14 +214,12 @@ public class PostViewModel extends ViewModel { private SortType sortType; private PostFilter postFilter; private String userWhere; - private int filter; private List<ReadPost> readPostList; private List<SubredditFilter> subredditFilterList; public Factory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, - int postType, SortType sortType, PostFilter postFilter, int filter, - List<ReadPost> readPostList) { + int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -233,15 +229,13 @@ public class PostViewModel extends ViewModel { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; } public Factory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, - int postType, SortType sortType, PostFilter postFilter, int filter, - List<ReadPost> readPostList) { + int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -252,7 +246,6 @@ public class PostViewModel extends ViewModel { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; } @@ -260,7 +253,7 @@ public class PostViewModel extends ViewModel { public Factory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, - int postType, SortType sortType, PostFilter postFilter, int filter, + int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) { this.retrofit = retrofit; this.accessToken = accessToken; @@ -272,7 +265,6 @@ public class PostViewModel extends ViewModel { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; this.subredditFilterList = subredditFilterList; } @@ -280,8 +272,7 @@ public class PostViewModel extends ViewModel { //User posts public Factory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, - int postType, SortType sortType, PostFilter postFilter, String where, int filter, - List<ReadPost> readPostList) { + int postType, SortType sortType, PostFilter postFilter, String where, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -293,14 +284,12 @@ public class PostViewModel extends ViewModel { this.sortType = sortType; this.postFilter = postFilter; userWhere = where; - this.filter = filter; this.readPostList = readPostList; } public Factory(Retrofit retrofit, String accessToken, String accountName, Locale locale, SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName, - String query, int postType, SortType sortType, PostFilter postFilter, int filter, - List<ReadPost> readPostList) { + String query, int postType, SortType sortType, PostFilter postFilter, List<ReadPost> readPostList) { this.retrofit = retrofit; this.accessToken = accessToken; this.accountName = accountName; @@ -312,7 +301,6 @@ public class PostViewModel extends ViewModel { this.postType = postType; this.sortType = sortType; this.postFilter = postFilter; - this.filter = filter; this.readPostList = readPostList; } @@ -321,19 +309,19 @@ public class PostViewModel extends ViewModel { public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { if (postType == PostDataSource.TYPE_FRONT_PAGE) { return (T) new PostViewModel(retrofit, accessToken, accountName, locale, sharedPreferences, - postFeedScrolledPositionSharedPreferences, postType, sortType, postFilter, filter, readPostList); + postFeedScrolledPositionSharedPreferences, postType, sortType, postFilter, readPostList); } else if (postType == PostDataSource.TYPE_SEARCH) { return (T) new PostViewModel(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, - postFilter, filter, readPostList); + postFilter, readPostList); } else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) { return (T) new PostViewModel(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, - postFilter, filter, readPostList, subredditFilterList); + postFilter, readPostList, subredditFilterList); } else { return (T) new PostViewModel(retrofit, accessToken, accountName, locale, sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, - postFilter, userWhere, filter, readPostList); + postFilter, userWhere, readPostList); } } } diff --git a/app/src/main/res/layout/activity_customize_post_filter.xml b/app/src/main/res/layout/activity_customize_post_filter.xml index 727ebe58..d11daee5 100644 --- a/app/src/main/res/layout/activity_customize_post_filter.xml +++ b/app/src/main/res/layout/activity_customize_post_filter.xml @@ -163,6 +163,36 @@ </LinearLayout> + <LinearLayout + android:id="@+id/post_type_gallery_linear_layout_customize_post_filter_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:paddingStart="32dp" + android:paddingEnd="8dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:id="@+id/post_type_gallery_text_view_customize_post_filter_activity" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:layout_gravity="center_vertical" + android:text="@string/post_type_gallery" + android:fontFamily="?attr/font_default" + android:textSize="?attr/font_default" /> + + <com.google.android.material.checkbox.MaterialCheckBox + android:id="@+id/post_type_gallery_check_box_customize_post_filter_activity" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" /> + + </LinearLayout> + <com.google.android.material.textfield.TextInputLayout android:id="@+id/title_excludes_strings_text_input_layout_customize_post_filter_activity" android:layout_width="match_parent" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index baa52b3f..02d9877a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -199,6 +199,7 @@ <string name="bottom_sheet_post_link">Link</string> <string name="bottom_sheet_post_image">Image</string> <string name="bottom_sheet_post_video">Video</string> + <string name="post_type_gallery">Gallery</string> <string name="select_from_gallery">Select a picture</string> <string name="select_again">Select again</string> diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 9c964d01..666bc186 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -44,11 +44,10 @@ <Preference app:key="security" app:title="@string/settings_security_title" - android:icon="@drawable/ic_security_24dp" + app:icon="@drawable/ic_security_24dp" app:fragment="ml.docilealligator.infinityforreddit.settings.SecurityPreferenceFragment" /> <Preference - app:key="security" app:title="@string/settings_data_saving_mode" app:icon="@drawable/ic_data_saving_mode_24dp" app:fragment="ml.docilealligator.infinityforreddit.settings.DataSavingModePreferenceFragment" /> |