Skip to content

Commit

Permalink
Merge pull request AY2324S2-CS2103T-T12-1#57 from tanguoyang/add-prof…
Browse files Browse the repository at this point in the history
…ile-picture

Add profile picture
  • Loading branch information
tanguoyang authored Mar 22, 2024
2 parents 5f08d28 + b9c4837 commit 59ba65c
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 65 deletions.
30 changes: 15 additions & 15 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Format: `help`

Adds a contact to the address book.

Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS g/GITHUB_USERNAME [t/TAG] [ts/TECH_STACK]…​`
Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS g/GITHUB_USERNAME [t/TAG] pp/PROFILE_PICTURE [ts/TECH_STACK]…​`

<box type="tip" seamless>

Expand All @@ -89,8 +89,8 @@ Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS g/GITHUB_USERNAME [t/TAG] [

Examples:

- `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01 g/johnDoee`
- `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 g/betBetty t/criminal ts/Flutter`
- `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01 g/johnDoee pp/https://api-prod-minimal-v510.vercel.app/assets/images/avatar/avatar_1.jpg`
- `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 g/betBetty t/criminal ts/Flutter pp/https://api-prod-minimal-v510.vercel.app/assets/images/avatar/avatar_1.jpg`

#### Listing all contacts : `list`

Expand All @@ -102,7 +102,7 @@ Format: `list`

Edits an existing contact in the address book.

Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [g/GITHUB_USERNAME] [t/TAG]…​ [ts/TECH_STACK]…​`
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [g/GITHUB_USERNAME] [pp/PROFILE_PICTURE] [t/TAG]…​ [ts/TECH_STACK]…​`

- Edits the contact at the specified `INDEX`. The index refers to the index number shown in the displayed contact list. The index **must be a positive integer** 1, 2, 3, …​
- At least one of the optional fields must be provided.
Expand Down Expand Up @@ -245,14 +245,14 @@ _Details coming soon ..._
## Command summary


| Action | Format, Examples |
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS g/GITHUB_USERNAME [t/TAG] [ts/TECH_STACK]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 g/Jamesho123 t/friend t/colleague ts/Java ts/C++` |
| **Clear** | `clear` |
| **Delete** | `delete INDEX`<br> e.g., `delete 3` |
| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [g/GITHUB_USERNAME] [t/TAG]…​ [ts/TECH_STACK]…​ `<br> e.g.,`edit 2 n/James Lee e/[email protected]` |
| **Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake` |
| **Find by Tags** | `find-tags KEYWORD [MORE_KEYWORDS]`<br> e.g., `find-tags School Work` |
| **Find Tech Stack** | `find-ts KEYWORD [MORE_KEYWORDS]`<br> e.g., `find-ts Java Python` |
| **List** | `list` |
| **Help** | `help` |
| Action | Format, Examples |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS g/GITHUB_USERNAME pp/PROFILE_PICTURE [t/TAG] [ts/TECH_STACK]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 g/Jamesho123 pp/https://api-prod-minimal-v510.vercel.app/assets/images/avatar/avatar_1.jpg t/friend t/colleague ts/Java ts/C++` |
| **Clear** | `clear` |
| **Delete** | `delete INDEX`<br> e.g., `delete 3` |
| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [g/GITHUB_USERNAME] [pp/PROFILE_PICTURE] [t/TAG]…​ [ts/TECH_STACK]…​ `<br> e.g.,`edit 2 n/James Lee e/[email protected]` |
| **Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake` |
| **Find by Tags** | `find-tags KEYWORD [MORE_KEYWORDS]`<br> e.g., `find-tags School Work` |
| **Find Tech Stack** | `find-ts KEYWORD [MORE_KEYWORDS]`<br> e.g., `find-ts Java Python` |
| **List** | `list` |
| **Help** | `help` |
1 change: 1 addition & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {
return initializedPrefs;
}


@Override
public void start(Stage primaryStage) {
logger.info("Starting CodeConnect " + MainApp.VERSION);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public static String format(Contact contact) {
.append(contact.getAddress())
.append("; GitHub Username: ")
.append(contact.getGitHubUsername())
.append("; Profile Picture: ")
.append(contact.getProfilePicture())
.append("; Tech Stack: ");
contact.getTechStack().forEach(builder::append);
builder.append("; Tags: ");
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUB_USERNAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TECH_STACK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUB_USERNAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROFILE_PICTURE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.contact.Contact;
import seedu.address.model.contact.ProfilePicture;

/**
* Adds a contact to the address book.
Expand All @@ -28,7 +30,8 @@ public class AddCommand extends Command {
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_GITHUB_USERNAME + "GITHUB USERNAME "
+ PREFIX_GITHUB_USERNAME + "GITHUB_USERNAME "
+ PREFIX_PROFILE_PICTURE + "PROFILE_PICTURE "
+ "[" + PREFIX_TECH_STACK + "TECH STACK]...\n"
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
Expand All @@ -37,6 +40,7 @@ public class AddCommand extends Command {
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_GITHUB_USERNAME + "johndoee123 "
+ PREFIX_PROFILE_PICTURE + ProfilePicture.DEFAULT_URL
+ PREFIX_TECH_STACK + "Java "
+ PREFIX_TECH_STACK + "Python "
+ PREFIX_TAG + "friends "
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TECH_STACK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROFILE_PICTURE;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_CONTACTS;

import java.util.Collections;
Expand All @@ -31,6 +32,7 @@
import seedu.address.model.contact.Phone;
import seedu.address.model.tag.Tag;
import seedu.address.model.techstack.TechStack;
import seedu.address.model.contact.ProfilePicture;

/**
* Edits the details of an existing contact in the address book.
Expand All @@ -48,6 +50,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_GITHUB_USERNAME + "GITHUB USERNAME]"
+ "[" + PREFIX_PROFILE_PICTURE + "PROFILE_PICTURE]"
+ "[" + PREFIX_TECH_STACK + "TECH_STACK...\n"
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
Expand Down Expand Up @@ -110,9 +113,10 @@ private static Contact createEditedContact(Contact contactToEdit, EditContactDes
editContactDescriptor.getGitHubUsername().orElse(contactToEdit.getGitHubUsername());
Set<TechStack> updatedTechStack = editContactDescriptor.getTechStack().orElse(contactToEdit.getTechStack());
Set<Tag> updatedTags = editContactDescriptor.getTags().orElse(contactToEdit.getTags());
ProfilePicture updatedProfilePicture = editContactDescriptor.getProfilePicture().orElse(contactToEdit.getProfilePicture());

return new Contact(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedGitHubUsername,
updatedTechStack, updatedTags);
updatedTechStack, updatedTags, updatedProfilePicture);
}

@Override
Expand Down Expand Up @@ -152,7 +156,8 @@ public static class EditContactDescriptor {
private Set<TechStack> techStack;
private Set<Tag> tags;

public EditContactDescriptor() {}
private ProfilePicture profilePicture;


/**
* Copy constructor.
Expand All @@ -166,14 +171,17 @@ public EditContactDescriptor(EditContactDescriptor toCopy) {
setGitHubUsername(toCopy.gitHubUsername);
setTechStack(toCopy.techStack);
setTags(toCopy.tags);
setProfilePicture(toCopy.profilePicture);
}

public EditContactDescriptor() {}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address,
gitHubUsername, techStack, tags);
gitHubUsername, techStack, tags, profilePicture);
}

public void setName(Name name) {
Expand Down Expand Up @@ -215,6 +223,14 @@ public Optional<GitHubUsername> getGitHubUsername() {
return Optional.ofNullable(gitHubUsername);
}

public void setProfilePicture(ProfilePicture profilePicture) {
this.profilePicture = profilePicture;
}

public Optional<ProfilePicture> getProfilePicture() {
return Optional.ofNullable(this.profilePicture);
}

/**
* Sets {@code techStack} to this object's {@code techStack}.
* A defensive copy of {@code techStack} is used internally.
Expand Down Expand Up @@ -267,7 +283,8 @@ public boolean equals(Object other) {
&& Objects.equals(address, otherEditContactDescriptor.address)
&& Objects.equals(gitHubUsername, otherEditContactDescriptor.gitHubUsername)
&& Objects.equals(techStack, otherEditContactDescriptor.techStack)
&& Objects.equals(tags, otherEditContactDescriptor.tags);
&& Objects.equals(tags, otherEditContactDescriptor.tags)
&& Objects.equals(profilePicture, otherEditContactDescriptor.profilePicture);
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TECH_STACK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROFILE_PICTURE;


import java.util.Set;
import java.util.stream.Stream;
Expand All @@ -20,6 +22,7 @@
import seedu.address.model.contact.Name;
import seedu.address.model.contact.Contact;
import seedu.address.model.contact.Phone;
import seedu.address.model.contact.ProfilePicture;
import seedu.address.model.tag.Tag;
import seedu.address.model.techstack.TechStack;

Expand All @@ -36,7 +39,7 @@ public class AddCommandParser implements Parser<AddCommand> {
public AddCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_GITHUB_USERNAME, PREFIX_TECH_STACK, PREFIX_TAG);
PREFIX_GITHUB_USERNAME, PREFIX_PROFILE_PICTURE, PREFIX_TECH_STACK, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_GITHUB_USERNAME,
PREFIX_PHONE, PREFIX_EMAIL)
Expand All @@ -45,7 +48,7 @@ public AddCommand parse(String args) throws ParseException {
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_GITHUB_USERNAME);
PREFIX_GITHUB_USERNAME, PREFIX_PROFILE_PICTURE);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Expand All @@ -54,8 +57,9 @@ public AddCommand parse(String args) throws ParseException {
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Set<TechStack> techStackList = ParserUtil.parseTechStacks(argMultimap.getAllValues(PREFIX_TECH_STACK));
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
ProfilePicture profilePicture = ParserUtil.parseProfilePicture(argMultimap.getValue(PREFIX_PROFILE_PICTURE).orElse(""));

Contact contact = new Contact(name, phone, email, address, gitHubUsername, techStackList, tagList);
Contact contact = new Contact(name, phone, email, address, gitHubUsername, techStackList, tagList, profilePicture);

return new AddCommand(contact);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class CliSyntax {
public static final Prefix PREFIX_GITHUB_USERNAME = new Prefix("g/");
public static final Prefix PREFIX_TECH_STACK = new Prefix("ts/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_PROFILE_PICTURE = new Prefix("pp/");

}
Loading

0 comments on commit 59ba65c

Please sign in to comment.