From 5faed3fd4a8fa45b83cccd2528a19db27d9c1e0f Mon Sep 17 00:00:00 2001 From: IvanaE Date: Mon, 26 Nov 2018 21:09:54 -0500 Subject: [PATCH] new ui for del 4 --- .../.idea/caches/build_file_checksums.ser | Bin 537 -> 537 bytes .../olympus/olympusservices/Bookings.java | 142 +++++++++++++--- .../olympus/olympusservices/DBHelper.java | 2 +- .../olympusservices/FindServiceProvider.java | 114 +++++++++---- .../olympusservices/HomeOwnerEditProfile.java | 2 +- .../olympus/olympusservices/MakeBooking.java | 61 ++++++- .../ServiceProviderWelcome.java | 2 +- .../src/main/res/drawable/customborder2.xml | 2 +- .../layout/activity_find_service_provider.xml | 102 +++++++++--- .../src/main/res/layout/booking_list_item.xml | 156 ++++++++++-------- .../app/src/main/res/layout/rating_item.xml | 77 +++++++++ 11 files changed, 502 insertions(+), 158 deletions(-) create mode 100644 OlympusServices/app/src/main/res/layout/rating_item.xml diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 53e0a9f4e570efb6483043b3371ca6ac679f9d5b..66d481e50942458fe6b32ac43428c079c4495dce 100644 GIT binary patch delta 60 zcmV-C0K@;81epYom;_LQMPHGeiIZvpa3LZ7bRrr+^B Sb6iPwVQyiQGyyh~>;Wye0~S;O delta 66 zcmV-I0KNa21epYom;^U?^z4zGi4Q14I$TwAWpZ;|VqtW3Xp^=9Hj^a*a1*WPSOtKy Y?=A2okcKFiw>@+K5tF|G8 providers = getAll("SELECT " + TABLE_SERVICEPROVIDERS + "." + COLUMN_SERVICEPROVIDERNAME + ", " + TABLE_LOGIN + "." + COLUMN_FIRSTNAME + ", " + TABLE_LOGIN + "." + COLUMN_LASTNAME + ", " - + TABLE_SERVICEPROVIDERS + "." + COLUMN_AVERAGERATING + ", " + + TABLE_SERVICEPROVIDERS + "." + COLUMN_AVERAGERATING + " " + " FROM " + TABLE_SERVICEPROVIDERS + " JOIN " + TABLE_LOGIN + " ON " + TABLE_SERVICEPROVIDERS + "." + COLUMN_SERVICEPROVIDERNAME + " = " + TABLE_LOGIN + "." + COLUMN_USERNAME 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 d29783f..1f526c7 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 @@ -15,6 +15,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.DatePicker; +import android.widget.RadioButton; +import android.widget.RadioGroup; import android.widget.RatingBar; import android.widget.TextView; import android.widget.TimePicker; @@ -44,8 +46,6 @@ public class FindServiceProvider extends AppCompatActivity { Bundle bundle = getIntent().getExtras(); username = bundle.getString("username"); - MaterialSpinner spinner = findViewById(R.id.RatingInput); - spinner.setItems("",1, 2, 3, 4, 5); dbHelper = new DBHelper(this); MaterialSpinner spinner2 = findViewById(R.id.ServicesInput); @@ -60,19 +60,13 @@ public class FindServiceProvider extends AppCompatActivity { spinner2.setItems(services); - //iffy code, update once we can pull the actual service providers - ServiceProvider provider = (ServiceProvider)dbHelper.findUserByUsername("testing"); - ServiceProvider[] providerslist = {provider}; - //iffy code ends here - mRecyclerView = (RecyclerView) findViewById(R.id.ServiceProviders); mLayoutManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mLayoutManager); - mAdapter = new MyAdapter(providerslist, this); - mRecyclerView.setAdapter(mAdapter); + // } @@ -89,31 +83,81 @@ public class FindServiceProvider extends AppCompatActivity { Button button = findViewById(R.id.Start); Button button2 = findViewById(R.id.End); Button button3 = findViewById(R.id.Date); - MaterialSpinner spinner2 = findViewById(R.id.RatingInput); + RadioGroup ratingselect = findViewById(R.id.RatingSelect); + int selectedId = ratingselect.getCheckedRadioButtonId(); + RadioButton ratingpicked; String service = spinner.getText().toString(); - int start; - int end; + String start; + String end; String date; - if(button.getText().toString()!="Start" && button.getText().toString()!="End" - && button3.getText().toString()!="Date"){ - start = Integer.parseInt(button.getText().toString()); - end = Integer.parseInt(button2.getText().toString()); + double rating; + List providers; + if(!button.getText().toString().equals("Start") && !button2.getText().toString().equals("End") + && !button3.getText().toString().equals("Date")){ + System.out.println(button.getText().toString()+":"+button2.getText().toString()+":"+button3.getText().toString()); + start = button.getText().toString(); + end = button2.getText().toString(); date = button3.getText().toString(); + + String[] dates = date.split("/"); + int month = Integer.parseInt(dates[0].replaceAll("\\s+","")); + int day = Integer.parseInt(dates[1].replaceAll("\\s+","")); + int year = Integer.parseInt(dates[2].replaceAll("\\s+","")); + + String[] starttimes = start.split(":"); + int starth = Integer.parseInt(starttimes[0].replaceAll("\\s+","")); + int startmin = Integer.parseInt(starttimes[1].replaceAll("\\s+","")); + + String[] endtimes = end.split(":"); + int endh = Integer.parseInt(endtimes[0].replaceAll("\\s+","")); + int endmin = Integer.parseInt(endtimes[1].replaceAll("\\s+","")); + + int[] times = {starth, startmin, endh, endmin}; + if(selectedId!=-1 && validateTime(times)){ + ratingpicked = (RadioButton) findViewById(selectedId); + rating = Double.parseDouble(ratingpicked.getText().toString()); + providers = dbHelper.getProvidersByTimeAndRating(service, rating, year, month, day, + starth, startmin, endh, endmin); + } + else if(validateTime(times)){ + providers = dbHelper.getProvidersByTime(service, year, month, day, + starth, startmin, endh, endmin); + } + else if(selectedId!=-1){ + Toast.makeText(this, "Times are invalid, only searching by service and rating"+starth+";"+startmin+","+endh+";"+endmin, Toast.LENGTH_SHORT).show(); + ratingpicked = (RadioButton) findViewById(selectedId); + rating = Double.parseDouble(ratingpicked.getText().toString()); + providers = dbHelper.getProvidersAboveRating(service, rating); + + } + else{ + Toast.makeText(this, "Times are invalid, only searching by service", Toast.LENGTH_SHORT).show(); + providers = dbHelper.getAllProvidersByService(service); + + } } else{ - //figure out with dbhelper + if(selectedId!=-1){ + ratingpicked = (RadioButton) findViewById(selectedId); + rating = Double.parseDouble(ratingpicked.getText().toString()); + providers = dbHelper.getProvidersAboveRating(service, rating); + } + else{ + providers = dbHelper.getAllProvidersByService(service); + } } - int rating; - if(spinner2.getText().toString()!=""){ - rating = Integer.parseInt(spinner2.getText().toString()); + //update recycler view + String[][] providerslist = new String[providers.size()][]; + for(int i=0; i { - private ServiceProvider[] serviceProviders; + private String[][] serviceProviders; private Context context; // Provide a reference to the views for each data item @@ -258,7 +300,7 @@ public class FindServiceProvider extends AppCompatActivity { // you provide access to all the views for a data item in a view holder // Provide a suitable constructor (depends on the kind of dataset) - public MyAdapter(ServiceProvider[] serviceProviders, Context context) { + public MyAdapter(String[][] serviceProviders, Context context) { this.serviceProviders = serviceProviders; } @@ -275,10 +317,10 @@ public class FindServiceProvider extends AppCompatActivity { // Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(ProviderHolder holder, int position) { - ServiceProvider serviceprovider = serviceProviders[position]; - holder.name.setText(serviceprovider.getFirstname()+" "+serviceprovider.getLastname()); - holder.rate.setText("5"); - //serviceprovider.getRating() + String[] serviceprovider = serviceProviders[position]; + holder.name.setText(serviceprovider[1]+" "+serviceprovider[2]); + holder.rate.setText(""+serviceprovider[3]); + diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java index 2819c18..ae8cc8a 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java @@ -39,7 +39,7 @@ public class HomeOwnerEditProfile extends AppCompatActivity { */ @Override public void onBackPressed(){ - Intent intent = new Intent(getApplicationContext(),ServiceProviderWelcome.class); + Intent intent = new Intent(getApplicationContext(),Welcome.class); intent.putExtra("username", username); startActivity(intent); finish(); 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 2873abe..b75780f 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 @@ -10,8 +10,11 @@ import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; +import android.widget.Toast; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; public class MakeBooking extends AppCompatActivity { String homeowner; @@ -49,7 +52,63 @@ public class MakeBooking extends AppCompatActivity { } public void Book(View view){ - // + Button button = findViewById(R.id.Start); + Button button2 = findViewById(R.id.End); + Button button3 = findViewById(R.id.Date); + + if(!button.getText().toString().equals("Start") && !button2.getText().toString().equals("End") + && !button3.getText().toString().equals("Date")){ + String[] dates = button3.getText().toString().split("/"); + int month = Integer.parseInt(dates[0].replaceAll("\\s+","")); + int day = Integer.parseInt(dates[1].replaceAll("\\s+","")); + int year = Integer.parseInt(dates[2].replaceAll("\\s+","")); + + String[] starttimes = button.getText().toString().split(":"); + int starth = Integer.parseInt(starttimes[0].replaceAll("\\s+","")); + int startmin = Integer.parseInt(starttimes[1].replaceAll("\\s+","")); + + String[] endtimes = button2.getText().toString().split(":"); + int endh = Integer.parseInt(endtimes[0].replaceAll("\\s+","")); + int endmin = Integer.parseInt(endtimes[1].replaceAll("\\s+","")); + + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date selecteddate = sdf.parse(dates[2].replaceAll("\\s+","") + "-" + dates[0].replaceAll("\\s+","") + "-" + dates[1].replaceAll("\\s+","")); + if(selecteddate.compareTo(date)<0){ + Toast.makeText(this, "Date must be a future date", Toast.LENGTH_SHORT).show(); + } + else{ + if (starth - + \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml b/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml index 9bd9a8d..a8097c3 100644 --- a/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml +++ b/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml @@ -38,67 +38,123 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" + android:gravity="start" + android:layout_gravity="start" >