comments for project.
This commit is contained in:
parent
c5f5157ef1
commit
970c3422f4
17 changed files with 435 additions and 13 deletions
Binary file not shown.
|
@ -25,7 +25,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</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" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -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"; }
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -11,6 +11,11 @@ import android.widget.EditText;
|
|||
|
||||
public class EditServiceDialogFragment 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 onDialogEdit(DialogFragment dialog);
|
||||
public void onDialogDelete(DialogFragment dialog);
|
||||
|
@ -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());
|
||||
|
|
|
@ -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"; }
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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<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) {
|
||||
this.name = name;
|
||||
this.rate = rate;
|
||||
serviceProviders = new ArrayList<ServiceProvider>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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())){
|
||||
|
|
|
@ -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<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){
|
||||
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<Service> getServices(){
|
||||
return services;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue