diff --git a/Deliverable3.zip b/Deliverable3.zip index 199d0fd..8124e2f 100644 Binary files a/Deliverable3.zip and b/Deliverable3.zip differ diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 7c3c27a..53e0a9f 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/.idea/misc.xml b/OlympusServices/.idea/misc.xml index dc34569..cc51e58 100644 --- a/OlympusServices/.idea/misc.xml +++ b/OlympusServices/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/OlympusServices/app/src/main/AndroidManifest.xml b/OlympusServices/app/src/main/AndroidManifest.xml index 37d14c4..425603f 100644 --- a/OlympusServices/app/src/main/AndroidManifest.xml +++ b/OlympusServices/app/src/main/AndroidManifest.xml @@ -70,8 +70,7 @@ android:label="Availabilities" android:screenOrientation="portrait" /> - - + 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 new file mode 100644 index 0000000..f0a94d0 --- /dev/null +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java @@ -0,0 +1,184 @@ +package com.uottawa.olympus.olympusservices; + +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.support.annotation.NonNull; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +public class Bookings extends AppCompatActivity { + + //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; + + String username; + DBHelper dbhelper; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_bookings); + Bundle bundle = getIntent().getExtras(); + username = bundle.getString("username"); + dbhelper = new DBHelper(this); + + /* + Booking[] bookings; + //get bookings here + mRecyclerView = (RecyclerView) findViewById(R.id.Bookings); + mLayoutManager = new LinearLayoutManager(this); + mRecyclerView.setLayoutManager(mLayoutManager); + mAdapter = new AdminServicesList.MyAdapter(booking, this); + mRecyclerView.setAdapter(mAdapter); + */ + } + + /** + * Override so that previous screen refreshes when pressing the + * back button on this activity of the app. + * + */ + @Override + public void onBackPressed(){ + Intent intent = new Intent(getApplicationContext(),Welcome.class); + intent.putExtra("username", username); + startActivity(intent); + finish(); + } + + + public class MyAdapter extends RecyclerView.Adapter { + + private Booking[] bookings; + private Context context; + + // Provide a reference to the views for each data item + // Complex data items may need more than one view per item, and + // 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(Booking[] bookings, Context context) { + this.bookings = bookings; + } + + // Create new views (invoked by the layout manager) + @NonNull + @Override + public BookingHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.booking_list_item, parent, false); + BookingHolder vh = new BookingHolder(v); + return vh; + } + + // Replace the contents of a view (invoked by the layout manager) + @Override + public void onBindViewHolder(BookingHolder holder, int position) { + Booking booking = bookings[position]; + //holder.name.setText(booking.getServiceprovider().getFirstname()+" "+booking.getServiceprovider().getLastname()); + + + + } + + // Return the size of your dataset (invoked by the layout manager) + @Override + public int getItemCount() { + return bookings.length; + } + + class BookingHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + + TextView homeowner; + TextView serviceprovider; + TextView date; + TextView start; + TextView end; + TextView status; + + public BookingHolder(View row){ + super(row); + homeowner = row.findViewById(R.id.HomeOwnerName); + serviceprovider = row.findViewById(R.id.ServiceProviderName); + date = row.findViewById(R.id.DateName); + start = row.findViewById(R.id.StartTime); + end = row.findViewById(R.id.EndTime); + status = row.findViewById(R.id.StatusName); + + row.setOnClickListener(this); + } + @Override + public void onClick(View view) { + if(dbhelper.findUserByUsername(username).getRole()=="ServiceProvider"){ + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Bookings.this); + alertDialogBuilder.setMessage("Cancel or Confirm your booking"); + alertDialogBuilder.setPositiveButton("Confirm", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + //confirm booking + Toast.makeText(Bookings.this,"Booking is confirmed",Toast.LENGTH_LONG).show(); + Bookings.this.recreate(); + } + }); + + alertDialogBuilder.setNegativeButton("No", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //delete booking + Toast.makeText(Bookings.this,"Booking is deleted",Toast.LENGTH_LONG).show(); + Bookings.this.recreate(); + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + } + else{ + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Bookings.this); + alertDialogBuilder.setMessage("Are you sure you want to cancel your booking"); + alertDialogBuilder.setPositiveButton("Cancel", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + //cancel booking + Toast.makeText(Bookings.this,"Booking is cancelled",Toast.LENGTH_LONG).show(); + Bookings.this.recreate(); + } + }); + + alertDialogBuilder.setNegativeButton("Nevermind", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + } + }); + + AlertDialog alertDialog = alertDialogBuilder.create(); + alertDialog.show(); + + } + + + } + + + } + + + } +} 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 895f2d0..d29783f 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 @@ -60,9 +60,10 @@ public class FindServiceProvider extends AppCompatActivity { spinner2.setItems(services); - //iffy code + //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); @@ -147,6 +148,7 @@ 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); + month++; String daystring; String monthstring; if((""+day).length()==1){ diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerBookings.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerBookings.java deleted file mode 100644 index 432bc80..0000000 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerBookings.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.uottawa.olympus.olympusservices; - -import android.content.Intent; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - -public class HomeOwnerBookings extends AppCompatActivity { - String username; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_home_owner_bookings); - Bundle bundle = getIntent().getExtras(); - username = bundle.getString("username"); - } - - /** - * Override so that previous screen refreshes when pressing the - * back button on this activity of the app. - * - */ - @Override - public void onBackPressed(){ - 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 ba73427..2873abe 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 @@ -64,6 +64,7 @@ public class MakeBooking extends AppCompatActivity { public void onDateSet(DatePicker view, int year, int month, int day) { Calendar newDate = Calendar.getInstance(); newDate.set(year, month, day); + month++; String daystring; String monthstring; if((""+day).length()==1){ diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderBookings.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderBookings.java deleted file mode 100644 index 8d1ccff..0000000 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderBookings.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.uottawa.olympus.olympusservices; - -import android.content.Intent; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - -public class ServiceProviderBookings extends AppCompatActivity { - String username; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_service_provider_bookings); - Bundle bundle = getIntent().getExtras(); - username = bundle.getString("username"); - } - - /** - * Override so that previous screen refreshes when pressing the - * back button on this activity of the app. - * - */ - @Override - public void onBackPressed(){ - Intent intent = new Intent(getApplicationContext(),ServiceProviderWelcome.class); - intent.putExtra("username", username); - startActivity(intent); - finish(); - } -} diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java index 73a3e8a..7a8c7cb 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java @@ -79,7 +79,7 @@ public class ServiceProviderWelcome extends AppCompatActivity { finish(); } public void SeeBookings(View view){ - Intent intent = new Intent(getApplicationContext(),ServiceProviderBookings.class); + Intent intent = new Intent(getApplicationContext(),Bookings.class); intent.putExtra("username", username); startActivity(intent); finish(); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java index ffe91bb..8ee61e6 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java @@ -61,7 +61,7 @@ public class Welcome extends AppCompatActivity { } public void SeeBookings(View view){ - Intent intent = new Intent(getApplicationContext(),HomeOwnerBookings.class); + Intent intent = new Intent(getApplicationContext(),Bookings.class); intent.putExtra("username", username); startActivity(intent); finish(); diff --git a/OlympusServices/app/src/main/res/drawable/customborder2.xml b/OlympusServices/app/src/main/res/drawable/customborder2.xml new file mode 100644 index 0000000..e26ab52 --- /dev/null +++ b/OlympusServices/app/src/main/res/drawable/customborder2.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/layout/activity_bookings.xml b/OlympusServices/app/src/main/res/layout/activity_bookings.xml new file mode 100644 index 0000000..eb704f7 --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/activity_bookings.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/layout/activity_home_owner_bookings.xml b/OlympusServices/app/src/main/res/layout/activity_home_owner_bookings.xml deleted file mode 100644 index dd7754a..0000000 --- a/OlympusServices/app/src/main/res/layout/activity_home_owner_bookings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/layout/activity_service_provider_bookings.xml b/OlympusServices/app/src/main/res/layout/activity_service_provider_bookings.xml deleted file mode 100644 index 28b14a4..0000000 --- a/OlympusServices/app/src/main/res/layout/activity_service_provider_bookings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/layout/booking_list_item.xml b/OlympusServices/app/src/main/res/layout/booking_list_item.xml new file mode 100644 index 0000000..451922b --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/booking_list_item.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProjectUML.ump b/ProjectUML.ump index 361d4a8..431ba24 100644 --- a/ProjectUML.ump +++ b/ProjectUML.ump @@ -25,6 +25,7 @@ isA UserType; class Admin { isA UserType; + 1 -- * Service creates; } class Service @@ -36,6 +37,22 @@ double rate; +class Booking +{ + int starth; + int startmin; + int endh; + int endmin; + int day; + int month; + int year; + status; +int rating; +* -- 1 HomeOwner; + * -- 1 ServiceProvider; + * -- 1 Service; +} + class UserType { position 475 69 141 109; @@ -54,10 +71,20 @@ class ServiceProvider class Admin { position 490 236 109 41; + position.association Admin__Service 66,41 0,52; + position.association Admin__Service:create 109,28 0,60; } class Service { - position 854 455 112 75; + position 849 474 112 75; position.association Service__ServiceProvider 65,0 65,143; -}//$?[End_of_model]$? \ No newline at end of file +} + +class Booking +{ + position 99 433 178 211; + position.association Booking__HomeOwner 62,0 54,41; + position.association Booking__ServiceProvider 178,50 0,94; + position.association Booking__Service 178,120 0,68; +} \ No newline at end of file diff --git a/README.md b/README.md index 190d550..9e78c1f 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,10 @@ password = admin ServiceProvider account is precreated with username = testing, -password = testing \ No newline at end of file +password = testing + +APK tested on a Sony Xperia XA2, model H3123 + +Build Status +[![CircleCI](https://circleci.com/gh/ebivibe/SEG2105-Olympus/tree/master.svg?style=svg&circle-token=01dbbc3800d7ee80871796675582a67ba7c83604)](https://circleci.com/gh/ebivibe/SEG2105-Olympus/tree/master) + diff --git a/UML Class Diagram.docx b/UML Class Diagram.docx index 5d4af73..70f59d3 100644 Binary files a/UML Class Diagram.docx and b/UML Class Diagram.docx differ diff --git a/~$L Class Diagram.docx b/~$L Class Diagram.docx new file mode 100644 index 0000000..94f7615 Binary files /dev/null and b/~$L Class Diagram.docx differ