mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Ignore case when matching post title in PostFilter. Always check duplicate PostFilter before saving a PostFilter not from settings.
This commit is contained in:
parent
6ad34783c5
commit
5af4085409
@ -259,7 +259,11 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
||||
postFilter = new PostFilter();
|
||||
originalName = "";
|
||||
} else {
|
||||
originalName = postFilter.name;
|
||||
if (!fromSettings) {
|
||||
originalName = "";
|
||||
} else {
|
||||
originalName = postFilter.name;
|
||||
}
|
||||
}
|
||||
bindView();
|
||||
}
|
||||
|
@ -107,14 +107,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
private PostFragment mFragment;
|
||||
private Menu mMenu;
|
||||
private AppBarLayout.LayoutParams params;
|
||||
private SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment;
|
||||
private SortTypeBottomSheetFragment popularAndAllSortTypeBottomSheetFragment;
|
||||
private SortTypeBottomSheetFragment subredditSortTypeBottomSheetFragment;
|
||||
private SortTypeBottomSheetFragment multiRedditSortTypeBottomSheetFragment;
|
||||
private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
|
||||
private SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment;
|
||||
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
|
||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -247,8 +239,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
} else {
|
||||
getCurrentAccountAndBindView(postFilter);
|
||||
}
|
||||
|
||||
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -293,35 +283,16 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
switch (postType) {
|
||||
case PostDataSource.TYPE_FRONT_PAGE:
|
||||
getSupportActionBar().setTitle(name);
|
||||
|
||||
bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle bestBundle = new Bundle();
|
||||
bestBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
|
||||
bestSortTypeBottomSheetFragment.setArguments(bestBundle);
|
||||
break;
|
||||
case PostDataSource.TYPE_SEARCH:
|
||||
getSupportActionBar().setTitle(R.string.search);
|
||||
|
||||
searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
|
||||
Bundle searchBundle = new Bundle();
|
||||
searchPostSortTypeBottomSheetFragment.setArguments(searchBundle);
|
||||
break;
|
||||
case PostDataSource.TYPE_SUBREDDIT:
|
||||
if (name.equals("popular") || name.equals("all")) {
|
||||
getSupportActionBar().setTitle(name.substring(0, 1).toUpperCase() + name.substring(1));
|
||||
|
||||
popularAndAllSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle popularBundle = new Bundle();
|
||||
popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle);
|
||||
} else {
|
||||
String subredditNamePrefixed = "r/" + name;
|
||||
getSupportActionBar().setTitle(subredditNamePrefixed);
|
||||
|
||||
subredditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle subredditSheetBundle = new Bundle();
|
||||
subredditSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
subredditSortTypeBottomSheetFragment.setArguments(subredditSheetBundle);
|
||||
}
|
||||
break;
|
||||
case PostDataSource.TYPE_MULTI_REDDIT:
|
||||
@ -333,22 +304,13 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
multiRedditName = name.substring(name.lastIndexOf("/") + 1);
|
||||
}
|
||||
getSupportActionBar().setTitle(multiRedditName);
|
||||
|
||||
multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle multiRedditBundle = new Bundle();
|
||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
|
||||
break;
|
||||
case PostDataSource.TYPE_USER:
|
||||
String usernamePrefixed = "u/" + name;
|
||||
getSupportActionBar().setTitle(usernamePrefixed);
|
||||
|
||||
userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
|
||||
break;
|
||||
}
|
||||
|
||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||
|
||||
if (initializeFragment) {
|
||||
mFragment = new PostFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@ -418,22 +380,42 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
case R.id.action_sort_filtered_thing_activity:
|
||||
switch (postType) {
|
||||
case PostDataSource.TYPE_FRONT_PAGE:
|
||||
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle bestBundle = new Bundle();
|
||||
bestBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
|
||||
bestSortTypeBottomSheetFragment.setArguments(bestBundle);
|
||||
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
|
||||
break;
|
||||
case PostDataSource.TYPE_SEARCH:
|
||||
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
|
||||
Bundle searchBundle = new Bundle();
|
||||
searchPostSortTypeBottomSheetFragment.setArguments(searchBundle);
|
||||
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
|
||||
break;
|
||||
case PostDataSource.TYPE_SUBREDDIT:
|
||||
if (name.equals("popular") || name.equals("all")) {
|
||||
SortTypeBottomSheetFragment popularAndAllSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle popularBundle = new Bundle();
|
||||
popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle);
|
||||
popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag());
|
||||
} else {
|
||||
SortTypeBottomSheetFragment subredditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle subredditSheetBundle = new Bundle();
|
||||
subredditSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
subredditSortTypeBottomSheetFragment.setArguments(subredditSheetBundle);
|
||||
subredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), subredditSortTypeBottomSheetFragment.getTag());
|
||||
}
|
||||
break;
|
||||
case PostDataSource.TYPE_MULTI_REDDIT:
|
||||
SortTypeBottomSheetFragment multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle multiRedditBundle = new Bundle();
|
||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
|
||||
multiRedditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), multiRedditSortTypeBottomSheetFragment.getTag());
|
||||
break;
|
||||
case PostDataSource.TYPE_USER:
|
||||
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
|
||||
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
|
||||
}
|
||||
return true;
|
||||
@ -463,6 +445,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
}
|
||||
return true;
|
||||
case R.id.action_change_post_layout_filtered_post_activity:
|
||||
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||
return true;
|
||||
}
|
||||
@ -522,6 +505,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
@Override
|
||||
public void sortTypeSelected(String sortType) {
|
||||
SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
|
||||
sortTimeBottomSheetFragment.setArguments(bundle);
|
||||
@ -548,7 +532,11 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
@Override
|
||||
public void fabOptionSelected(int option) {
|
||||
if (option == FilteredThingFABMoreOptionsBottomSheetFragment.FAB_OPTION_FILTER) {
|
||||
|
||||
Intent intent = new Intent(this, CustomizePostFilterActivity.class);
|
||||
if (mFragment != null) {
|
||||
intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, mFragment.getPostFilter());
|
||||
}
|
||||
startActivityForResult(intent, CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE);
|
||||
} else if (option == FilteredThingFABMoreOptionsBottomSheetFragment.FAB_OPTION_HIDE_READ_POSTS) {
|
||||
if (mFragment != null) {
|
||||
mFragment.hideReadPosts();
|
||||
|
@ -131,9 +131,15 @@ public class PostFilter implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
if (postFilter.onlyNSFW && !post.isNSFW()) {
|
||||
if (postFilter.onlySpoiler) {
|
||||
return post.isSpoiler();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (postFilter.onlySpoiler && !post.isSpoiler()) {
|
||||
if (postFilter.onlyNSFW) {
|
||||
return post.isNSFW();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!postFilter.containTextType && post.getPostType() == Post.TEXT_TYPE) {
|
||||
@ -164,7 +170,7 @@ public class PostFilter implements Parcelable {
|
||||
if (postFilter.postTitleExcludesStrings != null && !postFilter.postTitleExcludesStrings.equals("")) {
|
||||
String[] titles = postFilter.postTitleExcludesStrings.split(",", 0);
|
||||
for (String t : titles) {
|
||||
if (!t.equals("") && post.getTitle().contains(t)) {
|
||||
if (!t.equals("") && post.getTitle().toLowerCase().contains(t.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
|
||||
public class SavePostFilter {
|
||||
public interface SavePostFilterListener {
|
||||
//Need to make sure it is running in the UI thread.
|
||||
void success();
|
||||
void duplicate();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/submit_post"
|
||||
android:text="@string/filter_posts"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
|
Loading…
Reference in New Issue
Block a user