broken code will be fixed soon :(

This commit is contained in:
IvanaE 2018-11-13 13:40:14 -05:00
parent 19b42bf9a5
commit 1da25d2aff
7 changed files with 187 additions and 21 deletions

View file

@ -67,8 +67,8 @@
<activity
android:name=".ServiceProviderAvailabilities"
android:label="Availabilities"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<activity android:name=".SignUpPart2"></activity>
</application>
</manifest>

View file

@ -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<Service> 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<Service> services) {
this.services = services;
}
public List<Service> getServices(){
return services;
}
public String getAddress() {
return address;
}

View file

@ -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);
break;
case "Service Provider":
newUser = new ServiceProvider(username,password,firstname,lastname);
break;
default:
newUser = new HomeOwner(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
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();
}
break;
case "Service Provider":
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;
}
}
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();

View file

@ -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);
}
}

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".SignUpPart2">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//component used from https://github.com/rengwuxian/MaterialEditText
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/CompanyNameInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="Company Name"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:textCursorDrawable="@color/colorWhite"
android:layout_marginTop="20dp"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/PhoneNumberInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="Phone Number"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:inputType="phone"
android:textCursorDrawable="@color/colorWhite"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/AddressInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="Address"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:textCursorDrawable="@color/colorWhite"/>
<CheckBox
android:id="@+id/LicensedInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Licensed"
android:textSize="15sp"
android:textColor="@color/colorWhite"
android:buttonTint="@color/colorWhite"
android:layout_marginBottom="15dp"/>
<Button
android:id="@+id/SignUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign Up"
android:onClick="SignUp"
android:theme="@style/AppTheme.Button" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View file

@ -5,7 +5,7 @@
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorWhite</item>
<item name="colorAccent">@color/colorWhite</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">