SlideShare a Scribd company logo
1 of 80
Download to read offline
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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 .pdfarihantmum
 

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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 

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

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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