From 970c3422f4d421c6204838da3d7af9913e5bba58 Mon Sep 17 00:00:00 2001 From: Anshu Sharma Date: Fri, 9 Nov 2018 11:48:05 -0500 Subject: [PATCH] comments for project. --- .../.idea/caches/build_file_checksums.ser | Bin 537 -> 541 bytes OlympusServices/.idea/misc.xml | 2 +- .../olympus/olympusservices/Admin.java | 18 +++++ .../olympus/olympusservices/AdminWelcome.java | 43 +++++++++++ .../olympus/olympusservices/Appointment.java | 6 ++ .../EditServiceDialogFragment.java | 19 ++++- .../olympus/olympusservices/HomeOwner.java | 23 ++++++ .../olympus/olympusservices/LogIn.java | 26 +++++++ .../uottawa/olympus/olympusservices/Main.java | 23 ++++++ .../NewServiceDialogFragment.java | 20 +++++- .../olympus/olympusservices/Service.java | 45 ++++++++++++ .../olympusservices/ServiceProvider.java | 33 +++++++++ .../olympus/olympusservices/ServicesList.java | 50 +++++++++++++ .../olympus/olympusservices/SignUp.java | 31 +++++++- .../olympus/olympusservices/UserType.java | 68 ++++++++++++++++-- .../olympus/olympusservices/UsersList.java | 14 ++++ .../olympus/olympusservices/Welcome.java | 27 +++++++ 17 files changed, 435 insertions(+), 13 deletions(-) diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 4c7ae2cb6fe400b7e4228637a4b4ed7858152f3c..3c386bbc0c23101a7db3f0238b6fb246efa7a101 100644 GIT binary patch delta 208 zcmbQqGM8n-Oy<&M_7ms$oAVc^mXu`Xr5Ed^7bT|Tq?Q&jFhx79`7Hi}jU(g%69Yp< z0Rsbr!18}mhbLxkeX0=^7o4WADm~esQBokCp(pn9q-)YSHzjmEO+H_kT)`--x3ll5 ztp1!eJEm+r$Y=ZDR80wkj(%uyYEiL%VqS4ZX>mqkQEs9>)HeOe`x!m$1a_ANoPVqN z!(x@g!Gcdo`Xvkki3J7vNu`-NDKKXhGSo4!fm|}f@brooX+C1wkvG^<-dsLi0RY6+ BQJ4S# delta 225 zcmbQsGLvP(OlD3iripX>>je@E3SyEWT<0c1F4;NGhv_2efB)v z1U;#6r^5?N7WvH2o$SphtEKp_L`llwv-~WJf590h z>g!4vG@PwsLW@(2ieo&>67v#cpf<)#p2p}Y__>#P)t-c - + diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Admin.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Admin.java index 4d2938b..8b658b4 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Admin.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Admin.java @@ -1,10 +1,28 @@ package com.uottawa.olympus.olympusservices; +/** + * The class Admin is a child of the class userType. The class gives + * admin permission over the app such that the user can add and delete services + * and can add and delete other users from the database of the app. + * + */ + public class Admin extends UserType { + /** + * The constructor for the admin object with predefined fields. + * There should only be one admin object for the entire app. + */ Admin(){ super("admin", "admin", "Admin", "Admin"); } + /** + * The getRole() method returns a string "Admin" + * the app gets role of user type objects for access + * app permission purposes. + * + * @return String object "Admin" + */ public String getRole(){ return "Admin"; } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/AdminWelcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/AdminWelcome.java index 0068236..ed3a54c 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/AdminWelcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/AdminWelcome.java @@ -5,27 +5,70 @@ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; +/** + * The Admin Welcome class is the welcome + * screen for admin users when they have logged into the + * app. The admin welcome screen has features such as the + * user list and service list which it can only access. + * + */ + public class AdminWelcome extends AppCompatActivity { + /** + * Creates the xml pages for the class object + * on creation of the object. + * + * @param savedInstanceState Bundle for transfer of data. + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_admin_welcome); } + + /** + * Override so that nothing occurs when pressing the + * back button on this activity of the app. + * + */ @Override public void onBackPressed(){ } + /** + * Logs out the user and returns them back to + * main activity. End all current user activity + * for security purposes. + * + * @param view View object of current activity. + */ public void LogOut(View view){ Intent intent = new Intent(getApplicationContext(), Main.class); startActivity(intent); finish(); } + + /** + * On click of list of user button that goes to + * UserList screen for the admin to edit the user list + * of the app. + * + * @param view View object of current activity + */ public void goToUsers(View view){ Intent intent = new Intent(getApplicationContext(), UsersList.class); startActivity(intent); } + + /** + * On click of list of services button goes to + * ServiceList screen for the admin to edit the + * service list of the app. + * + * @param view + */ public void goToServices(View view){ Intent intent = new Intent(getApplicationContext(), ServicesList.class); startActivity(intent); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Appointment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Appointment.java index 93cd7a0..536383e 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Appointment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Appointment.java @@ -1,5 +1,11 @@ package com.uottawa.olympus.olympusservices; +/** + * This class is the class for Appointments + * which has not been implemented yet. This + * feature shall be expanded upon next deliverable. + * + */ public class Appointment { Service service; ServiceProvider provider; diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java index 2b06dc4..a9c7327 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java @@ -11,9 +11,14 @@ import android.widget.EditText; public class EditServiceDialogFragment extends DialogFragment{ -public interface NoticeDialogListener { - public void onDialogEdit(DialogFragment dialog); - public void onDialogDelete(DialogFragment dialog); + /** + * Creates a NoticeDialogListener interface for other classes to + * implement to have this class be functional in the other classes. + * + */ + public interface NoticeDialogListener { + public void onDialogEdit(DialogFragment dialog); + public void onDialogDelete(DialogFragment dialog); } EditServiceDialogFragment.NoticeDialogListener mListener; @@ -31,6 +36,14 @@ public interface NoticeDialogListener { + " must implement NoticeDialogListener"); } } + + /** + * Edit the Dialog to change rate of a service that the + * admin wants to change. + * + * @param savedInstanceState Bundle to transfer information. + * @return Dialog that is sent to admin for information. + */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwner.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwner.java index 4807fa2..690ff19 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwner.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwner.java @@ -1,12 +1,35 @@ package com.uottawa.olympus.olympusservices; +/** + * The class HomeOwner is a child of the class userType. The class permission + * to the user of a standard homeowner hence users with homeowner permissions + * are able to book service providers. Has not been implemented yet. + * + */ + public class HomeOwner extends UserType { + /** + * Constructor of the HomeOwner object that takes the username, password, + * lastname, and firstname as parameters to use for the creation of a + * HomeOwner object. + * + * @param username String for username. + * @param password String for password. + * @param firstname String for firstname. + * @param lastname String for lastname. + */ HomeOwner(String username, String password, String firstname, String lastname){ super(username, password, firstname, lastname); } + /** + * Returns the type of role the user is for this class. + * will return the string "HomeOwner". + * + * @return "HomeOwner" String object. + */ public String getRole(){ return "HomeOwner"; } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/LogIn.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/LogIn.java index 6afde1a..a147710 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/LogIn.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/LogIn.java @@ -7,14 +7,34 @@ import android.widget.EditText; import android.view.View; import android.widget.Toast; +/** + * The login activity for the app that checks + * credentials of users to allow them to log in and use + * the functionality of the app. + * + */ + public class LogIn extends AppCompatActivity { + /** + * On creation of this activity the login xml file + * is loaded up. + * + * @param savedInstanceState Bundle object for transfer of information. + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_log_in); } + /** + * On click of the login button the app checks if all specification + * for login credentials are met and then either sends an error toast + * or logs the user in. + * + * @param view View object that contains all the buttons and editTexts. + */ public void onClickLogIn(View view){ String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString(); String password = ((EditText) findViewById(R.id.PasswordInput)).getText().toString(); @@ -54,6 +74,12 @@ public class LogIn extends AppCompatActivity { } + + /** + * app closes the the activity when back is pressed and + * no user information written down is saved in the EditText for + * security purposes. + */ @Override public void onBackPressed(){ Intent intent = new Intent(getApplicationContext(), Main.class); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Main.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Main.java index 6245cb1..eb86354 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Main.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Main.java @@ -5,8 +5,21 @@ import android.os.Bundle; import android.content.Intent; import android.view.View; +/** + * The starting page of the app which contains two buttons + * of either registering for the app or logging into an existing + * account. + * + */ + public class Main extends AppCompatActivity { + /** + * On creation of the object the app loads up the xml page + * for the class and creates dbHelper object and Admin object + * and then add the admin into the database. + * @param savedInstanceState + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -18,6 +31,11 @@ public class Main extends AppCompatActivity { } + /** + * On click of the sign up button loads up the sign up activity + * + * @param view View object containing the buttons. + */ public void onClickSignUp(View view){ Intent intent = new Intent(getApplicationContext(),SignUp.class); startActivity(intent); @@ -25,6 +43,11 @@ public class Main extends AppCompatActivity { } + /** + * On click of the Login button loads up the login activity. + * + * @param view View object containing the buttons. + */ public void onClickLogIn(View view){ Intent intent = new Intent(getApplicationContext(),LogIn.class); startActivity(intent); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java index a5240f5..05078b9 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java @@ -18,9 +18,18 @@ import android.view.View; import com.rengwuxian.materialedittext.MaterialEditText; +/** + * Creates a dialog whenever admin adds a new service into the + * service list which the admin fills in to provide the fields of + * the service. + */ public class NewServiceDialogFragment extends DialogFragment { - + /** + * Creates a NoticeDialogListener interface for other classes to + * implement to have this class be functional in the other classes. + * + */ public interface NoticeDialogListener { public void onDialogNew(DialogFragment dialog); public void onDialogNevermind(DialogFragment dialog); @@ -42,8 +51,13 @@ public class NewServiceDialogFragment extends DialogFragment { } } - //String name = ((EditText) view.findViewById(R.id.NameInput)).getText().toString(); - //int rate = Integer.parseInt(((EditText) view.findViewById(R.id.RateInput)).getText().toString()) + /** + * Creates the Dialog to add the name and rate of a new service that + * the admin has added to the list of services. + * + * @param savedInstanceState Bundle to transfer information. + * @return Dialog that is sent to admin for information. + */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java index 266115a..1c311ef 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java @@ -3,33 +3,78 @@ package com.uottawa.olympus.olympusservices; import java.util.ArrayList; import java.util.List; +/** + * creates a service object that can be managed by admin and service providers + * and be viewed by the homeowner for the sale of service which is the main + * functionality of the app. + * + */ + public class Service { + //name of the service field. private String name; + //rate of the service field. private double rate; + //list of services the providers that offers this service. private List serviceProviders; + /** + * Constructor for a new service which uses the parameters + * to fill in the fields of the service and creates an arrayList + * for all the providers that provide that service. + * + * @param name String of the name of service. + * @param rate double of the price of service. + */ Service(String name, double rate) { this.name = name; this.rate = rate; serviceProviders = new ArrayList(); } + /** + * Gets the Name field of the service. + * + * @return String of the name. + */ public String getName() { return name; } + /** + * Gets the Rate field of the service. + * + * @return double of the rate. + */ public double getRate() { return rate; } + /** + * Changes the name field of the object to parameter given. + * + * @param name String object of new name + */ public void setName(String name) { this.name = name; } + /** + * Changes the rate field of the object to parameter given. + * + * @param rate double of new rate. + */ public void setRate(double rate) { this.rate = rate; } + /** + * Adds a new service provider that offers this service into the list + * of service providers that offer this service. + * + * @param user Service Provider object which is added to the service's list. + * @return boolean of if the Service provider has been added. + */ public boolean addServiceProvider(ServiceProvider user){ for (ServiceProvider listUser : serviceProviders){ if (user.getUsername().equals(listUser.getUsername())){ diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java index 15bfde4..caba948 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java @@ -3,17 +3,45 @@ package com.uottawa.olympus.olympusservices; import java.util.ArrayList; import java.util.List; +/** + * The service provider is the child userType class. The service provider + * class provides services which the homeowner can buy in the app. + * + */ + public class ServiceProvider extends UserType { + //Field for list of services that service provider offers. private List services; + /** + * Constructor for the service object which takes the parameters to + * fill out the service providers field. + * + * @param username String of the username. + * @param password String of the password. + * @param firstname String of the firstname. + * @param lastname String of the lastname. + */ ServiceProvider(String username, String password, String firstname, String lastname){ super(username, password, firstname, lastname); services = new ArrayList<>(); } + /** + * gets the role of the UserType. + * + * @return String "Service Provider" + */ public String getRole(){ return "ServiceProvider"; } + /** + * adds service to the to service list if the service is in the + * database list of services. + * + * @param service Service object which is added to the services field. + * @return boolean whether service is added. + */ public boolean addService(Service service){ for (Service listService : services){ if (service.getName().equals(listService.getName())){ @@ -24,6 +52,11 @@ public class ServiceProvider extends UserType { return true; } + /** + * Gets the services list field of service provider. + * + * @return arrayList of Services + */ public List getServices(){ return services; } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java index db0cd9e..cf2ee51 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java @@ -18,12 +18,26 @@ import android.widget.TextView; import java.util.Iterator; import java.util.List; +/** + * Creates the view and dialog listener for List of services + * which the admin can view and manipulate. + * + */ public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{ + //field for RecyclerView private RecyclerView mRecyclerView; + //field for adapter of Recycler view private RecyclerView.Adapter mAdapter; + //field for layout manager of Recyler view. private RecyclerView.LayoutManager mLayoutManager; + /** + * On creation loads up the xml, and generates the services list, + * and fillsout the recylerView fields. + * + * @param savedInstanceState Bundle to transfer information. + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -49,10 +63,22 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF } + + /** + * Adds new services to the generated list. + * + * @param view View object contains the generated list and buttons + */ public void addService(View view) { DialogFragment newFragment = new NewServiceDialogFragment(); newFragment.show(getSupportFragmentManager(), "addService"); } + + /** + * Edits services to the generated list. + * + * @param view View object contains the generated list and buttons + */ public void editService(View view, String name) { DialogFragment newFragment = new EditServiceDialogFragment(); newFragment.show(getSupportFragmentManager(), "editService"); @@ -61,6 +87,12 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF newFragment.setArguments(args); } //add new service + + /** + * Uses dialog to obtain the fields for addSerivce. + * + * @param dialog DialogFragment used to obtain the fields for the added service + */ @Override public void onDialogNew(DialogFragment dialog) { DBHelper dbHelper = new DBHelper(this); @@ -71,11 +103,23 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF this.recreate(); } //user clicked cancel + + /** + * Uses dialog to cancel adding a service. + * + * @param dialog DialogFragment that contains the cancel button. + */ @Override public void onDialogNevermind(DialogFragment dialog) { } //edits service with info from dialog + + /** + * Uses Dialog to edit service. + * + * @param dialog DialogFragment that contains the fields and buttons to edit rate. + */ @Override public void onDialogEdit(DialogFragment dialog) { DBHelper dbHelper = new DBHelper(this); @@ -86,6 +130,12 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF this.recreate(); } //deletes service with info from dialog + + /** + * Uses Dialog to delete a service from the serviceList. + * + * @param dialog DialogFragment that contains the delete service button. + */ @Override public void onDialogDelete(DialogFragment dialog) { DBHelper dbHelper = new DBHelper(this); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java index d4d8e38..1be83c4 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUp.java @@ -9,7 +9,21 @@ import android.widget.EditText; import android.view.View; import android.widget.Toast; +/** + * This class is used to create new userType where the user + * fills in his information and his data is sent to to the database + * to create a new userType object. + * + */ + public class SignUp extends AppCompatActivity { + + /** + * On creation of this class the xml page is loaded up onto the app and + * the EditTexts are set up to accept the information of the user. + * + * @param savedInstanceState Bundle for transferring information + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -25,6 +39,13 @@ public class SignUp extends AppCompatActivity { } + /** + * On click creates a new user if the the user information + * fits the criteria specified by the documentation and is + * not a duplicate of another user. + * + * @param view View object that contains all the editText and buttons used. + */ public void onClickSignUp(View view){ UserType newUser; String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString(); @@ -32,7 +53,6 @@ public class SignUp extends AppCompatActivity { String firstname = ((EditText) findViewById(R.id.FirstNameInput)).getText().toString(); String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString(); MaterialSpinner spinner = findViewById(R.id.RoleInput); - //TODO add message conditional to check if every EditText is filled up to standards if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*") && firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){ switch(spinner.getText().toString()){ @@ -49,7 +69,7 @@ public class SignUp extends AppCompatActivity { } DBHelper dbHelper = new DBHelper(this); - Intent intent = new Intent(getApplicationContext(),LogIn.class); //TODO check if signup should take to the login page or automatically login + Intent intent = new Intent(getApplicationContext(),LogIn.class); if(dbHelper.addUser(newUser)){ startActivity(intent); finish(); @@ -67,6 +87,13 @@ public class SignUp extends AppCompatActivity { Toast.makeText(this, "Fields may only contain alphanumeric values", Toast.LENGTH_LONG).show(); } } + + /** + * app closes the the activity when back is pressed and + * no user information written down is saved in the EditText for + * security purposes. + */ + @Override public void onBackPressed(){ Intent intent = new Intent(getApplicationContext(), Main.class); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java index 7539a2a..98f4766 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java @@ -3,16 +3,33 @@ package com.uottawa.olympus.olympusservices; import java.io.Serializable; +/** + * UserType is the abstract object that is the parent class + * of all users in this program with all common methods and + * fields set in this one class. + */ + public abstract class UserType { + //field for the username attached to the userType. String username; + //field for the password attached to the userType. String password; + //field for the firstname attached to the userType. String firstname; + //field for the lastname attached to the userType. String lastname; - - + /** + * Constructor filling out all the field values with given parameters + * entered by a new user for the app. + * + * @param username String object containing the username. + * @param password String object containing the password. + * @param firstname String object containing the firstname. + * @param lastname String object containing the lastname. + */ UserType(String username, String password, String firstname, String lastname){ this.username = username; this.password = password; @@ -20,25 +37,54 @@ public abstract class UserType { this.lastname = lastname; } + /** + * Abstract method to get the role of each userType child in the app. + * + * @return String object specifying the role of userType. + */ public abstract String getRole(); + /** + * Gets the username field of userType. + * + * @return String of the username. + */ public String getUsername() { return username; } + /** + * Gets the password field of userType. + * + * @return String of the password. + */ public String getPassword() { return password; } + /** + * Gets the firstname field of userType. + * + * @return String of firstname + */ public String getFirstname() { return firstname; } + /** + * Gets the lastname field of userType. + * + * @return String of lastname + */ public String getLastname() { return lastname; } - + /** + * Sets the username field with given parameters. + * + * @param username String for new username. + */ public void setUsername(String username) { //remember to call updateUser(String username, String password, String firstname, String lastname) //in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized @@ -47,6 +93,11 @@ public abstract class UserType { } + /** + * Sets the password field with given parameters. + * + * @param password String of new password. + */ public void setPassword(String password) { //remember to call updateUser(String username, String password, String firstname, String lastname) //in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized @@ -54,6 +105,11 @@ public abstract class UserType { this.password = password; } + /** + * Sets the firstname field with given parameters. + * + * @param firstname String of new firstname. + */ public void setFirstname(String firstname) { //remember to call updateUser(String username, String password, String firstname, String lastname) //in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized @@ -68,7 +124,11 @@ public abstract class UserType { this.lastname = lastname; } - + /** + * Compares this userType and another userType to see if there fields are equal. + * + * @param other Usertype object that is compared to this userType. + */ public boolean equals(UserType other){ if(this.username.equals(other.username)&&this.password.equals(other.password)&& this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){ diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java index 4cb5afb..680e7b6 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java @@ -8,8 +8,22 @@ import android.widget.GridView; import java.util.Iterator; import java.util.List; +/** + * screen for user list that the admin can access + * and manage all users in the program. Userlist is generated through + * the database using DBHelper class. + * + */ + public class UsersList extends AppCompatActivity { + /** + * on Creation of this class the app loads up the xml page for + * activity_user_list and generates a gridview using the database + * for all the users in the app. + * + * @param savedInstanceState bundle to transfer data + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java index 4389f62..24ac48c 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java @@ -6,8 +6,21 @@ import android.view.View; import android.widget.TextView; import android.content.Intent; +/** + * Welcome class creates the welcome screen for the HomeOwners and ServiceProviders + * as a temporary screen until full functionality of those two a classes are + * implemented. + * + */ public class Welcome extends AppCompatActivity { + /** + * On creation of this object the app will display the xml file for + * the welcome page which gets the role and username of the UserType + * object and welcomes the user with a message. + * + * @param savedInstanceState Bundle to transfer data + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -24,9 +37,23 @@ public class Welcome extends AppCompatActivity { } + + /** + * Override so that nothing occurs when pressing the + * back button on this activity of the app. + * + */ @Override public void onBackPressed(){ } + + /** + * Logs out the user and returns them back to + * main activity. End all current user activity + * for security purposes. + * + * @param view View object of current activity. + */ public void LogOut(View view){ Intent intent = new Intent(getApplicationContext(), Main.class); startActivity(intent);