|
|
|
@ -22,6 +22,7 @@ import android.text.TextUtils; |
|
|
|
|
import android.text.style.ForegroundColorSpan; |
|
|
|
|
import android.text.style.StrikethroughSpan; |
|
|
|
|
|
|
|
|
|
import org.floens.chan.ChanApplication; |
|
|
|
|
import org.floens.chan.chan.ChanUrls; |
|
|
|
|
import org.floens.chan.core.model.PostLinkable.Type; |
|
|
|
|
import org.floens.chan.ui.view.PostView; |
|
|
|
@ -205,8 +206,42 @@ public class Post { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case "a": { |
|
|
|
|
Element anchor = (Element) node; |
|
|
|
|
CharSequence anchor = parseAnchor((Element)node, total); |
|
|
|
|
if (anchor != null) { |
|
|
|
|
total = TextUtils.concat(total, anchor); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case "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); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: { |
|
|
|
|
// Unknown tag, add the inner part
|
|
|
|
|
if (node instanceof Element) { |
|
|
|
|
total = TextUtils.concat(total, ((Element) node).text()); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return total; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private CharSequence parseAnchor(Element anchor, CharSequence total) { |
|
|
|
|
String href = anchor.attr("href"); |
|
|
|
|
Set<String> classes = anchor.classNames(); |
|
|
|
|
|
|
|
|
@ -260,6 +295,11 @@ public class Post { |
|
|
|
|
if (id == resto) { |
|
|
|
|
key += " (OP)"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Append You when it's a reply to an saved reply
|
|
|
|
|
if (ChanApplication.getDatabaseManager().isSavedReply(board, id)) { |
|
|
|
|
key += " (You)"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -275,37 +315,10 @@ public class Post { |
|
|
|
|
link.setSpan(pl, 0, link.length(), 0); |
|
|
|
|
linkables.add(pl); |
|
|
|
|
|
|
|
|
|
total = TextUtils.concat(total, link); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case "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); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: { |
|
|
|
|
// Unknown tag, add the inner part
|
|
|
|
|
if (node instanceof Element) { |
|
|
|
|
total = TextUtils.concat(total, ((Element) node).text()); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return link; |
|
|
|
|
} else { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return total; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void detectLinks(String text, SpannableString spannable) { |
|
|
|
|