Skip to content

Commit 121069e

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # accounts
2 parents f25f60c + f07484f commit 121069e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+638
-337
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ Each of us have created one or more PRs and most of these have been merged into
4242
- By Amy
4343
- The App Screen UI is the screen that acts as a proxy between the user's login screen and their individual chats
4444
- Upon logging in, a user will will be rendered with a view of app screen
45-
- App Screen provides an ordered list of a user's chats, allowing the user to open an individual chat by clicking the chat button
46-
- ChatView(the window referenced above) will open, displaying the chats's GUI
47-
- Apart from that, app screen also provides buttons that allow a user to create new chats
45+
- App screen provides an ordered list of a user's chats and also allows a user to create new chats
46+
- Each chat button will also display a date indicating the date of the last message in a chat's conversation history, or no date if a chat has no messages
47+
- ChatView (the window referenced above) will open upon clicking an existing chat to display the chats's GUI
48+
- With respect to ChatView, clicking on the +Private Chat and +Group Chat buttons will also open an instance of ChatView for a user to create a new chat
49+
50+
<img width="214" alt="appscreen-nov 25" src="https://user-images.githubusercontent.com/71410005/204060542-82bb8432-09fc-4379-aee6-7a9039e58029.png">
51+
52+
4853

4954
### User Registration and Login
5055
- By Madhav

accounts

247 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package data_access;
2+
3+
import interface_adapters.User_search_IA.UserRetriever;
4+
import use_cases.user_registration_use_cases.UserExists;
5+
import use_cases.user_registration_use_cases.UserCreator;
6+
7+
public abstract class Database implements UserCreator, UserRetriever, UserExists {
8+
}

src/main/java/data_access/UserDatabase.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
import entities.chat.Chat;
44
import interface_adapters.User_search_IA.IRetrieveList;
5-
import interface_adapters.user_registration_interface_adapters.UserExists;
65
import entities.user_entities.User;
76
import interface_adapters.profile_modification_IA.UserModificationGateway;
8-
import use_cases.user_registration_use_cases.UserCreator;
97
import entities.user_entities.UserFactory;
108
import interface_adapters.Chat.UserChatGateway;
11-
import interface_adapters.User_search_IA.UserRetriever;
129

1310
import java.io.*;
1411
import java.util.ArrayList;
1512
import java.util.List;
16-
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway, UserChatGateway {
13+
public class UserDatabase extends Database implements IRetrieveList, UserModificationGateway, UserChatGateway {
1714
File accounts;
1815
List<User> accountList;
1916
public UserDatabase(){
20-
this.accounts = new File("accounts");
17+
this.accounts = new File("user_accounts");
2118
if(!accounts.exists()){
2219
try {
2320
accounts.createNewFile();
@@ -146,9 +143,8 @@ public void modifyUser(String oldUsername, User modified){
146143
@Override
147144
public ArrayList<Chat> getUserChats(String username) {
148145
for (User user: accountList){
149-
//if(getUser(username).equals(user)){
150146
if(user.getUsername().equals(username)){
151-
return user.getUserChats();
147+
return user.getChats();
152148
}
153149
}
154150
throw new RuntimeException("Invalid username");

src/main/java/entities/chat/Chat.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package entities.chat;
22
import entities.message.Message;
33

4+
import java.io.Serializable;
45
import java.time.LocalDateTime;
56
import java.util.ArrayList;
67
// Chat is an abstract class
7-
public class Chat {
8+
public class Chat implements Serializable {
89

910
protected String name;
1011
protected String chatID;
@@ -43,14 +44,14 @@ public String getSenderUsername(){
4344
* @return convHist
4445
*/
4546
public ArrayList<Message> getConvHist(){
46-
return new ArrayList<Message>(this.convHist);
47+
return new ArrayList<>(this.convHist);
4748
}
4849

4950
/**
5051
* Add a message to the chat's conversation history when a message is sent or received
5152
* @param message Message that is sent or received
5253
*/
53-
public void addtoconvHist(Message message){
54+
public void addToConvHist(Message message){
5455
this.convHist.add(message);
5556
}
5657

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package entities.chat;
2+
3+
public class CommonPrivatechat implements PrivateChatfactory{
4+
5+
@Override
6+
public PrivateChat create(String name, String chatID, String recipientUsername) {
7+
return new PrivateChat(name,chatID,recipientUsername);
8+
}
9+
10+
}

src/main/java/entities/chat/PrivateChat.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,28 @@ public class PrivateChat extends Chat {
1414
Arraylist<Message> convHist;
1515
*/
1616
protected String recipientUsername;
17+
protected String senderUsername;
1718

1819
/**
1920
* Create a private chat
2021
*
2122
* @param name The name of the chat (also the username of the recipient)
2223
* @param chatID The ID of the chat
23-
* @param senderUsername The user sending the messages
2424
* @param recipientUsername The user receiving the messages
2525
*
26+
*
2627
*/
27-
public PrivateChat(String name, String chatID, String senderUsername, String recipientUsername ){
28+
public PrivateChat(String name, String chatID, String recipientUsername ){
2829
this.name = name;
2930
this.chatID = chatID;
30-
this.senderUsername = senderUsername;
3131
this.recipientUsername = recipientUsername;
3232
this.convHist = new ArrayList<Message>();
33+
3334
}
3435

3536

37+
38+
3639
/**
3740
* Get the recipient's username
3841
* @return senderRecipient
@@ -45,6 +48,10 @@ public void setRecipientUsername(String recipientUsername) {
4548
this.recipientUsername= recipientUsername;
4649
}
4750

51+
public String getRecipientUsername(String recipientUsername) {
52+
return this.recipientUsername;
53+
}
54+
4855
public String getSenderUsername(){
4956
return this.senderUsername;
5057
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package entities.chat;
2+
3+
//in Entity layer Interface tor create private chat.
4+
5+
public interface PrivateChatfactory {
6+
7+
PrivateChat create(String name, String chatID, String recipientUsername);
8+
9+
}

src/main/java/entities/message/Message.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package entities.message;
22

3+
import java.io.Serializable;
34
import java.time.LocalDateTime;
45

56
/**
67
* Message (abstract class) containing the message content and associated metadata
78
* The type of the message content is dependent on which child(ren) of Message the message is
89
* The metadata is universal for all message types and includes the ID of the sender, timestamp, ID of message
910
*/
10-
public abstract class Message {
11+
public abstract class Message implements Serializable{
1112
/**
1213
* ID of message sender (UUID)
1314
*/

src/main/java/entities/user_entities/User.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public Boolean PasswordMatch(String attempt){
6060
}
6161

6262
public void login(){
63-
UserAppScreenGateway appScreenGateway = new UserAppScreenGateway(this.getUsername(), new UserDatabase(new File("test9")));
63+
UserAppScreenGateway appScreenGateway = new UserAppScreenGateway(this.getUsername(), new UserDatabase(new File("user_accounts")));
64+
appScreenGateway.login();
6465
}
6566

6667
public ArrayList<Chat> getChats() {

0 commit comments

Comments
 (0)