comments for project.

This commit is contained in:
Anshu Sharma 2018-11-09 11:48:05 -05:00
parent c5f5157ef1
commit 970c3422f4
17 changed files with 435 additions and 13 deletions

View file

@ -25,7 +25,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -1,10 +1,28 @@
package com.uottawa.olympus.olympusservices; 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 { 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(){ Admin(){
super("admin", "admin", "Admin", "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"; } public String getRole(){ return "Admin"; }
} }

View file

@ -5,27 +5,70 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_welcome); setContentView(R.layout.activity_admin_welcome);
} }
/**
* Override so that nothing occurs when pressing the
* back button on this activity of the app.
*
*/
@Override @Override
public void onBackPressed(){ 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){ public void LogOut(View view){
Intent intent = new Intent(getApplicationContext(), Main.class); Intent intent = new Intent(getApplicationContext(), Main.class);
startActivity(intent); startActivity(intent);
finish(); 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){ public void goToUsers(View view){
Intent intent = new Intent(getApplicationContext(), UsersList.class); Intent intent = new Intent(getApplicationContext(), UsersList.class);
startActivity(intent); 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){ public void goToServices(View view){
Intent intent = new Intent(getApplicationContext(), ServicesList.class); Intent intent = new Intent(getApplicationContext(), ServicesList.class);
startActivity(intent); startActivity(intent);

View file

@ -1,5 +1,11 @@
package com.uottawa.olympus.olympusservices; 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 { public class Appointment {
Service service; Service service;
ServiceProvider provider; ServiceProvider provider;

View file

@ -11,9 +11,14 @@ import android.widget.EditText;
public class EditServiceDialogFragment extends DialogFragment{ public class EditServiceDialogFragment extends DialogFragment{
public interface NoticeDialogListener { /**
public void onDialogEdit(DialogFragment dialog); * Creates a NoticeDialogListener interface for other classes to
public void onDialogDelete(DialogFragment dialog); * 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; EditServiceDialogFragment.NoticeDialogListener mListener;
@ -31,6 +36,14 @@ public interface NoticeDialogListener {
+ " must implement 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 @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

View file

@ -1,12 +1,35 @@
package com.uottawa.olympus.olympusservices; 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 { 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){ HomeOwner(String username, String password, String firstname, String lastname){
super(username, password, firstname, 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"; } public String getRole(){ return "HomeOwner"; }
} }

View file

@ -7,14 +7,34 @@ import android.widget.EditText;
import android.view.View; import android.view.View;
import android.widget.Toast; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in); 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){ public void onClickLogIn(View view){
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString(); String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString();
String password = ((EditText) findViewById(R.id.PasswordInput)).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 @Override
public void onBackPressed(){ public void onBackPressed(){
Intent intent = new Intent(getApplicationContext(), Main.class); Intent intent = new Intent(getApplicationContext(), Main.class);

View file

@ -5,8 +5,21 @@ import android.os.Bundle;
import android.content.Intent; import android.content.Intent;
import android.view.View; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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){ public void onClickSignUp(View view){
Intent intent = new Intent(getApplicationContext(),SignUp.class); Intent intent = new Intent(getApplicationContext(),SignUp.class);
startActivity(intent); 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){ public void onClickLogIn(View view){
Intent intent = new Intent(getApplicationContext(),LogIn.class); Intent intent = new Intent(getApplicationContext(),LogIn.class);
startActivity(intent); startActivity(intent);

View file

@ -18,9 +18,18 @@ import android.view.View;
import com.rengwuxian.materialedittext.MaterialEditText; 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 { 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 interface NoticeDialogListener {
public void onDialogNew(DialogFragment dialog); public void onDialogNew(DialogFragment dialog);
public void onDialogNevermind(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 @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {

View file

@ -3,33 +3,78 @@ package com.uottawa.olympus.olympusservices;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 { public class Service {
//name of the service field.
private String name; private String name;
//rate of the service field.
private double rate; private double rate;
//list of services the providers that offers this service.
private List<ServiceProvider> serviceProviders; private List<ServiceProvider> 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) { Service(String name, double rate) {
this.name = name; this.name = name;
this.rate = rate; this.rate = rate;
serviceProviders = new ArrayList<ServiceProvider>(); serviceProviders = new ArrayList<ServiceProvider>();
} }
/**
* Gets the Name field of the service.
*
* @return String of the name.
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Gets the Rate field of the service.
*
* @return double of the rate.
*/
public double getRate() { public double getRate() {
return rate; return rate;
} }
/**
* Changes the name field of the object to parameter given.
*
* @param name String object of new name
*/
public void setName(String name) { public void setName(String name) {
this.name = 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) { public void setRate(double rate) {
this.rate = 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){ public boolean addServiceProvider(ServiceProvider user){
for (ServiceProvider listUser : serviceProviders){ for (ServiceProvider listUser : serviceProviders){
if (user.getUsername().equals(listUser.getUsername())){ if (user.getUsername().equals(listUser.getUsername())){

View file

@ -3,17 +3,45 @@ package com.uottawa.olympus.olympusservices;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 { public class ServiceProvider extends UserType {
//Field for list of services that service provider offers.
private List<Service> services; private List<Service> 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){ ServiceProvider(String username, String password, String firstname, String lastname){
super(username, password, firstname, lastname); super(username, password, firstname, lastname);
services = new ArrayList<>(); services = new ArrayList<>();
} }
/**
* gets the role of the UserType.
*
* @return String "Service Provider"
*/
public String getRole(){ return "ServiceProvider"; } 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){ public boolean addService(Service service){
for (Service listService : services){ for (Service listService : services){
if (service.getName().equals(listService.getName())){ if (service.getName().equals(listService.getName())){
@ -24,6 +52,11 @@ public class ServiceProvider extends UserType {
return true; return true;
} }
/**
* Gets the services list field of service provider.
*
* @return arrayList of Services
*/
public List<Service> getServices(){ public List<Service> getServices(){
return services; return services;
} }

View file

@ -18,12 +18,26 @@ import android.widget.TextView;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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{ public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{
//field for RecyclerView
private RecyclerView mRecyclerView; private RecyclerView mRecyclerView;
//field for adapter of Recycler view
private RecyclerView.Adapter mAdapter; private RecyclerView.Adapter mAdapter;
//field for layout manager of Recyler view.
private RecyclerView.LayoutManager mLayoutManager; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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) { public void addService(View view) {
DialogFragment newFragment = new NewServiceDialogFragment(); DialogFragment newFragment = new NewServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "addService"); 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) { public void editService(View view, String name) {
DialogFragment newFragment = new EditServiceDialogFragment(); DialogFragment newFragment = new EditServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "editService"); newFragment.show(getSupportFragmentManager(), "editService");
@ -61,6 +87,12 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
newFragment.setArguments(args); newFragment.setArguments(args);
} }
//add new service //add new service
/**
* Uses dialog to obtain the fields for addSerivce.
*
* @param dialog DialogFragment used to obtain the fields for the added service
*/
@Override @Override
public void onDialogNew(DialogFragment dialog) { public void onDialogNew(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
@ -71,11 +103,23 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
this.recreate(); this.recreate();
} }
//user clicked cancel //user clicked cancel
/**
* Uses dialog to cancel adding a service.
*
* @param dialog DialogFragment that contains the cancel button.
*/
@Override @Override
public void onDialogNevermind(DialogFragment dialog) { public void onDialogNevermind(DialogFragment dialog) {
} }
//edits service with info from 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 @Override
public void onDialogEdit(DialogFragment dialog) { public void onDialogEdit(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
@ -86,6 +130,12 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
this.recreate(); this.recreate();
} }
//deletes service with info from dialog //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 @Override
public void onDialogDelete(DialogFragment dialog) { public void onDialogDelete(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);

View file

@ -9,7 +9,21 @@ import android.widget.EditText;
import android.view.View; import android.view.View;
import android.widget.Toast; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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){ public void onClickSignUp(View view){
UserType newUser; UserType newUser;
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString(); 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 firstname = ((EditText) findViewById(R.id.FirstNameInput)).getText().toString();
String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString(); String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString();
MaterialSpinner spinner = findViewById(R.id.RoleInput); 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]*") 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]*")){ && firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
switch(spinner.getText().toString()){ switch(spinner.getText().toString()){
@ -49,7 +69,7 @@ public class SignUp extends AppCompatActivity {
} }
DBHelper dbHelper = new DBHelper(this); 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)){ if(dbHelper.addUser(newUser)){
startActivity(intent); startActivity(intent);
finish(); finish();
@ -67,6 +87,13 @@ public class SignUp extends AppCompatActivity {
Toast.makeText(this, "Fields may only contain alphanumeric values", Toast.LENGTH_LONG).show(); 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 @Override
public void onBackPressed(){ public void onBackPressed(){
Intent intent = new Intent(getApplicationContext(), Main.class); Intent intent = new Intent(getApplicationContext(), Main.class);

View file

@ -3,16 +3,33 @@ package com.uottawa.olympus.olympusservices;
import java.io.Serializable; 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 { public abstract class UserType {
//field for the username attached to the userType.
String username; String username;
//field for the password attached to the userType.
String password; String password;
//field for the firstname attached to the userType.
String firstname; String firstname;
//field for the lastname attached to the userType.
String lastname; 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){ UserType(String username, String password, String firstname, String lastname){
this.username = username; this.username = username;
this.password = password; this.password = password;
@ -20,25 +37,54 @@ public abstract class UserType {
this.lastname = lastname; 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(); public abstract String getRole();
/**
* Gets the username field of userType.
*
* @return String of the username.
*/
public String getUsername() { public String getUsername() {
return username; return username;
} }
/**
* Gets the password field of userType.
*
* @return String of the password.
*/
public String getPassword() { public String getPassword() {
return password; return password;
} }
/**
* Gets the firstname field of userType.
*
* @return String of firstname
*/
public String getFirstname() { public String getFirstname() {
return firstname; return firstname;
} }
/**
* Gets the lastname field of userType.
*
* @return String of lastname
*/
public String getLastname() { public String getLastname() {
return lastname; return lastname;
} }
/**
* Sets the username field with given parameters.
*
* @param username String for new username.
*/
public void setUsername(String username) { public void setUsername(String username) {
//remember to call updateUser(String username, String password, String firstname, String lastname) //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 //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) { public void setPassword(String password) {
//remember to call updateUser(String username, String password, String firstname, String lastname) //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 //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; this.password = password;
} }
/**
* Sets the firstname field with given parameters.
*
* @param firstname String of new firstname.
*/
public void setFirstname(String firstname) { public void setFirstname(String firstname) {
//remember to call updateUser(String username, String password, String firstname, String lastname) //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 //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; 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){ public boolean equals(UserType other){
if(this.username.equals(other.username)&&this.password.equals(other.password)&& if(this.username.equals(other.username)&&this.password.equals(other.password)&&
this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){ this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){

View file

@ -8,8 +8,22 @@ import android.widget.GridView;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View file

@ -6,8 +6,21 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.content.Intent; 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 { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 @Override
public void onBackPressed(){ 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){ public void LogOut(View view){
Intent intent = new Intent(getApplicationContext(), Main.class); Intent intent = new Intent(getApplicationContext(), Main.class);
startActivity(intent); startActivity(intent);