fix conflict

This commit is contained in:
Anshu Sharma 2018-11-09 11:53:12 -05:00
commit 926ffa89b2
14 changed files with 88 additions and 22 deletions

View file

@ -17,7 +17,6 @@ public class LogInTest {
@Test @Test
public void checkSignIn() throws Exception{ public void checkSignIn() throws Exception{
//Lalala
} }
} }

View file

@ -8,6 +8,7 @@ import android.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast;
public class EditServiceDialogFragment extends DialogFragment{ public class EditServiceDialogFragment extends DialogFragment{
@ -60,18 +61,25 @@ public class EditServiceDialogFragment extends DialogFragment{
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("name", (String)getArguments().get("name")); args.putString("name", (String)getArguments().get("name"));
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
double rate = Double.parseDouble(rateInput.getText().toString()); if(rateInput.getText().toString().length()>0){
args.putDouble("rate", rate); Double rate = Double.parseDouble(rateInput.getText().toString());
args.putDouble("rate", rate);
EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogEdit(EditServiceDialogFragment.this); EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogEdit(EditServiceDialogFragment.this);
}
else{
Toast.makeText(getContext(), "Rate cannot be empty", Toast.LENGTH_LONG).show();
}
} }
}) })
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("name", (String)getArguments().get("name")); args.putString("name", (String)getArguments().get("name"));
EditServiceDialogFragment.this.setArguments(args); EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogDelete(EditServiceDialogFragment.this); mListener.onDialogDelete(EditServiceDialogFragment.this);
} }

View file

@ -15,6 +15,7 @@ import android.support.annotation.Nullable;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import android.view.View; import android.view.View;
import android.widget.Toast;
import com.rengwuxian.materialedittext.MaterialEditText; import com.rengwuxian.materialedittext.MaterialEditText;
@ -77,13 +78,21 @@ public class NewServiceDialogFragment extends DialogFragment {
EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput); EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput);
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
String name = nameInput.getText().toString(); String name = nameInput.getText().toString();
double rate = Double.parseDouble(rateInput.getText().toString()); DBHelper dbHelper = new DBHelper(getContext());
Bundle args = new Bundle(); if (rateInput.getText().toString().length()>0 && name.length()>0 && name.matches("[a-zA-Z]*")&& dbHelper.findService(name)==null){
args.putString("name", name); Double rate = Double.parseDouble(rateInput.getText().toString());
args.putDouble("rate", rate); Bundle args = new Bundle();
NewServiceDialogFragment.this.setArguments(args); args.putString("name", name);
mListener.onDialogNew(NewServiceDialogFragment.this); args.putDouble("rate", rate);
NewServiceDialogFragment.this.setArguments(args);
mListener.onDialogNew(NewServiceDialogFragment.this);
}
else if(!(rateInput.getText().toString().length()>0) || !(name.length()>0)|| !name.matches("[a-zA-Z]*")){
Toast.makeText(getContext(), "Service must have an alphanumeric name and a rate", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(getContext(), "Service already exists", Toast.LENGTH_LONG).show();
}
} }
}) })
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

View file

@ -14,6 +14,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.GridView; import android.widget.GridView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -141,6 +142,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name"); String name = (String)dialog.getArguments().get("name");
dbHelper.deleteService(name); dbHelper.deleteService(name);
Toast.makeText(this, "Service \""+(String)dialog.getArguments().get("name")+"\" has been deleted", Toast.LENGTH_LONG).show();
dialog.dismiss(); dialog.dismiss();
this.recreate(); this.recreate();
} }

View file

@ -53,6 +53,7 @@ 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);
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()){
@ -80,7 +81,7 @@ public class SignUp extends AppCompatActivity {
else if(firstname.length()==0 || lastname.length()==0 || username.length()==0 || password.length()==0){ 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(); Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_LONG).show();
} }
else if (username.length()<=5 || password.length()<=5 ){ else if (username.length()<5 || password.length()<5 ){
Toast.makeText(this, "Password and username must be longer than 4 characters", Toast.LENGTH_LONG).show(); Toast.makeText(this, "Password and username must be longer than 4 characters", Toast.LENGTH_LONG).show();
} }
else{ else{

View file

@ -50,7 +50,7 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_weight="1" android:layout_weight="1"
android:text="Hourly Rate" android:text="Hourly Rate($)"
android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="15sp" /> android:textSize="15sp" />
@ -67,11 +67,22 @@
android:layout_height="250dp"/> android:layout_height="250dp"/>
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/Title3"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Click on service to edit or delete"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="15sp" />
<Button <Button
android:id="@+id/newService" android:id="@+id/newService"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="5dp"
android:text="Add New Service" android:text="Add New Service"
android:onClick="addService" android:onClick="addService"
android:theme="@style/AppTheme.Button" /> android:theme="@style/AppTheme.Button" />

View file

@ -16,6 +16,7 @@
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite" android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp" android:textSize="15sp"
android:text=""
app:met_baseColor="@android:color/black" app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight" app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack" app:met_primaryColor="@color/colorBlack"

View file

@ -14,6 +14,7 @@
android:hint="@string/servicename" android:hint="@string/servicename"
android:textCursorDrawable="@color/colorWhite" android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp" android:textSize="15sp"
android:text=""
app:met_baseColor="@android:color/black" app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight" app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack" app:met_primaryColor="@color/colorBlack"
@ -28,6 +29,7 @@
android:layout_height="80dp" android:layout_height="80dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:hint="@string/servicerate" android:hint="@string/servicerate"
android:text=""
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite" android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp" android:textSize="15sp"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:background="@drawable/customborder" android:background="@drawable/customborder"
android:layout_marginBottom="5dp"> android:layout_marginBottom="5dp">
@ -9,7 +9,8 @@
<TextView <TextView
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingTop="8dp" android:paddingTop="6dp"
android:paddingBottom="6dp"
android:id="@+id/Name" android:id="@+id/Name"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -21,7 +22,8 @@
<TextView <TextView
android:id="@+id/Rate" android:id="@+id/Rate"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingTop="8dp" android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"

View file

@ -6,6 +6,10 @@ import static org.junit.Assert.*;
public class AdminTest { public class AdminTest {
/**
* Initiates an Admin account and tests if the strings match to the required inputs.
*/
@Test @Test
public void testAdmin() { public void testAdmin() {
Admin admin = new Admin(); Admin admin = new Admin();

View file

@ -6,6 +6,10 @@ import static org.junit.Assert.*;
public class HomeOwnerTest { public class HomeOwnerTest {
/**
* Initiates an Homeowner account and tests if the random strings match to the required inputs.
*/
@Test @Test
public void testHomeOwner(){ public void testHomeOwner(){
UserType user = new HomeOwner( "John123", "1234567890", "John", "Doe" ); UserType user = new HomeOwner( "John123", "1234567890", "John", "Doe" );

View file

@ -10,6 +10,10 @@ public class ServiceProviderTest {
ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe"); ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe");
/**
* Initiates an ServiceProvider account and tests if the random strings match to the required inputs.
*/
@Test @Test
public void testServiceProvider() { public void testServiceProvider() {
assertEquals( "John123", serviceprovider.getUsername() ); assertEquals( "John123", serviceprovider.getUsername() );
@ -27,13 +31,18 @@ public class ServiceProviderTest {
assertNotEquals("Doe", serviceprovider.getLastname()); assertNotEquals("Doe", serviceprovider.getLastname());
} }
/**
* adds services and tests if they match the requirements in order to function properly. Example: If a service has a same name it doesn't count as one.
*
*/
@Test @Test
public void addServiceTest() { public void addServiceTest() {
serviceprovider.addService( new Service( "KitchenCleaner", 50 ) ); serviceprovider.addService( new Service( "KitchenCleaner", 50 ) );
serviceprovider.addService( new Service( "FrenchMaid", 250 ) ); serviceprovider.addService( new Service( "FrenchMaid", 250 ) );
serviceprovider.addService( new Service( "FrenchMaid", 250 ) ); serviceprovider.addService( new Service( "FrenchMaid", 210 ) );
serviceprovider.addService( new Service( "SecretService", 150 ) );
serviceprovider.addService( new Service( "SecretService", 150 ) ); serviceprovider.addService( new Service( "SecretService", 150 ) );
serviceprovider.addService( new Service( "SecretService", 110 ) );
int numOfServices = serviceprovider.getServices().size(); int numOfServices = serviceprovider.getServices().size();
assertEquals( 3, numOfServices ); assertEquals( 3, numOfServices );
} }

View file

@ -7,6 +7,10 @@ import static org.junit.Assert.*;
public class ServiceTest { public class ServiceTest {
Service service = new Service( "FrenchMaid", 250 ); Service service = new Service( "FrenchMaid", 250 );
/**
* Initiates an Service account and tests if the random strings match to the required inputs.
*/
@Test @Test
public void testService(){ public void testService(){
assertEquals( "FrenchMaid", service.getName() ); assertEquals( "FrenchMaid", service.getName() );
@ -17,12 +21,18 @@ public class ServiceTest {
assertNotEquals( 250, service.getRate()); assertNotEquals( 250, service.getRate());
} }
/**
* adds service providers and tests if they match the requirements in order to function properly. Example: If a service has a same name it doesn't count as one.
*
*/
@Test @Test
public void addServiceProviderTest(){ public void addServiceProviderTest(){
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) );
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe" ) );
int numOfSP = service.getServiceProviders().size(); int numOfSP = service.getServiceProviders().size();
assertEquals( 2,numOfSP ); assertEquals( 2,numOfSP );
} }

View file

@ -11,6 +11,10 @@ import static org.junit.Assert.*;
public class UserTypeTest { public class UserTypeTest {
/**
* Tests if the every user that is created is equal to each other or not.
*/
@Test @Test
public void userTypeComparaison() { public void userTypeComparaison() {
UserType user = new HomeOwner("John123", "1234567890", "John", "Doe"); UserType user = new HomeOwner("John123", "1234567890", "John", "Doe");