Added support for spoiler text.

captchafix
Florens Douwes 11 years ago
parent c186e13c0f
commit 76fbe098ce
  1. 2
      Clover/src/org/floens/chan/core/manager/ThreadManager.java
  2. 10
      Clover/src/org/floens/chan/core/model/Post.java
  3. 12
      Clover/src/org/floens/chan/core/model/PostLinkable.java

@ -404,6 +404,8 @@ public class ThreadManager implements Loader.LoaderListener {
} else { } else {
openLink(linkable); openLink(linkable);
} }
} else if (linkable.type == PostLinkable.Type.SPOILER) {
new AlertDialog.Builder(activity).setMessage(linkable.value).show();
} }
} }

@ -279,6 +279,16 @@ public class Post {
} }
} }
total = TextUtils.concat(total, link);
} else if (nodeName.equals("s")) {
Element spoiler = (Element) node;
SpannableString link = new SpannableString(spoiler.text());
PostLinkable pl = new PostLinkable(this, spoiler.text(), spoiler.text(), Type.SPOILER);
link.setSpan(pl, 0, link.length(), 0);
linkables.add(pl);
total = TextUtils.concat(total, link); total = TextUtils.concat(total, link);
} else { } else {
// Unknown tag, add the inner part // Unknown tag, add the inner part

@ -27,7 +27,7 @@ import android.view.View;
*/ */
public class PostLinkable extends ClickableSpan { public class PostLinkable extends ClickableSpan {
public static enum Type { public static enum Type {
QUOTE, LINK QUOTE, LINK, SPOILER
}; };
public final Post post; public final Post post;
@ -51,7 +51,13 @@ public class PostLinkable extends ClickableSpan {
@Override @Override
public void updateDrawState(TextPaint ds) { public void updateDrawState(TextPaint ds) {
ds.setColor(type == Type.QUOTE ? Color.argb(255, 221, 0, 0) : Color.argb(255, 0, 0, 180)); if (type == Type.QUOTE || type == Type.LINK) {
ds.setUnderlineText(true); ds.setColor(type == Type.QUOTE ? Color.argb(255, 221, 0, 0) : Color.argb(255, 0, 0, 180));
ds.setUnderlineText(true);
} else if (type == Type.SPOILER) {
ds.setColor(0x00000000);
ds.bgColor = 0xff000000;
ds.setUnderlineText(false);
}
} }
} }

Loading…
Cancel
Save