From 7673fe141934937f52d9b53d89aef12c001b954c Mon Sep 17 00:00:00 2001 From: Snowyfox Date: Sun, 1 May 2022 08:33:17 -0400 Subject: [PATCH] Added NotificationsWindow as updatee Changed font to MotoyaLMaru --- ClipboardApi.java | 0 ComposeWindow.java | 0 ImageApi.java | 0 ImageWindow.java | 0 JKomasto.java | 0 KDE_Dialog_Appear.wav | Bin LoginWindow.java | 0 MastodonApi.java | 0 NotificationsWindow.java | 99 ++++++++++++++++---------------- PostWindow.java | 24 +------- RepliesWindow.java | 0 RequestListener.java | 0 RichTextPane.java | 5 ++ RudimentaryHTMLParser.java | 0 TimelineWindow.java | 24 ++++++-- TimelineWindowUpdater.java | 60 +++++++++++++------ TwoToggleButton.java | 0 graphics/Federated.xcf | Bin graphics/Flags.xcf | Bin graphics/Hourglass.xcf | Bin graphics/boostToggled.png | Bin graphics/boostUntoggled.png | Bin graphics/button.png | Bin graphics/disabledOverlay.png | Bin graphics/favouriteToggled.png | Bin graphics/favouriteUntoggled.png | Bin graphics/federated.png | Bin graphics/miscToggled.png | Bin graphics/miscUntoggled.png | Bin graphics/ref1.png | Bin graphics/replyToggled.png | Bin graphics/replyUntoggled.png | Bin graphics/selectedOverlay.png | Bin graphics/test1.png | Bin graphics/test2.png | Bin graphics/test3.png | Bin graphics/test4.png | Bin notifOptions.txt | 0 notifOptions.txt~ | 0 39 files changed, 119 insertions(+), 93 deletions(-) mode change 100644 => 100755 ClipboardApi.java mode change 100644 => 100755 ComposeWindow.java mode change 100644 => 100755 ImageApi.java mode change 100644 => 100755 ImageWindow.java mode change 100644 => 100755 JKomasto.java mode change 100644 => 100755 KDE_Dialog_Appear.wav mode change 100644 => 100755 LoginWindow.java mode change 100644 => 100755 MastodonApi.java mode change 100644 => 100755 NotificationsWindow.java mode change 100644 => 100755 PostWindow.java mode change 100644 => 100755 RepliesWindow.java mode change 100644 => 100755 RequestListener.java mode change 100644 => 100755 RichTextPane.java mode change 100644 => 100755 RudimentaryHTMLParser.java mode change 100644 => 100755 TimelineWindow.java mode change 100644 => 100755 TimelineWindowUpdater.java mode change 100644 => 100755 TwoToggleButton.java mode change 100644 => 100755 graphics/Federated.xcf mode change 100644 => 100755 graphics/Flags.xcf mode change 100644 => 100755 graphics/Hourglass.xcf mode change 100644 => 100755 graphics/boostToggled.png mode change 100644 => 100755 graphics/boostUntoggled.png mode change 100644 => 100755 graphics/button.png mode change 100644 => 100755 graphics/disabledOverlay.png mode change 100644 => 100755 graphics/favouriteToggled.png mode change 100644 => 100755 graphics/favouriteUntoggled.png mode change 100644 => 100755 graphics/federated.png mode change 100644 => 100755 graphics/miscToggled.png mode change 100644 => 100755 graphics/miscUntoggled.png mode change 100644 => 100755 graphics/ref1.png mode change 100644 => 100755 graphics/replyToggled.png mode change 100644 => 100755 graphics/replyUntoggled.png mode change 100644 => 100755 graphics/selectedOverlay.png mode change 100644 => 100755 graphics/test1.png mode change 100644 => 100755 graphics/test2.png mode change 100644 => 100755 graphics/test3.png mode change 100644 => 100755 graphics/test4.png mode change 100644 => 100755 notifOptions.txt mode change 100644 => 100755 notifOptions.txt~ diff --git a/ClipboardApi.java b/ClipboardApi.java old mode 100644 new mode 100755 diff --git a/ComposeWindow.java b/ComposeWindow.java old mode 100644 new mode 100755 diff --git a/ImageApi.java b/ImageApi.java old mode 100644 new mode 100755 diff --git a/ImageWindow.java b/ImageWindow.java old mode 100644 new mode 100755 diff --git a/JKomasto.java b/JKomasto.java old mode 100644 new mode 100755 diff --git a/KDE_Dialog_Appear.wav b/KDE_Dialog_Appear.wav old mode 100644 new mode 100755 diff --git a/LoginWindow.java b/LoginWindow.java old mode 100644 new mode 100755 diff --git a/MastodonApi.java b/MastodonApi.java old mode 100644 new mode 100755 diff --git a/NotificationsWindow.java b/NotificationsWindow.java old mode 100644 new mode 100755 index 838ad36..bb90639 --- a/NotificationsWindow.java +++ b/NotificationsWindow.java @@ -47,6 +47,56 @@ NotificationsWindow extends JFrame { // ---%-@-%--- + public void + displayEntity(Tree entity) + { + notifications = new ArrayList<>(); + for (Tree t: entity) + { + Notification n = new Notification(); + + n.id = t.get("id").value; + + String type = t.get("type").value; + if (type.equals("favourite")) + n.type = NotificationType.FAVOURITE; + else if (type.equals("reblog")) + n.type = NotificationType.BOOST; + else if (type.equals("mention")) + n.type = NotificationType.MENTION; + else if (type.equals("follow")) + n.type = NotificationType.FOLLOW; + else if (type.equals("follow_request")) + n.type = NotificationType.FOLLOWREQ; + else if (type.equals("poll")) + n.type = NotificationType.POLL; + else if (type.equals("status")) + n.type = NotificationType.ALERT; + + Tree actor = t.get("account"); + String aid, aname, adisp; + aid = actor.get("id").value; + aname = actor.get("username").value; + adisp = actor.get("display_name").value; + if (!adisp.isEmpty()) n.actorName = adisp; + else n.actorName = aname; + n.actorNumId = aid; + + if (n.type != NotificationType.FOLLOW) + { + Tree post = t.get("status"); + String pid, phtml, ptext; + pid = post.get("id").value; + phtml = post.get("content").value; + ptext = TimelineComponent.textApproximation(phtml); + n.postId = pid; + n.postText = ptext; + } + + notifications.add(n); + } + } + public void showLatestPage() { @@ -97,55 +147,8 @@ NotificationsWindow extends JFrame { public void requestSucceeded(Tree json) { - notifications = new ArrayList<>(); - for (Tree t: json) - { - Notification n = new Notification(); - - n.id = t.get("id").value; - - String type = t.get("type").value; - if (type.equals("favourite")) - n.type = NotificationType.FAVOURITE; - else if (type.equals("reblog")) - n.type = NotificationType.BOOST; - else if (type.equals("mention")) - n.type = NotificationType.MENTION; - else if (type.equals("follow")) - n.type = NotificationType.FOLLOW; - else if (type.equals("follow_request")) - n.type = NotificationType.FOLLOWREQ; - else if (type.equals("poll")) - n.type = NotificationType.POLL; - else if (type.equals("status")) - n.type = NotificationType.ALERT; - - Tree actor = t.get("account"); - String aid, aname, adisp; - aid = actor.get("id").value; - aname = actor.get("username").value; - adisp = actor.get("display_name").value; - if (!adisp.isEmpty()) n.actorName = adisp; - else n.actorName = aname; - n.actorNumId = aid; - - if (n.type != NotificationType.FOLLOW) - { - Tree post = t.get("status"); - String pid, phtml, ptext; - pid = post.get("id").value; - phtml = post.get("content").value; - ptext = - TimelineComponent - .textApproximation(phtml); - n.postId = pid; - n.postText = ptext; - } - - notifications.add(n); - } + displayEntity(json); } - } ); display.setCursor(null); diff --git a/PostWindow.java b/PostWindow.java old mode 100644 new mode 100755 index ef48ee1..fc0e202 --- a/PostWindow.java +++ b/PostWindow.java @@ -703,24 +703,6 @@ implements ActionListener { if (s.y > maxY) maxY = s.y; } body.setPreferredSize(new Dimension(1, maxY + 10)); - - ((java.awt.Graphics2D)g).setRenderingHint( - java.awt.RenderingHints.KEY_ANTIALIASING, - java.awt.RenderingHints.VALUE_ANTIALIAS_ON - ); - /* - * I suspect the reason why we are losing antialiasing, - * is that the JScrollPane asks us to paint once and - * then on scroll, it repaints from its capture of the - * viewport contents, rather than ask us to repaint. - * Then it wouldn't set the hint. - * - * We're scheduled to remove the scrolling functionality - * in favour of pages, so, we don't need to intercept - * the scroller for now. Though I feel like it would've - * made more sense to allow setting a widget's rendering - * hints. - */ } @@ -733,9 +715,9 @@ implements ActionListener { emojiUrls = new String[0][]; Border b = BorderFactory.createEmptyBorder(10, 10, 10, 10); - Font f1 = new Font("Dialog", Font.PLAIN, 18); - Font f2 = new Font("IPAGothic", Font.PLAIN, 14); - Font f3 = new Font("Dialog", Font.PLAIN, 20); + Font f1 = new Font("MotoyaLMaru", Font.PLAIN, 18); + Font f2 = new Font("MotoyaLMaru", Font.PLAIN, 14); + Font f3 = new Font("MotoyaLMaru", Font.PLAIN, 18); profile = new RoundButton(); favouriteBoost = new TwoToggleButton("favourite", "boost"); diff --git a/RepliesWindow.java b/RepliesWindow.java old mode 100644 new mode 100755 diff --git a/RequestListener.java b/RequestListener.java old mode 100644 new mode 100755 diff --git a/RichTextPane.java b/RichTextPane.java old mode 100644 new mode 100755 index b15086c..ff7a19f --- a/RichTextPane.java +++ b/RichTextPane.java @@ -71,6 +71,11 @@ implements MouseListener, MouseMotionListener, KeyListener { FontMetrics fm = g.getFontMetrics(getFont()); g.clearRect(0, 0, getWidth(), getHeight()); + ((java.awt.Graphics2D)g).setRenderingHint( + java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, + java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON + ); + int o = 0; for (Segment segment: text) { diff --git a/RudimentaryHTMLParser.java b/RudimentaryHTMLParser.java old mode 100644 new mode 100755 diff --git a/TimelineWindow.java b/TimelineWindow.java old mode 100644 new mode 100755 index 6e70483..d81f103 --- a/TimelineWindow.java +++ b/TimelineWindow.java @@ -85,6 +85,23 @@ implements ActionListener { // ---%-@-%--- + public void + receive(Tree pageEntity) + { + page.posts = pageEntity; + display.displayEntities(page.posts); + boolean full = pageEntity.size() >= PREVIEW_COUNT; + display.setNextPageAvailable(full); + display.setPreviousPageAvailable(true); + display.resetFocus(); + } + + public void + refresh() + { + + } + public void setTimelineType(TimelineType type) { @@ -148,12 +165,7 @@ implements ActionListener { public void requestSucceeded(Tree json) { - page.posts = json; - display.displayEntities(page.posts); - boolean full = json.size() >= PREVIEW_COUNT; - display.setNextPageAvailable(full); - display.setPreviousPageAvailable(true); - display.resetFocus(); + receive(json); } } diff --git a/TimelineWindowUpdater.java b/TimelineWindowUpdater.java old mode 100644 new mode 100755 index 24ea560..496bea2 --- a/TimelineWindowUpdater.java +++ b/TimelineWindowUpdater.java @@ -22,7 +22,10 @@ TimelineWindowUpdater { // - -%- - private List - updatees; + timelineUpdatees; + + private List + notificationUpdatees; private StringBuilder event, data; @@ -33,39 +36,56 @@ TimelineWindowUpdater { // - -%- - private Thread - federated, - local, - home; + spublic, + user; // ---%-@-%--- public void addWindow(TimelineWindow updatee) { - updatees.add(updatee); + timelineUpdatees.add(updatee); Connection c = new Connection(); c.type = updatee.getTimelineType(); - Thread t = new Thread(c); - switch (c.type) { + switch (c.type) + { case FEDERATED: - if (federated != null) return; - federated = t; break; case LOCAL: - if (local != null) return; - local = t; break; + if (spublic != null) return; + spublic = new Thread(c); + spublic.start(); + break; case HOME: - if (home != null) return; - home = t; break; - default: return; + if (user != null) return; + user = new Thread(c); + user.start(); + break; } - t.start(); } + public void + addWindow(NotificationsWindow updatee) + { + notificationUpdatees.add(updatee); + + Connection c = new Connection(); + c.type = TimelineType.HOME; + if (user != null) return; + user = new Thread(c); + user.start(); + } + public void removeWindow(TimelineWindow updatee) { - updatees.remove(updatee); + timelineUpdatees.remove(updatee); + } + + public void + removeWindow(NotificationsWindow updatee) + { + notificationUpdatees.remove(updatee); } // - -%- - @@ -83,6 +103,9 @@ TimelineWindowUpdater { for (TimelineWindow updatee: filter(type)) { updatee.showLatestPage(); } + for (NotificationsWindow updatee: notificationUpdatees) { + updatee.showLatestPage(); + } if (newNotif) { @@ -95,7 +118,7 @@ TimelineWindowUpdater { filter(TimelineType type) { List returnee = new ArrayList<>(); - for (TimelineWindow updatee: updatees) + for (TimelineWindow updatee: timelineUpdatees) if (updatee.getTimelineType() == type) returnee.add(updatee); return returnee; @@ -175,7 +198,8 @@ TimelineWindowUpdater { this.primaire = primaire; this.api = primaire.getMastodonApi(); - this.updatees = new ArrayList<>(); + this.timelineUpdatees = new ArrayList<>(); + this.notificationUpdatees = new ArrayList<>(); loadNotificationSound(); } diff --git a/TwoToggleButton.java b/TwoToggleButton.java old mode 100644 new mode 100755 diff --git a/graphics/Federated.xcf b/graphics/Federated.xcf old mode 100644 new mode 100755 diff --git a/graphics/Flags.xcf b/graphics/Flags.xcf old mode 100644 new mode 100755 diff --git a/graphics/Hourglass.xcf b/graphics/Hourglass.xcf old mode 100644 new mode 100755 diff --git a/graphics/boostToggled.png b/graphics/boostToggled.png old mode 100644 new mode 100755 diff --git a/graphics/boostUntoggled.png b/graphics/boostUntoggled.png old mode 100644 new mode 100755 diff --git a/graphics/button.png b/graphics/button.png old mode 100644 new mode 100755 diff --git a/graphics/disabledOverlay.png b/graphics/disabledOverlay.png old mode 100644 new mode 100755 diff --git a/graphics/favouriteToggled.png b/graphics/favouriteToggled.png old mode 100644 new mode 100755 diff --git a/graphics/favouriteUntoggled.png b/graphics/favouriteUntoggled.png old mode 100644 new mode 100755 diff --git a/graphics/federated.png b/graphics/federated.png old mode 100644 new mode 100755 diff --git a/graphics/miscToggled.png b/graphics/miscToggled.png old mode 100644 new mode 100755 diff --git a/graphics/miscUntoggled.png b/graphics/miscUntoggled.png old mode 100644 new mode 100755 diff --git a/graphics/ref1.png b/graphics/ref1.png old mode 100644 new mode 100755 diff --git a/graphics/replyToggled.png b/graphics/replyToggled.png old mode 100644 new mode 100755 diff --git a/graphics/replyUntoggled.png b/graphics/replyUntoggled.png old mode 100644 new mode 100755 diff --git a/graphics/selectedOverlay.png b/graphics/selectedOverlay.png old mode 100644 new mode 100755 diff --git a/graphics/test1.png b/graphics/test1.png old mode 100644 new mode 100755 diff --git a/graphics/test2.png b/graphics/test2.png old mode 100644 new mode 100755 diff --git a/graphics/test3.png b/graphics/test3.png old mode 100644 new mode 100755 diff --git a/graphics/test4.png b/graphics/test4.png old mode 100644 new mode 100755 diff --git a/notifOptions.txt b/notifOptions.txt old mode 100644 new mode 100755 diff --git a/notifOptions.txt~ b/notifOptions.txt~ old mode 100644 new mode 100755