diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 66d481e..03c8afe 100644 Binary files a/OlympusServices/.idea/caches/build_file_checksums.ser and b/OlympusServices/.idea/caches/build_file_checksums.ser differ diff --git a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java b/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java deleted file mode 100644 index 0487845..0000000 --- a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.uottawa.olympus.olympusservices; - -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - - -@RunWith(AndroidJUnit4.class) -public class LogInTest { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule(LogIn.class); - - @Test - public void checkSignIn() throws Exception{ - - } -} \ No newline at end of file diff --git a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/SignUpTest.java b/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/SignUpTest.java deleted file mode 100644 index b299158..0000000 --- a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/SignUpTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.uottawa.olympus.olympusservices; - -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; -import android.widget.TextView; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static android.support.test.espresso.Espresso.onData; -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard; -import static android.support.test.espresso.action.ViewActions.typeText; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withSpinnerText; -import static java.util.regex.Pattern.matches; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.core.AllOf.allOf; -import static org.junit.Assert.*; - -@RunWith(AndroidJUnit4.class) -public class SignUpTest { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule(SignUp.class); - private SignUp mActivity=null; - private TextView text; - - @Before - public void setUp() throws Exception { - mActivity = mActivityTestRule.getActivity(); - } - - @Test - public void checkSignUp1() throws Exception{ - onView(withId(R.id.UsernameInput)).perform(typeText("John123"), closeSoftKeyboard()); - onView(withId(R.id.PasswordInput)).perform(typeText("1234567890"), closeSoftKeyboard()); - onView(withId(R.id.FirstNameInput)).perform(typeText("John"), closeSoftKeyboard()); - onView(withId(R.id.LastNameInput)).perform(typeText("Doe"), closeSoftKeyboard()); - onView(withId(R.id.SignUp)).perform(click()); - } - - @Test - public void checkSignUp2() throws Exception{ - onView(withId(R.id.RoleInput)).perform(click()); - onData(allOf(is(instanceOf(String.class)), is("Service Provider"))).perform(click()); - onView(withId(R.id.UsernameInput)).perform(typeText("Service123"), closeSoftKeyboard()); - onView(withId(R.id.PasswordInput)).perform(typeText("1234567890"), closeSoftKeyboard()); - onView(withId(R.id.FirstNameInput)).perform(typeText("Jane"), closeSoftKeyboard()); - onView(withId(R.id.LastNameInput)).perform(typeText("Doe"), closeSoftKeyboard()); - onView(withId(R.id.SignUp)).perform(click()); - } - - @Test - public void checkSignUp3() throws Exception{ - onView(withId(R.id.UsernameInput)).perform(typeText(""), closeSoftKeyboard()); - onView(withId(R.id.PasswordInput)).perform(typeText(""), closeSoftKeyboard()); - onView(withId(R.id.FirstNameInput)).perform(typeText(""), closeSoftKeyboard()); - onView(withId(R.id.LastNameInput)).perform(typeText(""), closeSoftKeyboard()); - onView(withId(R.id.SignUp)).perform(click()); - } - - @Test - public void checkSignUp4() throws Exception{ - onView(withId(R.id.UsernameInput)).perform(typeText("$$$$$$"), closeSoftKeyboard()); - onView(withId(R.id.PasswordInput)).perform(typeText("$$$$$$"), closeSoftKeyboard()); - onView(withId(R.id.FirstNameInput)).perform(typeText("$$$$$$"), closeSoftKeyboard()); - onView(withId(R.id.LastNameInput)).perform(typeText("$$$$$$"), closeSoftKeyboard()); - onView(withId(R.id.SignUp)).perform(click()); - } - - public void checkSignUp5() throws Exception{ - onView(withId(R.id.UsernameInput)).perform(typeText("user"), closeSoftKeyboard()); - onView(withId(R.id.PasswordInput)).perform(typeText("pass"), closeSoftKeyboard()); - onView(withId(R.id.FirstNameInput)).perform(typeText("Honda"), closeSoftKeyboard()); - onView(withId(R.id.LastNameInput)).perform(typeText("Gokuchi"), closeSoftKeyboard()); - onView(withId(R.id.SignUp)).perform(click()); - } - - @After - public void tearDown() throws Exception { - mActivity=null; - } -} \ No newline at end of file diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java index 5577ecc..c7b38ca 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java @@ -12,11 +12,14 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; +import java.util.List; + public class Bookings extends AppCompatActivity { //field for RecyclerView @@ -37,14 +40,18 @@ public class Bookings extends AppCompatActivity { username = bundle.getString("username"); dbhelper = new DBHelper(this); - //Booking[] bookings = (Booking[])dbhelper.findBookings(username).toArray(); + List booking = (List)dbhelper.findBookings(username); + Booking[] bookings = new Booking[booking.size()]; + bookings = booking.toArray(bookings); - Booking[] testbooking = {new Booking(5, 5, 6, 6, 2, 3, 2019, (ServiceProvider)dbhelper.findUserByUsername("testing"), + /* mock data + Booking[] bookings = {new Booking(5, 5, 6, 6, 2, 3, 2019, (ServiceProvider)dbhelper.findUserByUsername("testing"), (HomeOwner)dbhelper.findUserByUsername("tester"), dbhelper.findService("service1"))}; + */ mRecyclerView = (RecyclerView) findViewById(R.id.Bookings); mLayoutManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mLayoutManager); - mAdapter = new MyAdapter(testbooking, this); + mAdapter = new MyAdapter(bookings, this); mRecyclerView.setAdapter(mAdapter); } @@ -98,7 +105,7 @@ public class Bookings extends AppCompatActivity { @Override public void onBindViewHolder(BookingHolder holder, int position) { Booking booking = bookings[position]; - holder.serviceprovider.setText(booking.getServiceprovider().getFirstname()+" "+booking.getServiceprovider().getLastname()); + holder.serviceprovider.setText(booking.getServiceprovider().getFirstname()+" "+booking.getServiceprovider().getLastname()+", "+booking.getServiceprovider().getCompanyname()); holder.homeowner.setText(booking.getHomeowner().getFirstname()+" "+booking.getHomeowner().getLastname()); holder.service.setText(booking.getService().getName()); String day; @@ -173,6 +180,7 @@ public class Bookings extends AppCompatActivity { year, (ServiceProvider)dbhelper.findUserByUsername(serviceprovider.getText().toString()), (HomeOwner)dbhelper.findUserByUsername(homeowner.getText().toString()), dbhelper.findService(service.getText().toString())))){ + Toast.makeText(Bookings.this,"Booking is confirmed",Toast.LENGTH_LONG).show(); Bookings.this.recreate(); } @@ -213,21 +221,30 @@ public class Bookings extends AppCompatActivity { RadioGroup ratingselect = ((AlertDialog) arg0).findViewById(R.id.RatingSelect); int selectedId = ratingselect.getCheckedRadioButtonId(); RadioButton ratingpicked; - if(selectedId!=-1){ + EditText comment = ((AlertDialog) arg0).findViewById(R.id.Comment); + if(selectedId!=-1 && !comment.getText().toString().equals("")){ ratingpicked = (RadioButton)((AlertDialog) arg0).findViewById(selectedId); double rating = Double.parseDouble(ratingpicked.getText().toString()); - Booking booking = new Booking(starth, startmin, endh, endmin, day, month, + /*Booking booking = new Booking(starth, startmin, endh, endmin, day, month, year, (ServiceProvider)dbhelper.findUserByUsername(serviceprovider.getText().toString()), (HomeOwner)dbhelper.findUserByUsername(homeowner.getText().toString()), - dbhelper.findService(service.getText().toString()));; - if(!dbhelper.addRating(booking, rating)){ - Toast.makeText(context, "Rating could not be added", Toast.LENGTH_SHORT).show(); + dbhelper.findService(service.getText().toString())); + */ + Booking booking = new Booking(starth, startmin, endh, endmin, day, month, year, new ServiceProvider(serviceprovider.getText().toString(), + "", "", "", "", "", "", true), + new HomeOwner(homeowner.getText().toString(), "", "", ""), + new Service(service.getText().toString(), 5)); + if(!dbhelper.addRating(booking, rating, comment.getText().toString())){ + Toast.makeText(Bookings.this, "Rating could not be added", Toast.LENGTH_SHORT).show(); } else{ Bookings.this.recreate(); } } + else{ + Toast.makeText(Bookings.this, "Rating and comment must be filled in", Toast.LENGTH_SHORT).show(); + } } }); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java index 3696b31..9f21cf0 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java @@ -1787,7 +1787,7 @@ public class DBHelper extends SQLiteOpenHelper { (ServiceProvider) findUserByUsername(cursor.getString(0)) : serviceProvider); HomeOwner homeowner = (homeOwner == null ? (HomeOwner) findUserByUsername(cursor.getString(1)) : homeOwner); - Service service = findService(cursor.getString(3)); + Service service = (Service)findService(cursor.getString(2)); Booking booking = new Booking(starth, startmin, endh, endmin, day, month, year, serviceprovider, homeowner, service); booking.setStatus(status); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/FindServiceProvider.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/FindServiceProvider.java index 1f526c7..717d6f7 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/FindServiceProvider.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/FindServiceProvider.java @@ -3,9 +3,11 @@ package com.uottawa.olympus.olympusservices; import android.app.DatePickerDialog; import android.app.TimePickerDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; @@ -13,8 +15,10 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; +import android.widget.ListView; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.RatingBar; @@ -78,6 +82,18 @@ public class FindServiceProvider extends AppCompatActivity { startActivity(intent); finish(); } + + public void Reset(View view){ + + + //clears recycler view + String[][] empty = {}; + mAdapter = new MyAdapter(empty, this); + mRecyclerView.setAdapter(mAdapter); + mAdapter.notifyDataSetChanged(); + + + } public void Search(View view){ MaterialSpinner spinner = findViewById(R.id.ServicesInput); Button button = findViewById(R.id.Start); @@ -320,6 +336,7 @@ public class FindServiceProvider extends AppCompatActivity { String[] serviceprovider = serviceProviders[position]; holder.name.setText(serviceprovider[1]+" "+serviceprovider[2]); holder.rate.setText(""+serviceprovider[3]); + holder.username.setText(serviceprovider[0]); @@ -336,18 +353,93 @@ public class FindServiceProvider extends AppCompatActivity { TextView name; TextView rate; + TextView username; public ProviderHolder(View row){ super(row); name = row.findViewById(R.id.Name); rate = row.findViewById(R.id.Rate); + username = row.findViewById(R.id.Username); row.setOnClickListener(this); } @Override public void onClick(View view) { - TextView nameview = (TextView)view.findViewById(R.id.Name); - String name = nameview.getText().toString(); - makeBooking(name); + TextView nameview = (TextView)view.findViewById(R.id.Username); + final String name = nameview.getText().toString(); + + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(FindServiceProvider.this); + + + alertDialogBuilder.setView(R.layout.sp_info_item); + + + alertDialogBuilder.setPositiveButton("Make Booking", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + makeBooking(name); + } + }); + + alertDialogBuilder.setNegativeButton("Nevermind", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + ServiceProvider sp = (ServiceProvider)dbHelper.findUserByUsername(name); + TextView spname = alertDialog.findViewById(R.id.NameName); + spname.setText(sp.getFirstname()+" "+sp.getLastname()); + + TextView company = alertDialog.findViewById(R.id.CompanyName); + company.setText(sp.getCompanyname()); + + TextView address = alertDialog.findViewById(R.id.AddressName); + address.setText(sp.getAddress()); + + TextView phone = alertDialog.findViewById(R.id.PhoneNumberName); + phone.setText(sp.getPhonenumber()); + + TextView licensed = alertDialog.findViewById(R.id.LicensedName); + if(sp.isLicensed()){ + licensed.setText("Yes"); + } + else{ + licensed.setText("No"); + } + TextView description = alertDialog.findViewById(R.id.DescriptionName); + description.setText(sp.getDescription()); + + TextView rating = alertDialog.findViewById(R.id.AverageRatingName); + MaterialSpinner spinner = findViewById(R.id.ServicesInput); + rating.setText(""+dbHelper.getAverageRating(name, spinner.getText().toString())); + + TextView ratingtext = alertDialog.findViewById(R.id.AverageRating); + ratingtext.setText("Rating for " +spinner.getText().toString()); + + //actual data + List randc = dbHelper.getAllRatingsAndComments(name,spinner.getText().toString()); + String[] ratings = new String[randc.size()]; + for(int i=0; i(FindServiceProvider.this, R.layout.simple_list_item_1_customized, ratings); + + ListView listView = (ListView) alertDialog.findViewById(R.id.RatingList); + listView.setAdapter(adapter); + + + } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MakeBooking.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MakeBooking.java index b75780f..5c51195 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MakeBooking.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MakeBooking.java @@ -81,17 +81,21 @@ public class MakeBooking extends AppCompatActivity { else{ if (starth + +