Skip to content

Commit

Permalink
Merge branch 'avatar2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesGoh authored Nov 7, 2017
2 parents caa3d18 + b09cac4 commit ec69cb3
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 165 deletions.
36 changes: 36 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 12 additions & 9 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,29 @@ 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 [email protected] +
* 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**:
****
**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/[email protected] a/John street, block 123, #01-01 b/11-11-1995 r/Likes panda bears`
`add n/John Doe p/98765432 e/[email protected] 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** +
Expand All @@ -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
Expand Down Expand Up @@ -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, ...
Expand Down Expand Up @@ -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`

****
Expand All @@ -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[]
Expand Down Expand Up @@ -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? +
Expand All @@ -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/[email protected]`
* *Edit task* : `edit task INDEX [n/NAME] [d/DESCRIPTION] [t/DEADLINE] [p/PRIORITY]` +
e.g. `edit task 2 p/veryhigh`
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/model/person/ReadOnlyPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/seedu/address/storage/StorageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 1 addition & 57 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,15 +97,6 @@ public class MainWindow extends UiPart<Region> {
@FXML
private MenuItem resetSizeMenuItem;

@FXML
private Button increaseFontSizeButton;

@FXML
private Button decreaseFontSizeButton;

@FXML
private Button resetFontSizeButton;

@FXML
private StackPane personListPanelPlaceholder;

Expand Down Expand Up @@ -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()));
}
Expand All @@ -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()));
}

Expand All @@ -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()));
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* An UI component that displays information of a {@code Person}.
*/
public class PersonCard extends UiPart<Region> {
//@@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.
Expand Down Expand Up @@ -133,7 +131,6 @@ public void updateAttributeSizes() {
}
//@@author


@Override
public boolean equals(Object other) {
// short circuit if same object
Expand All @@ -152,6 +149,7 @@ public boolean equals(Object other) {
&& person.equals(card.person);
}

//@@author charlesgoh
public Label getName() {
return name;
}
Expand Down Expand Up @@ -183,4 +181,5 @@ public int getFontSizeMultipler() {
public void setFontSizeMultipler(int fontSizeMultipler) {
this.fontSizeMultipler = fontSizeMultipler;
}
//author
}
23 changes: 23 additions & 0 deletions src/main/java/seedu/address/ui/ViewPersonPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +62,8 @@ private enum Colours {
@FXML
private Label remark;
@FXML
private ImageView avatarImage;
@FXML
private Label email;
@FXML
private FlowPane tags;
Expand All @@ -71,6 +75,7 @@ public ViewPersonPanel(ReadOnlyPerson person, int fontSizeMultiplier) {
this.fontSizeMultipler = fontSizeMultiplier;
initTags(person);
initializeWithPerson(person);
initializeAvatar();
updateAttributeSizes();
registerAsAnEventHandler(this);
}
Expand All @@ -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
Expand Down Expand Up @@ -192,5 +214,6 @@ private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedE
logger.info(LogsCenter.getEventHandlingLogMessage(event));
this.person = event.getNewSelection().person;
initializeWithPerson(person);
initializeAvatar();
}
}
Loading

0 comments on commit ec69cb3

Please sign in to comment.