biskuteri-cafe-JKomasto2/JKomasto.java

211 lines
3.0 KiB
Java
Executable File

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Image;
import java.util.List;
import java.time.ZonedDateTime;
import cafe.biskuteri.hinoki.Tree;
class
JKomasto {
private TimelineWindow
timelineWindow;
private ComposeWindow
composeWindow;
private PostWindow
autoViewWindow;
private LoginWindow
loginWindow;
private ImageWindow
mediaWindow;
private NotificationsWindow
notificationsWindow;
private WindowUpdater
windowUpdater;
private MastodonApi
api;
// ---%-@-%---
public MastodonApi
getMastodonApi() { return api; }
public void
finishedLogin()
{
timelineWindow.setCursor(new Cursor(Cursor.WAIT_CURSOR));
timelineWindow.showLatestPage();
notificationsWindow.showLatestPage();
timelineWindow.setVisible(true);
loginWindow.dispose();
timelineWindow.setCursor(null);
}
public PostWindow
getAutoViewWindow() { return autoViewWindow; }
public ComposeWindow
getComposeWindow() { return composeWindow; }
public ImageWindow
getMediaWindow() { return mediaWindow; }
public NotificationsWindow
getNotificationsWindow() { return notificationsWindow; }
public WindowUpdater
getWindowUpdater() { return windowUpdater; }
// ---%-@-%---
public static void
main(String... args)
{
new JKomasto().loginWindow.setVisible(true);
}
// ---%-@-%---
public
JKomasto()
{
api = new MastodonApi();
windowUpdater = new WindowUpdater(this);
timelineWindow = new TimelineWindow(this);
composeWindow = new ComposeWindow(this);
autoViewWindow = new PostWindow(this);
loginWindow = new LoginWindow(this);
mediaWindow = new ImageWindow();
notificationsWindow = new NotificationsWindow(this);
autoViewWindow.setTitle("Auto view - JKomasto");
composeWindow.dispose();
autoViewWindow.dispose();
timelineWindow.dispose();
mediaWindow.dispose();
notificationsWindow.dispose();
timelineWindow.setLocationByPlatform(true);
loginWindow.setLocationByPlatform(true);
}
}
enum
PostVisibility {
PUBLIC,
UNLISTED,
FOLLOWERS,
MENTIONED
}
enum
TimelineType {
FEDERATED,
LOCAL,
HOME,
LIST
}
enum
NotificationType {
MENTION,
BOOST,
FAVOURITE,
FOLLOW,
FOLLOWREQ,
POLL,
ALERT
}
class
TimelinePage {
public TimelineType
type;
public String
accountNumId, listId;
public Tree<String>
posts;
}
class
Notification {
public NotificationType
type;
public String
id;
public String
postId, postText, actorNumId, actorName;
}
class
Attachment {
public String
type;
public String
url;
public String
description;
public Image
image;
}
class
Composition {
public String
text,
contentWarning;
public PostVisibility
visibility;
public String
replyToPostId;
}