Browse Source

Add options for moderators, Various fixes

master
Apostolos Fanakis 6 years ago
parent
commit
c21b34f5c5
  1. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java
  2. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddRestaurantActivity.java
  3. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/RateItemActivity.java
  4. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/RateRestaurantActivity.java
  5. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java
  6. 51
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsActivity.java
  7. 82
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsAdapter.java
  8. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
  9. 32
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java
  10. 47
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java
  11. 10
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  12. 48
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java
  13. 48
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java
  14. 35
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java
  15. 13
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Diet.java
  16. 14
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java
  17. 20
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Restaurant.java
  18. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantUserView.java
  19. 14
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java
  20. 55
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main_list_row.xml
  21. 22
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/diets_row.xml
  22. 27
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/restaurant_item_row.xml
  23. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
  24. 2
      UI/AndroidApp/flavoursWithoutBorders/build.gradle
  25. 3
      UI/AndroidApp/flavoursWithoutBorders/gradle/wrapper/gradle-wrapper.properties

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java

@ -169,7 +169,7 @@ public class AddDietActivity extends BaseActivity {
@Override @Override
protected void onPostExecute(Integer result) { protected void onPostExecute(Integer result) {
Toast.makeText(AddDietActivity.this, Toast.makeText(AddDietActivity.this,
"Diet was added and awaits approval!", Toast.LENGTH_SHORT).show(); "Diet was added!", Toast.LENGTH_SHORT).show();
AddDietActivity.this.finish(); AddDietActivity.this.finish();
} }
} }

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

@ -284,7 +284,7 @@ public class AddRestaurantActivity extends BaseActivity implements AdapterView.O
if (response.code() == 201) { if (response.code() == 201) {
Toast.makeText(AddRestaurantActivity.this, Toast.makeText(AddRestaurantActivity.this,
"Restaurant was added and awaits approval!", Toast.LENGTH_SHORT).show(); "Restaurant was added!", Toast.LENGTH_SHORT).show();
return 0; return 0;
} }
return 1; return 1;

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/RateItemActivity.java

@ -144,7 +144,7 @@ public class RateItemActivity extends BaseActivity implements AdapterView.OnItem
builder.add(REQ_RATE_FOOD_ID, "" + item.getId()) builder.add(REQ_RATE_FOOD_ID, "" + item.getId())
.add(REQ_RATE_ITEM_GRADE, "" + ratingGrade) .add(REQ_RATE_ITEM_GRADE, "" + ratingGrade)
.add(REQ_RATE_ITEM_DESCRIPTION, "" + ratingText.getText().toString()) .add(REQ_RATE_ITEM_DESCRIPTION, "" + ratingText.getText().toString())
.add("user", "1") .add("user", "" + sessionManager.getUserId())
.build(); .build();
RequestBody formBody = builder.build(); RequestBody formBody = builder.build();
request = new Request.Builder() request = new Request.Builder()
@ -155,7 +155,7 @@ public class RateItemActivity extends BaseActivity implements AdapterView.OnItem
builder.add(REQ_RATE_DRINK_ID, "" + item.getId()) builder.add(REQ_RATE_DRINK_ID, "" + item.getId())
.add(REQ_RATE_ITEM_GRADE, "" + ratingGrade) .add(REQ_RATE_ITEM_GRADE, "" + ratingGrade)
.add(REQ_RATE_ITEM_DESCRIPTION, "" + ratingText.getText().toString()) .add(REQ_RATE_ITEM_DESCRIPTION, "" + ratingText.getText().toString())
.add("user", "1") .add("user", "" + sessionManager.getUserId())
.build(); .build();
RequestBody formBody = builder.build(); RequestBody formBody = builder.build();
request = new Request.Builder() request = new Request.Builder()

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/RateRestaurantActivity.java

@ -199,7 +199,7 @@ public class RateRestaurantActivity extends BaseActivity implements AdapterView.
.add(REQ_RATE_RESTAURANT_ID, "" + restaurant.getId()) .add(REQ_RATE_RESTAURANT_ID, "" + restaurant.getId())
.add(REQ_RATE_RESTAURANT_GRADE, "" + ratingGrade) .add(REQ_RATE_RESTAURANT_GRADE, "" + ratingGrade)
.add(REQ_RATE_RESTAURANT_TEXT, ratingText.getText().toString()) .add(REQ_RATE_RESTAURANT_TEXT, ratingText.getText().toString())
.add("user", "1"); .add("user", "" + sessionManager.getUserId());
if (ratingAccessibility != null) { if (ratingAccessibility != null) {
builder.add(REQ_RATE_RESTAURANT_ACCESSIBILITY, builder.add(REQ_RATE_RESTAURANT_ACCESSIBILITY,

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java

@ -88,7 +88,9 @@ public class SignUpActivity extends BaseActivity {
} }
public void onDateSet(DatePicker view, int year, int month, int day) { public void onDateSet(DatePicker view, int year, int month, int day) {
birthdayInput.setText(getResources().getString(R.string.sign_up_birthday_placeholder, year, month + 1, day)); birthdayInput.setText(getResources().getString(R.string.sign_up_birthday_placeholder, year,
((month < 9) ? "0" : "") + (month + 1),
((day < 10) ? "0" : "") + day));
} }
} }

51
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsActivity.java

@ -20,15 +20,19 @@ import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.AddDietActivity; import gr.auth.databases.flavours.activities.AddDietActivity;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.base.BaseApplication;
import gr.auth.databases.flavours.model.Diet; import gr.auth.databases.flavours.model.Diet;
import gr.auth.databases.flavours.utils.FollowDietStateTask; import gr.auth.databases.flavours.utils.FollowDietStateTask;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import static gr.auth.databases.flavours.session.SessionManager.acceptDietUrl;
import static gr.auth.databases.flavours.session.SessionManager.dietsUserViewUrl; import static gr.auth.databases.flavours.session.SessionManager.dietsUserViewUrl;
public class DietsActivity extends BaseActivity implements DietsAdapter.SubscribeDietsAdapterInteractionListener { public class DietsActivity extends BaseActivity implements
DietsAdapter.AcceptDietAdapterInteractionListener, DietsAdapter.SubscribeDietsAdapterInteractionListener {
private RecyclerView recyclerView; private RecyclerView recyclerView;
private FloatingActionButton FAB; private FloatingActionButton FAB;
private ArrayList<Diet> diets = new ArrayList<>(); private ArrayList<Diet> diets = new ArrayList<>();
@ -88,6 +92,13 @@ public class DietsActivity extends BaseActivity implements DietsAdapter.Subscrib
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@Override
public void onAcceptDietAdapterInteraction(Diet diet) {
AcceptDietTask acceptDietTask = new AcceptDietTask();
acceptDietTask.execute(diet.getId());
diets.get(diets.indexOf(diet)).setAccepted(true);
}
@Override @Override
public void onSubscribeDietsAdapterInteraction(Diet diet) { public void onSubscribeDietsAdapterInteraction(Diet diet) {
FollowDietStateTask followDietStateTask = new FollowDietStateTask(client); FollowDietStateTask followDietStateTask = new FollowDietStateTask(client);
@ -99,7 +110,7 @@ public class DietsActivity extends BaseActivity implements DietsAdapter.Subscrib
private static final String JSON_TAG_DIET_ID = "diet_id"; private static final String JSON_TAG_DIET_ID = "diet_id";
private static final String JSON_TAG_DIET_NAME = "diet_name"; private static final String JSON_TAG_DIET_NAME = "diet_name";
private static final String JSON_TAG_DIET_DESCRIPTION = "diet_description"; private static final String JSON_TAG_DIET_DESCRIPTION = "diet_description";
//private static final String JSON_TAG_DIET_IS_APPROVED = "food_calories"; private static final String JSON_TAG_DIET_IS_ACCEPTED = "diet_is_approved";
private static final String JSON_TAG_USER_FOLLOWS_DIET_LIST = "followed"; private static final String JSON_TAG_USER_FOLLOWS_DIET_LIST = "followed";
private static final String JSON_TAG_USER_FOLLOWS_DIET_DIET = "diet"; private static final String JSON_TAG_USER_FOLLOWS_DIET_DIET = "diet";
@ -137,7 +148,8 @@ public class DietsActivity extends BaseActivity implements DietsAdapter.Subscrib
diets.add(new Diet(diet.getInt(JSON_TAG_DIET_ID), diets.add(new Diet(diet.getInt(JSON_TAG_DIET_ID),
diet.getString(JSON_TAG_DIET_NAME), diet.getString(JSON_TAG_DIET_NAME),
diet.getString(JSON_TAG_DIET_DESCRIPTION), diet.getString(JSON_TAG_DIET_DESCRIPTION),
userDiets.contains(diet.getInt(JSON_TAG_DIET_ID)))); userDiets.contains(diet.getInt(JSON_TAG_DIET_ID)),
diet.getBoolean(JSON_TAG_DIET_IS_ACCEPTED)));
} }
return 1; return 1;
} catch (Exception e) { } catch (Exception e) {
@ -148,8 +160,39 @@ public class DietsActivity extends BaseActivity implements DietsAdapter.Subscrib
@Override @Override
protected void onPostExecute(Integer result) { protected void onPostExecute(Integer result) {
DietsAdapter dietsAdapter = new DietsAdapter(diets, DietsActivity.this); DietsAdapter dietsAdapter = new DietsAdapter(diets, DietsActivity.this,
DietsActivity.this);
recyclerView.setAdapter(dietsAdapter); recyclerView.setAdapter(dietsAdapter);
} }
} }
private class AcceptDietTask extends AsyncTask<Integer, Void, Integer> {
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Integer... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(acceptDietUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
BaseApplication.getInstance().getClient().newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
}
}
} }

82
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsAdapter.java

@ -12,13 +12,20 @@ import androidx.appcompat.widget.AppCompatImageButton;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.Diet; import gr.auth.databases.flavours.model.Diet;
import gr.auth.databases.flavours.session.SessionManager;
import static gr.auth.databases.flavours.base.BaseActivity.getSessionManager;
public class DietsAdapter extends RecyclerView.Adapter<DietsAdapter.DietViewHolder> { public class DietsAdapter extends RecyclerView.Adapter<DietsAdapter.DietViewHolder> {
private ArrayList<Diet> diets; private ArrayList<Diet> diets;
private AcceptDietAdapterInteractionListener acceptDietAdapterInteractionListener;
private SubscribeDietsAdapterInteractionListener subscribeDietsAdapterInteractionListener; private SubscribeDietsAdapterInteractionListener subscribeDietsAdapterInteractionListener;
DietsAdapter(ArrayList<Diet> diets, SubscribeDietsAdapterInteractionListener subscribeDietsAdapterInteractionListener) { DietsAdapter(ArrayList<Diet> diets,
AcceptDietAdapterInteractionListener acceptDietAdapterInteractionListener,
SubscribeDietsAdapterInteractionListener subscribeDietsAdapterInteractionListener) {
this.diets = diets; this.diets = diets;
this.acceptDietAdapterInteractionListener = acceptDietAdapterInteractionListener;
this.subscribeDietsAdapterInteractionListener = subscribeDietsAdapterInteractionListener; this.subscribeDietsAdapterInteractionListener = subscribeDietsAdapterInteractionListener;
} }
@ -41,21 +48,59 @@ public class DietsAdapter extends RecyclerView.Adapter<DietsAdapter.DietViewHold
holder.addDietButton.setImageResource(R.drawable.ic_add_black_18dp); holder.addDietButton.setImageResource(R.drawable.ic_add_black_18dp);
} }
holder.addDietButton.setOnClickListener(new View.OnClickListener() { if (!diets.get(position).isAccepted() &&
@Override (getSessionManager().getUserType() == SessionManager.UserType.MODERATOR)) {
public void onClick(View v) { holder.acceptDietBtn.setOnClickListener(new View.OnClickListener() {
subscribeDietsAdapterInteractionListener.onSubscribeDietsAdapterInteraction( @Override
diets.get(holder.getAdapterPosition())); public void onClick(View v) {
if (acceptDietAdapterInteractionListener != null) {
if ((diets.get(position).isFollowedByUser())) { acceptDietAdapterInteractionListener.
holder.addDietButton.setImageResource(R.drawable.ic_add_black_18dp); onAcceptDietAdapterInteraction(diets.get(holder.getAdapterPosition()));
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser()); diets.get(holder.getAdapterPosition()).setAccepted(true);
} else {
holder.addDietButton.setImageResource(R.drawable.ic_delete_black_18dp); holder.acceptDietBtn.setVisibility(View.GONE);
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser()); holder.addDietButton.setVisibility(View.VISIBLE);
holder.addDietButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeDietsAdapterInteractionListener.onSubscribeDietsAdapterInteraction(
diets.get(holder.getAdapterPosition()));
if ((diets.get(position).isFollowedByUser())) {
holder.addDietButton.setImageResource(R.drawable.ic_add_black_18dp);
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser());
} else {
holder.addDietButton.setImageResource(R.drawable.ic_delete_black_18dp);
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser());
}
}
});
}
} }
} });
}); holder.acceptDietBtn.setVisibility(View.VISIBLE);
holder.addDietButton.setVisibility(View.GONE);
} else {
holder.acceptDietBtn.setVisibility(View.GONE);
holder.addDietButton.setVisibility(View.VISIBLE);
holder.addDietButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeDietsAdapterInteractionListener.onSubscribeDietsAdapterInteraction(
diets.get(holder.getAdapterPosition()));
if ((diets.get(position).isFollowedByUser())) {
holder.addDietButton.setImageResource(R.drawable.ic_add_black_18dp);
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser());
} else {
holder.addDietButton.setImageResource(R.drawable.ic_delete_black_18dp);
diets.get(position).setFollowedByUser(!diets.get(position).isFollowedByUser());
}
}
});
}
} }
@Override @Override
@ -65,16 +110,21 @@ public class DietsAdapter extends RecyclerView.Adapter<DietsAdapter.DietViewHold
static class DietViewHolder extends RecyclerView.ViewHolder { static class DietViewHolder extends RecyclerView.ViewHolder {
TextView name, description; TextView name, description;
AppCompatImageButton addDietButton; AppCompatImageButton acceptDietBtn, addDietButton;
DietViewHolder(View v) { DietViewHolder(View v) {
super(v); super(v);
name = v.findViewById(R.id.diets_diet_name); name = v.findViewById(R.id.diets_diet_name);
description = v.findViewById(R.id.diets_diet_description); description = v.findViewById(R.id.diets_diet_description);
acceptDietBtn = v.findViewById(R.id.restaurant_item_row_accept_btn);
addDietButton = v.findViewById(R.id.diets_diet_subscribe); addDietButton = v.findViewById(R.id.diets_diet_subscribe);
} }
} }
public interface AcceptDietAdapterInteractionListener {
void onAcceptDietAdapterInteraction(Diet diet);
}
public interface SubscribeDietsAdapterInteractionListener { public interface SubscribeDietsAdapterInteractionListener {
void onSubscribeDietsAdapterInteraction(Diet diet); void onSubscribeDietsAdapterInteraction(Diet diet);
} }

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java

@ -299,6 +299,7 @@ public class MainActivity extends BaseActivity {
private static final String JSON_TAG_RESTAURANT_LATITUDE = "restaurant_latitude"; private static final String JSON_TAG_RESTAURANT_LATITUDE = "restaurant_latitude";
private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening"; private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening";
private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing"; private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing";
private static final String JSON_TAG_RESTAURANT_IS_ACCEPTED = "restaurant_is_approved";
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
@ -378,7 +379,8 @@ public class MainActivity extends BaseActivity {
jsonRestaurant.getDouble(JSON_TAG_RESTAURANT_LONGITUDE), jsonRestaurant.getDouble(JSON_TAG_RESTAURANT_LONGITUDE),
jsonRestaurant.getDouble(JSON_TAG_RESTAURANT_LATITUDE), jsonRestaurant.getDouble(JSON_TAG_RESTAURANT_LATITUDE),
jsonRestaurant.getString(JSON_TAG_RESTAURANT_OPENING), jsonRestaurant.getString(JSON_TAG_RESTAURANT_OPENING),
jsonRestaurant.getString(JSON_TAG_RESTAURANT_CLOSING))); jsonRestaurant.getString(JSON_TAG_RESTAURANT_CLOSING),
jsonRestaurant.getBoolean(JSON_TAG_RESTAURANT_IS_ACCEPTED)));
} }
return 1; return 1;
} catch (Exception e) { } catch (Exception e) {

32
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainAdapter.java

@ -11,21 +11,27 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.restaurant.RestaurantActivity; import gr.auth.databases.flavours.activities.restaurant.RestaurantActivity;
import gr.auth.databases.flavours.model.Restaurant; import gr.auth.databases.flavours.model.Restaurant;
import gr.auth.databases.flavours.session.SessionManager;
import static gr.auth.databases.flavours.activities.restaurant.RestaurantActivity.BUNDLE_ARG_RESTAURANT; import static gr.auth.databases.flavours.activities.restaurant.RestaurantActivity.BUNDLE_ARG_RESTAURANT;
import static gr.auth.databases.flavours.base.BaseActivity.getSessionManager;
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantViewHolder> { public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantViewHolder> {
private Context context; private Context context;
private ArrayList<Restaurant> restaurants; private ArrayList<Restaurant> restaurants;
private AcceptRestaurantAdapterInteractionListener acceptRestaurantAdapterInteractionListener;
public MainAdapter(Context context, ArrayList<Restaurant> restaurants) { public MainAdapter(Context context, ArrayList<Restaurant> restaurants,
AcceptRestaurantAdapterInteractionListener acceptRestaurantAdapterInteractionListener) {
this.context = context; this.context = context;
this.restaurants = restaurants; this.restaurants = restaurants;
this.acceptRestaurantAdapterInteractionListener = acceptRestaurantAdapterInteractionListener;
} }
@NonNull @NonNull
@ -84,6 +90,24 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantView
holder.typeText.setText(context.getResources().getString(R.string.main_ethnic_type)); holder.typeText.setText(context.getResources().getString(R.string.main_ethnic_type));
break; break;
} }
if (!restaurants.get(position).isAccepted() &&
(getSessionManager().getUserType() == SessionManager.UserType.MODERATOR)) {
holder.acceptRestaurantBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (acceptRestaurantAdapterInteractionListener != null) {
acceptRestaurantAdapterInteractionListener.
onAcceptRestaurantAdapterInteraction(restaurants.get(holder.getAdapterPosition()));
restaurants.get(holder.getAdapterPosition()).setAccepted(true);
holder.acceptRestaurantBtn.setVisibility(View.GONE);
}
}
});
holder.acceptRestaurantBtn.setVisibility(View.VISIBLE);
} else {
holder.acceptRestaurantBtn.setVisibility(View.GONE);
}
} }
@Override @Override
@ -95,6 +119,7 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantView
CardView card; CardView card;
TextView name, typeText, workingHours; TextView name, typeText, workingHours;
ImageView typeImage; ImageView typeImage;
AppCompatImageButton acceptRestaurantBtn;
RestaurantViewHolder(View v) { RestaurantViewHolder(View v) {
super(v); super(v);
@ -103,6 +128,11 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.RestaurantView
typeText = v.findViewById(R.id.main_row_type_txt); typeText = v.findViewById(R.id.main_row_type_txt);
workingHours = v.findViewById(R.id.main_row_working_hours); workingHours = v.findViewById(R.id.main_row_working_hours);
typeImage = v.findViewById(R.id.main_row_type_img); typeImage = v.findViewById(R.id.main_row_type_img);
acceptRestaurantBtn = v.findViewById(R.id.main_row_accept_restaurant_btn);
} }
} }
public interface AcceptRestaurantAdapterInteractionListener {
void onAcceptRestaurantAdapterInteraction(Restaurant restaurant);
}
} }

47
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java

@ -1,5 +1,6 @@
package gr.auth.databases.flavours.activities.main.fragments; package gr.auth.databases.flavours.activities.main.fragments;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -13,9 +14,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.main.MainAdapter; import gr.auth.databases.flavours.activities.main.MainAdapter;
import gr.auth.databases.flavours.base.BaseApplication;
import gr.auth.databases.flavours.model.Restaurant; import gr.auth.databases.flavours.model.Restaurant;
import okhttp3.Request;
import okhttp3.RequestBody;
public class MainListFragment extends Fragment { import static gr.auth.databases.flavours.session.SessionManager.acceptRestaurantUrl;
public class MainListFragment extends Fragment implements MainAdapter.AcceptRestaurantAdapterInteractionListener {
private static final String RESTAURANTS_TAG = "RESTAURANTS_TAG"; private static final String RESTAURANTS_TAG = "RESTAURANTS_TAG";
private ArrayList<Restaurant> restaurants; private ArrayList<Restaurant> restaurants;
@ -44,9 +50,46 @@ public class MainListFragment extends Fragment {
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
MainAdapter mainAdapter = new MainAdapter(getContext(), restaurants); MainAdapter mainAdapter = new MainAdapter(getContext(), restaurants, this);
recyclerView.setAdapter(mainAdapter); recyclerView.setAdapter(mainAdapter);
return rootView; return rootView;
} }
@Override
public void onAcceptRestaurantAdapterInteraction(Restaurant restaurant) {
AcceptRestaurantTask acceptRestaurantTask = new AcceptRestaurantTask();
acceptRestaurantTask.execute(restaurant.getId());
restaurants.get(restaurants.indexOf(restaurant)).setAccepted(true);
}
private class AcceptRestaurantTask extends AsyncTask<Integer, Void, Integer> {
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Integer... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(acceptRestaurantUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
BaseApplication.getInstance().getClient().newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
}
}
} }

10
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java

@ -213,6 +213,7 @@ public class RestaurantActivity extends BaseActivity
private static final String JSON_TAG_RESTAURANT_LATITUDE = "restaurant_latitude"; private static final String JSON_TAG_RESTAURANT_LATITUDE = "restaurant_latitude";
private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening"; private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening";
private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing"; private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing";
private static final String JSON_TAG_RESTAURANT_IS_ACCEPTED = "restaurant_is_approved";
private static final String JSON_TAG_RESTAURANT_AVG_RATING_OBJ = "averageRating"; private static final String JSON_TAG_RESTAURANT_AVG_RATING_OBJ = "averageRating";
private static final String JSON_TAG_RESTAURANT_AVG_RATING = "rating_grade__avg"; private static final String JSON_TAG_RESTAURANT_AVG_RATING = "rating_grade__avg";
@ -223,10 +224,12 @@ public class RestaurantActivity extends BaseActivity
private static final String JSON_TAG_RESTAURANT_FOODS = "foods"; private static final String JSON_TAG_RESTAURANT_FOODS = "foods";
private static final String JSON_TAG_RESTAURANT_FOOD_ID = "food_id"; private static final String JSON_TAG_RESTAURANT_FOOD_ID = "food_id";
private static final String JSON_TAG_RESTAURANT_FOOD_NAME = "food_name"; private static final String JSON_TAG_RESTAURANT_FOOD_NAME = "food_name";
private static final String JSON_TAG_RESTAURANT_FOOD_IS_ACCEPTED = "food_is_approved";
private static final String JSON_TAG_RESTAURANT_DRINKS = "drinks"; private static final String JSON_TAG_RESTAURANT_DRINKS = "drinks";
private static final String JSON_TAG_RESTAURANT_DRINK_ID = "drink_id"; private static final String JSON_TAG_RESTAURANT_DRINK_ID = "drink_id";
private static final String JSON_TAG_RESTAURANT_DRINK_NAME = "drink_name"; private static final String JSON_TAG_RESTAURANT_DRINK_NAME = "drink_name";
private static final String JSON_TAG_RESTAURANT_DRINK_IS_ACCEPTED = "drink_is_approved";
private static final String JSON_TAG_RESTAURANT_RATINGS = "ratings"; private static final String JSON_TAG_RESTAURANT_RATINGS = "ratings";
private static final String JSON_TAG_RESTAURANT_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_RESTAURANT_RATING_GRADE = "rating_grade";
@ -284,6 +287,7 @@ public class RestaurantActivity extends BaseActivity
jsonRestaurantInfo.getDouble(JSON_TAG_RESTAURANT_LATITUDE), jsonRestaurantInfo.getDouble(JSON_TAG_RESTAURANT_LATITUDE),
jsonRestaurantInfo.getString(JSON_TAG_RESTAURANT_OPENING), jsonRestaurantInfo.getString(JSON_TAG_RESTAURANT_OPENING),
jsonRestaurantInfo.getString(JSON_TAG_RESTAURANT_CLOSING), jsonRestaurantInfo.getString(JSON_TAG_RESTAURANT_CLOSING),
jsonRestaurantInfo.getBoolean(JSON_TAG_RESTAURANT_IS_ACCEPTED),
avgRestaurantRating, avgRestaurantRating,
ratingsPerDiet); ratingsPerDiet);
@ -292,7 +296,8 @@ public class RestaurantActivity extends BaseActivity
JSONObject food = jsonFoods.getJSONObject(foodIndex); JSONObject food = jsonFoods.getJSONObject(foodIndex);
foods.add(new ItemSummary(food.getString(JSON_TAG_RESTAURANT_FOOD_NAME), foods.add(new ItemSummary(food.getString(JSON_TAG_RESTAURANT_FOOD_NAME),
food.getInt(JSON_TAG_RESTAURANT_FOOD_ID), food.getInt(JSON_TAG_RESTAURANT_FOOD_ID),
ItemSummary.ItemType.FOOD)); ItemSummary.ItemType.FOOD,
food.getBoolean(JSON_TAG_RESTAURANT_FOOD_IS_ACCEPTED)));
} }
JSONArray jsonDrinks = jsonResponse.getJSONArray(JSON_TAG_RESTAURANT_DRINKS); JSONArray jsonDrinks = jsonResponse.getJSONArray(JSON_TAG_RESTAURANT_DRINKS);
@ -300,7 +305,8 @@ public class RestaurantActivity extends BaseActivity
JSONObject drink = jsonDrinks.getJSONObject(drinkIndex); JSONObject drink = jsonDrinks.getJSONObject(drinkIndex);
drinks.add(new ItemSummary(drink.getString(JSON_TAG_RESTAURANT_DRINK_NAME), drinks.add(new ItemSummary(drink.getString(JSON_TAG_RESTAURANT_DRINK_NAME),
drink.getInt(JSON_TAG_RESTAURANT_DRINK_ID), drink.getInt(JSON_TAG_RESTAURANT_DRINK_ID),
ItemSummary.ItemType.DRINK)); ItemSummary.ItemType.DRINK,
drink.getBoolean(JSON_TAG_RESTAURANT_DRINK_IS_ACCEPTED)));
} }
JSONArray jsonRatings = jsonResponse.getJSONArray(JSON_TAG_RESTAURANT_RATINGS); JSONArray jsonRatings = jsonResponse.getJSONArray(JSON_TAG_RESTAURANT_RATINGS);

48
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java

@ -1,5 +1,6 @@
package gr.auth.databases.flavours.activities.restaurant.fragments; package gr.auth.databases.flavours.activities.restaurant.fragments;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -11,10 +12,16 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.base.BaseApplication;
import gr.auth.databases.flavours.base.BaseFragment; import gr.auth.databases.flavours.base.BaseFragment;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.Request;
import okhttp3.RequestBody;
public class RestaurantDrinksFragment extends BaseFragment { import static gr.auth.databases.flavours.session.SessionManager.acceptDrinkUrl;
public class RestaurantDrinksFragment extends BaseFragment implements
RestaurantItemAdapter.AcceptItemAdapterInteractionListener {
public RestaurantDrinksFragment() { public RestaurantDrinksFragment() {
// Required empty public constructor // Required empty public constructor
@ -43,7 +50,7 @@ public class RestaurantDrinksFragment extends BaseFragment {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener,
ItemSummary.ItemType.DRINK, drinks); ItemSummary.ItemType.DRINK, drinks, this);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter); mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
@ -52,7 +59,44 @@ public class RestaurantDrinksFragment extends BaseFragment {
return rootView; return rootView;
} }
@Override
public void onAcceptItemAdapterInteraction(ItemSummary item) {
AcceptItemTask acceptItemTask = new AcceptItemTask();
acceptItemTask.execute(item.getId());
drinks.get(drinks.indexOf(item)).setAccepted(true);
}
public interface RestaurantDrinksFragmentInteractionListener extends FragmentInteractionListener { public interface RestaurantDrinksFragmentInteractionListener extends FragmentInteractionListener {
void onRestaurantDrinksFragmentInteraction(ItemSummary foodSummary); void onRestaurantDrinksFragmentInteraction(ItemSummary foodSummary);
} }
private class AcceptItemTask extends AsyncTask<Integer, Void, Integer> {
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Integer... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(acceptDrinkUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
BaseApplication.getInstance().getClient().newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
}
}
} }

48
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java

@ -1,5 +1,6 @@
package gr.auth.databases.flavours.activities.restaurant.fragments; package gr.auth.databases.flavours.activities.restaurant.fragments;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -11,10 +12,16 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.base.BaseApplication;
import gr.auth.databases.flavours.base.BaseFragment; import gr.auth.databases.flavours.base.BaseFragment;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.Request;
import okhttp3.RequestBody;
public class RestaurantFoodsFragment extends BaseFragment { import static gr.auth.databases.flavours.session.SessionManager.acceptFoodUrl;
public class RestaurantFoodsFragment extends BaseFragment implements
RestaurantItemAdapter.AcceptItemAdapterInteractionListener {
public RestaurantFoodsFragment() { public RestaurantFoodsFragment() {
// Required empty public constructor // Required empty public constructor
@ -43,7 +50,7 @@ public class RestaurantFoodsFragment extends BaseFragment {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener,
ItemSummary.ItemType.FOOD, foods); ItemSummary.ItemType.FOOD, foods, this);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter); mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
@ -52,7 +59,44 @@ public class RestaurantFoodsFragment extends BaseFragment {
return rootView; return rootView;
} }
@Override
public void onAcceptItemAdapterInteraction(ItemSummary item) {
AcceptItemTask acceptItemTask = new AcceptItemTask();
acceptItemTask.execute(item.getId());
foods.get(foods.indexOf(item)).setAccepted(true);
}
public interface RestaurantFoodsFragmentInteractionListener extends FragmentInteractionListener { public interface RestaurantFoodsFragmentInteractionListener extends FragmentInteractionListener {
void onRestaurantFoodsFragmentInteraction(ItemSummary foodSummary); void onRestaurantFoodsFragmentInteraction(ItemSummary foodSummary);
} }
private class AcceptItemTask extends AsyncTask<Integer, Void, Integer> {
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Integer... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(acceptFoodUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
BaseApplication.getInstance().getClient().newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
}
}
} }

35
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java

@ -8,19 +8,25 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.base.BaseFragment; import gr.auth.databases.flavours.base.BaseFragment;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import gr.auth.databases.flavours.session.SessionManager;
import static gr.auth.databases.flavours.base.BaseActivity.getSessionManager;
public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener foodInteractionListener; private RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener foodInteractionListener;
private RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener drinkInteractionListener; private RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener drinkInteractionListener;
private final ArrayList<ItemSummary> items; private final ArrayList<ItemSummary> items;
private AcceptItemAdapterInteractionListener acceptItemAdapterInteractionListener;
RestaurantItemAdapter(BaseFragment.FragmentInteractionListener interactionListener, RestaurantItemAdapter(BaseFragment.FragmentInteractionListener interactionListener,
ItemSummary.ItemType itemType, ArrayList<ItemSummary> items) { ItemSummary.ItemType itemType, ArrayList<ItemSummary> items,
AcceptItemAdapterInteractionListener acceptRestaurantAdapterInteractionListener) {
if (itemType == ItemSummary.ItemType.FOOD) { if (itemType == ItemSummary.ItemType.FOOD) {
this.foodInteractionListener = (RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener) interactionListener; this.foodInteractionListener = (RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener) interactionListener;
} else if (itemType == ItemSummary.ItemType.DRINK) { } else if (itemType == ItemSummary.ItemType.DRINK) {
@ -28,6 +34,7 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
} }
this.items = items; this.items = items;
this.acceptItemAdapterInteractionListener = acceptRestaurantAdapterInteractionListener;
} }
@NonNull @NonNull
@ -41,7 +48,7 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
@Override @Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
ItemSummary item = items.get(position); ItemSummary item = items.get(position);
ItemViewHolder itemViewHolder = (ItemViewHolder) holder; final ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
itemViewHolder.card.setOnClickListener(new View.OnClickListener() { itemViewHolder.card.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -61,6 +68,24 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
}); });
itemViewHolder.item.setText(item.getItemName()); itemViewHolder.item.setText(item.getItemName());
if (!items.get(position).isAccepted() &&
(getSessionManager().getUserType() == SessionManager.UserType.MODERATOR)) {
itemViewHolder.acceptItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (acceptItemAdapterInteractionListener != null) {
acceptItemAdapterInteractionListener.
onAcceptItemAdapterInteraction(items.get(holder.getAdapterPosition()));
items.get(holder.getAdapterPosition()).setAccepted(true);
itemViewHolder.acceptItem.setVisibility(View.GONE);
}
}
});
itemViewHolder.acceptItem.setVisibility(View.VISIBLE);
} else {
itemViewHolder.acceptItem.setVisibility(View.GONE);
}
} }
@Override @Override
@ -71,11 +96,17 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
private static class ItemViewHolder extends RecyclerView.ViewHolder { private static class ItemViewHolder extends RecyclerView.ViewHolder {
CardView card; CardView card;
TextView item; TextView item;
AppCompatImageButton acceptItem;
ItemViewHolder(View itemView) { ItemViewHolder(View itemView) {
super(itemView); super(itemView);
card = itemView.findViewById(R.id.restaurant_item_row_card); card = itemView.findViewById(R.id.restaurant_item_row_card);
item = itemView.findViewById(R.id.restaurant_item_row_item); item = itemView.findViewById(R.id.restaurant_item_row_item);
acceptItem = itemView.findViewById(R.id.restaurant_item_row_accept_btn);
} }
} }
public interface AcceptItemAdapterInteractionListener {
void onAcceptItemAdapterInteraction(ItemSummary item);
}
} }

13
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Diet.java

@ -3,13 +3,14 @@ package gr.auth.databases.flavours.model;
public class Diet { public class Diet {
private int id; private int id;
private String name, description; private String name, description;
private boolean isFollowedByUser; private boolean isFollowedByUser, isAccepted;
public Diet(int id, String name, String description, boolean isFollowedByUser) { public Diet(int id, String name, String description, boolean isFollowedByUser, boolean isAccepted) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.isFollowedByUser = isFollowedByUser; this.isFollowedByUser = isFollowedByUser;
this.isAccepted = isAccepted;
} }
public int getId() { public int getId() {
@ -31,4 +32,12 @@ public class Diet {
public void setFollowedByUser(boolean followedByUser) { public void setFollowedByUser(boolean followedByUser) {
isFollowedByUser = followedByUser; isFollowedByUser = followedByUser;
} }
public boolean isAccepted() {
return isAccepted;
}
public void setAccepted(boolean accepted) {
isAccepted = accepted;
}
} }

14
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java

@ -46,11 +46,13 @@ public class ItemSummary implements Parcelable {
private String itemName; private String itemName;
private int id; private int id;
private ItemType type; private ItemType type;
private boolean isAccepted;
public ItemSummary(String item, int id, ItemType type) { public ItemSummary(String item, int id, ItemType type, boolean isAccepted) {
this.itemName = item; this.itemName = item;
this.id = id; this.id = id;
this.type = type; this.type = type;
this.isAccepted = isAccepted;
} }
public String getItemName() { public String getItemName() {
@ -65,6 +67,14 @@ public class ItemSummary implements Parcelable {
return type; return type;
} }
public boolean isAccepted() {
return isAccepted;
}
public void setAccepted(boolean accepted) {
isAccepted = accepted;
}
@Override @Override
public int describeContents() { public int describeContents() {
return 0; return 0;
@ -75,6 +85,7 @@ public class ItemSummary implements Parcelable {
out.writeInt(id); out.writeInt(id);
out.writeString(itemName); out.writeString(itemName);
out.writeInt(type.getId()); out.writeInt(type.getId());
out.writeByte((byte) (isAccepted ? 1 : 0));
} }
public static final Parcelable.Creator<ItemSummary> CREATOR = new Parcelable.Creator<ItemSummary>() { public static final Parcelable.Creator<ItemSummary> CREATOR = new Parcelable.Creator<ItemSummary>() {
@ -91,5 +102,6 @@ public class ItemSummary implements Parcelable {
id = in.readInt(); id = in.readInt();
itemName = in.readString(); itemName = in.readString();
type = ItemType.getEnumTypeFromId(in.readInt()); type = ItemType.getEnumTypeFromId(in.readInt());
isAccepted = in.readByte() != 0;
} }
} }

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

@ -59,12 +59,13 @@ public class Restaurant implements Parcelable {
} }
} }
private final int id; private int id;
private final String name, type, openingTime, closingTime; private String name, type, openingTime, closingTime;
private final double longitude, latitude; private double longitude, latitude;
private boolean isAccepted;
public Restaurant(int id, String name, String type, double longitude, double latitude, public Restaurant(int id, String name, String type, double longitude, double latitude,
String openingTime, String closingTime) { String openingTime, String closingTime, boolean isAccepted) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.type = type; this.type = type;
@ -72,6 +73,7 @@ public class Restaurant implements Parcelable {
this.latitude = latitude; this.latitude = latitude;
this.openingTime = openingTime; this.openingTime = openingTime;
this.closingTime = closingTime; this.closingTime = closingTime;
this.isAccepted = isAccepted;
} }
public int getId() { public int getId() {
@ -102,6 +104,14 @@ public class Restaurant implements Parcelable {
return closingTime; return closingTime;
} }
public boolean isAccepted() {
return isAccepted;
}
public void setAccepted(boolean accepted) {
isAccepted = accepted;
}
@Override @Override
public int describeContents() { public int describeContents() {
return 0; return 0;
@ -116,6 +126,7 @@ public class Restaurant implements Parcelable {
out.writeDouble(latitude); out.writeDouble(latitude);
out.writeString(openingTime); out.writeString(openingTime);
out.writeString(closingTime); out.writeString(closingTime);
out.writeByte((byte) (isAccepted ? 1 : 0));
} }
public static final Parcelable.Creator<Restaurant> CREATOR = new Parcelable.Creator<Restaurant>() { public static final Parcelable.Creator<Restaurant> CREATOR = new Parcelable.Creator<Restaurant>() {
@ -136,5 +147,6 @@ public class Restaurant implements Parcelable {
latitude = in.readDouble(); latitude = in.readDouble();
openingTime = in.readString(); openingTime = in.readString();
closingTime = in.readString(); closingTime = in.readString();
isAccepted = in.readByte() != 0;
} }
} }

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantUserView.java

@ -9,9 +9,9 @@ public class RestaurantUserView extends Restaurant {
private ArrayList<DietRatingPair> averageRatingPerDiet; private ArrayList<DietRatingPair> averageRatingPerDiet;
public RestaurantUserView(int id, String name, String type, double longitude, double latitude, public RestaurantUserView(int id, String name, String type, double longitude, double latitude,
String openingTime, String closingTime, double averageRating, String openingTime, String closingTime, boolean isAccepted, double averageRating,
ArrayList<DietRatingPair> averageRatingPerDiet) { ArrayList<DietRatingPair> averageRatingPerDiet) {
super(id, name, type, longitude, latitude, openingTime, closingTime); super(id, name, type, longitude, latitude, openingTime, closingTime, isAccepted);
this.averageRating = averageRating; this.averageRating = averageRating;
this.averageRatingPerDiet = averageRatingPerDiet; this.averageRatingPerDiet = averageRatingPerDiet;
} }

14
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java

@ -48,11 +48,11 @@ public class SessionManager {
} }
//Generic constants //Generic constants
public static final String baseServerUrl = "http://83.212.109.171:8181/"; private static final String baseServerUrl = "http://83.212.109.171:8181/";
public static final String loginUrl = baseServerUrl + "api/rest-auth/login/"; private static final String loginUrl = baseServerUrl + "api/rest-auth/login/";
public static final String signupUrl = baseServerUrl + "api/rest-auth/registration/"; private static final String signupUrl = baseServerUrl + "api/rest-auth/registration/";
public static final String logoutUrl = baseServerUrl + "api/rest-auth/logout/"; private static final String logoutUrl = baseServerUrl + "api/rest-auth/logout/";
public static final String setUserBirthday = baseServerUrl + "api/setUserBirthday/"; private static final String setUserBirthday = baseServerUrl + "api/setUserBirthday/";
public static final String restaurantsUrl = baseServerUrl + "api/restaurant/"; public static final String restaurantsUrl = baseServerUrl + "api/restaurant/";
public static final String restaurantsUserViewUrl = baseServerUrl + "api/restaurantUserView/"; public static final String restaurantsUserViewUrl = baseServerUrl + "api/restaurantUserView/";
public static final String getUserDietsUrl = baseServerUrl + "api/userDiets/"; public static final String getUserDietsUrl = baseServerUrl + "api/userDiets/";
@ -72,6 +72,10 @@ public class SessionManager {
public static final String addDietUrl = baseServerUrl + "api/addDiet/"; public static final String addDietUrl = baseServerUrl + "api/addDiet/";
public static final String addIngredientToFoodUrl = baseServerUrl + "api/foodhasingredient/"; public static final String addIngredientToFoodUrl = baseServerUrl + "api/foodhasingredient/";
public static final String addIngredientToDrinkUrl = baseServerUrl + "api/drinkhasingredient/"; public static final String addIngredientToDrinkUrl = baseServerUrl + "api/drinkhasingredient/";
public static final String acceptRestaurantUrl = baseServerUrl + "api/acceptRestaurant/";
public static final String acceptFoodUrl = baseServerUrl + "api/acceptFood/";
public static final String acceptDrinkUrl = baseServerUrl + "api/acceptDrink/";
public static final String acceptDietUrl = baseServerUrl + "api/acceptDiet/";
// Client & Cookies // Client & Cookies
private final OkHttpClient client; private final OkHttpClient client;

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

@ -13,10 +13,9 @@
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true">
<LinearLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingTop="6dp" android:paddingTop="6dp"
android:paddingEnd="4dp" android:paddingEnd="4dp"
@ -26,35 +25,45 @@
android:id="@+id/main_row_type_img" android:id="@+id/main_row_type_img"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/main_row_type" /> android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/main_row_type"
android:src="@drawable/restaurant_marker" />
<LinearLayout <TextView
android:layout_width="0dp" android:id="@+id/main_row_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_toStartOf="@+id/main_row_type_txt"
android:layout_weight="0.5" android:layout_toEndOf="@+id/main_row_type_img"
android:orientation="vertical"> android:ellipsize="end"
android:text="@string/main_row_name"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/main_row_name" android:id="@+id/main_row_working_hours"
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:layout_below="@+id/main_row_name"
android:text="@string/main_row_name" android:layout_toEndOf="@+id/main_row_type_img"
android:textStyle="bold" /> android:text="@string/main_row_working_hours" />
<TextView
android:id="@+id/main_row_working_hours"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_row_working_hours" />
</LinearLayout>
<TextView <TextView
android:id="@+id/main_row_type_txt" android:id="@+id/main_row_type_txt"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:contentDescription="@string/main_row_type" android:contentDescription="@string/main_row_type"
android:textColor="@color/colorAccent" /> android:textColor="@color/colorAccent" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/main_row_accept_restaurant_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/main_row_type_img"
android:layout_alignParentEnd="true"
android:layout_gravity="end"
android:src="@drawable/ic_check_black_18dp"
android:visibility="gone" />
</RelativeLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

22
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/diets_row.xml

@ -39,11 +39,25 @@
android:ellipsize="end" android:ellipsize="end"
android:text="@string/diet_description" /> android:text="@string/diet_description" />
<androidx.appcompat.widget.AppCompatImageButton <LinearLayout
android:id="@+id/diets_diet_subscribe" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end"
android:src="@drawable/ic_add_black_18dp" /> android:gravity="end"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/restaurant_item_row_accept_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_check_black_18dp"
android:visibility="gone" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/diets_diet_subscribe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_black_18dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

27
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/restaurant_item_row.xml

@ -13,11 +13,28 @@
card_view:cardPreventCornerOverlap="false" card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true">
<TextView <LinearLayout
android:id="@+id/restaurant_item_row_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="6dp" android:orientation="vertical"
android:textColor="@color/colorAccent" android:paddingStart="4dp"
android:textSize="16sp" /> android:paddingTop="6dp"
android:paddingEnd="4dp"
android:paddingBottom="6dp">
<TextView
android:id="@+id/restaurant_item_row_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorAccent"
android:textSize="16sp" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/restaurant_item_row_accept_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:src="@drawable/ic_check_black_18dp"
android:visibility="gone" />
</LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

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

@ -16,7 +16,7 @@
<string name="sign_up_hint_birthday">Birthday</string> <string name="sign_up_hint_birthday">Birthday</string>
<string name="sign_up_btn_sign_up">SIGN UP</string> <string name="sign_up_btn_sign_up">SIGN UP</string>
<string name="sign_up_btn_go_to_login">or login</string> <string name="sign_up_btn_go_to_login">or login</string>
<string name="sign_up_birthday_placeholder">%1$d-%2$d-%3$d</string> <string name="sign_up_birthday_placeholder">%1$d-%2$s-%3$s</string>
<!-- Drawer --> <!-- Drawer -->
<string name="drawer_home">Home</string> <string name="drawer_home">Home</string>

2
UI/AndroidApp/flavoursWithoutBorders/build.gradle

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

3
UI/AndroidApp/flavoursWithoutBorders/gradle/wrapper/gradle-wrapper.properties

@ -1,5 +1,6 @@
#Mon Jan 14 20:35:57 EET 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

Loading…
Cancel
Save