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