Add filter option that removes the post completely

filtering
Floens 10 years ago
parent 8a472097db
commit 4288b6ab18
  1. 5
      Clover/app/src/main/java/org/floens/chan/core/manager/FilterEngine.java
  2. 1
      Clover/app/src/main/java/org/floens/chan/core/model/Post.java
  3. 3
      Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java
  4. 4
      Clover/app/src/main/java/org/floens/chan/ui/adapter/PostsFilter.java
  5. 3
      Clover/app/src/main/java/org/floens/chan/ui/controller/FiltersController.java
  6. 3
      Clover/app/src/main/res/values/strings.xml

@ -73,7 +73,8 @@ public class FilterEngine {
public enum FilterAction { public enum FilterAction {
HIDE(0), HIDE(0),
COLOR(1); COLOR(1),
REMOVE(2);
public final int id; public final int id;
@ -85,7 +86,7 @@ public class FilterEngine {
return enums[id]; return enums[id];
} }
private static FilterAction[] enums = new FilterAction[2]; private static FilterAction[] enums = new FilterAction[3];
static { static {
for (FilterAction type : values()) { for (FilterAction type : values()) {

@ -68,6 +68,7 @@ public class Post {
public boolean spoiler = false; public boolean spoiler = false;
public int filterHighlightedColor = 0; public int filterHighlightedColor = 0;
public boolean filterStub = false; public boolean filterStub = false;
public boolean filterRemove = false;
/** /**
* This post replies to the these ids. Is an unmodifiable list after finish(). * This post replies to the these ids. Is an unmodifiable list after finish().
*/ */

@ -343,6 +343,9 @@ public class ChanReaderRequest extends JsonReaderRequest<ChanReaderRequest.ChanR
case HIDE: case HIDE:
post.filterStub = true; post.filterStub = true;
break; break;
case REMOVE:
post.filterRemove = true;
break;
} }
} }
} }

@ -124,11 +124,11 @@ public class PostsFilter {
} }
} }
// Process hidden // Process hidden either by a filter or by thread hiding
Iterator<Post> i = posts.iterator(); Iterator<Post> i = posts.iterator();
while (i.hasNext()) { while (i.hasNext()) {
Post post = i.next(); Post post = i.next();
if (databaseManager.isThreadHidden(post)) { if (post.filterRemove || databaseManager.isThreadHidden(post)) {
i.remove(); i.remove();
} }
} }

@ -87,6 +87,8 @@ public class FiltersController extends Controller implements ToolbarMenuItem.Too
return getString(R.string.filter_hide); return getString(R.string.filter_hide);
case COLOR: case COLOR:
return getString(R.string.filter_color); return getString(R.string.filter_color);
case REMOVE:
return getString(R.string.filter_remove);
} }
return null; return null;
} }
@ -161,6 +163,7 @@ public class FiltersController extends Controller implements ToolbarMenuItem.Too
private void deleteFilter(Filter filter) { private void deleteFilter(Filter filter) {
filterEngine.remove(filter); filterEngine.remove(filter);
EventBus.getDefault().post(new RefreshUIMessage("filters"));
adapter.load(); adapter.load();
//TODO: undo //TODO: undo
} }

@ -133,7 +133,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="filter_boards">Boards</string> <string name="filter_boards">Boards</string>
<string name="filter_boards_all">all</string> <string name="filter_boards_all">all</string>
<string name="filter_hide">Hide post</string> <string name="filter_hide">Hide post</string>
<string name="filter_color">Highlight</string> <string name="filter_color">Highlight post</string>
<string name="filter_remove">Remove post</string>
<string name="filter_invalid_pattern">Invalid pattern</string> <string name="filter_invalid_pattern">Invalid pattern</string>
<string name="filter_preview">Test your filter</string> <string name="filter_preview">Test your filter</string>
<string name="filter_no_matches">Does not match</string> <string name="filter_no_matches">Does not match</string>

Loading…
Cancel
Save