aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java66
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java1
4 files changed, 39 insertions, 42 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
index fabc37d2..c2e48860 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -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();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index e360315e..c7d07187 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -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();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
index 3bc28b0e..9c8dbcc8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
@@ -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;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
index aa5a47c3..c7f10885 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
@@ -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();
}