aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/bienvenidoainternet/baiparser/structure
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/bienvenidoainternet/baiparser/structure')
-rw-r--r--app/src/main/java/org/bienvenidoainternet/baiparser/structure/Board.java15
-rw-r--r--app/src/main/java/org/bienvenidoainternet/baiparser/structure/BoardItem.java43
-rw-r--r--app/src/main/java/org/bienvenidoainternet/baiparser/structure/ReplyID.java10
3 files changed, 58 insertions, 10 deletions
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/Board.java b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/Board.java
index cb95e63..536f476 100644
--- a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/Board.java
+++ b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/Board.java
@@ -24,16 +24,28 @@ import android.os.Parcelable;
public class Board implements Parcelable{
private String boardName, boardDir;
private int boardType;
- public Board(String boardName,String boardDir,int boardType){
+
+ public boolean isCanAttachFiles() {
+ return canAttachFiles;
+ }
+
+ public void setCanAttachFiles(boolean canAttachFiles) {
+ this.canAttachFiles = canAttachFiles;
+ }
+
+ private boolean canAttachFiles;
+ public Board(String boardName, String boardDir, int boardType, boolean canAttachFiles){
this.boardName = boardName;
this.boardDir = boardDir;
this.boardType = boardType;
+ this.canAttachFiles = canAttachFiles;
}
public Board(Parcel in){
this.boardName = in.readString();
this.boardDir = in.readString();
this.boardType = in.readInt();
+ this.canAttachFiles = in.readByte() != 0;
}
public String getBoardDir() {
@@ -70,5 +82,6 @@ public class Board implements Parcelable{
dest.writeString(boardName);
dest.writeString(boardDir);
dest.writeInt(boardType);
+ dest.writeByte((byte)(canAttachFiles ? 1 : 0));
}
}
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/BoardItem.java b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/BoardItem.java
index b21d598..8eb55e5 100644
--- a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/BoardItem.java
+++ b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/BoardItem.java
@@ -3,6 +3,12 @@ package org.bienvenidoainternet.baiparser.structure;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Log;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
/**
* BaiApp - Bienvenido a internet Android Application
@@ -31,12 +37,13 @@ public class BoardItem implements Parcelable {
private String message = "";
private String subject = "";
private String posterId = "";
- private int parentid, id, idcolor, totalreplies = 0, totalfiles, thumb_height, thumb_weight, filesize, deleted_code, bbs_id = 1, parentPostCount;
+ public String youtubeURL = "", youtubeID = "";
+ private int parentid = 0, id = 0, idcolor, totalreplies = 0, totalfiles, thumb_height, thumb_weight, filesize, deleted_code, bbs_id = 1, parentPostCount;
private long timestamp = 0;
private Bitmap thumbBitmap = null;
public boolean downloadingThumb = false;
- public boolean isReply = false;
+ public boolean isReply = false, isLocked = false, youtubeLink = false;
private Board parentBoard = null;
protected BoardItem(Parcel in) {
@@ -49,6 +56,8 @@ public class BoardItem implements Parcelable {
message = in.readString();
subject = in.readString();
posterId = in.readString();
+ youtubeURL = in.readString();
+ youtubeID = in.readString();
parentid = in.readInt();
id = in.readInt();
idcolor = in.readInt();
@@ -64,6 +73,8 @@ public class BoardItem implements Parcelable {
thumbBitmap = in.readParcelable(Bitmap.class.getClassLoader());
downloadingThumb = in.readByte() != 0;
isReply = in.readByte() != 0;
+ isLocked = in.readByte() != 0;
+ youtubeLink = in.readByte() != 0;
parentBoard = in.readParcelable(Board.class.getClassLoader());
}
@@ -124,12 +135,22 @@ public class BoardItem implements Parcelable {
}
public void setMessage(String message) {
- // TODO: Dar formato a los mensajes de otra forma
- this.message = message.replace("<span class=\"unkfunc\">", "<font color=#85c749><i>");
- this.message = this.message.replace("</span>", "</i></font>");
- if (this.message.contains("<hr")){
- this.message = this.message.replace("<hr />", "<br><br><small><font color=#FF8800><i>") + "</i></small></font>";
+ Document msg = Jsoup.parse(message);
+ if (!msg.getElementsByClass("yt").isEmpty()){
+ Element you = msg.getElementsByClass("yt").first();
+ if (this.getFile().isEmpty()){
+ this.thumb = you.getElementsByTag("img").attr("src");
+ String[] parts = thumb.split("/");
+ this.youtubeLink = true;
+ this.youtubeURL = "https://www.youtube.com/watch?v=" + parts[4];
+ this.youtubeID = parts[4];
+ Log.v("ID", youtubeID);
+ }
}
+ msg.select("img[src]").remove();
+ msg.select("span[class=unkfunc]").tagName("font").attr("color", "#8fb56c").wrap("<i></i>");
+ msg.select("div[class=yt]").wrap("<font color=red'><i></i></font>");
+ this.message = msg.html();
}
public String getName() {
@@ -288,6 +309,10 @@ public class BoardItem implements Parcelable {
return this.email.equals("sage");
}
+ public void setLockStatus(int i){
+ this.isLocked = i == 0 ? false : true;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -304,6 +329,8 @@ public class BoardItem implements Parcelable {
dest.writeString(message);
dest.writeString(subject);
dest.writeString(posterId);
+ dest.writeString(youtubeURL);
+ dest.writeString(youtubeID);
dest.writeInt(parentid);
dest.writeInt(id);
dest.writeInt(idcolor);
@@ -319,6 +346,8 @@ public class BoardItem implements Parcelable {
dest.writeParcelable(thumbBitmap, flags);
dest.writeByte((byte) (downloadingThumb ? 1 : 0));
dest.writeByte((byte) (isReply ? 1 : 0));
+ dest.writeByte((byte) (isLocked ? 1 : 0));
+ dest.writeByte((byte) (youtubeLink ? 1 : 0));
dest.writeParcelable(parentBoard, flags);
}
}
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/ReplyID.java b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/ReplyID.java
index 2780e74..9cf2319 100644
--- a/app/src/main/java/org/bienvenidoainternet/baiparser/structure/ReplyID.java
+++ b/app/src/main/java/org/bienvenidoainternet/baiparser/structure/ReplyID.java
@@ -4,6 +4,8 @@ import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
+import org.bienvenidoainternet.baiparser.ThemeManager;
+
import java.util.Random;
/**
@@ -26,10 +28,14 @@ import java.util.Random;
public class ReplyID implements Parcelable{
public String id;
public int color;
- public ReplyID(String id){
+ public ReplyID(String id, ThemeManager tm){
this.id = id;
Random r = new Random();
- this.color = Color.rgb(r.nextInt(125) + 127, r.nextInt(127) + 127, r.nextInt(127) + 127);
+ if (tm.isDarkTheme()){
+ this.color = Color.rgb(r.nextInt(125) + 127, r.nextInt(127) + 127, r.nextInt(127) + 127);
+ }else{
+ this.color = Color.rgb(r.nextInt(125), r.nextInt(127), r.nextInt(127));
+ }
}
protected ReplyID(Parcel in) {