From 267111fb908a9b5d4fe28cd222785e4830260c62 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 26 Dec 2018 20:29:32 +0200 Subject: [PATCH] Init RestaurantActivity --- .../flavoursWithoutBorders/app/build.gradle | 1 + .../activities/main/MainActivity.java | 10 +- .../flavours/activities/main/MainAdapter.java | 16 +- .../restaurant/AddRestaurantActivity.java | 189 +++++++++++++++++- .../restaurant/RestaurantActivity.java | 119 +++++++++++ .../restaurant/RestaurantAdapter.java | 70 +++++++ .../fragments/RestaurantListFragment.java | 42 ++++ .../fragments/RestaurantMapFragment.java | 90 +++++++++ .../databases/flavours/base/BaseActivity.java | 4 +- .../auth/databases/flavours/model/Rating.java | 39 ++++ .../databases/flavours/model/Restaurant.java | 57 +++++- .../res/layout/activity_add_restaurant.xml | 61 ++++++ .../app/src/main/res/layout/activity_main.xml | 2 +- .../res/layout/activity_main_list_row.xml | 1 + .../main/res/layout/activity_restaurant.xml | 64 +++++- .../layout/activity_restaurant_list_row.xml | 37 ++++ .../res/layout/fragment_restaurant_list.xml | 10 + .../res/layout/fragment_restaurant_map.xml | 5 + .../app/src/main/res/layout/map_view.xml | 8 - ...tollbar_menu.xml => main_toolbar_menu.xml} | 0 .../main/res/menu/restaurant_toolbar_menu.xml | 12 ++ .../activity_add_restaurant_spinner_type.xml | 11 + .../app/src/main/res/values/strings.xml | 15 ++ 23 files changed, 829 insertions(+), 34 deletions(-) create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml delete mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml rename UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/{main_tollbar_menu.xml => main_toolbar_menu.xml} (100%) create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle b/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle index b597ccf..996f3be 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle +++ b/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle @@ -36,6 +36,7 @@ dependencies { implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar' implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.gms:play-services-maps:16.0.0' + implementation 'com.borax12.materialdaterangepicker:library:1.9' } configurations.all { diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java index 51317d3..e011eb7 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java @@ -32,11 +32,13 @@ public class MainActivity extends BaseActivity { setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.main_toolbar); - toolbar.setTitle("Restaurants"); + toolbar.setTitle(getString(R.string.main_toolbar_title)); setSupportActionBar(toolbar); ActionBar actionbar = getSupportActionBar(); - actionbar.setDisplayHomeAsUpEnabled(true); - actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } createDrawer(); @@ -86,7 +88,7 @@ public class MainActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.main_tollbar_menu, menu); + getMenuInflater().inflate(R.menu.main_toolbar_menu, menu); menuMapItem = menu.findItem(R.id.main_toolbar_menu_map); return true; } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java index 1b9e95c..362e802 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java @@ -1,6 +1,7 @@ package gr.auth.databases.flavours.activities.main; import android.content.Context; +import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,8 +9,10 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; import androidx.recyclerview.widget.RecyclerView; import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.activities.restaurant.RestaurantActivity; import gr.auth.databases.flavours.model.Restaurant; public class MainAdapter extends RecyclerView.Adapter { @@ -32,10 +35,17 @@ public class MainAdapter extends RecyclerView.Adapter adapter = ArrayAdapter.createFromResource(this, + R.array.restaurant_type, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spinner.setAdapter(adapter); + spinner.setOnItemSelectedListener(this); + + gMapView = findViewById(R.id.add_restaurant_map); + gMapView.onCreate(savedInstanceState); + gMapView.getMapAsync(this); + + workingHours = findViewById(R.id.add_restaurant_working_hours); + workingHours.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Calendar now = Calendar.getInstance(); + TimePickerDialog tpd; + + String timeSet = workingHours.getText().toString(); + if (!timeSet.isEmpty()) { + int hourStart, minuteStart, hourEnd, minuteEnd; + String[] startEnd = timeSet.split("-"); + + hourStart = Integer.parseInt(startEnd[0].split(":")[0].trim()); + minuteStart = Integer.parseInt(startEnd[0].split(":")[1].trim()); + hourEnd = Integer.parseInt(startEnd[1].split(":")[0].trim()); + minuteEnd = Integer.parseInt(startEnd[1].split(":")[1].trim()); + + tpd = TimePickerDialog.newInstance(AddRestaurantActivity.this, + hourStart, minuteStart, true, hourEnd, minuteEnd); + } else { + tpd = TimePickerDialog.newInstance(AddRestaurantActivity.this, + now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), true); + } + + tpd.show(getFragmentManager(), "Timepickerdialog"); + } + return false; + } + }); + + findViewById(R.id.add_restaurant_add_btn).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (restaurantType == null || restaurantType.isEmpty()) { + Toast.makeText(view.getContext(), "Please select a restaurant type first.", + Toast.LENGTH_SHORT).show(); + return; + } + + /*Log.d("THISSS", restaurantName.getText().toString()); + Log.d("THISSS", restaurantType); + Log.d("THISSS", "" + selectLocationMarker.getPosition().longitude); + Log.d("THISSS", "" + selectLocationMarker.getPosition().latitude); + Log.d("THISSS", workingHours.getText().toString());*/ + } + }); createDrawer(); + drawer.setSelection(-1); } @Override @@ -46,4 +143,84 @@ public class AddRestaurantActivity extends BaseActivity { return super.onOptionsItemSelected(item); } + public void onItemSelected(AdapterView parent, View view, + int pos, long id) { + restaurantType = Restaurant.RestaurantType.getWorkingTypeFromId(pos); + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + } + + @Override + public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int hourOfDayEnd, int minuteEnd) { + String hourString = hourOfDay < 10 ? "0" + hourOfDay : "" + hourOfDay; + String minuteString = minute < 10 ? "0" + minute : "" + minute; + String hourStringEnd = hourOfDayEnd < 10 ? "0" + hourOfDayEnd : "" + hourOfDayEnd; + String minuteStringEnd = minuteEnd < 10 ? "0" + minuteEnd : "" + minuteEnd; + + workingHours.setText(getString(R.string.add_restaurant_working_hours_placeholder, + hourString, minuteString, hourStringEnd, minuteStringEnd)); + } + + @Override + public void onResume() { + super.onResume(); + + if (gMapView != null) { + gMapView.onResume(); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + + if (gMapView != null) { + gMapView.onDestroy(); + } + } + + @Override + public void onStart() { + super.onStart(); + + if (gMapView != null) { + gMapView.onStart(); + } + } + + @Override + public void onStop() { + super.onStop(); + + if (gMapView != null) { + gMapView.onStop(); + } + + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + + if (gMapView != null) { + gMapView.onSaveInstanceState(outState); + } + } + + /** + * Manipulates the map once available. + * This callback is triggered when the map is ready to be used. + * This is where we can add markers or lines, add listeners or move the camera. In this case, + * we just add a marker near Sydney, Australia. + * If Google Play services is not installed on the device, the user will be prompted to install + * it inside the SupportMapFragment. This method will only be triggered once the user has + * installed Google Play services and returned to the app. + */ + @Override + public void onMapReady(GoogleMap googleMap) { + googleMap.addMarker(selectLocationMarker); + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(Thessaloniki, 12.0f)); + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java index 929ff5a..926e5b9 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java @@ -1,15 +1,134 @@ package gr.auth.databases.flavours.activities.restaurant; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantListFragment; +import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantMapFragment; import gr.auth.databases.flavours.base.BaseActivity; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; public class RestaurantActivity extends BaseActivity { + private static final int NUM_PAGES = 2; + + private ViewPager viewPager; + private MenuItem menuMapItem; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_restaurant); + + Toolbar toolbar = findViewById(R.id.restaurant_toolbar); + toolbar.setTitle(getString(R.string.restaurant_toolbar_title)); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } + + createDrawer(); + drawer.setSelection(-1); + + viewPager = findViewById(R.id.restaurant_pager); + viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + public void onPageScrollStateChanged(int state) { + } + + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + } + + public void onPageSelected(int position) { + if (menuMapItem == null) { + return; + } + + if (position == 0) { + menuMapItem.setIcon(R.drawable.ic_map_black_24dp); + } else { + menuMapItem.setIcon(R.drawable.ic_list_black_24dp); + } + } + }); + + findViewById(R.id.restaurant_fab).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class); + startActivity(intent);*/ + } + }); + + PagerAdapter pagerAdapter = new RestaurantPagerAdapter(getSupportFragmentManager()); + viewPager.setAdapter(pagerAdapter); + } + + @Override + public void onBackPressed() { + if (drawer.isDrawerOpen()) { + drawer.closeDrawer(); + } else if (viewPager.getCurrentItem() == 1) { + viewPager.setCurrentItem(0); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.restaurant_toolbar_menu, menu); + menuMapItem = menu.findItem(R.id.restaurant_toolbar_menu_map); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == R.id.main_toolbar_menu_map) { + if (viewPager.getCurrentItem() == 0) { + viewPager.setCurrentItem(1); + } else if (viewPager.getCurrentItem() == 1) { + viewPager.setCurrentItem(0); + } + return true; + } else if (id == android.R.id.home) { + drawer.openDrawer(); + return true; + } + + return super.onOptionsItemSelected(item); + } + + private class RestaurantPagerAdapter extends FragmentStatePagerAdapter { + RestaurantPagerAdapter(FragmentManager fm) { + super(fm); + } + + @NonNull + @Override + public Fragment getItem(int position) { + if (position == 0) { + return new RestaurantListFragment(); + } else { + return new RestaurantMapFragment(); + } + } + + @Override + public int getCount() { + return NUM_PAGES; + } } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java new file mode 100644 index 0000000..47dacd4 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java @@ -0,0 +1,70 @@ +package gr.auth.databases.flavours.activities.restaurant; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.model.Rating; + +public class RestaurantAdapter extends RecyclerView.Adapter { + private Context context; + private Rating[] ratings; + + public RestaurantAdapter(Context context, Rating[] ratings) { + this.context = context; + this.ratings = ratings; + } + + @NonNull + @Override + public RestaurantAdapter.RatingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, + int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_restaurant_list_row, + parent, false); + return new RatingViewHolder(v); + } + + @Override + public void onBindViewHolder(@NonNull RatingViewHolder holder, int position) { + Log.d("THISSSS", "" + position + ratings[position].getUsername()); + holder.username.setText(ratings[position].getUsername()); + holder.date.setText(ratings[position].getDate()); + + holder.grade.setText(context.getString(R.string.restaurant_row_grade_placeholder, + ratings[position].getGrade())); + + if (ratings[position].getAccessibility() != null) { + holder.accessibility.setVisibility(View.VISIBLE); + holder.accessibility.setText(context.getString(R.string.restaurant_row_accessibility_placeholder, + ratings[position].getAccessibility().toString())); + } else { + holder.accessibility.setVisibility(View.GONE); + } + + holder.text.setText(ratings[position].getText()); + } + + @Override + public int getItemCount() { + return ratings.length; + } + + static class RatingViewHolder extends RecyclerView.ViewHolder { + TextView username, date, grade, accessibility, text; + + RatingViewHolder(View v) { + super(v); + username = v.findViewById(R.id.restaurant_row_username); + date = v.findViewById(R.id.restaurant_row_date); + grade = v.findViewById(R.id.restaurant_row_grade); + accessibility = v.findViewById(R.id.restaurant_row_accessibility); + text = v.findViewById(R.id.restaurant_row_text); + } + } +} \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java new file mode 100644 index 0000000..e681ffd --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java @@ -0,0 +1,42 @@ +package gr.auth.databases.flavours.activities.restaurant.fragments; + + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.activities.restaurant.RestaurantAdapter; +import gr.auth.databases.flavours.model.Rating; + +public class RestaurantListFragment extends Fragment { + private Rating[] ratings = new Rating[7]; + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_restaurant_list, container, false); + + RecyclerView recyclerView = rootView.findViewById(R.id.restaurant_recycler); + recyclerView.setHasFixedSize(true); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + recyclerView.setLayoutManager(layoutManager); + + ratings[0] = new Rating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", Rating.Accessibility.MODERATE); + ratings[1] = new Rating(5, "Ανύπαρκτος", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", Rating.Accessibility.EASY); + ratings[2] = new Rating(4, "Γαρδένιος ο Stoner", "-", "2018-06-08", Rating.Accessibility.EASY); + ratings[3] = new Rating(4, "Μαγκούστα", "Μου άρεσε.", "2018-06-08", Rating.Accessibility.MODERATE); + ratings[4] = new Rating(5, "Νταλίκας", "Τέλειο.", "2018-06-08", Rating.Accessibility.EASY); + ratings[5] = new Rating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null); + ratings[6] = new Rating(4, "eddie lives inside you", "-", "2018-06-08", Rating.Accessibility.MODERATE); + + RestaurantAdapter restaurantAdapter = new RestaurantAdapter(getContext(), ratings); + recyclerView.setAdapter(restaurantAdapter); + + return rootView; + } +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java new file mode 100644 index 0000000..d6acb57 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java @@ -0,0 +1,90 @@ +package gr.auth.databases.flavours.activities.restaurant.fragments; + + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapView; +import com.google.android.gms.maps.OnMapReadyCallback; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import gr.auth.databases.flavours.R; + +public class RestaurantMapFragment extends Fragment implements OnMapReadyCallback { + private MapView gMapView = null; + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_restaurant_map, container, false); + + gMapView = rootView.findViewById(R.id.restaurant_map); + gMapView.getMapAsync(this); + gMapView.onCreate(getArguments()); + + return rootView; + } + + @Override + public void onResume() { + super.onResume(); + + if (gMapView != null) { + gMapView.onResume(); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + + if (gMapView != null) { + gMapView.onDestroy(); + } + } + + @Override + public void onStart() { + super.onStart(); + + if (gMapView != null) { + gMapView.onStart(); + } + } + + @Override + public void onStop() { + super.onStop(); + + if (gMapView != null) { + gMapView.onStop(); + } + + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + + if (gMapView != null) { + gMapView.onSaveInstanceState(outState); + } + } + + /** + * Manipulates the map once available. + * This callback is triggered when the map is ready to be used. + * This is where we can add markers or lines, add listeners or move the camera. In this case, + * we just add a marker near Sydney, Australia. + * If Google Play services is not installed on the device, the user will be prompted to install + * it inside the SupportMapFragment. This method will only be triggered once the user has + * installed Google Play services and returned to the app. + */ + @Override + public void onMapReady(GoogleMap googleMap) { + //googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(grill15, 12.0f)); + } +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java index da83e19..7c567b0 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java @@ -201,8 +201,8 @@ public abstract class BaseActivity extends AppCompatActivity { drawerBuilder.addDrawerItems(homeItem, loginLogoutItem); drawer = drawerBuilder.build(); - if (!isMainActivity) - drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false); + /*if (!isMainActivity) + drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);*/ drawer.setOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() { @Override diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java new file mode 100644 index 0000000..ba11aa3 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java @@ -0,0 +1,39 @@ +package gr.auth.databases.flavours.model; + +public class Rating { + public enum Accessibility { + EASY, MODERATE, HARD + } + + private int grade; + private String username, text, date; + private Accessibility accessibility; + + public Rating(int grade, String username, String text, String date, Accessibility accessibility) { + this.grade = grade; + this.username = username; + this.text = text; + this.date = date; + this.accessibility = accessibility; + } + + public int getGrade() { + return grade; + } + + public String getUsername() { + return username; + } + + public String getText() { + return text; + } + + public String getDate() { + return date; + } + + public Accessibility getAccessibility() { + return accessibility; + } +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java index 2706c47..00b0bf6 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java @@ -1,11 +1,66 @@ package gr.auth.databases.flavours.model; +import androidx.annotation.Nullable; + public class Restaurant { + public enum RestaurantType { + CAFETERIA(0), PUB(1), BAR(2), RESTAURANT(3), FAST_FOOD(4), ETHNIC(5), UNSUPPORTED(-1); + + private int id; + + RestaurantType(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + @Nullable + public static String getWorkingTypeFromId(int id) { + switch (id) { + case 0: + return "Cafeteria"; + case 1: + return "Pub"; + case 2: + return "Bar"; + case 3: + return "Restaurant"; + case 4: + return "Fast Food"; + case 5: + return "Ethnic"; + default: + return null; + } + } + + public static RestaurantType getEnumTypeFromId(int id) { + switch (id) { + case 0: + return CAFETERIA; + case 1: + return PUB; + case 2: + return BAR; + case 3: + return RESTAURANT; + case 4: + return FAST_FOOD; + case 5: + return ETHNIC; + default: + return UNSUPPORTED; + } + } + } + private final String name, type, openingTime, closingTime; public Restaurant(String name, String type, String openingTime, String closingTime) { this.name = name; - this.type= type; + this.type = type; this.openingTime = openingTime; this.closingTime = closingTime; } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml index e4a64de..c914ec8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml @@ -1,6 +1,7 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml index 4e6e36e..d5fdbb9 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml @@ -35,6 +35,6 @@ android:layout_gravity="bottom|end" android:layout_margin="16dp" android:src="@drawable/ic_add_white_24dp" - app:fabSize="mini" + app:fabSize="normal" app:layout_behavior="gr.auth.databases.flavours.utils.ScrollAwareFABBehavior" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml index 055c231..6cc4bd1 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml @@ -1,6 +1,7 @@ - + app:popupTheme="@style/Theme.AppCompat.Light" + app:title="@string/restaurant_toolbar_title" /> - + + android:layout_height="match_parent" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:orientation="horizontal" + app:layout_collapseMode="parallax"> + + + android:id="@+id/add_restaurant_type" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:layout_weight="1" + android:gravity="end" + android:text="@string/restaurant_type" + android:textColor="@color/colorAccent" + app:layout_scrollFlags="enterAlways" /> - + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml new file mode 100644 index 0000000..d8717d9 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml new file mode 100644 index 0000000..1965e4b --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml new file mode 100644 index 0000000..53586fe --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml deleted file mode 100644 index d29d3e7..0000000 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml +++ /dev/null @@ -1,8 +0,0 @@ - - \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_tollbar_menu.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_toolbar_menu.xml similarity index 100% rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_tollbar_menu.xml rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_toolbar_menu.xml diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml new file mode 100644 index 0000000..ceedeec --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml new file mode 100644 index 0000000..7bb8aaa --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml @@ -0,0 +1,11 @@ + + + + Cafeteria + Pub + Bar + Restaurant + Fast Food + Ethnic + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml index 62caf88..22aa61c 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml @@ -25,6 +25,7 @@ Main + Restaurants Filter results Show in map @@ -40,4 +41,18 @@ Restaurant type Restaurant working hours %1$s - %2$s + + + Restaurant Name + Working hours + Restaurant type + Grade = %1$d/5 + Accessibility = %1$s + + + Add Restaurant + Restaurant\'s name + Working hours + %1$s:%2$s - %3$s:%4$s + ADD RESTAURANT