diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 9b6c530710f1..ccf3231751aa 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -250,6 +250,42 @@ standardised the handling of font size change requests through events. **Pros:** Less tedious to implement and very intuitive for the user + **Cons:** Users who prefer typing commands will not have the option of editing their font sizes using the CLI +=== Setting Avatar on ViewPersonPanel + +The following function allows the setting of URL for the `ImageView` attribute within the `ViewPersonPanel` class: +[source,java] +---- +private void initializeAvatar() { + try { + String avatarPath = person.getAvatar().value; + if (!avatarPath.equals("")) { + logger.info("Initializing avatar to image at saved URL"); + Image newImage = new Image(avatarPath); + avatarImage.setImage(newImage); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +---- + +The `initializeAvatar` method piggybacks on the `handlePersonPanelSelectionChangedEvent` event handler. Whenever there is +a change in the person selection panel, this function will call the `initializeAvatar` method, which will update +the `ImageView` attribute. +[source,java] +---- +@Subscribe + private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event) { + logger.info(LogsCenter.getEventHandlingLogMessage(event)); + this.person = event.getNewSelection().person; + initializeWithPerson(person); + initializeAvatar(); + } +---- + +[NOTE] +As of version 1.5rc, the avatar field supports only URLs sourced online. References to local files may not work at the moment. + // tag::undoredo[] === Undo/Redo mechanism diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 972e201bb100..849344446764 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -112,13 +112,13 @@ You can use the `add` command to add new people to your address book [NOTE] `add` can be replaced by `a` for faster input. -Format: `add n/NAME p/[PHONE_NUMBER] e/[EMAIL] a/[ADDRESS] r/[REMARK] [t/TAG]...` + +Format: `add n/NAME p/[PHONE_NUMBER] e/[EMAIL] a/[ADDRESS] r/[REMARK] v/[AVATAR] [t/TAG]...` + **** **Things To Note** + * A person can have any number of tags (including 0) + * The `EMAIL` should be in the format address@email.domain + -* You can set a person's `Name`, `Phone`, `Email`, `Address` or `Remark` to be private by placing a `p` in front of the prefix. + +* You can set a person's `Name`, `Phone`, `Email`, `Address`, `Remark`, `Avatar` to be private by placing a `p` in front of the prefix. + **** **Example Scenarios**: @@ -126,14 +126,15 @@ Format: `add n/NAME p/[PHONE_NUMBER] e/[EMAIL] a/[ADDRESS] r/[REMARK] [t/TAG]... **Example Scenario 1** + Suppose you wanted to add your new friend John Doe. You could type the following command to add his details: -`add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01 b/11-11-1995 r/Likes panda bears` +`add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01 b/11-11-1995 r/Likes panda bears +v/https://helloworld/image.png` **** **** **Example Scenario 2** + Now suppose you have another friend named Ima Hidearu, who does not provide you with all the contact information that you need. You can choose to omit these fields by typing in the command: -`add n/Ima Hidearu a/ e/ p/ r/ t/secretive` +`add n/Ima Hidearu a/ e/ p/ r/ v/ t/secretive` **** **** **Example Scenario 3** + @@ -146,6 +147,9 @@ option while typing in your command: **** // end::addprivacy[] +[NOTE] +As of version 1.5rc, the avatar field supports only URLs sourced online. References to local files may not work. + === Adding a task: `add task` You can use the `add task` command to add new tasks to your address book. This allows you to keep track of your @@ -217,7 +221,7 @@ Instead of typing out `list` every time, you can alternatively use `l` to shorte You can use the `edit` command to quickly fix mistakes in your entries, or add/remove details in your contacts. You may wish to edit your contacts when they change their phone numbers, for example. + `edit` can be replaced by `e` for faster input. + -Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK] [t/TAG]...` + +Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK] [v/AVATAR] [t/TAG]...` + **** * The index refers to the index number shown in the last listing. The index *must be a positive integer* 1, 2, 3, ... @@ -279,7 +283,7 @@ Changes the tag called `friends` to one called `enemies` instead. All existing c === Changing the Privacy of a person's details : `changeprivacy`(Since V1.3) You can use the `changeprivacy` command to set the privacy settings for each field of an existing `Person` in the address book, which allows you to choose specifically what information will be displayed. + -Format: `changeprivacy INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK]` +Format: `changeprivacy INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK] [v/AVATAR]` Shorthand commands: `cp` **** @@ -298,7 +302,6 @@ Examples: Sets the phone number of the 1st person to be public and their email address to be private. The 1st person's phone number will be displayed, if available, while their email address will be hidden in the UI. * `cp 2 a/false n/true e/false` + Sets the address and email of the 2nd person to be public and their name to be private. The 2nd person's address and email will be displayed, if available, while their name will be hidden in the UI. -<<<<<<< HEAD // end::changeprivacy[] // tag::favourite[] @@ -829,7 +832,6 @@ If you click on a box containing a contact, an internet browser on the right sid * If a person's name or address is set to private, the browser will not perform a search if you click on their box. * Right clicking on the browser will allow you to go to the previous or next page, as well as reload the page. **** - == FAQ *Q*: How do I transfer my data to another Computer? + @@ -856,7 +858,8 @@ e.g. `delete 3` e.g. `delete task 4` * *Delete tag* : `deletetag INDEX t/[TAG]` + e.g. `deletetag 1 2 t/friends` -* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [r/REMARK] [t/TAG]...` + +* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] +[v/AVATAR] [t/TAG]...` + e.g. `edit 2 n/James Lee e/jameslee@example.com` * *Edit task* : `edit task INDEX [n/NAME] [d/DESCRIPTION] [t/DEADLINE] [p/PRIORITY]` + e.g. `edit task 2 p/veryhigh` diff --git a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java index 3683eb261419..56c2929b9ada 100644 --- a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java +++ b/src/main/java/seedu/address/model/person/ReadOnlyPerson.java @@ -58,6 +58,8 @@ default String getAsText() { .append(getAddress()) .append(" Remark: ") .append(getRemark()) + .append(" Avatar: ") + .append(getAvatar()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 46b9aa2aa95b..d2c197c39058 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -90,16 +90,6 @@ public void backupAddressBook(ReadOnlyAddressBook addressBook, String filePath) logger.fine("Attempting to write to backup data file in custom location"); this.saveAddressBook(addressBook, filePath); } - - /** - * Default back up data which saves file in the same directory as the main save file - * @param addressBook - * @throws IOException - */ - public void backupAddressBookDefault(ReadOnlyAddressBook addressBook) throws IOException { - logger.fine("Attempting to write to backup data file"); - this.saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath() + "-backup.xml"); - } //@@author @Override diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index ae1fe1123778..d7ad5ae9e759 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -9,7 +9,6 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Scene; -import javafx.scene.control.Button; import javafx.scene.control.MenuItem; import javafx.scene.control.TextInputControl; import javafx.scene.input.KeyCombination; @@ -98,15 +97,6 @@ public class MainWindow extends UiPart { @FXML private MenuItem resetSizeMenuItem; - @FXML - private Button increaseFontSizeButton; - - @FXML - private Button decreaseFontSizeButton; - - @FXML - private Button resetFontSizeButton; - @FXML private StackPane personListPanelPlaceholder; @@ -286,21 +276,6 @@ GuiSettings getCurrentGuiSetting() { */ @FXML public void handleIncreaseFontSize() { - increaseFontSize(); - } - - /** - * Handle increase font size command for button - */ - @FXML - public void handleIncreaseFontSizeButton() { - increaseFontSize(); - } - - /** - * Calls method to increase font size - */ - public void increaseFontSize() { logger.info("Handling increase in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getIncreaseSizeEventIndex())); } @@ -310,23 +285,7 @@ public void increaseFontSize() { */ @FXML public void handleDecreaseFontSize() { - decreaseFontSize(); - } - - /** - * Handle decrease font size command for button - */ - @FXML - public void handleDecreaseFontSizeButton() { - decreaseFontSize(); - } - - /** - * Calls method to decrease font size - */ - public void decreaseFontSize() { - logger.info("Handling increase in font size"); - personListPanel.decreaseFontSize(); + logger.info("Handling decrease in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getDecreaseSizeEventIndex())); } @@ -335,21 +294,6 @@ public void decreaseFontSize() { */ @FXML public void handleResetFontSize() { - resetFontSize(); - } - - /** - * Handle reset font size command for button - */ - @FXML - public void handleResetFontSizeButton() { - resetFontSize(); - } - - /** - * Calls method to reset font size - */ - public void resetFontSize() { logger.info("Handling reset in font size"); raise(new ChangeFontSizeEvent(ChangeFontSizeEvent.getResetSizeEventIndex())); } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 6ec82fe41988..018d9e8f7489 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -15,12 +15,10 @@ * An UI component that displays information of a {@code Person}. */ public class PersonCard extends UiPart { - //@@author charlesgoh public static final int DEFAULT_NAME_SIZE = 15; public static final int DEFAULT_ATTRIBUTE_SIZE = 10; public static final int FONT_SIZE_EXTENDER = 5; public static final int DEFAULT_FONT_SIZE_MULTIPLIER = 0; - //@@author private static final String FXML = "PersonListCard.fxml"; /** * Preset values for random selection later. @@ -133,7 +131,6 @@ public void updateAttributeSizes() { } //@@author - @Override public boolean equals(Object other) { // short circuit if same object @@ -152,6 +149,7 @@ public boolean equals(Object other) { && person.equals(card.person); } + //@@author charlesgoh public Label getName() { return name; } @@ -183,4 +181,5 @@ public int getFontSizeMultipler() { public void setFontSizeMultipler(int fontSizeMultipler) { this.fontSizeMultipler = fontSizeMultipler; } + //author } diff --git a/src/main/java/seedu/address/ui/ViewPersonPanel.java b/src/main/java/seedu/address/ui/ViewPersonPanel.java index 481f94cca496..678b59cdfda5 100644 --- a/src/main/java/seedu/address/ui/ViewPersonPanel.java +++ b/src/main/java/seedu/address/ui/ViewPersonPanel.java @@ -9,6 +9,8 @@ import javafx.beans.binding.Bindings; import javafx.fxml.FXML; import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; @@ -60,6 +62,8 @@ private enum Colours { @FXML private Label remark; @FXML + private ImageView avatarImage; + @FXML private Label email; @FXML private FlowPane tags; @@ -71,6 +75,7 @@ public ViewPersonPanel(ReadOnlyPerson person, int fontSizeMultiplier) { this.fontSizeMultipler = fontSizeMultiplier; initTags(person); initializeWithPerson(person); + initializeAvatar(); updateAttributeSizes(); registerAsAnEventHandler(this); } @@ -95,6 +100,23 @@ private void initializeWithPerson(ReadOnlyPerson person) { initTags(person); }); } + //author charlesgoh + /** + * Sets avatar to a filepath or the avatar placeholder by default + */ + private void initializeAvatar() { + try { + String avatarPath = person.getAvatar().value; + if (!avatarPath.equals("")) { + logger.info("Initializing avatar to image at saved URL"); + Image newImage = new Image(avatarPath); + avatarImage.setImage(newImage); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //author //@@author wangyiming1019 /** * Locate hashed colour for tag. If not found, new colour is assigned to tag @@ -192,5 +214,6 @@ private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedE logger.info(LogsCenter.getEventHandlingLogMessage(event)); this.person = event.getNewSelection().person; initializeWithPerson(person); + initializeAvatar(); } } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 008af2cc24b0..9741b133963b 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -2,14 +2,12 @@ - - @@ -18,68 +16,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -