SlideShare a Scribd company logo
Creating a WhatsApp Clone - Part IX
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public class ChatForm extends Form {
private ChatContact contact;
private final int DAY = 24 * 60 * 60000;
private final SimpleDateFormat DAY_FORMAT =
new SimpleDateFormat("MMMMMM dd, yyyy");
private boolean todayAdded;
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
ChatForm
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
ChatForm
public ChatContact getContact() {
return contact;
}
public ChatForm(ChatContact contact, Form parent) {
super(contact.name.get(), BoxLayout.yLast());
setUIID("ChatForm");
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
ChatForm
this.contact = contact;
Toolbar tb = getToolbar();
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
ChatForm
tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW,
e -> parent.showBack());
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
ChatForm
tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM,
e -> {});
tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE,
e -> {});
tb.addCommandToOverflowMenu("View contact", null, e -> {});
tb.addCommandToOverflowMenu("Media", null, e -> {});
tb.addCommandToOverflowMenu("Search", null, e -> {});
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
ChatForm
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
tb.addCommandToOverflowMenu("Mute notifications", null, e -> {});
tb.addCommandToOverflowMenu("Wallpaper", null, e -> {});
final Component cc = createInputContainer();
add(cc);
if(contact.chats.size() > 0) {
Date time = contact.chats.get(0).time.get();
long currentDay = time.getTime() / DAY;
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ChatForm
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
addDay(time, currentDay);
for(ChatMessage m : contact.chats) {
time = m.time.get();
long c = time.getTime() / DAY;
if(c != currentDay) {
currentDay = c;
addDay(time, currentDay);
}
addMessageToUINoAnimation(m);
}
}
addShowListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
removeShowListener(this);
getContentPane().scrollComponentToVisible(cc);
}
});
}
private void addDay(Date d, long currentDay) {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
}
private void addDay(Date d, long currentDay) {
String text;
long t = System.currentTimeMillis() / DAY;
if(t == currentDay) {
text = "Today";
todayAdded = true;
} else {
if(t - 1 == currentDay) {
text = "Yesterday";
} else {
text = DAY_FORMAT.format(d);
}
}
Label day = new Label(text.toUpperCase(), "Day");
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
addComponent(getContentPane().getComponentCount() - 1,
FlowLayout.encloseCenter(day));
}
private Container createInputContainer() {
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
ChatForm
TextField input = new TextField("", "Type a message", 20,
TextArea.ANY);
input.getAllStyles().setBorder(Border.createEmpty());
input.setSingleLineTextArea(false);
input.setDoneListener(e -> {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
time.set(new Date()).
sentTo.set(contact.id.get()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
});
Button emoji = new Button("", FontImage.MATERIAL_MOOD,
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
"TextFieldIcon");
Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT,
"TextFieldIcon");
ChatForm
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
"TextFieldIcon");
Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT,
"TextFieldIcon");
camera.addActionListener(e -> openCamera());
attach.addActionListener(e -> openFile());
Container inputContainer = BorderLayout.centerEastWest(input,
BoxLayout.encloseX(attach, camera),
emoji);
inputContainer.setUIID("ChatTextField");
Button microphone = new Button("", FontImage.MATERIAL_MIC,
"RecordButton") {
@Override
public void pointerPressed(int x, int y) {
if(getMaterialIcon() == FontImage.MATERIAL_MIC) {
} else {
super.pointerPressed(x, y);
}
}
ChatForm
"TextFieldIcon");
Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE,
"TextFieldIcon");
Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT,
"TextFieldIcon");
camera.addActionListener(e -> openCamera());
attach.addActionListener(e -> openFile());
Container inputContainer = BorderLayout.centerEastWest(input,
BoxLayout.encloseX(attach, camera),
emoji);
inputContainer.setUIID("ChatTextField");
Button microphone = new Button("", FontImage.MATERIAL_MIC,
"RecordButton") {
@Override
public void pointerPressed(int x, int y) {
if(getMaterialIcon() == FontImage.MATERIAL_MIC) {
} else {
super.pointerPressed(x, y);
}
}
ChatForm
Container inputContainer = BorderLayout.centerEastWest(input,
BoxLayout.encloseX(attach, camera),
emoji);
inputContainer.setUIID("ChatTextField");
Button microphone = new Button("", FontImage.MATERIAL_MIC,
"RecordButton") {
@Override
public void pointerPressed(int x, int y) {
if(getMaterialIcon() == FontImage.MATERIAL_MIC) {
} else {
super.pointerPressed(x, y);
}
}
@Override
public void pointerReleased(int x, int y) {
if(getMaterialIcon() == FontImage.MATERIAL_MIC) {
} else {
super.pointerReleased(x, y);
ChatForm
super.pointerReleased(x, y);
}
}
};
input.addDataChangedListener((i, ii) -> {
if(input.getText().length() == 0) {
microphone.setMaterialIcon(FontImage.MATERIAL_MIC);
} else {
microphone.setMaterialIcon(FontImage.MATERIAL_SEND);
}
});
microphone.addActionListener(e -> {
if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
}
});
ChatForm
input.addDataChangedListener((i, ii) -> {
if(input.getText().length() == 0) {
microphone.setMaterialIcon(FontImage.MATERIAL_MIC);
} else {
microphone.setMaterialIcon(FontImage.MATERIAL_SEND);
}
});
microphone.addActionListener(e -> {
if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
}
});
return BorderLayout.
centerCenterEastWest(inputContainer, microphone, null);
}
private String twoDigit(int i) {
ChatForm
input.addDataChangedListener((i, ii) -> {
if(input.getText().length() == 0) {
microphone.setMaterialIcon(FontImage.MATERIAL_MIC);
} else {
microphone.setMaterialIcon(FontImage.MATERIAL_SEND);
}
});
microphone.addActionListener(e -> {
if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
}
});
return BorderLayout.
centerCenterEastWest(inputContainer, microphone, null);
}
private String twoDigit(int i) {
ChatForm
input.addDataChangedListener((i, ii) -> {
if(input.getText().length() == 0) {
microphone.setMaterialIcon(FontImage.MATERIAL_MIC);
} else {
microphone.setMaterialIcon(FontImage.MATERIAL_SEND);
}
});
microphone.addActionListener(e -> {
if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
body.set(input.getText()));
input.stopEditing();
input.setText("");
}
});
return BorderLayout.
centerCenterEastWest(inputContainer, microphone, null);
}
private String twoDigit(int i) {
ChatForm
});
return BorderLayout.
centerCenterEastWest(inputContainer, microphone, null);
}
private String twoDigit(int i) {
return i < 10 ? "0" + i : "" + i;
}
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
ChatForm
});
return BorderLayout.
centerCenterEastWest(inputContainer, microphone, null);
}
private String twoDigit(int i) {
return i < 10 ? "0" + i : "" + i;
}
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
ChatForm
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
getContentPane().scrollComponentToVisible(
getContentPane().getComponentAt(
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
ChatForm
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
getContentPane().scrollComponentToVisible(
getContentPane().getComponentAt(
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
ChatForm
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
getContentPane().scrollComponentToVisible(
getContentPane().getComponentAt(
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
ChatForm
private String getTime(long t) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(t));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return twoDigit(h) + ":" + twoDigit(m);
}
public void addMessageToUI(ChatMessage m) {
if(!todayAdded) {
addDay(new Date(), System.currentTimeMillis() / DAY);
}
addMessageToUINoAnimation(m);
getContentPane().animateLayoutAndWait(100);
getContentPane().scrollComponentToVisible(
getContentPane().getComponentAt(
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
ChatForm
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
Component cmp;
if(m.attachments.size() == 0) {
cmp = createTextMessage(m.body.get(), m.time.get().getTime());
} else {
cmp = createMediaMessage(
m.attachments.iterator().next().getValue(),
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
ChatForm
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
Component cmp;
if(m.attachments.size() == 0) {
cmp = createTextMessage(m.body.get(), m.time.get().getTime());
} else {
cmp = createMediaMessage(
m.attachments.iterator().next().getValue(),
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
ChatForm
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
Component cmp;
if(m.attachments.size() == 0) {
cmp = createTextMessage(m.body.get(), m.time.get().getTime());
} else {
cmp = createMediaMessage(
m.attachments.iterator().next().getValue(),
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
ChatForm
getContentPane().getComponentCount() - 1));
}
private Component addMessageToUINoAnimation(ChatMessage m) {
boolean left = m.authorId.get() == null ||
!m.authorId.get().equals(Server.user().id.get());
String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight";
Component cmp;
if(m.attachments.size() == 0) {
cmp = createTextMessage(m.body.get(), m.time.get().getTime());
} else {
cmp = createMediaMessage(
m.attachments.iterator().next().getValue(),
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
ChatForm
cmp = createTextMessage(m.body.get(), m.time.get().getTime());
} else {
cmp = createMediaMessage(
m.attachments.iterator().next().getValue(),
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
m.time.get().getTime());
}
ChatBubbleBorder cb = ChatBubbleBorder.create();
if(getContentPane().getComponentCount() > 1) {
Container cnt = (Container)getContentPane().
getComponentAt(getContentPane().getComponentCount() - 2);
if(cnt.getUIID().equals("Container")) {
Component cc = cnt.getComponentAt(0);
if(cc instanceof Container) {
cnt = (Container)cc;
}
}
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
ChatForm
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
Container cnt;
if(left) {
cnt = FlowLayout.encloseIn(cmp);
} else {
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
ChatForm
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
Container cnt;
if(left) {
cnt = FlowLayout.encloseIn(cmp);
} else {
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
ChatForm
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
Container cnt;
if(left) {
cnt = FlowLayout.encloseIn(cmp);
} else {
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
ChatForm
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
Container cnt;
if(left) {
cnt = FlowLayout.encloseIn(cmp);
} else {
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
ChatForm
if(!cnt.getUIID().equals(uiid)) {
cb.leftArrow(left).rightArrow(!left);
} else {
Style s = cnt.getAllStyles();
s.setPaddingBottom(0);
s.setMarginBottom(0);
}
} else {
cb.leftArrow(left).rightArrow(!left);
}
Container cnt;
if(left) {
cnt = FlowLayout.encloseIn(cmp);
} else {
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
ChatForm
cnt = FlowLayout.encloseRight(cmp);
}
cmp.setUIID(uiid);
addComponent(getContentPane().getComponentCount() - 1, cnt);
cnt.putClientProperty("message", m);
cmp.getAllStyles().setBorder(cb);
return cnt;
}
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
private void addMessage(ChatMessage m) {
Server.sendMessage(m, contact);
addMessageToUI(m);
}
private Component createTextMessage(String t, long mt) {
TextArea bubbleText = new TextArea(t);
bubbleText.setActAsLabel(true);
bubbleText.setEditable(false);
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
ChatForm
bubbleText.setFocusable(false);
bubbleText.setUIID("ChatText");
Label time = new Label(getTime(mt), "ChatTime");
Container bubble;
if(t.length() < 30) {
bubble = BoxLayout.encloseX(bubbleText, time);
} else {
bubble = BoxLayout.encloseY(bubbleText, time);
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
ChatForm
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
ChatForm
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
ChatForm
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
ChatForm
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
ChatForm
}
return bubble;
}
public Component createMediaMessage(String media, long mt) {
try(InputStream is = openFileInputStream(media)) {
int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2;
EncodedImage img = EncodedImage.create(is,
(int)getFileLength(media));
Button thumb = new Button("", img.fill(s, s),"ChatText");
Label time = new Label(getTime(mt), "ChatTime");
return LayeredLayout.encloseIn(thumb,
FlowLayout.encloseRightBottom(
time));
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
ChatForm
} catch(IOException ex) {
log(ex);
return new SpanLabel("Failed to load media");
}
}
public void openCamera() {
String pic = Capture.capturePhoto();
if(pic != null) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
attachments.put("Pic", pic));
}
}
public void openFile() {
FileChooser.showOpenDialog("*/*", e -> {
if(e != null) {
String file = (String)e.getSource();
if(file != null) {
ChatForm
}
}
public void openFile() {
FileChooser.showOpenDialog("*/*", e -> {
if(e != null) {
String file = (String)e.getSource();
if(file != null) {
String l = file.toLowerCase();
if(l.endsWith("jpg") || l.endsWith("jpeg") ||
l.endsWith("png")) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
attachments.put("Pic", file));
}
}
}
});
}
}
ChatForm
}
}
public void openFile() {
FileChooser.showOpenDialog("*/*", e -> {
if(e != null) {
String file = (String)e.getSource();
if(file != null) {
String l = file.toLowerCase();
if(l.endsWith("jpg") || l.endsWith("jpeg") ||
l.endsWith("png")) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
attachments.put("Pic", file));
}
}
}
});
}
}
ChatForm
}
}
public void openFile() {
FileChooser.showOpenDialog("*/*", e -> {
if(e != null) {
String file = (String)e.getSource();
if(file != null) {
String l = file.toLowerCase();
if(l.endsWith("jpg") || l.endsWith("jpeg") ||
l.endsWith("png")) {
addMessage(new ChatMessage().
authorId.set(Server.user().id.get()).
sentTo.set(contact.id.get()).
time.set(new Date()).
attachments.put("Pic", file));
}
}
}
});
}
}
ChatForm

More Related Content

Similar to Creating a Whatsapp Clone - Part IX.pdf

Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfCreating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdfCreating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part V.pdf
Creating a Whatsapp Clone - Part V.pdfCreating a Whatsapp Clone - Part V.pdf
Creating a Whatsapp Clone - Part V.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part VI - Transcript.pdfCreating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part VI - Transcript.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdfCreating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdfCreating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VIII.pdfCreating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VIII.pdf
ShaiAlmog1
 
Creating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfCreating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdf
ShaiAlmog1
 
How do I - Create a List of Items.pdf
How do I - Create a List of Items.pdfHow do I - Create a List of Items.pdf
How do I - Create a List of Items.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XXXV.pdf
Creating a Facebook Clone - Part XXXV.pdfCreating a Facebook Clone - Part XXXV.pdf
Creating a Facebook Clone - Part XXXV.pdf
ShaiAlmog1
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdfCreating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdfCreating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XLIII.pdf
Creating a Facebook Clone - Part XLIII.pdfCreating a Facebook Clone - Part XLIII.pdf
Creating a Facebook Clone - Part XLIII.pdf
ShaiAlmog1
 
Creating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdfCreating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdf
ShaiAlmog1
 
Windows Phone Launchers and Choosers
Windows Phone Launchers and ChoosersWindows Phone Launchers and Choosers
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 

Similar to Creating a Whatsapp Clone - Part IX.pdf (20)

Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfCreating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdfCreating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part VII.pdf
 
Creating a Whatsapp Clone - Part V.pdf
Creating a Whatsapp Clone - Part V.pdfCreating a Whatsapp Clone - Part V.pdf
Creating a Whatsapp Clone - Part V.pdf
 
Creating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part VI - Transcript.pdfCreating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part VI - Transcript.pdf
 
Creating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdfCreating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XVI.pdf
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdfCreating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdf
 
Creating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VIII.pdfCreating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VIII.pdf
 
Creating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdfCreating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXIX.pdf
 
How do I - Create a List of Items.pdf
How do I - Create a List of Items.pdfHow do I - Create a List of Items.pdf
How do I - Create a List of Items.pdf
 
Creating a Facebook Clone - Part XXXV.pdf
Creating a Facebook Clone - Part XXXV.pdfCreating a Facebook Clone - Part XXXV.pdf
Creating a Facebook Clone - Part XXXV.pdf
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdf
 
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdfCreating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdf
 
Creating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdfCreating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdf
 
Creating a Facebook Clone - Part XLIII.pdf
Creating a Facebook Clone - Part XLIII.pdfCreating a Facebook Clone - Part XLIII.pdf
Creating a Facebook Clone - Part XLIII.pdf
 
Creating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdfCreating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdf
 
Ss
SsSs
Ss
 
Windows Phone Launchers and Choosers
Windows Phone Launchers and ChoosersWindows Phone Launchers and Choosers
Windows Phone Launchers and Choosers
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 

More from ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdfCreating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdfCreating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part VII.pdf
Creating a Whatsapp Clone - Part VII.pdfCreating a Whatsapp Clone - Part VII.pdf
Creating a Whatsapp Clone - Part VII.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdfCreating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
ShaiAlmog1
 

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 
Creating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdfCreating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part VI.pdf
 
Creating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdfCreating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdf
 
Creating a Whatsapp Clone - Part VII.pdf
Creating a Whatsapp Clone - Part VII.pdfCreating a Whatsapp Clone - Part VII.pdf
Creating a Whatsapp Clone - Part VII.pdf
 
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdfCreating a Whatsapp Clone - Part XIII - Transcript.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
 

Recently uploaded

The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

Creating a Whatsapp Clone - Part IX.pdf

  • 1. Creating a WhatsApp Clone - Part IX
  • 2. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 3. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 4. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 5. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 6. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 7. public class ChatForm extends Form { private ChatContact contact; private final int DAY = 24 * 60 * 60000; private final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMMMMM dd, yyyy"); private boolean todayAdded; public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, ChatForm
  • 8. public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> parent.showBack()); tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM, e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE, e -> {}); tb.addCommandToOverflowMenu("View contact", null, e -> {}); ChatForm
  • 9. public ChatContact getContact() { return contact; } public ChatForm(ChatContact contact, Form parent) { super(contact.name.get(), BoxLayout.yLast()); setUIID("ChatForm"); this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> parent.showBack()); tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM, e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE, e -> {}); tb.addCommandToOverflowMenu("View contact", null, e -> {}); ChatForm
  • 10. this.contact = contact; Toolbar tb = getToolbar(); tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> parent.showBack()); tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM, e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE, e -> {}); tb.addCommandToOverflowMenu("View contact", null, e -> {}); tb.addCommandToOverflowMenu("Media", null, e -> {}); tb.addCommandToOverflowMenu("Search", null, e -> {}); tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); ChatForm
  • 11. tb.setBackCommand("", Toolbar.BackCommandPolicy.AS_ARROW, e -> parent.showBack()); tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM, e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE, e -> {}); tb.addCommandToOverflowMenu("View contact", null, e -> {}); tb.addCommandToOverflowMenu("Media", null, e -> {}); tb.addCommandToOverflowMenu("Search", null, e -> {}); tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; ChatForm
  • 12. tb.addCommandToLeftBar("", contact.getSmallIcon(), e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_VIDEOCAM, e -> {}); tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_PHONE, e -> {}); tb.addCommandToOverflowMenu("View contact", null, e -> {}); tb.addCommandToOverflowMenu("Media", null, e -> {}); tb.addCommandToOverflowMenu("Search", null, e -> {}); tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); ChatForm
  • 13. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ChatForm
  • 14. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ChatForm
  • 15. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ChatForm
  • 16. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ChatForm
  • 17. tb.addCommandToOverflowMenu("Mute notifications", null, e -> {}); tb.addCommandToOverflowMenu("Wallpaper", null, e -> {}); final Component cc = createInputContainer(); add(cc); if(contact.chats.size() > 0) { Date time = contact.chats.get(0).time.get(); long currentDay = time.getTime() / DAY; addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ChatForm
  • 18. addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { removeShowListener(this); getContentPane().scrollComponentToVisible(cc); } }); } private void addDay(Date d, long currentDay) { ChatForm
  • 19. addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { removeShowListener(this); getContentPane().scrollComponentToVisible(cc); } }); } private void addDay(Date d, long currentDay) { ChatForm
  • 20. addDay(time, currentDay); for(ChatMessage m : contact.chats) { time = m.time.get(); long c = time.getTime() / DAY; if(c != currentDay) { currentDay = c; addDay(time, currentDay); } addMessageToUINoAnimation(m); } } addShowListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { removeShowListener(this); getContentPane().scrollComponentToVisible(cc); } }); } private void addDay(Date d, long currentDay) { ChatForm
  • 21. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 22. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 23. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 24. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 25. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 26. } private void addDay(Date d, long currentDay) { String text; long t = System.currentTimeMillis() / DAY; if(t == currentDay) { text = "Today"; todayAdded = true; } else { if(t - 1 == currentDay) { text = "Yesterday"; } else { text = DAY_FORMAT.format(d); } } Label day = new Label(text.toUpperCase(), "Day"); addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { ChatForm
  • 27. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 28. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 29. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 30. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 31. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 32. addComponent(getContentPane().getComponentCount() - 1, FlowLayout.encloseCenter(day)); } private Container createInputContainer() { TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, ChatForm
  • 33. TextField input = new TextField("", "Type a message", 20, TextArea.ANY); input.getAllStyles().setBorder(Border.createEmpty()); input.setSingleLineTextArea(false); input.setDoneListener(e -> { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). time.set(new Date()). sentTo.set(contact.id.get()). body.set(input.getText())); input.stopEditing(); input.setText(""); }); Button emoji = new Button("", FontImage.MATERIAL_MOOD, "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, "TextFieldIcon"); Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT, "TextFieldIcon"); ChatForm
  • 34. "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, "TextFieldIcon"); Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT, "TextFieldIcon"); camera.addActionListener(e -> openCamera()); attach.addActionListener(e -> openFile()); Container inputContainer = BorderLayout.centerEastWest(input, BoxLayout.encloseX(attach, camera), emoji); inputContainer.setUIID("ChatTextField"); Button microphone = new Button("", FontImage.MATERIAL_MIC, "RecordButton") { @Override public void pointerPressed(int x, int y) { if(getMaterialIcon() == FontImage.MATERIAL_MIC) { } else { super.pointerPressed(x, y); } } ChatForm
  • 35. "TextFieldIcon"); Button attach = new Button("", FontImage.MATERIAL_ATTACH_FILE, "TextFieldIcon"); Button camera = new Button("", FontImage.MATERIAL_CAMERA_ALT, "TextFieldIcon"); camera.addActionListener(e -> openCamera()); attach.addActionListener(e -> openFile()); Container inputContainer = BorderLayout.centerEastWest(input, BoxLayout.encloseX(attach, camera), emoji); inputContainer.setUIID("ChatTextField"); Button microphone = new Button("", FontImage.MATERIAL_MIC, "RecordButton") { @Override public void pointerPressed(int x, int y) { if(getMaterialIcon() == FontImage.MATERIAL_MIC) { } else { super.pointerPressed(x, y); } } ChatForm
  • 36. Container inputContainer = BorderLayout.centerEastWest(input, BoxLayout.encloseX(attach, camera), emoji); inputContainer.setUIID("ChatTextField"); Button microphone = new Button("", FontImage.MATERIAL_MIC, "RecordButton") { @Override public void pointerPressed(int x, int y) { if(getMaterialIcon() == FontImage.MATERIAL_MIC) { } else { super.pointerPressed(x, y); } } @Override public void pointerReleased(int x, int y) { if(getMaterialIcon() == FontImage.MATERIAL_MIC) { } else { super.pointerReleased(x, y); ChatForm
  • 37. super.pointerReleased(x, y); } } }; input.addDataChangedListener((i, ii) -> { if(input.getText().length() == 0) { microphone.setMaterialIcon(FontImage.MATERIAL_MIC); } else { microphone.setMaterialIcon(FontImage.MATERIAL_SEND); } }); microphone.addActionListener(e -> { if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). body.set(input.getText())); input.stopEditing(); input.setText(""); } }); ChatForm
  • 38. input.addDataChangedListener((i, ii) -> { if(input.getText().length() == 0) { microphone.setMaterialIcon(FontImage.MATERIAL_MIC); } else { microphone.setMaterialIcon(FontImage.MATERIAL_SEND); } }); microphone.addActionListener(e -> { if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). body.set(input.getText())); input.stopEditing(); input.setText(""); } }); return BorderLayout. centerCenterEastWest(inputContainer, microphone, null); } private String twoDigit(int i) { ChatForm
  • 39. input.addDataChangedListener((i, ii) -> { if(input.getText().length() == 0) { microphone.setMaterialIcon(FontImage.MATERIAL_MIC); } else { microphone.setMaterialIcon(FontImage.MATERIAL_SEND); } }); microphone.addActionListener(e -> { if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). body.set(input.getText())); input.stopEditing(); input.setText(""); } }); return BorderLayout. centerCenterEastWest(inputContainer, microphone, null); } private String twoDigit(int i) { ChatForm
  • 40. input.addDataChangedListener((i, ii) -> { if(input.getText().length() == 0) { microphone.setMaterialIcon(FontImage.MATERIAL_MIC); } else { microphone.setMaterialIcon(FontImage.MATERIAL_SEND); } }); microphone.addActionListener(e -> { if(microphone.getMaterialIcon() == FontImage.MATERIAL_SEND) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). body.set(input.getText())); input.stopEditing(); input.setText(""); } }); return BorderLayout. centerCenterEastWest(inputContainer, microphone, null); } private String twoDigit(int i) { ChatForm
  • 41. }); return BorderLayout. centerCenterEastWest(inputContainer, microphone, null); } private String twoDigit(int i) { return i < 10 ? "0" + i : "" + i; } private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); ChatForm
  • 42. }); return BorderLayout. centerCenterEastWest(inputContainer, microphone, null); } private String twoDigit(int i) { return i < 10 ? "0" + i : "" + i; } private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); ChatForm
  • 43. private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); getContentPane().scrollComponentToVisible( getContentPane().getComponentAt( getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; ChatForm
  • 44. private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); getContentPane().scrollComponentToVisible( getContentPane().getComponentAt( getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; ChatForm
  • 45. private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); getContentPane().scrollComponentToVisible( getContentPane().getComponentAt( getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; ChatForm
  • 46. private String getTime(long t) { Calendar c = Calendar.getInstance(); c.setTime(new Date(t)); int h = c.get(Calendar.HOUR_OF_DAY); int m = c.get(Calendar.MINUTE); return twoDigit(h) + ":" + twoDigit(m); } public void addMessageToUI(ChatMessage m) { if(!todayAdded) { addDay(new Date(), System.currentTimeMillis() / DAY); } addMessageToUINoAnimation(m); getContentPane().animateLayoutAndWait(100); getContentPane().scrollComponentToVisible( getContentPane().getComponentAt( getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; ChatForm
  • 47. getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; Component cmp; if(m.attachments.size() == 0) { cmp = createTextMessage(m.body.get(), m.time.get().getTime()); } else { cmp = createMediaMessage( m.attachments.iterator().next().getValue(), m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { ChatForm
  • 48. getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; Component cmp; if(m.attachments.size() == 0) { cmp = createTextMessage(m.body.get(), m.time.get().getTime()); } else { cmp = createMediaMessage( m.attachments.iterator().next().getValue(), m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { ChatForm
  • 49. getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; Component cmp; if(m.attachments.size() == 0) { cmp = createTextMessage(m.body.get(), m.time.get().getTime()); } else { cmp = createMediaMessage( m.attachments.iterator().next().getValue(), m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { ChatForm
  • 50. getContentPane().getComponentCount() - 1)); } private Component addMessageToUINoAnimation(ChatMessage m) { boolean left = m.authorId.get() == null || !m.authorId.get().equals(Server.user().id.get()); String uiid = left ? "ChatBubbleLeft" : "ChatBubbleRight"; Component cmp; if(m.attachments.size() == 0) { cmp = createTextMessage(m.body.get(), m.time.get().getTime()); } else { cmp = createMediaMessage( m.attachments.iterator().next().getValue(), m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { ChatForm
  • 51. cmp = createTextMessage(m.body.get(), m.time.get().getTime()); } else { cmp = createMediaMessage( m.attachments.iterator().next().getValue(), m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); ChatForm
  • 52. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 53. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 54. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 55. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 56. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 57. m.time.get().getTime()); } ChatBubbleBorder cb = ChatBubbleBorder.create(); if(getContentPane().getComponentCount() > 1) { Container cnt = (Container)getContentPane(). getComponentAt(getContentPane().getComponentCount() - 2); if(cnt.getUIID().equals("Container")) { Component cc = cnt.getComponentAt(0); if(cc instanceof Container) { cnt = (Container)cc; } } if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } ChatForm
  • 58. if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } Container cnt; if(left) { cnt = FlowLayout.encloseIn(cmp); } else { cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } ChatForm
  • 59. if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } Container cnt; if(left) { cnt = FlowLayout.encloseIn(cmp); } else { cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } ChatForm
  • 60. if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } Container cnt; if(left) { cnt = FlowLayout.encloseIn(cmp); } else { cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } ChatForm
  • 61. if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } Container cnt; if(left) { cnt = FlowLayout.encloseIn(cmp); } else { cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } ChatForm
  • 62. if(!cnt.getUIID().equals(uiid)) { cb.leftArrow(left).rightArrow(!left); } else { Style s = cnt.getAllStyles(); s.setPaddingBottom(0); s.setMarginBottom(0); } } else { cb.leftArrow(left).rightArrow(!left); } Container cnt; if(left) { cnt = FlowLayout.encloseIn(cmp); } else { cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } ChatForm
  • 63. cnt = FlowLayout.encloseRight(cmp); } cmp.setUIID(uiid); addComponent(getContentPane().getComponentCount() - 1, cnt); cnt.putClientProperty("message", m); cmp.getAllStyles().setBorder(cb); return cnt; } private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { ChatForm
  • 64. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 65. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 66. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 67. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 68. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 69. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 70. private void addMessage(ChatMessage m) { Server.sendMessage(m, contact); addMessageToUI(m); } private Component createTextMessage(String t, long mt) { TextArea bubbleText = new TextArea(t); bubbleText.setActAsLabel(true); bubbleText.setEditable(false); bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } ChatForm
  • 71. bubbleText.setFocusable(false); bubbleText.setUIID("ChatText"); Label time = new Label(getTime(mt), "ChatTime"); Container bubble; if(t.length() < 30) { bubble = BoxLayout.encloseX(bubbleText, time); } else { bubble = BoxLayout.encloseY(bubbleText, time); } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { ChatForm
  • 72. } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); ChatForm
  • 73. } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); ChatForm
  • 74. } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); ChatForm
  • 75. } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); ChatForm
  • 76. } return bubble; } public Component createMediaMessage(String media, long mt) { try(InputStream is = openFileInputStream(media)) { int s = Math.min(getDisplayWidth(), getDisplayHeight()) / 2; EncodedImage img = EncodedImage.create(is, (int)getFileLength(media)); Button thumb = new Button("", img.fill(s, s),"ChatText"); Label time = new Label(getTime(mt), "ChatTime"); return LayeredLayout.encloseIn(thumb, FlowLayout.encloseRightBottom( time)); } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); ChatForm
  • 77. } catch(IOException ex) { log(ex); return new SpanLabel("Failed to load media"); } } public void openCamera() { String pic = Capture.capturePhoto(); if(pic != null) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). attachments.put("Pic", pic)); } } public void openFile() { FileChooser.showOpenDialog("*/*", e -> { if(e != null) { String file = (String)e.getSource(); if(file != null) { ChatForm
  • 78. } } public void openFile() { FileChooser.showOpenDialog("*/*", e -> { if(e != null) { String file = (String)e.getSource(); if(file != null) { String l = file.toLowerCase(); if(l.endsWith("jpg") || l.endsWith("jpeg") || l.endsWith("png")) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). attachments.put("Pic", file)); } } } }); } } ChatForm
  • 79. } } public void openFile() { FileChooser.showOpenDialog("*/*", e -> { if(e != null) { String file = (String)e.getSource(); if(file != null) { String l = file.toLowerCase(); if(l.endsWith("jpg") || l.endsWith("jpeg") || l.endsWith("png")) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). attachments.put("Pic", file)); } } } }); } } ChatForm
  • 80. } } public void openFile() { FileChooser.showOpenDialog("*/*", e -> { if(e != null) { String file = (String)e.getSource(); if(file != null) { String l = file.toLowerCase(); if(l.endsWith("jpg") || l.endsWith("jpeg") || l.endsWith("png")) { addMessage(new ChatMessage(). authorId.set(Server.user().id.get()). sentTo.set(contact.id.get()). time.set(new Date()). attachments.put("Pic", file)); } } } }); } } ChatForm