<commit_before>// Copyright 2015 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ca.ualberta.trinkettrader.User.Profile;

import android.location.Location;

import java.util.ArrayList;
import java.util.Observer;

/**
 * A profile class containing the User's personal information and whether photos will be
 * automatically downloaded to their device.
 */
public class UserProfile implements ca.ualberta.trinkettrader.Observable {

    private ArrayList<Observer> observers;
    private Boolean arePhotosDownloadable;
    private Boolean needToSave;
    private ContactInfo contactInfo;
    private Location defaultLocation;
    private String email;
    private String username;


    /**
     * UserProfile Constructor for generating new attribute classes
     */
    public UserProfile() {
        this.arePhotosDownloadable = Boolean.FALSE;
        this.contactInfo = new ContactInfo();
        this.defaultLocation = new Location("this");
        this.email = "";
        this.username = "";
        this.needToSave = Boolean.TRUE;
    }

    /**
     * Adds the specified observer to the list of observers. If it is already
     * registered, it is not added a second time.
     *
     * @param observer the Observer to add.
     */
    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    /**
     * Removes the specified observer from the list of observers. Passing null
     * won't do anything.
     *
     * @param observer the observer to remove.
     */
    @Override
    public synchronized void deleteObserver(Observer observer) {
        observers.remove(observer);
    }

    /**
     * If {@code hasChanged()} returns {@code true}, calls the {@code update()}
     * method for every observer in the list of observers using null as the
     * argument. Afterwards, calls {@code clearChanged()}.
     * <p/>
     * Equivalent to calling {@code notifyObservers(null)}.
     */
    @Override
    public void notifyObservers() {
        for (Observer observer : observers) {
            observer.notify();
        }
    }

    /**
     * Returns Boolean on whether photo download setting is set. This setting determines
     * whether the photos of foreign trinkets are automatically downloaded to the device.
     * If false, the user must manually select which photos to download.
     *
     * @return Boolean
     */
    public Boolean getArePhotosDownloadable() {
        return arePhotosDownloadable;
    }

    /**
     * Set whether photos are downloadable
     *
     * @param arePhotosDownloadable
     */
    public void setArePhotosDownloadable(Boolean arePhotosDownloadable) {
        this.arePhotosDownloadable = arePhotosDownloadable;
    }

    /**<commit_msg>User profile JDs not done<commit_after>// Copyright 2015 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ca.ualberta.trinkettrader.User.Profile;

import android.location.Location;

import java.util.ArrayList;
import java.util.Observer;

/**
 * A profile class containing the information about a user and settings for their account.  The user can
 * add information about themselves such as contact information for other users to view.  They can also set
 * the default settings for their account, such as the default location for their trinkets and whether
 * they want photo downloads enabled.  A user's UserProfile is instantiated along with the user object.
 *
 * The UserProfile has a Boolean needToSave attribute to determine if there have been changes to the
 * user's profile that need to be saved to the network.  Whenever an attribute or setting in the user's
 * profile is changed then needToSave is set to true and the user will be re-saved to the network.
 */
public class UserProfile implements ca.ualberta.trinkettrader.Observable {

    private ArrayList<Observer> observers;
    private Boolean arePhotosDownloadable;
    private Boolean needToSave;
    private ContactInfo contactInfo;
    private Location defaultLocation;
    private String email;
    private String username;


    /**
     * Default constructor.  Initializes all attributes to be blank.  By default photo downloads are
     * disabled and the default location for {@link ca.ualberta.trinkettrader.Inventory.Trinket.Trinket Trinkets}
     * is the phone's GPS location.  This constructor is called when a user logs in to the app.  As this
     * user should be saved so that their profile can be accessed from the network later, by default
     * needToSave is set to true, indicating that the user should be saved to the network.
     */
    public UserProfile() {
        this.arePhotosDownloadable = Boolean.FALSE;
        this.contactInfo = new ContactInfo();
        this.defaultLocation = new Location("this");
        this.email = "";
        this.username = "";
        this.needToSave = Boolean.TRUE;
    }

    /**
     * Adds the specified observer to the list of observers. If it is already
     * registered, it is not added a second time.
     *
     * @param observer the Observer to add.
     */
    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    /**
     * Removes the specified observer from the list of observers. Passing null
     * won't do anything.
     *
     * @param observer the observer to remove.
     */
    @Override
    public synchronized void deleteObserver(Observer observer) {
        observers.remove(observer);
    }

    /**
     * If {@code hasChanged()} returns {@code true}, calls the {@code update()}
     * method for every observer in the list of observers using null as the
     * argument. Afterwards, calls {@code clearChanged()}.
     * <p/>
     * Equivalent to calling {@code notifyObservers(null)}.
     */
    @Override
    public void notifyObservers() {
        for (Observer observer : observers) {
            observer.notify();
        }
    }

    /**
     * Returns Boolean on whether photo download setting is set. This setting determines
     * whether the photos of foreign trinkets are automatically downloaded to the device.
     * If false, the user must manually select which photos to download.
     *
     * @return Boolean
     */
    public Boolean getArePhotosDownloadable() {
        return arePhotosDownloadable;
    }

    /**
     * Set whether photos are downloadable.  This setting determines
     * whether the photos of foreign trinkets are automatically downloaded to the device.
     * If false, the user must manually select which photos to download.
     *
     * @param arePhotosDownloadable
     */
    public void setArePhotosDownloadable(Boolean arePhotosDownloadable) {
        this.arePhotosDownloadable = arePhotosDownloadable;
    }

    /**
{'fraction_non_alphanumeric': 0.07820872671599897, 'fraction_numerical': 0.002041337075784639, 'mean_word_length': 2.9155844155844157, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 31, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6016188', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1930, 'n_words': 831}