Skip to content

Commit fcef438

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents c621e28 + 55fb007 commit fcef438

File tree

11 files changed

+73
-13
lines changed

11 files changed

+73
-13
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ Each of us have created one or more PRs and most of these have been merged into
1111

1212
![image](https://user-images.githubusercontent.com/18428059/202935072-ba09587d-c67d-4599-9986-9c652480356f.png)
1313

14+
### Profile display
15+
- By Parmis
16+
- Implemented by UserSearchUI, which allows a user to type in a user's username to view their features (user and username so far).
17+
- User information is captured using ChangeController interface, which uses UserDatabse interfaces to retrieve the user of interest:
18+
![img.png](img.png)
19+
- Here, Alex123 is not a user of the chat system:
20+
![img_1.png](img_1.png)
21+
- parmis is a user of the chat system though:
22+
![img_2.png](img_2.png)
23+
24+
### Profile feature modification
25+
- By Parmis
26+
- Implemented by UserMdoificationUI, which allows a user to verify their authority to access their account by confirming their username and password, and then choosing the feature they wish to modify, and enter the new value for it.
27+
- User information is captured using UserPresenter interface, which uses UserAuthenticationI to confirm user's authority to make the change, then uses Changeable interface (use case) to make the changes to the User entity, and finally uses UserModificationGateway to relay the changed info to UserDatabase:
28+
![img_3.png](img_3.png)
29+
- Here: Parmis's password is actually 123, so she doesn't get the chance to change her email:
30+
![img_4.png](img_4.png)
31+
- as you can see, her email is unchanged.
32+
- now she enters the right password and tries again:
33+
![img_5.png](img_5.png)
34+
- This time, change was successful. She could use this tool to similarly change her username or password too:
35+
![img_6.png](img_6.png)
36+
37+
38+
### App Screen UI
39+
- By Amy
40+
- The App Screen UI is the screen that acts as a proxy between the user's login screen and their individual chats
41+
- Upon logging in, a user will will be rendered with a view of app screen
42+
- App Screen provides an ordered list of a user's chats, allowing the user to open an individual chat by clicking the chat button
43+
- ChatView(the window referenced above) will open, displaying the chats's GUI
44+
- Apart from that, app screen also provides buttons that allow a user to create new chats
45+
46+
1447

1548
## Template Readme
1649
This is a template repository for CSC 207 projects.

src/main/java/data_access/UserDatabase.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package data_access;
22

3+
import entities.chat.Chat;
34
import interface_adapters.User_search_IA.IRetrieveList;
45
import interface_adapters.user_registration_interface_adapters.UserExists;
56
import entities.user_entities.User;
67
import interface_adapters.profile_modification_IA.UserModificationGateway;
78
import use_cases.user_registration_use_cases.UserCreator;
89
import entities.user_entities.UserFactory;
10+
import interface_adapters.Chat.UserChatGateway;
911
import interface_adapters.User_search_IA.UserRetriever;
1012

1113
import java.io.*;
1214
import java.util.ArrayList;
1315
import java.util.List;
14-
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway {
16+
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway, UserChatGateway {
1517
File accounts;
1618
List<User> accountList;
1719
public UserDatabase(){
@@ -125,6 +127,16 @@ public void modifyUser(String oldUsername, User modified){
125127
}
126128
}
127129

130+
@Override
131+
public ArrayList<Chat> getUserChats(String username) {
132+
for (User user: accountList){
133+
if (getUser(username).equals(user)){
134+
return user.getUserChats();
135+
}
136+
}
137+
throw new RuntimeException("Invalid username");
138+
}
139+
128140
// Below two methods are used by conversation history-related interactors
129141
// (Commented as objects are not found)
130142
// /**

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package entities.user_entities;
22

33
import entities.chat.Chat;
4+
import interface_adapters.profile_modification_IA.UserAuthenticationI;
45
import interface_adapters.login_interface_adapters.Login;
56
import use_cases.user_attribute_modification_use_case.Changeable;
67
import interface_adapters.app_screen_interface_adapters.UserAppScreenGateway;
8+
import entities.chat;
79

810
import java.io.Serializable;
911
import java.util.ArrayList;
1012

11-
public abstract class User implements Serializable, Changeable, Login {
13+
public abstract class User implements Serializable, Changeable, Login, UserAuthenticationI {
1214
protected String username;
1315
protected String password;
1416
protected String email;
@@ -47,6 +49,7 @@ public void changeFeature(String feature, String newFeature){
4749
}
4850
}
4951

52+
@Override
5053
public Boolean PasswordMatch(String attempt){
5154
return (this.getPassword().equals(attempt));
5255
}
@@ -55,4 +58,9 @@ public void login(){
5558
UserAppScreenGateway appScreenGateway = new UserAppScreenGateway(this.getUsername());
5659
}
5760

61+
public ArrayList<Chat> getChats() {
62+
return this.userChats;
63+
}
64+
65+
5866
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package interface_adapters.Chat;
22

3+
import entities.chat.Chat;
4+
35
import java.util.ArrayList;
46

57
public interface UserChatGateway {
68

7-
// ArrayList<Chat> getUserChats(String username);
9+
ArrayList<Chat> getUserChats(String username);
810
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package interface_adapters.app_screen_interface_adapters;
22

3-
import java.util.ArrayList;
4-
5-
import entities.chat.Chat;
6-
import interface_adapters.*;
73
import data_access.UserDatabase;
4+
import entities.chat.Chat;
85
import interface_adapters.login_interface_adapters.Login;
96

107
import java.util.ArrayList;
@@ -13,7 +10,6 @@ public class UserAppScreenGateway implements Login {
1310

1411
private final UserDatabase userDatabase;
1512
private final String username;
16-
private ArrayList<Chat> userChats;
1713

1814
/**
1915
* Create gateway between user and appscreen
@@ -27,9 +23,9 @@ public UserAppScreenGateway(String username){
2723
/**
2824
* Log the user into the system
2925
*/
30-
public void login(){;
31-
this.userChats = this.userDatabase.getUserChats(this.username);
32-
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, this.userChats);
26+
public void login(){
27+
ArrayList<Chat> userChats = this.userDatabase.getUserChats(this.username);
28+
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, userChats);
3329
}
3430

3531
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package interface_adapters.profile_modification_IA;
2+
3+
// allows for ChangeController to authenticate user's username and password.
4+
5+
public interface UserAuthenticationI {
6+
public Boolean PasswordMatch(String attempt);
7+
}

src/main/java/screens/Profile_screen/UserSearchUI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void actionPerformed(ActionEvent e) {
3131
}
3232

3333
});
34+
frame.setTitle("User Search Tool");
3435
frame.add(field);
3536
label = new JLabel();
3637
frame.add(label);

src/main/java/screens/chat_screen/ChatView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public ChatView( boolean isNewchat){
9393

9494

9595
// create a setup for display of buttons and other component of the frame.
96-
public void chatdisplay(){
96+
public void chatDisplay(){
9797

9898
// set frame size and frame title
9999
frame.setSize(450, 500);

src/main/java/screens/profile_update_screen/UserModificationUI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void actionPerformed(ActionEvent e) {
6262

6363
label = new JLabel();
6464

65+
frame.setTitle("Profile Editor Tool");
6566
frame.add(usernameField);
6667
frame.add(passwordField);
6768
frame.add(cb);

src/main/java/use_cases/app_screen_use_case/ChatName.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package use_cases.app_screen_use_case;
22

3-
43
import entities.chat.Chat;
54

65
public interface ChatName {

0 commit comments

Comments
 (0)