Browse Source

Init RestaurantActivity

master
Apostolos Fanakis 6 years ago
parent
commit
267111fb90
  1. 1
      UI/AndroidApp/flavoursWithoutBorders/app/build.gradle
  2. 6
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
  3. 12
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java
  4. 185
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java
  5. 119
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  6. 70
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java
  7. 42
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java
  8. 90
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java
  9. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java
  10. 39
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java
  11. 55
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java
  12. 61
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml
  13. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml
  14. 1
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml
  15. 62
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml
  16. 37
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml
  17. 10
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml
  18. 5
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml
  19. 8
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml
  20. 0
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_toolbar_menu.xml
  21. 12
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml
  22. 11
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml
  23. 15
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml

1
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 {

6
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();
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;
}

12
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<MainAdapter.RestaurantViewHolder> {
@ -32,6 +35,13 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantView
@Override
public void onBindViewHolder(@NonNull RestaurantViewHolder holder, int position) {
holder.card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, RestaurantActivity.class);
context.startActivity(intent);
}
});
holder.name.setText(restaurants[position].getName());
holder.workingHours.setText(context.getString(R.string.main_row_working_hours_placeholder,
restaurants[position].getOpeningTime().substring(0, 5),
@ -69,11 +79,13 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantView
}
static class RestaurantViewHolder extends RecyclerView.ViewHolder {
CardView card;
TextView name, typeText, workingHours;
ImageView typeImage;
RestaurantViewHolder(View v) {
super(v);
card = v.findViewById(R.id.main_row_card);
name = v.findViewById(R.id.main_row_name);
typeText = v.findViewById(R.id.main_row_type_txt);
workingHours = v.findViewById(R.id.main_row_working_hours);

185
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java

@ -1,28 +1,125 @@
package gr.auth.databases.flavours.activities.restaurant;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.borax12.materialdaterangepicker.time.RadialPickerLayout;
import com.borax12.materialdaterangepicker.time.TimePickerDialog;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.Calendar;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.model.Restaurant;
public class AddRestaurantActivity extends BaseActivity {
public class AddRestaurantActivity extends BaseActivity implements AdapterView.OnItemSelectedListener,
TimePickerDialog.OnTimeSetListener, OnMapReadyCallback {
private MapView gMapView = null;
private EditText workingHours;
private String restaurantType;
private LatLng Thessaloniki = new LatLng(40.628477, 22.952040);
private MarkerOptions selectLocationMarker = new MarkerOptions().position(Thessaloniki)
.title("Restaurant location")
.snippet("Please move the marker if needed.")
.draggable(true);
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(R.layout.activity_add_restaurant);
Toolbar toolbar = findViewById(R.id.main_toolbar);
toolbar.setTitle("Add Restaurant");
Toolbar toolbar = findViewById(R.id.add_restaurant_toolbar);
toolbar.setTitle(getString(R.string.add_restaurant_toolbar_title));
setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar();
if (actionbar != null) {
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp);
}
final EditText restaurantName = findViewById(R.id.add_restaurant_name);
Spinner spinner = findViewById(R.id.add_restaurant_type);
ArrayAdapter<CharSequence> 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));
}
}

119
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;
}
}
}

70
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<RestaurantAdapter.RatingViewHolder> {
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);
}
}
}

42
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;
}
}

90
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));
}
}

4
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

39
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;
}
}

55
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java

@ -1,6 +1,61 @@
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) {

61
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
@ -20,4 +21,64 @@
app:popupTheme="@style/Theme.AppCompat.Light" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/add_restaurant_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/add_restaurant_hint_name"
android:importantForAutofill="no"
android:inputType="text"
tools:targetApi="o" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/add_restaurant_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" />
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/add_restaurant_map"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_weight="1" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/add_restaurant_working_hours"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/add_restaurant_hint_working_hours"
android:importantForAutofill="no"
android:inputType="time"
tools:targetApi="o" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/add_restaurant_add_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/add_restaurant_add_btn" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

2
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" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

1
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_row_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"

62
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml

@ -17,21 +17,65 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.AppCompat.Light" />
</com.google.android.material.appbar.AppBarLayout>
app:popupTheme="@style/Theme.AppCompat.Light"
app:title="@string/restaurant_toolbar_title" />
<androidx.core.widget.NestedScrollView
<!--<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/restaurant_collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:orientation="horizontal"
app:layout_collapseMode="parallax">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:id="@+id/add_restaurant_working_hours"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/restaurant_working_hours"
android:textColor="@color/colorAccent"
app:layout_scrollFlags="enterAlways" />
<TextView
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" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<!--</android.support.design.widget.CollapsingToolbarLayout>-->
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/restaurant_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/restaurant_appbar"
app:layout_anchorGravity="bottom|start"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/restaurant_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
app:fabSize="normal"
app:layout_behavior="gr.auth.databases.flavours.utils.ScrollAwareFABBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

37
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant_list_row.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="6dp"
android:orientation="vertical">
<TextView
android:id="@+id/restaurant_row_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:textStyle="bold" />
<TextView
android:id="@+id/restaurant_row_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp" />
<TextView
android:id="@+id/restaurant_row_grade"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/restaurant_row_accessibility"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/restaurant_row_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

10
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/restaurant_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

5
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/restaurant_map"
android:layout_width="match_parent"
android:layout_height="match_parent" />

8
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/map_view.xml

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.main.MainActivity" />

0
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_tollbar_menu.xml → UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/main_toolbar_menu.xml

12
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/menu/restaurant_toolbar_menu.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activities.main.MainActivity">
<item
android:id="@+id/restaurant_toolbar_menu_map"
android:icon="@drawable/ic_map_black_24dp"
android:orderInCategory="200"
android:title="@string/main_toolbar_menu_map"
app:showAsAction="ifRoom" />
</menu>

11
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/activity_add_restaurant_spinner_type.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="restaurant_type">
<item>Cafeteria</item>
<item>Pub</item>
<item>Bar</item>
<item>Restaurant</item>
<item>Fast Food</item>
<item>Ethnic</item>
</string-array>
</resources>

15
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml

@ -25,6 +25,7 @@
<!-- Main -->
<string name="main_activity_title">Main</string>
<string name="main_toolbar_title">Restaurants</string>
<string name="main_toolbar_menu_filter">Filter results</string>
<string name="main_toolbar_menu_map">Show in map</string>
@ -40,4 +41,18 @@
<string name="main_row_type">Restaurant type</string>
<string name="main_row_working_hours">Restaurant working hours</string>
<string name="main_row_working_hours_placeholder">%1$s - %2$s</string>
<!-- Restaurant -->
<string name="restaurant_toolbar_title">Restaurant Name</string>
<string name="restaurant_working_hours">Working hours</string>
<string name="restaurant_type">Restaurant type</string>
<string name="restaurant_row_grade_placeholder">Grade = %1$d/5</string>
<string name="restaurant_row_accessibility_placeholder">Accessibility = %1$s</string>
<!-- Add Restaurant -->
<string name="add_restaurant_toolbar_title">Add Restaurant</string>
<string name="add_restaurant_hint_name">Restaurant\'s name</string>
<string name="add_restaurant_hint_working_hours">Working hours</string>
<string name="add_restaurant_working_hours_placeholder">%1$s:%2$s - %3$s:%4$s</string>
<string name="add_restaurant_add_btn">ADD RESTAURANT</string>
</resources>

Loading…
Cancel
Save