From 39d31138dfa4ff0fa7626e4c5323a78ef9978fb2 Mon Sep 17 00:00:00 2001 From: Floens Date: Tue, 26 Jan 2016 13:11:47 +0100 Subject: [PATCH] Don't auto add new sfw boards, mark some boards as nsfw Also keep /f/ out --- .../floens/chan/core/manager/BoardManager.java | 4 ++-- .../java/org/floens/chan/core/model/Board.java | 8 +++++--- .../floens/chan/core/net/BoardsRequest.java | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/core/manager/BoardManager.java b/Clover/app/src/main/java/org/floens/chan/core/manager/BoardManager.java index 6235a7851c..c9ace4da1d 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/manager/BoardManager.java +++ b/Clover/app/src/main/java/org/floens/chan/core/manager/BoardManager.java @@ -136,12 +136,12 @@ private void setBoardsFromServer(List serverList) { } if (!has) { - Logger.d(TAG, "Adding unknown board: " + serverBoard.value); + /*Logger.d(TAG, "Adding unknown board: " + serverBoard.value); if (serverBoard.workSafe) { serverBoard.saved = true; serverBoard.order = allBoards.size(); - } + }*/ allBoards.add(serverBoard); } diff --git a/Clover/app/src/main/java/org/floens/chan/core/model/Board.java b/Clover/app/src/main/java/org/floens/chan/core/model/Board.java index 0e3dd652ee..d961ba0426 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/model/Board.java +++ b/Clover/app/src/main/java/org/floens/chan/core/model/Board.java @@ -17,6 +17,8 @@ */ package org.floens.chan.core.model; +import android.text.TextUtils; + import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; @@ -126,12 +128,12 @@ public Board(String key, String value, boolean saved, boolean workSafe) { public String description; public boolean finish() { - if (key == null || value == null || perPage < 0 || pages < 0) + if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value) || perPage < 0 || pages < 0) return false; - // Also filters out /f/, it can't be viewed anyway - if (cooldownThreads < 0 || cooldownReplies < 0 || cooldownImages < 0 || cooldownRepliesIntra < 0 || cooldownImagesIntra < 0) + if (cooldownThreads < 0 || cooldownReplies < 0 || cooldownImages < 0 || cooldownRepliesIntra < 0 || cooldownImagesIntra < 0) { return false; + } return true; } diff --git a/Clover/app/src/main/java/org/floens/chan/core/net/BoardsRequest.java b/Clover/app/src/main/java/org/floens/chan/core/net/BoardsRequest.java index b9c6891ecd..7cfc9f2ea2 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/net/BoardsRequest.java +++ b/Clover/app/src/main/java/org/floens/chan/core/net/BoardsRequest.java @@ -26,9 +26,19 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; public class BoardsRequest extends JsonReaderRequest> { + public static List BLOCKED = Collections.singletonList( + "f" + ); + + public static List TREAT_AS_NOT_WORKSAFE = Arrays.asList( + "a", "c", "w", "cm", "jp", "mlp", "lgbt" + ); + public BoardsRequest(String url, Listener> listener, ErrorListener errorListener) { super(url, listener, errorListener); } @@ -169,6 +179,14 @@ private Board readBoardEntry(JsonReader reader) throws IOException { return null; } + if (BLOCKED.contains(board.value)) { + return null; + } + + if (TREAT_AS_NOT_WORKSAFE.contains(board.value)) { + board.workSafe = false; + } + return board; } }