mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 06:24:50 +01:00
Changed boost display.
Fixed bug in emoji parsing.
This commit is contained in:
parent
695d1057a2
commit
d546ef3210
@ -202,10 +202,26 @@ RudimentaryHTMLParser {
|
||||
pc = c;
|
||||
continue;
|
||||
}
|
||||
if (emoji && Character.isWhitespace(c))
|
||||
{
|
||||
emoji = false;
|
||||
if (e.length() > 0) {
|
||||
t.append(':');
|
||||
t.append(empty(e));
|
||||
}
|
||||
}
|
||||
if (emoji) e.append((char)c);
|
||||
else t.append((char)c);
|
||||
pc = c;
|
||||
}
|
||||
if (emoji)
|
||||
{
|
||||
emoji = false;
|
||||
if (e.length() > 0) {
|
||||
t.append(':');
|
||||
t.append(empty(e));
|
||||
}
|
||||
}
|
||||
if (t.length() > 0) {
|
||||
Tree<String> text = new Tree<String>();
|
||||
text.key = "text";
|
||||
|
@ -1,28 +0,0 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
class
|
||||
TestWindow extends JFrame {
|
||||
|
||||
TestWindow()
|
||||
{
|
||||
RichTextPane display = new RichTextPane();
|
||||
setContentPane(display);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setLocationByPlatform(true);
|
||||
setSize(320, 240);
|
||||
setVisible(true);
|
||||
setVisible(false);
|
||||
|
||||
String s = "This is a standard English sentence.";
|
||||
RichTextPane.Builder b = new RichTextPane.Builder();
|
||||
for (String word: s.split(" ")) b = b.text(word).spacer(" ");
|
||||
List<RichTextPane.Segment> text = b.finish();
|
||||
FontMetrics fm = display.getFontMetrics(display.getFont());
|
||||
RichTextPane.layout(text, fm, display.getWidth());
|
||||
display.setText(text);
|
||||
}
|
||||
|
||||
}
|
@ -319,15 +319,18 @@ implements ActionListener {
|
||||
{
|
||||
Post addee = new Post();
|
||||
|
||||
if (post.get("reblog").size() != 0) {
|
||||
addee.postId = post.get("id").value;
|
||||
// This fixes timeline navigation, but note that
|
||||
// we will be pranked here if we try to reply
|
||||
// to the boosted post.
|
||||
|
||||
if (post.get("reblog").size() != 0)
|
||||
{
|
||||
Tree<String> a = post.get("account");
|
||||
String s = a.get("display_name").value;
|
||||
addee.boosterName = s;
|
||||
addee.boosterName = a.get("display_name").value;
|
||||
post = post.get("reblog");
|
||||
}
|
||||
|
||||
addee.postId = post.get("id").value;
|
||||
|
||||
try {
|
||||
String s = post.get("created_at").value;
|
||||
addee.date = ZonedDateTime.parse(s);
|
||||
@ -350,8 +353,10 @@ implements ActionListener {
|
||||
if (tagName.equals("br")) b.append(" \n ");
|
||||
if (tagName.equals("/p")) b.append(" \n \n ");
|
||||
}
|
||||
if (node.key.equals("text")) b.append(node.value);
|
||||
if (node.key.equals("emoji")) b.append(node.value);
|
||||
if (node.key.equals("text"))
|
||||
b.append(node.value);
|
||||
if (node.key.equals("emoji"))
|
||||
b.append(":" + node.value + ":");
|
||||
}
|
||||
addee.text = b.toString();
|
||||
|
||||
@ -533,11 +538,13 @@ implements
|
||||
{
|
||||
PostPreviewComponent c = postPreviews.get(o);
|
||||
Post p = posts.get(o);
|
||||
{
|
||||
c.setTopLeft(p.authorName);
|
||||
if (p.boosterName != null)
|
||||
c.setTopLeft("boosted by " + p.boosterName);
|
||||
}
|
||||
{
|
||||
String f = "";
|
||||
if (p.boosterName != null)
|
||||
f += "b";
|
||||
if (p.attachments.length > 0)
|
||||
f += "a";
|
||||
|
||||
@ -553,11 +560,13 @@ implements
|
||||
|
||||
c.setTopRight(f + " " + t);
|
||||
}
|
||||
{
|
||||
if (p.contentWarning != null)
|
||||
c.setBottom("(" + p.contentWarning + ")");
|
||||
else
|
||||
c.setBottom(p.text + " ");
|
||||
}
|
||||
}
|
||||
for (int o = posts.size(); o < postPreviews.size(); ++o)
|
||||
{
|
||||
postPreviews.get(o).reset();
|
||||
@ -849,11 +858,16 @@ PostPreviewComponent extends JComponent {
|
||||
bottom.setFont(f3);
|
||||
bottom.setOpaque(false);
|
||||
|
||||
JPanel left = new JPanel();
|
||||
left.setOpaque(false);
|
||||
left.setLayout(new BorderLayout());
|
||||
left.add(top, BorderLayout.NORTH);
|
||||
left.add(bottom);
|
||||
|
||||
setFocusable(true);
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout());
|
||||
add(top, BorderLayout.NORTH);
|
||||
add(bottom);
|
||||
add(left);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user