Browse Source

Finalization, Add API connection for ingredient addition in foods and drinks, Make usernames clickable

master
Apostolos Fanakis 6 years ago
parent
commit
69df9e59df
  1. 45
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java
  2. 20
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java
  3. 45
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java
  4. 20
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java
  5. 38
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/ingredients/IngredientsActivity.java
  6. 10
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
  7. 57
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java
  8. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java
  9. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java
  10. 39
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java
  11. 3
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java
  12. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  13. 20
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java
  14. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java
  15. 11
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Profile.java
  16. 11
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java
  17. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantRating.java
  18. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java
  19. 22
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java
  20. 45
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ProhibitIngredientStateTask.java
  21. 22
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java
  22. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml
  23. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_ingredient.xml
  24. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml
  25. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml
  26. 10
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml
  27. 15
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml
  28. 25
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_ingredient_row.xml
  29. 3
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml

45
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java

@ -35,12 +35,15 @@ import gr.auth.databases.flavours.model.Drink;
import gr.auth.databases.flavours.model.Ingredient; import gr.auth.databases.flavours.model.Ingredient;
import gr.auth.databases.flavours.model.ItemRating; import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.FormBody;
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.activities.RateItemActivity.BUNDLE_RATE_ITEM; import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM;
import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT; import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT;
import static gr.auth.databases.flavours.session.SessionManager.addIngredientToDrinkUrl;
import static gr.auth.databases.flavours.session.SessionManager.drinksUserViewUrl; import static gr.auth.databases.flavours.session.SessionManager.drinksUserViewUrl;
public class DrinkActivity extends BaseActivity { public class DrinkActivity extends BaseActivity {
@ -141,8 +144,8 @@ public class DrinkActivity extends BaseActivity {
if (requestCode == ADD_INGREDIENT_REQUEST) { if (requestCode == ADD_INGREDIENT_REQUEST) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT); Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT);
//TODO AddIngredientToDrink addIngredientToDrink = new AddIngredientToDrink();
Toast.makeText(this, "Ingredient added and awaits approval.", Toast.LENGTH_LONG).show(); addIngredientToDrink.execute(result);
} }
} }
} }
@ -202,6 +205,7 @@ public class DrinkActivity extends BaseActivity {
private static final String JSON_TAG_DRINK_RATINGS = "ratings"; private static final String JSON_TAG_DRINK_RATINGS = "ratings";
private static final String JSON_TAG_DRINK_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_DRINK_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_DRINK_RATING_USER_ID = "user_id";
private static final String JSON_TAG_DRINK_RATING_USERNAME = "username"; private static final String JSON_TAG_DRINK_RATING_USERNAME = "username";
private static final String JSON_TAG_DRINK_RATING_TEXT = "rating_text"; private static final String JSON_TAG_DRINK_RATING_TEXT = "rating_text";
private static final String JSON_TAG_DRINK_RATING_DATE = "rating_date"; private static final String JSON_TAG_DRINK_RATING_DATE = "rating_date";
@ -254,6 +258,7 @@ public class DrinkActivity extends BaseActivity {
for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRatings.getJSONObject(ratingIndex); JSONObject rating = jsonRatings.getJSONObject(ratingIndex);
ratings.add(new ItemRating(rating.getInt(JSON_TAG_DRINK_RATING_GRADE), ratings.add(new ItemRating(rating.getInt(JSON_TAG_DRINK_RATING_GRADE),
rating.getInt(JSON_TAG_DRINK_RATING_USER_ID),
rating.getString(JSON_TAG_DRINK_RATING_USERNAME), rating.getString(JSON_TAG_DRINK_RATING_USERNAME),
rating.getString(JSON_TAG_DRINK_RATING_TEXT), rating.getString(JSON_TAG_DRINK_RATING_TEXT),
rating.getString(JSON_TAG_DRINK_RATING_DATE), rating.getString(JSON_TAG_DRINK_RATING_DATE),
@ -274,4 +279,40 @@ public class DrinkActivity extends BaseActivity {
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
} }
} }
private class AddIngredientToDrink extends AsyncTask<Ingredient, Void, Integer> {
private static final String JSON_TAG_FOOD_ID = "drink";
private static final String JSON_TAG_FOOD_INGREDIENT_NAME = "ingredient_name";
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Ingredient... params) {
//Builds the request
RequestBody formBody = new FormBody.Builder()
.add(JSON_TAG_FOOD_ID, "" + mDrink.getId())
.add(JSON_TAG_FOOD_INGREDIENT_NAME, params[0].getName())
.build();
Request request = new Request.Builder()
.url(addIngredientToDrinkUrl)
.post(formBody)
.build();
try {
//Makes request & handles response
client.newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
Toast.makeText(DrinkActivity.this, "Ingredient added.", Toast.LENGTH_LONG).show();
}
}
} }

20
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java

@ -1,6 +1,7 @@
package gr.auth.databases.flavours.activities.drink.fragments; package gr.auth.databases.flavours.activities.drink.fragments;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration;
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.activities.profile.ProfileActivity;
import gr.auth.databases.flavours.model.ItemRating; import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.utils.ItemRatingsAdapter; import gr.auth.databases.flavours.utils.ItemRatingsAdapter;
public class DrinkRatingsFragment extends Fragment { import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_ID;
import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_NAME;
public class DrinkRatingsFragment extends Fragment implements
ItemRatingsAdapter.ProfileItemRatingsAdapterInteractionListener {
public DrinkRatingsFragment() { public DrinkRatingsFragment() {
// Required empty public constructor // Required empty public constructor
@ -48,7 +54,7 @@ public class DrinkRatingsFragment extends Fragment {
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings, 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());
@ -59,4 +65,14 @@ public class DrinkRatingsFragment extends Fragment {
return rootView; return rootView;
} }
@Override
public void onProfileItemRatingsAdapterInteraction(int profileID, String profileUsername) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
Bundle extras = new Bundle();
extras.putInt(BUNDLE_USER_ID, profileID);
extras.putString(BUNDLE_USER_NAME, profileUsername);
intent.putExtras(extras);
startActivity(intent);
}
} }

45
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java

@ -35,12 +35,15 @@ import gr.auth.databases.flavours.model.Food;
import gr.auth.databases.flavours.model.Ingredient; import gr.auth.databases.flavours.model.Ingredient;
import gr.auth.databases.flavours.model.ItemRating; import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.FormBody;
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.activities.RateItemActivity.BUNDLE_RATE_ITEM; import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM;
import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT; import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT;
import static gr.auth.databases.flavours.session.SessionManager.addIngredientToFoodUrl;
import static gr.auth.databases.flavours.session.SessionManager.foodsUserViewUrl; import static gr.auth.databases.flavours.session.SessionManager.foodsUserViewUrl;
public class FoodActivity extends BaseActivity { public class FoodActivity extends BaseActivity {
@ -141,8 +144,8 @@ public class FoodActivity extends BaseActivity {
if (requestCode == ADD_INGREDIENT_REQUEST) { if (requestCode == ADD_INGREDIENT_REQUEST) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT); Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT);
//TODO AddIngredientToFood addIngredientToFood = new AddIngredientToFood();
Toast.makeText(this, "Ingredient added and awaits approval.", Toast.LENGTH_LONG).show(); addIngredientToFood.execute(result);
} }
} }
} }
@ -202,6 +205,7 @@ public class FoodActivity extends BaseActivity {
private static final String JSON_TAG_FOOD_RATINGS = "ratings"; private static final String JSON_TAG_FOOD_RATINGS = "ratings";
private static final String JSON_TAG_FOOD_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_FOOD_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_FOOD_RATING_USER_ID = "user_id";
private static final String JSON_TAG_FOOD_RATING_USERNAME = "username"; private static final String JSON_TAG_FOOD_RATING_USERNAME = "username";
private static final String JSON_TAG_FOOD_RATING_TEXT = "rating_text"; private static final String JSON_TAG_FOOD_RATING_TEXT = "rating_text";
private static final String JSON_TAG_FOOD_RATING_DATE = "rating_date"; private static final String JSON_TAG_FOOD_RATING_DATE = "rating_date";
@ -254,6 +258,7 @@ public class FoodActivity extends BaseActivity {
for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRatings.getJSONObject(ratingIndex); JSONObject rating = jsonRatings.getJSONObject(ratingIndex);
ratings.add(new ItemRating(rating.getInt(JSON_TAG_FOOD_RATING_GRADE), ratings.add(new ItemRating(rating.getInt(JSON_TAG_FOOD_RATING_GRADE),
rating.getInt(JSON_TAG_FOOD_RATING_USER_ID),
rating.getString(JSON_TAG_FOOD_RATING_USERNAME), rating.getString(JSON_TAG_FOOD_RATING_USERNAME),
rating.getString(JSON_TAG_FOOD_RATING_TEXT), rating.getString(JSON_TAG_FOOD_RATING_TEXT),
rating.getString(JSON_TAG_FOOD_RATING_DATE), rating.getString(JSON_TAG_FOOD_RATING_DATE),
@ -274,4 +279,40 @@ public class FoodActivity extends BaseActivity {
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
} }
} }
private class AddIngredientToFood extends AsyncTask<Ingredient, Void, Integer> {
private static final String JSON_TAG_FOOD_ID = "food";
private static final String JSON_TAG_FOOD_INGREDIENT_NAME = "ingredient_name";
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Ingredient... params) {
//Builds the request
RequestBody formBody = new FormBody.Builder()
.add(JSON_TAG_FOOD_ID, "" + mFood.getId())
.add(JSON_TAG_FOOD_INGREDIENT_NAME, params[0].getName())
.build();
Request request = new Request.Builder()
.url(addIngredientToFoodUrl)
.post(formBody)
.build();
try {
//Makes request & handles response
client.newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
Toast.makeText(FoodActivity.this, "Ingredient added.", Toast.LENGTH_LONG).show();
}
}
} }

20
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java

@ -1,6 +1,7 @@
package gr.auth.databases.flavours.activities.food.fragments; package gr.auth.databases.flavours.activities.food.fragments;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration;
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.activities.profile.ProfileActivity;
import gr.auth.databases.flavours.model.ItemRating; import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.utils.ItemRatingsAdapter; import gr.auth.databases.flavours.utils.ItemRatingsAdapter;
public class FoodRatingsFragment extends Fragment { import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_ID;
import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_NAME;
public class FoodRatingsFragment extends Fragment implements
ItemRatingsAdapter.ProfileItemRatingsAdapterInteractionListener {
public FoodRatingsFragment() { public FoodRatingsFragment() {
// Required empty public constructor // Required empty public constructor
@ -48,7 +54,7 @@ public class FoodRatingsFragment extends Fragment {
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings, 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());
@ -59,4 +65,14 @@ public class FoodRatingsFragment extends Fragment {
return rootView; return rootView;
} }
@Override
public void onProfileItemRatingsAdapterInteraction(int profileID, String profileUsername) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
Bundle extras = new Bundle();
extras.putInt(BUNDLE_USER_ID, profileID);
extras.putString(BUNDLE_USER_NAME, profileUsername);
intent.putExtras(extras);
startActivity(intent);
}
} }

38
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/ingredients/IngredientsActivity.java

@ -23,14 +23,13 @@ import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.AddIngredientActivity; import gr.auth.databases.flavours.activities.AddIngredientActivity;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.model.Ingredient; import gr.auth.databases.flavours.model.Ingredient;
import gr.auth.databases.flavours.utils.ProhibitIngredientStateTask;
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.activities.AddIngredientActivity.INGREDIENT_ADD_RESULT; import static gr.auth.databases.flavours.activities.AddIngredientActivity.INGREDIENT_ADD_RESULT;
import static gr.auth.databases.flavours.session.SessionManager.ingredientsUserViewUrl; import static gr.auth.databases.flavours.session.SessionManager.ingredientsUserViewUrl;
import static gr.auth.databases.flavours.session.SessionManager.prohibitIngredientUrl;
public class IngredientsActivity extends BaseActivity public class IngredientsActivity extends BaseActivity
implements IngredientsAdapter.SubscribeIngredientsAdapterInteractionListener, implements IngredientsAdapter.SubscribeIngredientsAdapterInteractionListener,
@ -41,7 +40,6 @@ public class IngredientsActivity extends BaseActivity
private RecyclerView recyclerView; private RecyclerView recyclerView;
private ArrayList<String> userProhibitsIngredients; private ArrayList<String> userProhibitsIngredients;
private boolean isCalledForResult; private boolean isCalledForResult;
private FloatingActionButton FAB;
private ArrayList<Ingredient> ingredients = new ArrayList<>(); private ArrayList<Ingredient> ingredients = new ArrayList<>();
private IngredientsAdapter ingredientsAdapter; private IngredientsAdapter ingredientsAdapter;
@ -62,7 +60,7 @@ public class IngredientsActivity extends BaseActivity
createDrawer(); createDrawer();
FAB = findViewById(R.id.ingredients_fab); FloatingActionButton FAB = findViewById(R.id.ingredients_fab);
FAB.setOnClickListener(new View.OnClickListener() { FAB.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -114,7 +112,7 @@ public class IngredientsActivity extends BaseActivity
@Override @Override
public void onSubscribeIngredientsAdapterInteraction(Ingredient ingredient) { public void onSubscribeIngredientsAdapterInteraction(Ingredient ingredient) {
ProhibitIngredientStateTask prohibitIngredientStateTask = new ProhibitIngredientStateTask(); ProhibitIngredientStateTask prohibitIngredientStateTask = new ProhibitIngredientStateTask(client);
prohibitIngredientStateTask.execute(ingredient.getName()); prohibitIngredientStateTask.execute(ingredient.getName());
} }
@ -204,34 +202,4 @@ public class IngredientsActivity extends BaseActivity
recyclerView.setAdapter(ingredientsAdapter); recyclerView.setAdapter(ingredientsAdapter);
} }
} }
private class ProhibitIngredientStateTask extends AsyncTask<String, Void, Integer> {
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(String... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(prohibitIngredientUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
client.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/main/MainActivity.java

@ -310,8 +310,12 @@ public class MainActivity extends BaseActivity {
StringBuilder requestUrl = new StringBuilder(restaurantsUrl); StringBuilder requestUrl = new StringBuilder(restaurantsUrl);
if (!mSelectedRestaurantTypes.isEmpty()) { if (!mSelectedRestaurantTypes.isEmpty()) {
requestUrl.append("?filter_restaurant_type="); requestUrl.append("?filter_restaurant_type=");
for (int typeIndex : mSelectedRestaurantTypes) { for (int selectedTypeIndex = 0; selectedTypeIndex < mSelectedRestaurantTypes.size(); ++selectedTypeIndex) {
int typeIndex = mSelectedRestaurantTypes.get(selectedTypeIndex);
requestUrl.append(Restaurant.RestaurantType.getWorkingTypeFromId(typeIndex)); requestUrl.append(Restaurant.RestaurantType.getWorkingTypeFromId(typeIndex));
if (selectedTypeIndex < mSelectedRestaurantTypes.size() - 1) {
requestUrl.append(",");
}
} }
} }
if (maxDistance != -1) { if (maxDistance != -1) {
@ -348,6 +352,10 @@ public class MainActivity extends BaseActivity {
requestUrl.append("filter_restaurant_calories=").append(maxCalories); requestUrl.append("filter_restaurant_calories=").append(maxCalories);
} }
mSelectedRestaurantTypes.clear();
maxDistance = -1;
maxCalories = -1;
//Builds the request //Builds the request
Request request = new Request.Builder() Request request = new Request.Builder()
.url(requestUrl.toString()) .url(requestUrl.toString())

57
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java

@ -2,11 +2,8 @@ package gr.auth.databases.flavours.activities.profile;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import org.json.JSONArray; import org.json.JSONArray;
@ -29,6 +26,7 @@ import gr.auth.databases.flavours.activities.profile.fragments.ProfileInfoFragme
import gr.auth.databases.flavours.activities.profile.fragments.ProfileRestaurantRatingsFragment; import gr.auth.databases.flavours.activities.profile.fragments.ProfileRestaurantRatingsFragment;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.model.DietSummary; import gr.auth.databases.flavours.model.DietSummary;
import gr.auth.databases.flavours.model.IngredientSummary;
import gr.auth.databases.flavours.model.ItemRating; import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.model.Profile; import gr.auth.databases.flavours.model.Profile;
import gr.auth.databases.flavours.model.RestaurantRating; import gr.auth.databases.flavours.model.RestaurantRating;
@ -43,7 +41,6 @@ public class ProfileActivity extends BaseActivity {
public static final String BUNDLE_USER_ID = "BUNDLE_USER_ID"; public static final String BUNDLE_USER_ID = "BUNDLE_USER_ID";
public static final String BUNDLE_USER_NAME = "BUNDLE_USER_NAME"; public static final String BUNDLE_USER_NAME = "BUNDLE_USER_NAME";
private ViewPager viewPager; private ViewPager viewPager;
private FloatingActionButton FAB;
private int profileID; private int profileID;
private Profile profileUserView; private Profile profileUserView;
@ -73,30 +70,7 @@ public class ProfileActivity extends BaseActivity {
createDrawer(); createDrawer();
FAB = findViewById(R.id.profile_fab);
FAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
viewPager = findViewById(R.id.profile_pager); viewPager = findViewById(R.id.profile_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 (position != 0) {
FAB.hide();
} else {
FAB.show();
}
}
});
tabLayout = findViewById(R.id.profile_tabs); tabLayout = findViewById(R.id.profile_tabs);
ProfileTask profileTask = new ProfileTask(); ProfileTask profileTask = new ProfileTask();
@ -126,7 +100,7 @@ public class ProfileActivity extends BaseActivity {
private void setupViewPager(ViewPager viewPager) { private void setupViewPager(ViewPager viewPager) {
RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager()); RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager());
adapter.addFrag(ProfileInfoFragment.newInstance(profileUserView), "INFO"); adapter.addFrag(ProfileInfoFragment.newInstance(profileUserView, profileID == sessionManager.getUserId()), "INFO");
adapter.addFrag(ProfileFoodRatingsFragment.newInstance(foodRatings), "FOODS"); adapter.addFrag(ProfileFoodRatingsFragment.newInstance(foodRatings), "FOODS");
adapter.addFrag(ProfileDrinkRatingsFragment.newInstance(drinkRatings), "DRINKS"); adapter.addFrag(ProfileDrinkRatingsFragment.newInstance(drinkRatings), "DRINKS");
adapter.addFrag(ProfileRestaurantRatingsFragment.newInstance(restaurantRatings), "PLACES"); adapter.addFrag(ProfileRestaurantRatingsFragment.newInstance(restaurantRatings), "PLACES");
@ -173,12 +147,17 @@ public class ProfileActivity extends BaseActivity {
private static final String JSON_TAG_PROFILE_RESTAURANTS_OWNED = "owns"; private static final String JSON_TAG_PROFILE_RESTAURANTS_OWNED = "owns";
private static final String JSON_TAG_PROFILE_RESTAURANT_OWNED_ID = "restaurant_id"; private static final String JSON_TAG_PROFILE_RESTAURANT_OWNED_ID = "restaurant_id";
private static final String JSON_TAG_PROFILE_RESTAURANT_OWNED_NAME = "restaurant_name"; private static final String JSON_TAG_PROFILE_RESTAURANT_OWNED_NAME = "restaurant_name";
private static final String JSON_TAG_PROFILE_DIETS_FOLLOWED = "diets"; private static final String JSON_TAG_PROFILE_DIETS_FOLLOWED = "diets";
private static final String JSON_TAG_PROFILE_DIET_FOLLOWED_ID = "diet_id"; private static final String JSON_TAG_PROFILE_DIET_FOLLOWED_ID = "diet_id";
private static final String JSON_TAG_PROFILE_DIET_FOLLOWED_NAME = "diet_name"; private static final String JSON_TAG_PROFILE_DIET_FOLLOWED_NAME = "diet_name";
private static final String JSON_TAG_PROFILE_INGREDIENTS_PROHIBITED = "ingredients";
private static final String JSON_TAG_PROFILE_INGREDIENTS_PROHIBITED_NAME = "ingredient_name";
private static final String JSON_TAG_FOOD_RATINGS = "foodRatings"; private static final String JSON_TAG_FOOD_RATINGS = "foodRatings";
private static final String JSON_TAG_FOOD_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_FOOD_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_FOOD_RATING_USER_ID = "user_id";
private static final String JSON_TAG_FOOD_RATING_USERNAME = "username"; private static final String JSON_TAG_FOOD_RATING_USERNAME = "username";
private static final String JSON_TAG_FOOD_RATING_TEXT = "rating_text"; private static final String JSON_TAG_FOOD_RATING_TEXT = "rating_text";
private static final String JSON_TAG_FOOD_RATING_DATE = "rating_date"; private static final String JSON_TAG_FOOD_RATING_DATE = "rating_date";
@ -186,6 +165,7 @@ public class ProfileActivity extends BaseActivity {
private static final String JSON_TAG_DRINK_RATINGS = "drinkRatings"; private static final String JSON_TAG_DRINK_RATINGS = "drinkRatings";
private static final String JSON_TAG_DRINK_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_DRINK_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_DRINK_RATING_USER_ID = "user_id";
private static final String JSON_TAG_DRINK_RATING_USERNAME = "username"; private static final String JSON_TAG_DRINK_RATING_USERNAME = "username";
private static final String JSON_TAG_DRINK_RATING_TEXT = "rating_text"; private static final String JSON_TAG_DRINK_RATING_TEXT = "rating_text";
private static final String JSON_TAG_DRINK_RATING_DATE = "rating_date"; private static final String JSON_TAG_DRINK_RATING_DATE = "rating_date";
@ -193,6 +173,7 @@ public class ProfileActivity extends BaseActivity {
private static final String JSON_TAG_RESTAURANT_RATINGS = "restaurantRatings"; private static final String JSON_TAG_RESTAURANT_RATINGS = "restaurantRatings";
private static final String JSON_TAG_RESTAURANT_RATING_GRADE = "rating_grade"; private static final String JSON_TAG_RESTAURANT_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_RESTAURANT_RATING_USER_ID = "user_id";
private static final String JSON_TAG_RESTAURANT_RATING_USERNAME = "username"; private static final String JSON_TAG_RESTAURANT_RATING_USERNAME = "username";
private static final String JSON_TAG_RESTAURANT_RATING_TEXT = "rating_text"; private static final String JSON_TAG_RESTAURANT_RATING_TEXT = "rating_text";
private static final String JSON_TAG_RESTAURANT_RATING_DATE = "rating_date"; private static final String JSON_TAG_RESTAURANT_RATING_DATE = "rating_date";
@ -236,9 +217,17 @@ public class ProfileActivity extends BaseActivity {
JSONArray jsonDietsFollowed = jsonProfileInfo.getJSONArray(JSON_TAG_PROFILE_DIETS_FOLLOWED); JSONArray jsonDietsFollowed = jsonProfileInfo.getJSONArray(JSON_TAG_PROFILE_DIETS_FOLLOWED);
for (int dietIndex = 0; dietIndex < jsonDietsFollowed.length(); ++dietIndex) { for (int dietIndex = 0; dietIndex < jsonDietsFollowed.length(); ++dietIndex) {
JSONObject restaurantOwned = jsonDietsFollowed.getJSONObject(dietIndex); JSONObject jsonDiet = jsonDietsFollowed.getJSONObject(dietIndex);
dietsFollowed.add(new DietSummary(restaurantOwned.getInt(JSON_TAG_PROFILE_DIET_FOLLOWED_ID), dietsFollowed.add(new DietSummary(jsonDiet.getInt(JSON_TAG_PROFILE_DIET_FOLLOWED_ID),
restaurantOwned.getString(JSON_TAG_PROFILE_DIET_FOLLOWED_NAME))); jsonDiet.getString(JSON_TAG_PROFILE_DIET_FOLLOWED_NAME)));
}
ArrayList<IngredientSummary> ingredientsProhibited = new ArrayList<>();
JSONArray jsonIngredientsProhibited = jsonProfileInfo.getJSONArray(JSON_TAG_PROFILE_INGREDIENTS_PROHIBITED);
for (int ingredientIndex = 0; ingredientIndex < jsonIngredientsProhibited.length(); ++ingredientIndex) {
JSONObject jsonIngredient = jsonIngredientsProhibited.getJSONObject(ingredientIndex);
ingredientsProhibited.add(new IngredientSummary(jsonIngredient.getString(JSON_TAG_PROFILE_INGREDIENTS_PROHIBITED_NAME)));
} }
profileUserView = new Profile(profileID, profileUserView = new Profile(profileID,
@ -247,12 +236,14 @@ public class ProfileActivity extends BaseActivity {
jsonProfileInfo.getString(JSON_TAG_PROFILE_USERNAME), jsonProfileInfo.getString(JSON_TAG_PROFILE_USERNAME),
jsonProfileInfo.getString(JSON_TAG_PROFILE_EMAIL), jsonProfileInfo.getString(JSON_TAG_PROFILE_EMAIL),
restaurantsOwned, restaurantsOwned,
dietsFollowed); dietsFollowed,
ingredientsProhibited);
JSONArray jsonFoodRatings = jsonResponse.getJSONArray(JSON_TAG_FOOD_RATINGS); JSONArray jsonFoodRatings = jsonResponse.getJSONArray(JSON_TAG_FOOD_RATINGS);
for (int ratingIndex = 0; ratingIndex < jsonFoodRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonFoodRatings.length(); ++ratingIndex) {
JSONObject rating = jsonFoodRatings.getJSONObject(ratingIndex); JSONObject rating = jsonFoodRatings.getJSONObject(ratingIndex);
foodRatings.add(new ItemRating(rating.getInt(JSON_TAG_FOOD_RATING_GRADE), foodRatings.add(new ItemRating(rating.getInt(JSON_TAG_FOOD_RATING_GRADE),
rating.getInt(JSON_TAG_FOOD_RATING_USER_ID),
rating.getString(JSON_TAG_FOOD_RATING_USERNAME), rating.getString(JSON_TAG_FOOD_RATING_USERNAME),
rating.getString(JSON_TAG_FOOD_RATING_TEXT), rating.getString(JSON_TAG_FOOD_RATING_TEXT),
rating.getString(JSON_TAG_FOOD_RATING_DATE), rating.getString(JSON_TAG_FOOD_RATING_DATE),
@ -264,6 +255,7 @@ public class ProfileActivity extends BaseActivity {
for (int ratingIndex = 0; ratingIndex < jsonDrinkRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonDrinkRatings.length(); ++ratingIndex) {
JSONObject rating = jsonDrinkRatings.getJSONObject(ratingIndex); JSONObject rating = jsonDrinkRatings.getJSONObject(ratingIndex);
drinkRatings.add(new ItemRating(rating.getInt(JSON_TAG_DRINK_RATING_GRADE), drinkRatings.add(new ItemRating(rating.getInt(JSON_TAG_DRINK_RATING_GRADE),
rating.getInt(JSON_TAG_DRINK_RATING_USER_ID),
rating.getString(JSON_TAG_DRINK_RATING_USERNAME), rating.getString(JSON_TAG_DRINK_RATING_USERNAME),
rating.getString(JSON_TAG_DRINK_RATING_TEXT), rating.getString(JSON_TAG_DRINK_RATING_TEXT),
rating.getString(JSON_TAG_DRINK_RATING_DATE), rating.getString(JSON_TAG_DRINK_RATING_DATE),
@ -275,6 +267,7 @@ public class ProfileActivity extends BaseActivity {
for (int ratingIndex = 0; ratingIndex < jsonRestaurantRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonRestaurantRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRestaurantRatings.getJSONObject(ratingIndex); JSONObject rating = jsonRestaurantRatings.getJSONObject(ratingIndex);
restaurantRatings.add(new RestaurantRating(rating.getInt(JSON_TAG_RESTAURANT_RATING_GRADE), restaurantRatings.add(new RestaurantRating(rating.getInt(JSON_TAG_RESTAURANT_RATING_GRADE),
rating.getInt(JSON_TAG_RESTAURANT_RATING_USER_ID),
rating.getString(JSON_TAG_RESTAURANT_RATING_USERNAME), rating.getString(JSON_TAG_RESTAURANT_RATING_USERNAME),
rating.getString(JSON_TAG_RESTAURANT_RATING_TEXT), rating.getString(JSON_TAG_RESTAURANT_RATING_TEXT),
rating.getString(JSON_TAG_RESTAURANT_RATING_DATE), rating.getString(JSON_TAG_RESTAURANT_RATING_DATE),

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java

@ -48,7 +48,7 @@ public class ProfileDrinkRatingsFragment extends Fragment {
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, drinkRatings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, drinkRatings, null);
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());

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java

@ -47,7 +47,7 @@ public class ProfileFoodRatingsFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, foodRatings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, foodRatings, null);
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());

39
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java

@ -13,8 +13,10 @@ import androidx.fragment.app.Fragment;
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.BaseApplication;
import gr.auth.databases.flavours.model.DietSummary; import gr.auth.databases.flavours.model.DietSummary;
import gr.auth.databases.flavours.model.IngredientSummary;
import gr.auth.databases.flavours.model.Profile; import gr.auth.databases.flavours.model.Profile;
import gr.auth.databases.flavours.utils.FollowDietStateTask; import gr.auth.databases.flavours.utils.FollowDietStateTask;
import gr.auth.databases.flavours.utils.ProhibitIngredientStateTask;
public class ProfileInfoFragment extends Fragment { public class ProfileInfoFragment extends Fragment {
@ -23,13 +25,16 @@ public class ProfileInfoFragment extends Fragment {
} }
private static final String PROFILE_INFO = "PROFILE_INFO"; private static final String PROFILE_INFO = "PROFILE_INFO";
private static final String PROFILE_IS_ME = "PROFILE_IS_ME";
private Profile profileUserView; private Profile profileUserView;
private boolean isMe = false;
public static ProfileInfoFragment newInstance(Profile profileUserView) { public static ProfileInfoFragment newInstance(Profile profileUserView, boolean isMe) {
ProfileInfoFragment fragment = new ProfileInfoFragment(); ProfileInfoFragment fragment = new ProfileInfoFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(PROFILE_INFO, profileUserView); args.putParcelable(PROFILE_INFO, profileUserView);
args.putBoolean(PROFILE_IS_ME, isMe);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -39,6 +44,7 @@ public class ProfileInfoFragment extends Fragment {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
profileUserView = getArguments().getParcelable(PROFILE_INFO); profileUserView = getArguments().getParcelable(PROFILE_INFO);
isMe = getArguments().getBoolean(PROFILE_IS_ME);
} }
@Override @Override
@ -88,6 +94,7 @@ public class ProfileInfoFragment extends Fragment {
dietName.setText(dietFollowed.getName()); dietName.setText(dietFollowed.getName());
AppCompatImageButton removeDiet = userDietRow.findViewById(R.id.profile_diet_remove); AppCompatImageButton removeDiet = userDietRow.findViewById(R.id.profile_diet_remove);
if (isMe) {
removeDiet.setVisibility(View.VISIBLE); removeDiet.setVisibility(View.VISIBLE);
removeDiet.setOnClickListener(new View.OnClickListener() { removeDiet.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -97,11 +104,41 @@ public class ProfileInfoFragment extends Fragment {
dietsList.removeView(userDietRow); dietsList.removeView(userDietRow);
} }
}); });
}
dietsList.addView(userDietRow); dietsList.addView(userDietRow);
} }
} }
if (!profileUserView.getIngredientsProhibited().isEmpty()) {
(rootView.findViewById(R.id.profile_ingredients_list_title)).setVisibility(View.VISIBLE);
final LinearLayout ingredientsList = rootView.findViewById(R.id.profile_ingredients_list);
ingredientsList.setVisibility(View.VISIBLE);
for (final IngredientSummary ingredientProhibited : profileUserView.getIngredientsProhibited()) {
final View userIngredientRow = getLayoutInflater().inflate(R.layout.profile_ingredient_row, ingredientsList, false);
TextView ingredientName = userIngredientRow.findViewById(R.id.profile_ingredient_name);
ingredientName.setText(ingredientProhibited.getName());
AppCompatImageButton removeDiet = userIngredientRow.findViewById(R.id.profile_ingredient_remove);
if (isMe) {
removeDiet.setVisibility(View.VISIBLE);
removeDiet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ProhibitIngredientStateTask prohibitIngredientStateTask = new ProhibitIngredientStateTask(BaseApplication.getInstance().getClient());
prohibitIngredientStateTask.execute(ingredientProhibited.getName());
ingredientsList.removeView(userIngredientRow);
}
});
}
ingredientsList.addView(userIngredientRow);
}
}
return rootView; return rootView;
} }
} }

3
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java

@ -47,7 +47,8 @@ public class ProfileRestaurantRatingsFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, restaurantRatings); RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, restaurantRatings,
null);
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());

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

@ -230,6 +230,7 @@ public class RestaurantActivity extends BaseActivity
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";
private static final String JSON_TAG_RESTAURANT_RATING_USER_ID = "user_id";
private static final String JSON_TAG_RESTAURANT_RATING_USERNAME = "username"; private static final String JSON_TAG_RESTAURANT_RATING_USERNAME = "username";
private static final String JSON_TAG_RESTAURANT_RATING_TEXT = "rating_text"; private static final String JSON_TAG_RESTAURANT_RATING_TEXT = "rating_text";
private static final String JSON_TAG_RESTAURANT_RATING_DATE = "rating_date"; private static final String JSON_TAG_RESTAURANT_RATING_DATE = "rating_date";
@ -306,6 +307,7 @@ public class RestaurantActivity extends BaseActivity
for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) { for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRatings.getJSONObject(ratingIndex); JSONObject rating = jsonRatings.getJSONObject(ratingIndex);
ratings.add(new RestaurantRating(rating.getInt(JSON_TAG_RESTAURANT_RATING_GRADE), ratings.add(new RestaurantRating(rating.getInt(JSON_TAG_RESTAURANT_RATING_GRADE),
rating.getInt(JSON_TAG_RESTAURANT_RATING_USER_ID),
rating.getString(JSON_TAG_RESTAURANT_RATING_USERNAME), rating.getString(JSON_TAG_RESTAURANT_RATING_USERNAME),
rating.getString(JSON_TAG_RESTAURANT_RATING_TEXT), rating.getString(JSON_TAG_RESTAURANT_RATING_TEXT),
rating.getString(JSON_TAG_RESTAURANT_RATING_DATE), rating.getString(JSON_TAG_RESTAURANT_RATING_DATE),

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

@ -1,6 +1,7 @@
package gr.auth.databases.flavours.activities.restaurant.fragments; package gr.auth.databases.flavours.activities.restaurant.fragments;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration;
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.activities.profile.ProfileActivity;
import gr.auth.databases.flavours.model.RestaurantRating; import gr.auth.databases.flavours.model.RestaurantRating;
import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter; import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter;
public class RestaurantRatingsFragment extends Fragment { import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_ID;
import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_NAME;
public class RestaurantRatingsFragment extends Fragment implements
RestaurantRatingsAdapter.ProfileRestaurantRatingsAdapterInteractionListener {
public RestaurantRatingsFragment() { public RestaurantRatingsFragment() {
// Required empty public constructor // Required empty public constructor
@ -47,7 +53,7 @@ public class RestaurantRatingsFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings); RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings, 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());
@ -58,4 +64,14 @@ public class RestaurantRatingsFragment extends Fragment {
return rootView; return rootView;
} }
@Override
public void onProfileRestaurantRatingsAdapterInteraction(int profileID, String profileUsername) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
Bundle extras = new Bundle();
extras.putInt(BUNDLE_USER_ID, profileID);
extras.putString(BUNDLE_USER_NAME, profileUsername);
intent.putExtras(extras);
startActivity(intent);
}
} }

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

@ -59,8 +59,8 @@ public class ItemRating extends Rating {
private PortionSize portionSize; private PortionSize portionSize;
public ItemRating(int grade, String username, String text, String date, PortionSize portionSize) { public ItemRating(int grade, int userID, String username, String text, String date, PortionSize portionSize) {
super(grade, username, text, date); super(grade, userID, username, text, date);
this.portionSize = portionSize; this.portionSize = portionSize;
} }

11
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Profile.java

@ -10,9 +10,11 @@ public class Profile implements Parcelable {
private String username, email; private String username, email;
private ArrayList<RestaurantSummary> restaurantsOwned; private ArrayList<RestaurantSummary> restaurantsOwned;
private ArrayList<DietSummary> dietsFollowed; private ArrayList<DietSummary> dietsFollowed;
private ArrayList<IngredientSummary> ingredientsProhibited;
public Profile(int id, int age, int reviewsNumber, String username, String email, public Profile(int id, int age, int reviewsNumber, String username, String email,
ArrayList<RestaurantSummary> restaurantsOwned, ArrayList<DietSummary> dietsFollowed) { ArrayList<RestaurantSummary> restaurantsOwned, ArrayList<DietSummary> dietsFollowed,
ArrayList<IngredientSummary> ingredientsProhibited) {
this.id = id; this.id = id;
this.age = age; this.age = age;
this.reviewsNumber = reviewsNumber; this.reviewsNumber = reviewsNumber;
@ -20,6 +22,7 @@ public class Profile implements Parcelable {
this.email = email; this.email = email;
this.restaurantsOwned = restaurantsOwned; this.restaurantsOwned = restaurantsOwned;
this.dietsFollowed = dietsFollowed; this.dietsFollowed = dietsFollowed;
this.ingredientsProhibited = ingredientsProhibited;
} }
public int getId() { public int getId() {
@ -50,6 +53,10 @@ public class Profile implements Parcelable {
return dietsFollowed; return dietsFollowed;
} }
public ArrayList<IngredientSummary> getIngredientsProhibited() {
return ingredientsProhibited;
}
@Override @Override
public int describeContents() { public int describeContents() {
return 0; return 0;
@ -64,6 +71,7 @@ public class Profile implements Parcelable {
out.writeString(email); out.writeString(email);
out.writeList(restaurantsOwned); out.writeList(restaurantsOwned);
out.writeList(dietsFollowed); out.writeList(dietsFollowed);
out.writeList(ingredientsProhibited);
} }
public static final Parcelable.Creator<Profile> CREATOR = new Parcelable.Creator<Profile>() { public static final Parcelable.Creator<Profile> CREATOR = new Parcelable.Creator<Profile>() {
@ -84,5 +92,6 @@ public class Profile implements Parcelable {
email = in.readString(); email = in.readString();
restaurantsOwned = (ArrayList<RestaurantSummary>) in.readArrayList(DietRatingPair.class.getClassLoader()); restaurantsOwned = (ArrayList<RestaurantSummary>) in.readArrayList(DietRatingPair.class.getClassLoader());
dietsFollowed = (ArrayList<DietSummary>) in.readArrayList(DietRatingPair.class.getClassLoader()); dietsFollowed = (ArrayList<DietSummary>) in.readArrayList(DietRatingPair.class.getClassLoader());
ingredientsProhibited = (ArrayList<IngredientSummary>) in.readArrayList(DietRatingPair.class.getClassLoader());
} }
} }

11
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java

@ -4,11 +4,12 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class Rating implements Parcelable { public class Rating implements Parcelable {
private int grade; private int grade, userID;
private String username, text, date; private String username, text, date;
Rating(int grade, String username, String text, String date) { Rating(int grade, int userID, String username, String text, String date) {
this.grade = grade; this.grade = grade;
this.userID = userID;
this.username = username; this.username = username;
this.text = text; this.text = text;
this.date = date; this.date = date;
@ -18,6 +19,10 @@ public class Rating implements Parcelable {
return grade; return grade;
} }
public int getUserID() {
return userID;
}
public String getUsername() { public String getUsername() {
return username; return username;
} }
@ -38,6 +43,7 @@ public class Rating implements Parcelable {
@Override @Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(grade); out.writeInt(grade);
out.writeInt(userID);
out.writeString(username); out.writeString(username);
out.writeString(text); out.writeString(text);
out.writeString(date); out.writeString(date);
@ -55,6 +61,7 @@ public class Rating implements Parcelable {
Rating(Parcel in) { Rating(Parcel in) {
grade = in.readInt(); grade = in.readInt();
userID = in.readInt();
username = in.readString(); username = in.readString();
text = in.readString(); text = in.readString();
date = in.readString(); date = in.readString();

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

@ -62,8 +62,8 @@ public class RestaurantRating extends Rating {
private Accessibility accessibility; private Accessibility accessibility;
private String diet; private String diet;
public RestaurantRating(int grade, String username, String text, String date, Accessibility accessibility, String diet) { public RestaurantRating(int grade, int userID, String username, String text, String date, Accessibility accessibility, String diet) {
super(grade, username, text, date); super(grade, userID, username, text, date);
this.accessibility = accessibility; this.accessibility = accessibility;
this.diet = diet; this.diet = diet;
} }

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

@ -70,6 +70,8 @@ public class SessionManager {
public static final String followDietUrl = baseServerUrl + "api/followDiet/"; public static final String followDietUrl = baseServerUrl + "api/followDiet/";
public static final String addIngredientUrl = baseServerUrl + "api/ingredient/"; public static final String addIngredientUrl = baseServerUrl + "api/ingredient/";
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 addIngredientToDrinkUrl = baseServerUrl + "api/drinkhasingredient/";
// Client & Cookies // Client & Cookies
private final OkHttpClient client; private final OkHttpClient client;

22
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java

@ -16,10 +16,13 @@ import gr.auth.databases.flavours.model.ItemRating;
public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.RatingViewHolder> { public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.RatingViewHolder> {
private Context context; private Context context;
private ArrayList<ItemRating> ratings; private ArrayList<ItemRating> ratings;
private ProfileItemRatingsAdapterInteractionListener profileItemRatingsAdapterInteractionListener;
public ItemRatingsAdapter(@NonNull Context context, ArrayList<ItemRating> ratings) { public ItemRatingsAdapter(@NonNull Context context, ArrayList<ItemRating> ratings,
ProfileItemRatingsAdapterInteractionListener profileItemRatingsAdapterInteractionListener) {
this.context = context; this.context = context;
this.ratings = ratings; this.ratings = ratings;
this.profileItemRatingsAdapterInteractionListener = profileItemRatingsAdapterInteractionListener;
} }
@NonNull @NonNull
@ -32,8 +35,19 @@ public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.
} }
@Override @Override
public void onBindViewHolder(@NonNull RatingViewHolder holder, int position) { public void onBindViewHolder(@NonNull final RatingViewHolder holder, int position) {
holder.authorUsername.setText(ratings.get(position).getUsername()); holder.authorUsername.setText(ratings.get(position).getUsername());
if (profileItemRatingsAdapterInteractionListener != null) {
holder.authorUsername.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
profileItemRatingsAdapterInteractionListener.
onProfileItemRatingsAdapterInteraction(
ratings.get(holder.getAdapterPosition()).getUserID(),
ratings.get(holder.getAdapterPosition()).getUsername());
}
});
}
holder.date.setText(ratings.get(position).getDate()); holder.date.setText(ratings.get(position).getDate());
holder.grade.setText(context.getString(R.string.item_ratings_row_grade_placeholder, holder.grade.setText(context.getString(R.string.item_ratings_row_grade_placeholder,
@ -72,4 +86,8 @@ public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.
text = v.findViewById(R.id.item__rating_text); text = v.findViewById(R.id.item__rating_text);
} }
} }
public interface ProfileItemRatingsAdapterInteractionListener {
void onProfileItemRatingsAdapterInteraction(int profileID, String profileUsername);
}
} }

45
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ProhibitIngredientStateTask.java

@ -0,0 +1,45 @@
package gr.auth.databases.flavours.utils;
import android.os.AsyncTask;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import static gr.auth.databases.flavours.session.SessionManager.prohibitIngredientUrl;
public class ProhibitIngredientStateTask extends AsyncTask<String, Void, Integer> {
private OkHttpClient client;
public ProhibitIngredientStateTask(OkHttpClient client) {
this.client = client;
}
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(String... params) {
RequestBody requestBody = RequestBody.create(null, new byte[]{});
//Builds the request
Request request = new Request.Builder()
.patch(requestBody)
.url(prohibitIngredientUrl + params[0] + "/")
.build();
try {
//Makes request & handles response
client.newCall(request).execute();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
}
}

22
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java

@ -16,10 +16,13 @@ import gr.auth.databases.flavours.model.RestaurantRating;
public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRatingsAdapter.RatingViewHolder> { public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRatingsAdapter.RatingViewHolder> {
private Context context; private Context context;
private ArrayList<RestaurantRating> ratings; private ArrayList<RestaurantRating> ratings;
private ProfileRestaurantRatingsAdapterInteractionListener profileRestaurantRatingsAdapterInteractionListener;
public RestaurantRatingsAdapter(@NonNull Context context, ArrayList<RestaurantRating> ratings) { public RestaurantRatingsAdapter(@NonNull Context context, ArrayList<RestaurantRating> ratings,
ProfileRestaurantRatingsAdapterInteractionListener profileRestaurantRatingsAdapterInteractionListener) {
this.context = context; this.context = context;
this.ratings = ratings; this.ratings = ratings;
this.profileRestaurantRatingsAdapterInteractionListener = profileRestaurantRatingsAdapterInteractionListener;
} }
@NonNull @NonNull
@ -32,8 +35,19 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRat
} }
@Override @Override
public void onBindViewHolder(@NonNull RatingViewHolder holder, int position) { public void onBindViewHolder(@NonNull final RatingViewHolder holder, int position) {
holder.username.setText(ratings.get(position).getUsername()); holder.username.setText(ratings.get(position).getUsername());
if (profileRestaurantRatingsAdapterInteractionListener != null) {
holder.username.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
profileRestaurantRatingsAdapterInteractionListener.
onProfileRestaurantRatingsAdapterInteraction(
ratings.get(holder.getAdapterPosition()).getUserID(),
ratings.get(holder.getAdapterPosition()).getUsername());
}
});
}
holder.date.setText(ratings.get(position).getDate()); holder.date.setText(ratings.get(position).getDate());
holder.grade.setText(context.getString(R.string.restaurant_ratings_row_grade_placeholder, holder.grade.setText(context.getString(R.string.restaurant_ratings_row_grade_placeholder,
@ -83,4 +97,8 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRat
text = v.findViewById(R.id.restaurant_rating_text); text = v.findViewById(R.id.restaurant_rating_text);
} }
} }
public interface ProfileRestaurantRatingsAdapterInteractionListener {
void onProfileRestaurantRatingsAdapterInteraction(int profileID, String profileUsername);
}
} }

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
@ -25,6 +24,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorBackground"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_ingredient.xml

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
@ -25,6 +24,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorBackground"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml

@ -3,7 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
@ -25,6 +24,7 @@
android:id="@+id/diets_list" android:id="@+id/diets_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorBackground"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml

@ -3,7 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
@ -25,6 +24,7 @@
android:id="@+id/ingredients_list" android:id="@+id/ingredients_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorBackground"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

@ -39,14 +39,4 @@
app:layout_anchor="@id/profile_appbar" app:layout_anchor="@id/profile_appbar"
app:layout_anchorGravity="bottom|start" app:layout_anchorGravity="bottom|start"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/profile_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> </androidx.coordinatorlayout.widget.CoordinatorLayout>

15
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml

@ -49,5 +49,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" /> android:visibility="gone" />
<TextView
android:id="@+id/profile_ingredients_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_ingredients_list_title"
android:textStyle="bold"
android:visibility="gone" />
<LinearLayout
android:id="@+id/profile_ingredients_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

25
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_ingredient_row.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profile_ingredient_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:orientation="horizontal">
<TextView
android:id="@+id/profile_ingredient_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:text="@string/ingredient_name" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/profile_ingredient_remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete_black_18dp"
android:visibility="gone" />
</LinearLayout>

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

@ -94,7 +94,8 @@
<string name="profile_number_of_reviews_placeholder">Number of reviews submitted: %1$d</string> <string name="profile_number_of_reviews_placeholder">Number of reviews submitted: %1$d</string>
<string name="profile_owns_restaurant">Owns restaurant</string> <string name="profile_owns_restaurant">Owns restaurant</string>
<string name="profile_owns_restaurant_placeholder">Owns the restaurant: %1$s</string> <string name="profile_owns_restaurant_placeholder">Owns the restaurant: %1$s</string>
<string name="profile_diet_list_title">Diets:</string> <string name="profile_diet_list_title">Diets followed:</string>
<string name="profile_ingredients_list_title">Ingredients prohibited:</string>
<!-- Diets --> <!-- Diets -->
<string name="diets_toolbar_title">Diets</string> <string name="diets_toolbar_title">Diets</string>

Loading…
Cancel
Save