diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index e4933e6..3825acd 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/main/AndroidManifest.xml b/OlympusServices/app/src/main/AndroidManifest.xml index d915ea2..a42982d 100644 --- a/OlympusServices/app/src/main/AndroidManifest.xml +++ b/OlympusServices/app/src/main/AndroidManifest.xml @@ -72,7 +72,8 @@ - + + \ No newline at end of file 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 aadd2ca..895f2d0 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 @@ -8,6 +8,7 @@ import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -29,6 +30,13 @@ public class FindServiceProvider extends AppCompatActivity { String username; DBHelper dbHelper; + //field for RecyclerView + private RecyclerView mRecyclerView; + //field for adapter of Recycler view + private RecyclerView.Adapter mAdapter; + //field for layout manager of Recyler view. + private RecyclerView.LayoutManager mLayoutManager; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -37,7 +45,7 @@ public class FindServiceProvider extends AppCompatActivity { username = bundle.getString("username"); MaterialSpinner spinner = findViewById(R.id.RatingInput); - spinner.setItems(1, 2, 3, 4, 5); + spinner.setItems("",1, 2, 3, 4, 5); dbHelper = new DBHelper(this); MaterialSpinner spinner2 = findViewById(R.id.ServicesInput); @@ -51,6 +59,21 @@ public class FindServiceProvider extends AppCompatActivity { } spinner2.setItems(services); + + //iffy code + ServiceProvider provider = (ServiceProvider)dbHelper.findUserByUsername("testing"); + ServiceProvider[] providerslist = {provider}; + + mRecyclerView = (RecyclerView) findViewById(R.id.ServiceProviders); + + + mLayoutManager = new LinearLayoutManager(this); + mRecyclerView.setLayoutManager(mLayoutManager); + + mAdapter = new MyAdapter(providerslist, this); + mRecyclerView.setAdapter(mAdapter); + // + } @Override @@ -61,6 +84,54 @@ public class FindServiceProvider extends AppCompatActivity { finish(); } public void Search(View view){ + MaterialSpinner spinner = findViewById(R.id.ServicesInput); + Button button = findViewById(R.id.Start); + Button button2 = findViewById(R.id.End); + Button button3 = findViewById(R.id.Date); + MaterialSpinner spinner2 = findViewById(R.id.RatingInput); + + String service = spinner.getText().toString(); + int start; + int 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()); + date = button3.getText().toString(); + } + else{ + //figure out with dbhelper + } + + int rating; + if(spinner2.getText().toString()!=""){ + rating = Integer.parseInt(spinner2.getText().toString()); + } + else{ + //figure out with dbhelper + } + //do search here + //update recylcler view + + } + + public void makeBooking(String serviceprovider){ + MaterialSpinner spinner = findViewById(R.id.ServicesInput); + String service = spinner.getText().toString(); + Intent intent = new Intent(getApplicationContext(),MakeBooking.class); + intent.putExtra("homeowner", username); + intent.putExtra("serviceprovider", serviceprovider); + intent.putExtra("service", service); + startActivity(intent); + finish(); + + + + + + + } @@ -76,7 +147,21 @@ public class FindServiceProvider extends AppCompatActivity { public void onDateSet(DatePicker view, int year, int month, int day) { Calendar newDate = Calendar.getInstance(); newDate.set(year, month, day); - button.setText(month + " / " + (day) + " / " + String daystring; + String monthstring; + if((""+day).length()==1){ + daystring = "0"+day; + } + else{ + daystring = day+""; + } + if((""+month).length()==1){ + monthstring = "0"+month; + } + else{ + monthstring = ""+month; + } + button.setText(monthstring + " / " + daystring + " / " + year); } @@ -190,7 +275,8 @@ public class FindServiceProvider extends AppCompatActivity { public void onBindViewHolder(ProviderHolder holder, int position) { ServiceProvider serviceprovider = serviceProviders[position]; holder.name.setText(serviceprovider.getFirstname()+" "+serviceprovider.getLastname()); - holder.rate.setText(String.format("$%,.2f", serviceprovider.getRating())); + holder.rate.setText("5"); + //serviceprovider.getRating() @@ -217,6 +303,7 @@ public class FindServiceProvider extends AppCompatActivity { public void onClick(View view) { TextView nameview = (TextView)view.findViewById(R.id.Name); String name = nameview.getText().toString(); + makeBooking(name); } 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 new file mode 100644 index 0000000..ba73427 --- /dev/null +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MakeBooking.java @@ -0,0 +1,166 @@ +package com.uottawa.olympus.olympusservices; + +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.TextView; +import android.widget.TimePicker; + +import java.util.Calendar; + +public class MakeBooking extends AppCompatActivity { + String homeowner; + String serviceprovider; + String service; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_make_booking); + Bundle bundle = getIntent().getExtras(); + homeowner = bundle.getString("homeowner"); + serviceprovider = bundle.getString("serviceprovider"); + service = bundle.getString("service"); + + TextView homeo = findViewById(R.id.HomeOwner); + TextView servicep = findViewById(R.id.ServiceProvider); + TextView serv = findViewById(R.id.Service); + + homeo.setText("Home Owner: \n"+homeowner); + servicep.setText("ServiceProvider: \n"+serviceprovider); + serv.setText("Service: \n"+service); + + } + + @Override + public void onBackPressed(){ + Intent intent = new Intent(getApplicationContext(),Welcome.class); + intent.putExtra("username", homeowner); + startActivity(intent); + finish(); + } + public void Cancel(View view){ + onBackPressed(); + } + + public void Book(View view){ + // + } + + public void onClickDate(View view){ + + final Button button = (Button)view; + final Calendar c = Calendar.getInstance(); + + DatePickerDialog datePickerDialog = new DatePickerDialog(this, + new DatePickerDialog.OnDateSetListener() { + + @Override + public void onDateSet(DatePicker view, int year, int month, int day) { + Calendar newDate = Calendar.getInstance(); + newDate.set(year, month, day); + String daystring; + String monthstring; + if((""+day).length()==1){ + daystring = "0"+day; + } + else{ + daystring = day+""; + } + if((""+month).length()==1){ + monthstring = "0"+month; + } + else{ + monthstring = ""+month; + } + button.setText(monthstring + " / " + daystring + " / " + + year); + } + + }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); + datePickerDialog.show(); + + } + + + public void onClickTime(View view){ + final Calendar c = Calendar.getInstance(); + int hour = c.get(Calendar.HOUR_OF_DAY); + int minute = c.get(Calendar.MINUTE); + final Button button = (Button)view; + + // Launch Time Picker Dialog + TimePickerDialog timePickerDialog = new TimePickerDialog(this, + new TimePickerDialog.OnTimeSetListener() { + + @Override + public void onTimeSet(TimePicker view, int hourOfDay, + int minute) { + String time = ""; + + button.setText(formatTime(hourOfDay,minute)); + //set availibility for service provider and check start time is less than finish + } + + }, hour, minute, false); + timePickerDialog.show(); + + } + + private String formatTime(int hours, int minutes){ + String time = ""; + if(hours<10){ + time = time+"0"+hours+":"; + }else{ + time = time+hours+":"; + } + if (minutes<10){ + time = time+"0"+minutes; + } + else { + time = time+minutes; + } + return time; + } + + private int[] parseTime(String startTime, String endTime){ + int[] times = new int[4]; + if(startTime.equals("START")){ + times[0]=0; + times[1]=0; + }else{ + times[0] = Integer.parseInt(startTime.substring(0,2)); + times[1] = Integer.parseInt(startTime.substring(3)); + } + if(endTime.equals("END")){ + times[2]=0; + times[3]=0; + }else{ + times[2] = Integer.parseInt(endTime.substring(0,2)); + times[3] = Integer.parseInt(endTime.substring(3)); + } + return times; + } + + private boolean validateTime(int[] time){ + if(time[0]==0&&time[1]==0&&time[2]==0&&time[3]==0){ + return true; + } + if(time[2]>time[0]){ + return true; + }else{ + if(time[2]==time[0]&&time[3]>time[1]){ + return true; + }else{ + return false; + } + } + } + + +} diff --git a/OlympusServices/app/src/main/res/layout/activity_make_booking.xml b/OlympusServices/app/src/main/res/layout/activity_make_booking.xml new file mode 100644 index 0000000..79c7e1e --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/activity_make_booking.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + +