Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public List<Post> filterHiddenPosts(List<Post> posts, int siteId, String board)
true,
false,
false,
false,
hiddenPost.hideRepliesToThisPost,
false
);
Expand Down Expand Up @@ -203,6 +204,7 @@ private void applyPostFilterActionToChildPosts(Post parentPost, Map<Integer, Pos
parentPost.filterStub,
parentPost.filterRemove,
parentPost.filterWatch,
parentPost.filterPrioritize,
true,
parentPost.filterSaved
);
Expand All @@ -222,6 +224,7 @@ private Post rebuildPostWithCustomFilter(
boolean filterStub,
boolean filterRemove,
boolean filterWatch,
boolean filterPrioritize,
boolean filterReplies,
boolean filterSaved
) {
Expand Down Expand Up @@ -250,6 +253,7 @@ private Post rebuildPostWithCustomFilter(
filterStub,
filterRemove,
filterWatch,
filterPrioritize,
filterReplies,
false,
filterSaved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public enum FilterAction {
HIDE,
COLOR,
REMOVE,
WATCH;
WATCH,
PRIORITIZE;

public static String actionName(FilterAction action) {
return StringUtils.caseAndSpace(action.name() + " post", null, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public class Post

public final boolean filterWatch;

public final boolean filterPrioritize;

public final boolean filterReplies;

public final boolean filterOnlyOP;
Expand Down Expand Up @@ -151,6 +153,7 @@ private Post(Builder builder) {
filterStub = builder.filterStub;
filterRemove = builder.filterRemove;
filterWatch = builder.filterWatch;
filterPrioritize = builder.filterPrioritize;
filterReplies = builder.filterReplies;
filterOnlyOP = builder.filterOnlyOP;
filterSaved = builder.filterSaved;
Expand Down Expand Up @@ -198,6 +201,7 @@ public boolean equals(Object o) {
&& filterStub == post.filterStub
&& filterRemove == post.filterRemove
&& filterWatch == post.filterWatch
&& filterPrioritize == post.filterPrioritize
&& filterReplies == post.filterReplies
&& filterOnlyOP == post.filterOnlyOP
&& filterSaved == post.filterSaved
Expand Down Expand Up @@ -244,6 +248,7 @@ public int hashCode() {
filterStub,
filterRemove,
filterWatch,
filterPrioritize,
filterReplies,
filterOnlyOP,
filterSaved,
Expand Down Expand Up @@ -302,6 +307,7 @@ public Post clone() {
filterStub,
filterRemove,
filterWatch,
filterPrioritize,
filterReplies,
filterOnlyOP,
filterSaved
Expand Down Expand Up @@ -385,6 +391,7 @@ public static final class Builder
public boolean filterStub;
public boolean filterRemove;
public boolean filterWatch;
public boolean filterPrioritize;
public boolean filterReplies;
public boolean filterOnlyOP;
public boolean filterSaved;
Expand Down Expand Up @@ -546,6 +553,7 @@ public Builder filter(
boolean stub,
boolean remove,
boolean watch,
boolean prioritize,
boolean filterReplies,
boolean onlyOnOp,
boolean filterSaved
Expand All @@ -554,6 +562,7 @@ public Builder filter(
filterStub = filterStub | stub;
filterRemove = filterRemove | remove;
filterWatch = filterWatch | watch;
filterPrioritize = filterPrioritize | prioritize;
this.filterReplies = this.filterReplies | filterReplies;
filterOnlyOP = filterOnlyOP | onlyOnOp;
this.filterSaved = this.filterSaved | filterSaved;
Expand Down Expand Up @@ -621,6 +630,7 @@ public Post.Builder clone() {
filterStub,
filterRemove,
filterWatch,
filterPrioritize,
filterReplies,
filterOnlyOP,
filterSaved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,23 @@ private void processPostFilter(Post.Builder post) {
false,
false,
false,
false,
f.applyToReplies,
f.onlyOnOP,
f.applyToSaved
);
break;
case HIDE:
post.filter(new int[]{0}, true, false, false, f.applyToReplies, f.onlyOnOP, false);
post.filter(new int[]{0}, true, false, false, false, f.applyToReplies, f.onlyOnOP, false);
break;
case REMOVE:
post.filter(new int[]{0}, false, true, false, f.applyToReplies, f.onlyOnOP, false);
post.filter(new int[]{0}, false, true, false, false, f.applyToReplies, f.onlyOnOP, false);
break;
case WATCH:
post.filter(new int[]{0}, false, false, true, false, true, false);
post.filter(new int[]{0}, false, false, true, false, false, true, false);
break;
case PRIORITIZE:
post.filter(new int[]{0}, false, false, false, true, false, true, false);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ public List<Post> apply(ChanThread thread) {
// Process order
Collections.sort(posts, postsOrder.postComparator);

// Partition posts into posts to sort with priority and normal posts and then rebuild
List<Post> postsToSortToTop = new ArrayList<>();
List<Post> postsNotToSortToTop = new ArrayList<>();

for (Post post : posts) {
if (post.filterPrioritize) {
postsToSortToTop.add(post);
} else {
postsNotToSortToTop.add(post);
}
}
posts.clear();
posts.addAll(postsToSortToTop);
posts.addAll(postsNotToSortToTop);

// Process search
if (!TextUtils.isEmpty(query)) {
boolean add;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.github.adamantcheese.chan.Chan.inject;
import static com.github.adamantcheese.chan.core.manager.FilterEngine.FilterAction.COLOR;
import static com.github.adamantcheese.chan.core.manager.FilterEngine.FilterAction.PRIORITIZE;
import static com.github.adamantcheese.chan.core.manager.FilterEngine.FilterAction.WATCH;
import static com.github.adamantcheese.chan.ui.widget.DefaultAlertDialog.getDefaultAlertBuilder;
import static com.github.adamantcheese.chan.utils.AndroidUtils.*;
Expand Down Expand Up @@ -386,7 +387,7 @@ private void updateFilterAction() {
filter.color = 0xffff0000;
}
colorPreview.setBackgroundColor(filter.color);
if (filter.action != WATCH.ordinal()) {
if (filter.action != WATCH.ordinal() && filter.action != PRIORITIZE.ordinal()) {
applyToReplies.setEnabled(true);
onlyOnOP.setEnabled(true);
onlyOnOP.setChecked(false);
Expand Down
1 change: 1 addition & 0 deletions Kuroba/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Actions do the following:<br>
<b>Watch:</b> If you have the thread watcher enabled and background watching on, catalogs will be periodically checked
based on your interval setting and any OP that matches the filter will be put into your bookmarks. Any catalogs loaded
by the you navigating to them from the board select popup will also be checked.<br>
<b>Prioritize:</b> Prioritize the post when sorting the board index and force it to be before non-prioritized posts.<br>
<br>
Enabled filters have priority from top to bottom in your list. Filter precedence for actions is as follows:<br>
1) Capcode or sticky<br>
Expand Down