From b144e3251a7131c31991bd03a10883a4850eeb33 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 2 Jan 2019 17:34:10 +0200 Subject: [PATCH] Add ProfileActivity, Minor fixes --- .../app/src/main/AndroidManifest.xml | 1 + .../drink/fragments/DrinkInfoFragment.java | 6 +- .../food/fragments/FoodInfoFragment.java | 6 +- .../activities/profile/ProfileActivity.java | 136 ++++++++++++++++++ .../ProfileDrinkRatingsFragment.java | 71 +++++++++ .../fragments/ProfileFoodRatingsFragment.java | 71 +++++++++ .../fragments/ProfileInfoFragment.java | 76 ++++++++++ .../ProfileRestaurantRatingsFragment.java | 71 +++++++++ .../restaurant/RestaurantActivity.java | 1 - .../fragments/RestaurantRatingsFragment.java | 6 +- .../databases/flavours/base/BaseActivity.java | 37 +++-- .../flavours/utils/IngredientItemAdapter.java | 2 +- .../flavours/utils/ItemRatingsAdapter.java | 4 +- .../RestaurantRatingsAdapter.java | 8 +- .../src/main/res/layout/activity_profile.xml | 52 +++++++ .../main/res/layout/fragment_drink_info.xml | 12 +- .../main/res/layout/fragment_food_info.xml | 12 +- .../main/res/layout/fragment_profile_info.xml | 54 +++++++ .../src/main/res/layout/ingredient_row.xml | 4 +- .../src/main/res/layout/profile_diet_row.xml | 25 ++++ .../app/src/main/res/values/strings.xml | 53 ++++--- 21 files changed, 655 insertions(+), 53 deletions(-) create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java rename UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/{activities/restaurant/fragments => utils}/RestaurantRatingsAdapter.java (91%) create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_row.xml diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml index 83ac49f..3872bf6 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml @@ -52,6 +52,7 @@ + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java index d0cecdc..981eea4 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java @@ -40,9 +40,11 @@ public class DrinkInfoFragment extends Fragment { final View rootView = inflater.inflate(R.layout.fragment_drink_info, container, false); TextView restaurantServing = rootView.findViewById(R.id.drink_serving_restaurant); - restaurantServing.setText(getString(R.string.drink_serving_restaurant, "Restaurant's name")); + restaurantServing.setText(getString(R.string.drink_serving_restaurant_placeholder, "Restaurant's name")); TextView hasAlcohol = rootView.findViewById(R.id.drink_contains_alcohol); - hasAlcohol.setText(getString(R.string.drink_has_alcohol, "YES")); + hasAlcohol.setText(getString(R.string.drink_has_alcohol_placeholder, "YES")); + TextView rating = rootView.findViewById(R.id.drink_rating); + rating.setText(getString(R.string.drink_rating_placeholder, 4.65)); TextView description = rootView.findViewById(R.id.drink_description); description.setText("a description"); return rootView; diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java index 5e21f5a..ab731c7 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java @@ -40,9 +40,11 @@ public class FoodInfoFragment extends Fragment { final View rootView = inflater.inflate(R.layout.fragment_food_info, container, false); TextView restaurantServing = rootView.findViewById(R.id.food_serving_restaurant); - restaurantServing.setText(getString(R.string.food_serving_restaurant, "Restaurant's name")); + restaurantServing.setText(getString(R.string.food_serving_restaurant_placeholder, "Restaurant's name")); TextView calories = rootView.findViewById(R.id.food_calories); - calories.setText(getString(R.string.food_calories, 500)); + calories.setText(getString(R.string.food_calories_placeholder, 500)); + TextView rating = rootView.findViewById(R.id.food_rating); + rating.setText(getString(R.string.food_rating_placeholder, 4.65)); TextView description = rootView.findViewById(R.id.food_description); description.setText("some awesome description"); return rootView; 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 new file mode 100644 index 0000000..b1c70dc --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java @@ -0,0 +1,136 @@ +package gr.auth.databases.flavours.activities.profile; + +import android.os.Bundle; +import android.view.MenuItem; +import android.view.View; + +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.activities.profile.fragments.ProfileDrinkRatingsFragment; +import gr.auth.databases.flavours.activities.profile.fragments.ProfileFoodRatingsFragment; +import gr.auth.databases.flavours.activities.profile.fragments.ProfileInfoFragment; +import gr.auth.databases.flavours.activities.profile.fragments.ProfileRestaurantRatingsFragment; +import gr.auth.databases.flavours.base.BaseActivity; + +public class ProfileActivity extends BaseActivity { + public static final String BUNDLE_USER_ID = "BUNDLE_USER_ID"; + private ViewPager viewPager; + private FloatingActionButton FAB; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_profile); + + Toolbar toolbar = findViewById(R.id.profile_toolbar); + toolbar.setTitle("Username"); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } + + 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(); + } + } + }); + + setupViewPager(viewPager); + TabLayout tabLayout = findViewById(R.id.profile_tabs); + tabLayout.setupWithViewPager(viewPager); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == android.R.id.home) { + drawer.openDrawer(); + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onBackPressed() { + if (drawer.isDrawerOpen()) { + drawer.closeDrawer(); + } else { + super.onBackPressed(); + } + } + + private void setupViewPager(ViewPager viewPager) { + RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager()); + adapter.addFrag(ProfileInfoFragment.newInstance(64), "INFO"); + adapter.addFrag(ProfileFoodRatingsFragment.newInstance(64), "FOODS"); + adapter.addFrag(ProfileDrinkRatingsFragment.newInstance(64), "DRINKS"); + adapter.addFrag(ProfileRestaurantRatingsFragment.newInstance(64), "PLACES"); + viewPager.setAdapter(adapter); + } + + private class RestaurantPagerAdapter extends FragmentPagerAdapter { + private final List mFragmentList = new ArrayList<>(); + private final List mFragmentTitleList = new ArrayList<>(); + + RestaurantPagerAdapter(FragmentManager manager) { + super(manager); + } + + @NonNull + @Override + public Fragment getItem(int position) { + return mFragmentList.get(position); + } + + @Override + public int getCount() { + return mFragmentList.size(); + } + + void addFrag(Fragment fragment, String title) { + mFragmentList.add(fragment); + mFragmentTitleList.add(title); + } + + @Override + public CharSequence getPageTitle(int position) { + return mFragmentTitleList.get(position); + } + } +} 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 new file mode 100644 index 0000000..ee4ae94 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java @@ -0,0 +1,71 @@ +package gr.auth.databases.flavours.activities.profile.fragments; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +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.model.ItemRating; +import gr.auth.databases.flavours.utils.ItemRatingsAdapter; + +public class ProfileDrinkRatingsFragment extends Fragment { + + public ProfileDrinkRatingsFragment() { + // Required empty public constructor + } + + private static final String PROFILE_ID = "PROFILE_ID"; + + private int profileId; + + public static ProfileDrinkRatingsFragment newInstance(int profileId) { + ProfileDrinkRatingsFragment fragment = new ProfileDrinkRatingsFragment(); + Bundle args = new Bundle(); + args.putInt(PROFILE_ID, profileId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + profileId = getArguments().getInt(PROFILE_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); + + ArrayList ratings = new ArrayList<>(); + ratings.add(new ItemRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM)); + ratings.add(new ItemRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM)); + ratings.add(new ItemRating(5, "Apostolof", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null)); + ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM)); + + Context context = getContext(); + assert context != null; + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); + mainContent.setAdapter(itemAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + mainContent.setLayoutManager(layoutManager); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(), + layoutManager.getOrientation()); + mainContent.addItemDecoration(dividerItemDecoration); + + return rootView; + } +} 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 new file mode 100644 index 0000000..fe200e6 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java @@ -0,0 +1,71 @@ +package gr.auth.databases.flavours.activities.profile.fragments; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +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.model.ItemRating; +import gr.auth.databases.flavours.utils.ItemRatingsAdapter; + +public class ProfileFoodRatingsFragment extends Fragment { + + public ProfileFoodRatingsFragment() { + // Required empty public constructor + } + + private static final String PROFILE_ID = "PROFILE_ID"; + + private int profileId; + + public static ProfileFoodRatingsFragment newInstance(int profileId) { + ProfileFoodRatingsFragment fragment = new ProfileFoodRatingsFragment(); + Bundle args = new Bundle(); + args.putInt(PROFILE_ID, profileId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + profileId = getArguments().getInt(PROFILE_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); + + ArrayList ratings = new ArrayList<>(); + ratings.add(new ItemRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM)); + ratings.add(new ItemRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM)); + ratings.add(new ItemRating(5, "Apostolof", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG)); + ratings.add(new ItemRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null)); + ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM)); + + Context context = getContext(); + assert context != null; + ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); + mainContent.setAdapter(itemAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + mainContent.setLayoutManager(layoutManager); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(), + layoutManager.getOrientation()); + mainContent.addItemDecoration(dividerItemDecoration); + + return rootView; + } +} 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 new file mode 100644 index 0000000..a3a8c1c --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java @@ -0,0 +1,76 @@ +package gr.auth.databases.flavours.activities.profile.fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.fragment.app.Fragment; +import gr.auth.databases.flavours.R; + +public class ProfileInfoFragment extends Fragment { + + public ProfileInfoFragment() { + // Required empty public constructor + } + + private static final String PROFILE_ID = "PROFILE_ID"; + + private int profileId; + + public static ProfileInfoFragment newInstance(int profileId) { + ProfileInfoFragment fragment = new ProfileInfoFragment(); + Bundle args = new Bundle(); + args.putInt(PROFILE_ID, profileId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + profileId = getArguments().getInt(PROFILE_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_profile_info, container, false); + + TextView email = rootView.findViewById(R.id.profile_email); + email.setText(getString(R.string.profile_email_placeholder, "apotwohd@gmail.com")); + TextView age = rootView.findViewById(R.id.profile_age); + age.setText(getString(R.string.profile_age_placeholder, 23)); + + TextView numberOfRatings = rootView.findViewById(R.id.profile_number_of_reviews); + numberOfRatings.setText(getString(R.string.profile_number_of_reviews_placeholder, 52)); + numberOfRatings.setVisibility(View.VISIBLE); + TextView ownsRestaurant = rootView.findViewById(R.id.profile_owns_restaurant); + ownsRestaurant.setText(getString(R.string.profile_owns_restaurant_placeholder, "Κανένα :(")); + ownsRestaurant.setVisibility(View.VISIBLE); + + (rootView.findViewById(R.id.profile_diets_list_title)).setVisibility(View.VISIBLE); + + LinearLayout dietsList = rootView.findViewById(R.id.profile_diets_list); + dietsList.setVisibility(View.VISIBLE); + View userDietRow = getLayoutInflater().inflate(R.layout.profile_diet_row, dietsList, false); + + TextView dietName = userDietRow.findViewById(R.id.profile_diet_name); + dietName.setText("Όγκος φυσικά"); + AppCompatImageButton removeDiet = userDietRow.findViewById(R.id.profile_diet_remove); + removeDiet.setVisibility(View.VISIBLE); + removeDiet.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //TODO + } + }); + + dietsList.addView(userDietRow); + 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 new file mode 100644 index 0000000..798ea8d --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java @@ -0,0 +1,71 @@ +package gr.auth.databases.flavours.activities.profile.fragments; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +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.model.RestaurantRating; +import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter; + +public class ProfileRestaurantRatingsFragment extends Fragment { + + public ProfileRestaurantRatingsFragment() { + // Required empty public constructor + } + + private static final String PROFILE_ID = "PROFILE_ID"; + + private int profileId; + + public static ProfileRestaurantRatingsFragment newInstance(int profileId) { + ProfileRestaurantRatingsFragment fragment = new ProfileRestaurantRatingsFragment(); + Bundle args = new Bundle(); + args.putInt(PROFILE_ID, profileId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + profileId = getArguments().getInt(PROFILE_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); + + ArrayList ratings = new ArrayList<>(); + ratings.add(new RestaurantRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", RestaurantRating.Accessibility.MODERATE)); + ratings.add(new RestaurantRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", RestaurantRating.Accessibility.EASY)); + ratings.add(new RestaurantRating(4, "Apostolof", "-", "2018-06-08", RestaurantRating.Accessibility.EASY)); + ratings.add(new RestaurantRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", RestaurantRating.Accessibility.MODERATE)); + ratings.add(new RestaurantRating(5, "Apostolof", "Τέλειο.", "2018-06-08", RestaurantRating.Accessibility.EASY)); + ratings.add(new RestaurantRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null)); + ratings.add(new RestaurantRating(4, "Apostolof", "-", "2018-06-08", RestaurantRating.Accessibility.MODERATE)); + + Context context = getContext(); + assert context != null; + RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); + mainContent.setAdapter(itemAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); + mainContent.setLayoutManager(layoutManager); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(), + layoutManager.getOrientation()); + mainContent.addItemDecoration(dividerItemDecoration); + + return rootView; + } +} 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 fe4ad0c..cbb0347 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 @@ -34,7 +34,6 @@ import static gr.auth.databases.flavours.activities.AddItemActivity.ITEM_TYPE; public class RestaurantActivity extends BaseActivity implements RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener, RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener { - private ViewPager viewPager; private FloatingActionButton FAB; 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 3ef4256..b95aaca 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,5 +1,6 @@ package gr.auth.databases.flavours.activities.restaurant.fragments; +import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.model.RestaurantRating; +import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter; public class RestaurantRatingsFragment extends Fragment { @@ -53,7 +55,9 @@ public class RestaurantRatingsFragment extends Fragment { ratings.add(new RestaurantRating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null)); ratings.add(new RestaurantRating(4, "eddie lives inside you", "-", "2018-06-08", RestaurantRating.Accessibility.MODERATE)); - RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(getContext(), ratings); + Context context = getContext(); + assert context != null; + RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings); 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/base/BaseActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java index f561caa..e5e49f1 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java @@ -18,6 +18,7 @@ import com.mikepenz.materialdrawer.DrawerBuilder; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.ProfileDrawerItem; import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; +import com.mikepenz.materialdrawer.model.interfaces.IProfile; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; @@ -27,9 +28,13 @@ import androidx.preference.PreferenceManager; import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.activities.LoginActivity; import gr.auth.databases.flavours.activities.main.MainActivity; +import gr.auth.databases.flavours.activities.profile.ProfileActivity; import gr.auth.databases.flavours.session.SessionManager; import okhttp3.OkHttpClient; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_ID; + public abstract class BaseActivity extends AppCompatActivity { // Client & Cookies protected static OkHttpClient client; @@ -158,21 +163,23 @@ public abstract class BaseActivity extends AppCompatActivity { .withHeaderBackground(R.color.primary) .withTextColor(getResources().getColor(R.color.iron)) .addProfiles(profileDrawerItem) - /*.withOnAccountHeaderListener((view, profile, currentProfile) -> { - if (sessionManager.isLoggedIn()) { - Intent intent = new Intent(BaseActivity.this, ProfileActivity.class); - Bundle extras = new Bundle(); - extras.putString(BUNDLE_PROFILE_URL, "https://www.thmmy.gr/smf/index.php?action=profile"); - extras.putString(BUNDLE_PROFILE_USERNAME, sessionManager.getUsername()); - intent.putExtras(extras); - intent.setFlags(FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - return false; - } else - startLoginActivity(); - return true; - - })*/ + .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { + @Override + public boolean onProfileChanged(View view, IProfile profile, boolean current) { + //if (sessionManager.isLoggedIn()) { + Intent intent = new Intent(BaseActivity.this, ProfileActivity.class); + Bundle extras = new Bundle(); + extras.putInt(BUNDLE_USER_ID, sessionManager.getUserId()); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + return false; + //TODO + /*} else + startLoginActivity();*/ + //return true; + } + }) .build(); DrawerBuilder drawerBuilder = new DrawerBuilder() diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java index 47042a1..20f16d8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java @@ -36,7 +36,7 @@ public class IngredientItemAdapter extends RecyclerView.Adapter ratings; - RestaurantRatingsAdapter(@NonNull Context context, ArrayList ratings) { + public RestaurantRatingsAdapter(@NonNull Context context, ArrayList ratings) { this.context = context; this.ratings = ratings; } @@ -36,12 +36,12 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml index 488f07b..a73f42f 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml @@ -10,17 +10,23 @@ android:id="@+id/drink_serving_restaurant" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/drink_serving_restaurant_placeholder" /> + android:text="@string/drink_serving_restaurant" /> + android:text="@string/drink_has_alcohol" /> + + + android:text="@string/drink_description" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml index e091bd9..63f6122 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml @@ -10,17 +10,23 @@ android:id="@+id/food_serving_restaurant" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/food_serving_restaurant_placeholder" /> + android:text="@string/food_serving_restaurant" /> + android:text="@string/food_calories" /> + + + android:text="@string/food_description" /> \ 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 new file mode 100644 index 0000000..3e3b745 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/ingredient_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/ingredient_row.xml index cb4739c..1e01dbe 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/ingredient_row.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/ingredient_row.xml @@ -10,12 +10,12 @@ android:id="@+id/ingredient_name" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/ingredient_name_placeholder" + android:text="@string/ingredient_name" android:textStyle="bold" /> + android:text="@string/ingredient_has_alcohol" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_row.xml new file mode 100644 index 0000000..e3f20a7 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_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 b1edbea..1a06219 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml @@ -46,31 +46,50 @@ Restaurant Name Working hours: %1$s - %2$s Restaurant type: %1$s - Restaurant average rating: %1$f - Restaurant average rating for diet %1$s: %2$f - Grade = %1$d/5 - Accessibility = %1$s + Restaurant average rating: %1$.2f + Restaurant average rating for diet %1$s: %2$.2f + Grade = %1$d/5 + Accessibility = %1$s + + + Grade = %1$d/5 + Portion size = %1$s Food - Restaurant - Restaurant: %1$s - Food calories - Food calories: %1$d - Food description + Restaurant + Restaurant: %1$s + Food calories + Food calories: %1$d + Food average rating + Food average rating: %1$.2f/5 + Food description Drink - Restaurant - Restaurant: %1$s - Drink has alcohol - Drink has alcohol: %1$s - Drink description + Restaurant + Restaurant: %1$s + Drink has alcohol + Drink has alcohol: %1$s + Drink average rating + Drink average rating: %1$.2f/5 + Drink description + + + Email + Email: %1$s + Age + Age: %1$d + Number of reviews submitted + Number of reviews submitted: %1$d + Owns restaurant + Owns the restaurant: %1$s + Diets: - Ingredient name - Ingredient contains alcohol - Ingredient contains alcohol: %1$s + Ingredient name + Ingredient contains alcohol + Ingredient contains alcohol: %1$s Add Restaurant