diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java index f71279f..9fe81c1 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java +++ b/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.ItemRating; import gr.auth.databases.flavours.model.ItemSummary; +import okhttp3.FormBody; import okhttp3.Request; +import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; 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.session.SessionManager.addIngredientToDrinkUrl; import static gr.auth.databases.flavours.session.SessionManager.drinksUserViewUrl; public class DrinkActivity extends BaseActivity { @@ -141,8 +144,8 @@ public class DrinkActivity extends BaseActivity { if (requestCode == ADD_INGREDIENT_REQUEST) { if (resultCode == Activity.RESULT_OK) { Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT); - //TODO - Toast.makeText(this, "Ingredient added and awaits approval.", Toast.LENGTH_LONG).show(); + AddIngredientToDrink addIngredientToDrink = new AddIngredientToDrink(); + 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_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_TEXT = "rating_text"; 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) { JSONObject rating = jsonRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_DRINK_RATING_DATE), @@ -274,4 +279,40 @@ public class DrinkActivity extends BaseActivity { tabLayout.setupWithViewPager(viewPager); } } + + private class AddIngredientToDrink extends AsyncTask { + 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(); + } + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java index 2faa31b..5bfa7c8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java +++ b/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; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; 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.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() { // Required empty public constructor @@ -48,7 +54,7 @@ public class DrinkRatingsFragment extends Fragment { Context context = getContext(); assert context != null; - ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings, this); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); @@ -59,4 +65,14 @@ public class DrinkRatingsFragment extends Fragment { 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); + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java index 6f006d3..03a5ea7 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java +++ b/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.ItemRating; import gr.auth.databases.flavours.model.ItemSummary; +import okhttp3.FormBody; import okhttp3.Request; +import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; 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.session.SessionManager.addIngredientToFoodUrl; import static gr.auth.databases.flavours.session.SessionManager.foodsUserViewUrl; public class FoodActivity extends BaseActivity { @@ -141,8 +144,8 @@ public class FoodActivity extends BaseActivity { if (requestCode == ADD_INGREDIENT_REQUEST) { if (resultCode == Activity.RESULT_OK) { Ingredient result = data.getParcelableExtra(INGREDIENT_PICK_RESULT); - //TODO - Toast.makeText(this, "Ingredient added and awaits approval.", Toast.LENGTH_LONG).show(); + AddIngredientToFood addIngredientToFood = new AddIngredientToFood(); + 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_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_TEXT = "rating_text"; 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) { JSONObject rating = jsonRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_FOOD_RATING_DATE), @@ -274,4 +279,40 @@ public class FoodActivity extends BaseActivity { tabLayout.setupWithViewPager(viewPager); } } + + private class AddIngredientToFood extends AsyncTask { + 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(); + } + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java index fe8c4e5..d4becb4 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java +++ b/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; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; 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.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() { // Required empty public constructor @@ -48,7 +54,7 @@ public class FoodRatingsFragment extends Fragment { Context context = getContext(); assert context != null; - ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings, this); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); @@ -59,4 +65,14 @@ public class FoodRatingsFragment extends Fragment { 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); + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/ingredients/IngredientsActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/ingredients/IngredientsActivity.java index 248986c..1e3f1cf 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/ingredients/IngredientsActivity.java +++ b/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.base.BaseActivity; import gr.auth.databases.flavours.model.Ingredient; +import gr.auth.databases.flavours.utils.ProhibitIngredientStateTask; import okhttp3.Request; -import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; 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.prohibitIngredientUrl; public class IngredientsActivity extends BaseActivity implements IngredientsAdapter.SubscribeIngredientsAdapterInteractionListener, @@ -41,7 +40,6 @@ public class IngredientsActivity extends BaseActivity private RecyclerView recyclerView; private ArrayList userProhibitsIngredients; private boolean isCalledForResult; - private FloatingActionButton FAB; private ArrayList ingredients = new ArrayList<>(); private IngredientsAdapter ingredientsAdapter; @@ -62,7 +60,7 @@ public class IngredientsActivity extends BaseActivity createDrawer(); - FAB = findViewById(R.id.ingredients_fab); + FloatingActionButton FAB = findViewById(R.id.ingredients_fab); FAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -114,7 +112,7 @@ public class IngredientsActivity extends BaseActivity @Override public void onSubscribeIngredientsAdapterInteraction(Ingredient ingredient) { - ProhibitIngredientStateTask prohibitIngredientStateTask = new ProhibitIngredientStateTask(); + ProhibitIngredientStateTask prohibitIngredientStateTask = new ProhibitIngredientStateTask(client); prohibitIngredientStateTask.execute(ingredient.getName()); } @@ -204,34 +202,4 @@ public class IngredientsActivity extends BaseActivity recyclerView.setAdapter(ingredientsAdapter); } } - - private class ProhibitIngredientStateTask extends AsyncTask { - @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) { - } - } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java index 121025e..1f3deae 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java @@ -310,8 +310,12 @@ public class MainActivity extends BaseActivity { StringBuilder requestUrl = new StringBuilder(restaurantsUrl); if (!mSelectedRestaurantTypes.isEmpty()) { 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)); + if (selectedTypeIndex < mSelectedRestaurantTypes.size() - 1) { + requestUrl.append(","); + } } } if (maxDistance != -1) { @@ -348,6 +352,10 @@ public class MainActivity extends BaseActivity { requestUrl.append("filter_restaurant_calories=").append(maxCalories); } + mSelectedRestaurantTypes.clear(); + maxDistance = -1; + maxCalories = -1; + //Builds the request Request request = new Request.Builder() .url(requestUrl.toString()) diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java index d4a285a..503f5e4 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java +++ b/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.Bundle; -import android.util.Log; import android.view.MenuItem; -import android.view.View; -import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.tabs.TabLayout; 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.base.BaseActivity; 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.Profile; 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_NAME = "BUNDLE_USER_NAME"; private ViewPager viewPager; - private FloatingActionButton FAB; private int profileID; private Profile profileUserView; @@ -73,30 +70,7 @@ public class ProfileActivity extends BaseActivity { 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.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); ProfileTask profileTask = new ProfileTask(); @@ -126,7 +100,7 @@ public class ProfileActivity extends BaseActivity { private void setupViewPager(ViewPager viewPager) { 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(ProfileDrinkRatingsFragment.newInstance(drinkRatings), "DRINKS"); 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_RESTAURANT_OWNED_ID = "restaurant_id"; 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_DIET_FOLLOWED_ID = "diet_id"; 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_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_TEXT = "rating_text"; 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_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_TEXT = "rating_text"; 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_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_TEXT = "rating_text"; 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); for (int dietIndex = 0; dietIndex < jsonDietsFollowed.length(); ++dietIndex) { - JSONObject restaurantOwned = jsonDietsFollowed.getJSONObject(dietIndex); - dietsFollowed.add(new DietSummary(restaurantOwned.getInt(JSON_TAG_PROFILE_DIET_FOLLOWED_ID), - restaurantOwned.getString(JSON_TAG_PROFILE_DIET_FOLLOWED_NAME))); + JSONObject jsonDiet = jsonDietsFollowed.getJSONObject(dietIndex); + dietsFollowed.add(new DietSummary(jsonDiet.getInt(JSON_TAG_PROFILE_DIET_FOLLOWED_ID), + jsonDiet.getString(JSON_TAG_PROFILE_DIET_FOLLOWED_NAME))); + } + + ArrayList 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, @@ -247,12 +236,14 @@ public class ProfileActivity extends BaseActivity { jsonProfileInfo.getString(JSON_TAG_PROFILE_USERNAME), jsonProfileInfo.getString(JSON_TAG_PROFILE_EMAIL), restaurantsOwned, - dietsFollowed); + dietsFollowed, + ingredientsProhibited); JSONArray jsonFoodRatings = jsonResponse.getJSONArray(JSON_TAG_FOOD_RATINGS); for (int ratingIndex = 0; ratingIndex < jsonFoodRatings.length(); ++ratingIndex) { JSONObject rating = jsonFoodRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_FOOD_RATING_DATE), @@ -264,6 +255,7 @@ public class ProfileActivity extends BaseActivity { for (int ratingIndex = 0; ratingIndex < jsonDrinkRatings.length(); ++ratingIndex) { JSONObject rating = jsonDrinkRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_DRINK_RATING_DATE), @@ -275,6 +267,7 @@ public class ProfileActivity extends BaseActivity { for (int ratingIndex = 0; ratingIndex < jsonRestaurantRatings.length(); ++ratingIndex) { JSONObject rating = jsonRestaurantRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_RESTAURANT_RATING_DATE), diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java index 81cb020..4819f9d 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java +++ b/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(); assert context != null; - ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, drinkRatings); + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, drinkRatings, null); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java index 1bb2cdc..0f69c1c 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java +++ b/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); Context context = getContext(); assert context != null; - ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, foodRatings); + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, foodRatings, null); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java index 1268294..84c4568 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java +++ b/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.base.BaseApplication; 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.utils.FollowDietStateTask; +import gr.auth.databases.flavours.utils.ProhibitIngredientStateTask; 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_IS_ME = "PROFILE_IS_ME"; 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(); Bundle args = new Bundle(); args.putParcelable(PROFILE_INFO, profileUserView); + args.putBoolean(PROFILE_IS_ME, isMe); fragment.setArguments(args); return fragment; } @@ -39,6 +44,7 @@ public class ProfileInfoFragment extends Fragment { super.onCreate(savedInstanceState); assert getArguments() != null; profileUserView = getArguments().getParcelable(PROFILE_INFO); + isMe = getArguments().getBoolean(PROFILE_IS_ME); } @Override @@ -88,20 +94,51 @@ public class ProfileInfoFragment extends Fragment { dietName.setText(dietFollowed.getName()); AppCompatImageButton removeDiet = userDietRow.findViewById(R.id.profile_diet_remove); - removeDiet.setVisibility(View.VISIBLE); - removeDiet.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - FollowDietStateTask followDietStateTask = new FollowDietStateTask(BaseApplication.getInstance().getClient()); - followDietStateTask.execute(dietFollowed.getId()); - dietsList.removeView(userDietRow); - } - }); + if (isMe) { + removeDiet.setVisibility(View.VISIBLE); + removeDiet.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + FollowDietStateTask followDietStateTask = new FollowDietStateTask(BaseApplication.getInstance().getClient()); + followDietStateTask.execute(dietFollowed.getId()); + dietsList.removeView(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; } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java index 9870b03..3da6669 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java +++ b/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); Context context = getContext(); assert context != null; - RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, restaurantRatings); + RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, restaurantRatings, + null); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java index 74fc178..f94c393 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java @@ -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_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_TEXT = "rating_text"; 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) { JSONObject rating = jsonRatings.getJSONObject(ratingIndex); 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_TEXT), rating.getString(JSON_TAG_RESTAURANT_RATING_DATE), diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java index bf10af5..221ad8c 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java +++ b/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; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,10 +15,15 @@ import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; 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.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() { // 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); Context context = getContext(); assert context != null; - RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings); + RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings, this); RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); @@ -58,4 +64,14 @@ public class RestaurantRatingsFragment extends Fragment { 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); + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java index d7edda4..0e488e7 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java +++ b/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; - public ItemRating(int grade, String username, String text, String date, PortionSize portionSize) { - super(grade, username, text, date); + public ItemRating(int grade, int userID, String username, String text, String date, PortionSize portionSize) { + super(grade, userID, username, text, date); this.portionSize = portionSize; } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Profile.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Profile.java index e10be28..211187c 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Profile.java +++ b/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 ArrayList restaurantsOwned; private ArrayList dietsFollowed; + private ArrayList ingredientsProhibited; public Profile(int id, int age, int reviewsNumber, String username, String email, - ArrayList restaurantsOwned, ArrayList dietsFollowed) { + ArrayList restaurantsOwned, ArrayList dietsFollowed, + ArrayList ingredientsProhibited) { this.id = id; this.age = age; this.reviewsNumber = reviewsNumber; @@ -20,6 +22,7 @@ public class Profile implements Parcelable { this.email = email; this.restaurantsOwned = restaurantsOwned; this.dietsFollowed = dietsFollowed; + this.ingredientsProhibited = ingredientsProhibited; } public int getId() { @@ -50,6 +53,10 @@ public class Profile implements Parcelable { return dietsFollowed; } + public ArrayList getIngredientsProhibited() { + return ingredientsProhibited; + } + @Override public int describeContents() { return 0; @@ -64,6 +71,7 @@ public class Profile implements Parcelable { out.writeString(email); out.writeList(restaurantsOwned); out.writeList(dietsFollowed); + out.writeList(ingredientsProhibited); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @@ -84,5 +92,6 @@ public class Profile implements Parcelable { email = in.readString(); restaurantsOwned = (ArrayList) in.readArrayList(DietRatingPair.class.getClassLoader()); dietsFollowed = (ArrayList) in.readArrayList(DietRatingPair.class.getClassLoader()); + ingredientsProhibited = (ArrayList) in.readArrayList(DietRatingPair.class.getClassLoader()); } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java index 3b02b5c..42608c8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java @@ -4,11 +4,12 @@ import android.os.Parcel; import android.os.Parcelable; public class Rating implements Parcelable { - private int grade; + private int grade, userID; 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.userID = userID; this.username = username; this.text = text; this.date = date; @@ -18,6 +19,10 @@ public class Rating implements Parcelable { return grade; } + public int getUserID() { + return userID; + } + public String getUsername() { return username; } @@ -38,6 +43,7 @@ public class Rating implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeInt(grade); + out.writeInt(userID); out.writeString(username); out.writeString(text); out.writeString(date); @@ -55,6 +61,7 @@ public class Rating implements Parcelable { Rating(Parcel in) { grade = in.readInt(); + userID = in.readInt(); username = in.readString(); text = in.readString(); date = in.readString(); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantRating.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantRating.java index c9c25eb..d4d7288 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/RestaurantRating.java +++ b/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 String diet; - public RestaurantRating(int grade, String username, String text, String date, Accessibility accessibility, String diet) { - super(grade, username, text, date); + public RestaurantRating(int grade, int userID, String username, String text, String date, Accessibility accessibility, String diet) { + super(grade, userID, username, text, date); this.accessibility = accessibility; this.diet = diet; } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java index dccb39e..a851e4d 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java +++ b/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 addIngredientUrl = baseServerUrl + "api/ingredient/"; 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 private final OkHttpClient client; diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java index 98853b4..0a9b9d5 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java +++ b/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 { private Context context; private ArrayList ratings; + private ProfileItemRatingsAdapterInteractionListener profileItemRatingsAdapterInteractionListener; - public ItemRatingsAdapter(@NonNull Context context, ArrayList ratings) { + public ItemRatingsAdapter(@NonNull Context context, ArrayList ratings, + ProfileItemRatingsAdapterInteractionListener profileItemRatingsAdapterInteractionListener) { this.context = context; this.ratings = ratings; + this.profileItemRatingsAdapterInteractionListener = profileItemRatingsAdapterInteractionListener; } @NonNull @@ -32,8 +35,19 @@ public class ItemRatingsAdapter extends RecyclerView.Adapter { + 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) { + } +} \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java index 2bccfb7..211f0b0 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java +++ b/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 { private Context context; private ArrayList ratings; + private ProfileRestaurantRatingsAdapterInteractionListener profileRestaurantRatingsAdapterInteractionListener; - public RestaurantRatingsAdapter(@NonNull Context context, ArrayList ratings) { + public RestaurantRatingsAdapter(@NonNull Context context, ArrayList ratings, + ProfileRestaurantRatingsAdapterInteractionListener profileRestaurantRatingsAdapterInteractionListener) { this.context = context; this.ratings = ratings; + this.profileRestaurantRatingsAdapterInteractionListener = profileRestaurantRatingsAdapterInteractionListener; } @NonNull @@ -32,8 +35,19 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml index 0ac0827..267cfbc 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_ingredients.xml @@ -3,7 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml index 70bda49..d40d78a 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml @@ -39,14 +39,4 @@ app:layout_anchor="@id/profile_appbar" app:layout_anchorGravity="bottom|start" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> - - \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml index 9463dc3..34b8fcc 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml @@ -49,5 +49,20 @@ android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone" /> + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_ingredient_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_ingredient_row.xml new file mode 100644 index 0000000..b9215cd --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_ingredient_row.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml index 4b8cdbe..b8e05e2 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml @@ -94,7 +94,8 @@ Number of reviews submitted: %1$d Owns restaurant Owns the restaurant: %1$s - Diets: + Diets followed: + Ingredients prohibited: Diets