diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser deleted file mode 100644 index 7382ddd..0000000 Binary files a/OlympusServices/.idea/caches/build_file_checksums.ser and /dev/null differ diff --git a/OlympusServices/app/src/main/AndroidManifest.xml b/OlympusServices/app/src/main/AndroidManifest.xml index 341d033..d2c0e60 100644 --- a/OlympusServices/app/src/main/AndroidManifest.xml +++ b/OlympusServices/app/src/main/AndroidManifest.xml @@ -47,28 +47,28 @@ + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> + android:screenOrientation="portrait" /> - + android:screenOrientation="portrait"> + \ No newline at end of file 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 43cf751..b768ad8 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 @@ -31,6 +31,8 @@ public class ServiceProvider extends UserType { private boolean licensed; + + /** * Constructor for the service object which takes the parameters to * fill out the service providers field. @@ -40,10 +42,15 @@ public class ServiceProvider extends UserType { * @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, String address, + String phonenumber, String companyname, boolean licensed){ super(username, password, firstname, lastname); services = new ArrayList<>(); availabilities = new int[7][4]; + this.address = address; + this.phonenumber = phonenumber; + this.companyname = companyname; + this.licensed = licensed; } /** @@ -75,9 +82,7 @@ public class ServiceProvider extends UserType { * * @return arrayList of Services */ - public List getServices(){ - return services; - } + public void setAvailabilities(int day, int startHour, int startMin, int endHour, int endMin){ @@ -91,6 +96,17 @@ public class ServiceProvider extends UserType { return availabilities; } + public void setAvailabilities(int[][] availabilities) { + this.availabilities = availabilities; + } + public void setServices(List services) { + this.services = services; + } + + public List getServices(){ + return services; + } + public String getAddress() { return address; } 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 bba931c..9eda906 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 @@ -56,27 +56,45 @@ public class SignUp extends AppCompatActivity { 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]*")){ + DBHelper dbHelper = new DBHelper(this); + Intent intent = new Intent(getApplicationContext(),LogIn.class); switch(spinner.getText().toString()){ case "Home Owner": newUser = new HomeOwner(username,password,firstname,lastname); + if(dbHelper.addUser(newUser)){ + startActivity(intent); + finish(); + }else{ + Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show(); + } break; case "Service Provider": - newUser = new ServiceProvider(username,password,firstname,lastname); + if(dbHelper.findUserByUsername(username)==null) { + Intent intent2 = new Intent(getApplicationContext(), SignUpPart2.class); + intent2.putExtra("firstname", firstname); + intent2.putExtra("lastname", lastname); + intent2.putExtra("username", username); + intent2.putExtra("password", password); + startActivity(intent); + finish(); + }else{ + Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show(); + } break; + default: newUser = new HomeOwner(username,password,firstname,lastname); //if nothing is enter then defaults to user role. + + if(dbHelper.addUser(newUser)){ + startActivity(intent); + finish(); + }else{ + Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show(); + } break; } - DBHelper dbHelper = new DBHelper(this); - Intent intent = new Intent(getApplicationContext(),LogIn.class); - if(dbHelper.addUser(newUser)){ - startActivity(intent); - finish(); - }else{ - Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show(); - } } else if(firstname.length()==0 || lastname.length()==0 || username.length()==0 || password.length()==0){ Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_LONG).show(); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java new file mode 100644 index 0000000..4e01909 --- /dev/null +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java @@ -0,0 +1,39 @@ +package com.uottawa.olympus.olympusservices; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.CheckBox; +import android.widget.EditText; + +public class SignUpPart2 extends AppCompatActivity { + private String username; + private String password; + private String firstname; + private String lastname; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sign_up_part2); + Bundle bundle = getIntent().getExtras(); + username = bundle.getString("username"); + password = bundle.getString("password"); + firstname = bundle.getString("firstname"); + lastname = bundle.getString("lastname"); + } + + public void SignUp(View view){ + DBHelper dbHelper = new DBHelper(this); + Intent intent = new Intent(getApplicationContext(),LogIn.class); + String companyname = ((EditText) findViewById(R.id.CompanyNameInput)).getText().toString(); + String phonenumber = ((EditText) findViewById(R.id.PhoneNumberInput)).getText().toString(); + String address = ((EditText) findViewById(R.id.AddressInput)).getText().toString(); + boolean licensed = ((CheckBox) findViewById(R.id.LicensedInput)).isChecked(); + + ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, + address, phonenumber, companyname, licensed); + + } +} diff --git a/OlympusServices/app/src/main/res/layout/activity_sign_up_part2.xml b/OlympusServices/app/src/main/res/layout/activity_sign_up_part2.xml new file mode 100644 index 0000000..71f0f3e --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/activity_sign_up_part2.xml @@ -0,0 +1,93 @@ + + + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + + + +