diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml index 8542a75..7fd9929 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml @@ -10,6 +10,8 @@ --> + + + + 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 new file mode 100644 index 0000000..2fad6f9 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java @@ -0,0 +1,137 @@ +package gr.auth.databases.flavours.activities.drink; + +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.drink.fragments.DrinkInfoFragment; +import gr.auth.databases.flavours.activities.drink.fragments.DrinkIngredientsFragment; +import gr.auth.databases.flavours.base.BaseActivity; + +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; + +public class DrinkActivity extends BaseActivity { + + private ViewPager viewPager; + private FloatingActionButton FAB; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_drink); + + Toolbar toolbar = findViewById(R.id.drink_toolbar); + toolbar.setTitle("White Russian"); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } + + createDrawer(); + drawer.setSelection(-1); + + FAB = findViewById(R.id.drink_fab); + FAB.hide(); + FAB.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class); + startActivity(intent);*/ + } + }); + + viewPager = findViewById(R.id.drink_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.drink_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(DrinkInfoFragment.newInstance(64), "INFO"); + adapter.addFrag(DrinkIngredientsFragment.newInstance(64), "INGREDIENTS"); + /*adapter.addFrag(DrinkRatingsFragment.newInstance(64), "RATINGS");*/ + 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/drink/fragments/DrinkInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java new file mode 100644 index 0000000..d0cecdc --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java @@ -0,0 +1,50 @@ +package gr.auth.databases.flavours.activities.drink.fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import gr.auth.databases.flavours.R; + +public class DrinkInfoFragment extends Fragment { + + public DrinkInfoFragment() { + // Required empty public constructor + } + + private static final String DRINK_ID = "DRINK_ID"; + + private int drinkId; + + public static DrinkInfoFragment newInstance(int drinkId) { + DrinkInfoFragment fragment = new DrinkInfoFragment(); + Bundle args = new Bundle(); + args.putInt(DRINK_ID, drinkId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + drinkId = getArguments().getInt(DRINK_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + 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")); + TextView hasAlcohol = rootView.findViewById(R.id.drink_contains_alcohol); + hasAlcohol.setText(getString(R.string.drink_has_alcohol, "YES")); + 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/drink/fragments/DrinkIngredientsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkIngredientsFragment.java new file mode 100644 index 0000000..0ed6a98 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkIngredientsFragment.java @@ -0,0 +1,66 @@ +package gr.auth.databases.flavours.activities.drink.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.IngredientSummary; +import gr.auth.databases.flavours.utils.IngredientItemAdapter; + +public class DrinkIngredientsFragment extends Fragment { + + public DrinkIngredientsFragment() { + // Required empty public constructor + } + + private static final String DRINK_ID = "DRINK_ID"; + + private int drinkId; + + public static DrinkIngredientsFragment newInstance(int drinkId) { + DrinkIngredientsFragment fragment = new DrinkIngredientsFragment(); + Bundle args = new Bundle(); + args.putInt(DRINK_ID, drinkId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + drinkId = getArguments().getInt(DRINK_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 ingredients = new ArrayList<>(); + ingredients.add(new IngredientSummary("Βότκα", true)); + ingredients.add(new IngredientSummary("Γάλα", false)); + + Context context = getContext(); + assert context != null; + IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients); + 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/food/FoodActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java new file mode 100644 index 0000000..c2cd567 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java @@ -0,0 +1,137 @@ +package gr.auth.databases.flavours.activities.food; + +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.food.fragments.FoodInfoFragment; +import gr.auth.databases.flavours.activities.food.fragments.FoodIngredientsFragment; +import gr.auth.databases.flavours.base.BaseActivity; + +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; + +public class FoodActivity extends BaseActivity { + + private ViewPager viewPager; + private FloatingActionButton FAB; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_food); + + Toolbar toolbar = findViewById(R.id.food_toolbar); + toolbar.setTitle("Γεμιστά"); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } + + createDrawer(); + drawer.setSelection(-1); + + FAB = findViewById(R.id.food_fab); + FAB.hide(); + FAB.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class); + startActivity(intent);*/ + } + }); + + viewPager = findViewById(R.id.food_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.food_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(FoodInfoFragment.newInstance(64), "INFO"); + adapter.addFrag(FoodIngredientsFragment.newInstance(64), "INGREDIENTS"); + /*adapter.addFrag(FoodRatingsFragment.newInstance(64), "RATINGS");*/ + 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/food/fragments/FoodInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java new file mode 100644 index 0000000..5e21f5a --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java @@ -0,0 +1,50 @@ +package gr.auth.databases.flavours.activities.food.fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import gr.auth.databases.flavours.R; + +public class FoodInfoFragment extends Fragment { + + public FoodInfoFragment() { + // Required empty public constructor + } + + private static final String FOOD_ID = "FOOD_ID"; + + private int foodId; + + public static FoodInfoFragment newInstance(int foodId) { + FoodInfoFragment fragment = new FoodInfoFragment(); + Bundle args = new Bundle(); + args.putInt(FOOD_ID, foodId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + foodId = getArguments().getInt(FOOD_ID); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + 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")); + TextView calories = rootView.findViewById(R.id.food_calories); + calories.setText(getString(R.string.food_calories, 500)); + 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/food/fragments/FoodIngredientsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodIngredientsFragment.java new file mode 100644 index 0000000..863b336 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodIngredientsFragment.java @@ -0,0 +1,66 @@ +package gr.auth.databases.flavours.activities.food.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.IngredientSummary; +import gr.auth.databases.flavours.utils.IngredientItemAdapter; + +public class FoodIngredientsFragment extends Fragment { + + public FoodIngredientsFragment() { + // Required empty public constructor + } + + private static final String FOOD_ID = "FOOD_ID"; + + private int foodId; + + public static FoodIngredientsFragment newInstance(int foodId) { + FoodIngredientsFragment fragment = new FoodIngredientsFragment(); + Bundle args = new Bundle(); + args.putInt(FOOD_ID, foodId); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + assert getArguments() != null; + foodId = getArguments().getInt(FOOD_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 ingredients = new ArrayList<>(); + ingredients.add(new IngredientSummary("Κιμάς", false)); + ingredients.add(new IngredientSummary("Ρύζι", false)); + + Context context = getContext(); + assert context != null; + IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients); + 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/main/MainActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java index 1dd9c98..0af5997 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 @@ -1,6 +1,7 @@ package gr.auth.databases.flavours.activities.main; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java index 6cc16c7..b85a40d 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/fragments/MainListFragment.java @@ -18,9 +18,9 @@ public class MainListFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_main_list, container, false); + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.reusable_recycler_list, container, false); - RecyclerView recyclerView = rootView.findViewById(R.id.main_recycler); + RecyclerView recyclerView = rootView.findViewById(R.id.recycler_list); recyclerView.setHasFixedSize(true); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); 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 48ce4fd..6bdb6b1 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 @@ -8,6 +8,8 @@ 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.drink.DrinkActivity; +import gr.auth.databases.flavours.activities.food.FoodActivity; import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantDrinksFragment; import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantFoodsFragment; import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantInfoFragment; @@ -15,7 +17,10 @@ import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantRati import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.model.ItemSummary; +import android.content.Intent; import android.os.Bundle; +import android.util.Log; +import android.view.MenuItem; import android.view.View; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -37,7 +42,7 @@ public class RestaurantActivity extends BaseActivity setContentView(R.layout.activity_restaurant); Toolbar toolbar = findViewById(R.id.restaurant_toolbar); - toolbar.setTitle(getString(R.string.restaurant_toolbar_title)); + toolbar.setTitle("Αιθερόπλοο"); setSupportActionBar(toolbar); ActionBar actionbar = getSupportActionBar(); if (actionbar != null) { @@ -80,7 +85,7 @@ public class RestaurantActivity extends BaseActivity tabLayout.setupWithViewPager(viewPager); } - /*@Override + @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); @@ -90,7 +95,7 @@ public class RestaurantActivity extends BaseActivity } return super.onOptionsItemSelected(item); - }*/ + } @Override public void onBackPressed() { @@ -103,12 +108,14 @@ public class RestaurantActivity extends BaseActivity @Override public void onRestaurantFoodsFragmentInteraction(ItemSummary item) { - // todo + Intent intent = new Intent(this, FoodActivity.class); + startActivity(intent); } @Override public void onRestaurantDrinksFragmentInteraction(ItemSummary item) { - // todo + Intent intent = new Intent(this, DrinkActivity.class); + startActivity(intent); } private void setupViewPager(ViewPager viewPager) { diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java index c60d91a..6d1c01b 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java @@ -2,6 +2,7 @@ package gr.auth.databases.flavours.activities.restaurant.fragments; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -43,14 +44,15 @@ public class RestaurantDrinksFragment extends BaseFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View rootView = inflater.inflate(R.layout.fragment_restaurant_items, container, false); + final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); ArrayList drinks = new ArrayList<>(); - drinks.add(new ItemSummary("White russian", ItemSummary.ItemType.DRINK)); - drinks.add(new ItemSummary("Τσίπουρο Τσάπουρας", ItemSummary.ItemType.DRINK)); + drinks.add(new ItemSummary("White russian", 5, ItemSummary.ItemType.DRINK)); + drinks.add(new ItemSummary("Τσίπουρο Τσάπουρας", 5, ItemSummary.ItemType.DRINK)); - RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, drinks); - RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list); + RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, + ItemSummary.ItemType.DRINK, drinks); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); mainContent.setLayoutManager(layoutManager); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java index 170ad83..e13f208 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java @@ -42,14 +42,15 @@ public class RestaurantFoodsFragment extends BaseFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View rootView = inflater.inflate(R.layout.fragment_restaurant_items, container, false); + final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); ArrayList foods = new ArrayList<>(); - foods.add(new ItemSummary("Γιουβαρλάκια", ItemSummary.ItemType.FOOD)); - foods.add(new ItemSummary("Γεμιστά", ItemSummary.ItemType.FOOD)); + foods.add(new ItemSummary("Γιουβαρλάκια", 5, ItemSummary.ItemType.FOOD)); + foods.add(new ItemSummary("Γεμιστά", 5, ItemSummary.ItemType.FOOD)); - RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, foods); - RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list); + RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, + ItemSummary.ItemType.FOOD, foods); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); mainContent.setLayoutManager(layoutManager); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java index 8e769ae..6af4901 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java @@ -7,9 +7,13 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; +import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; +import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.MarkerOptions; import androidx.annotation.NonNull; import gr.auth.databases.flavours.R; @@ -124,6 +128,11 @@ public class RestaurantInfoFragment extends BaseFragment implements OnMapReadyCa */ @Override public void onMapReady(GoogleMap googleMap) { - //googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(grill15, 12.0f)); + LatLng aitheroploo = new LatLng(40.6144, 22.9598); + googleMap.addMarker(new MarkerOptions() + .position(aitheroploo) + .title("Αιθερόπλοο") + .icon(BitmapDescriptorFactory.fromResource(R.drawable.pub_marker))); + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(aitheroploo, 12.0f)); } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java index 695ebc6..13ecf2e 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java @@ -1,5 +1,6 @@ package gr.auth.databases.flavours.activities.restaurant.fragments; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -15,12 +16,18 @@ import gr.auth.databases.flavours.base.BaseFragment; import gr.auth.databases.flavours.model.ItemSummary; public class RestaurantItemAdapter extends RecyclerView.Adapter { - private final RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener interactionListener; + private RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener foodInteractionListener; + private RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener drinkInteractionListener; private final ArrayList items; RestaurantItemAdapter(BaseFragment.FragmentInteractionListener interactionListener, - ArrayList items) { - this.interactionListener = (RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener) interactionListener; + ItemSummary.ItemType itemType, ArrayList items) { + if (itemType == ItemSummary.ItemType.FOOD) { + this.foodInteractionListener = (RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener) interactionListener; + } else if (itemType == ItemSummary.ItemType.DRINK) { + this.drinkInteractionListener = (RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener) interactionListener; + } + this.items = items; } @@ -40,14 +47,20 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter ratings = new ArrayList<>(); ratings.add(new Rating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", Rating.Accessibility.MODERATE)); @@ -54,7 +54,7 @@ public class RestaurantRatingsFragment extends Fragment { ratings.add(new Rating(4, "eddie lives inside you", "-", "2018-06-08", Rating.Accessibility.MODERATE)); RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(getContext(), ratings); - RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list); + RecyclerView mainContent = rootView.findViewById(R.id.recycler_list); mainContent.setAdapter(itemAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); mainContent.setLayoutManager(layoutManager); 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 7c567b0..f561caa 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 @@ -52,13 +52,17 @@ public abstract class BaseActivity extends AppCompatActivity { isMainActivity = this instanceof MainActivity; if (client == null) - client = BaseApplication.getInstance().getClient(); //must check every time - e.g. + client = BaseApplication.getInstance().getClient(); //must check every time // they become null when app restarts after crash if (sessionManager == null) sessionManager = BaseApplication.getInstance().getSessionManager(); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + + if (!checkPerms()) { + requestPerms(); + } } @Override @@ -226,12 +230,12 @@ public abstract class BaseActivity extends AppCompatActivity { //True if permissions are OK private boolean checkPerms() { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - String[] PERMISSIONS_STORAGE = { - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; + String[] PERMISSIONS_MAP = { + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.INTERNET}; - return !(checkSelfPermission(PERMISSIONS_STORAGE[0]) == PackageManager.PERMISSION_DENIED || - checkSelfPermission(PERMISSIONS_STORAGE[1]) == PackageManager.PERMISSION_DENIED); + return !(checkSelfPermission(PERMISSIONS_MAP[0]) == PackageManager.PERMISSION_DENIED || + checkSelfPermission(PERMISSIONS_MAP[1]) == PackageManager.PERMISSION_DENIED); } return true; } @@ -239,21 +243,19 @@ public abstract class BaseActivity extends AppCompatActivity { //Display popup for user to grant permission private void requestPerms() { //Runtime permissions request for devices with API >= 23 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - String[] PERMISSIONS_STORAGE = { - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; + String[] PERMISSIONS_MAP = { + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.INTERNET}; - requestPermissions(PERMISSIONS_STORAGE, PERMISSIONS_REQUEST_CODE); + requestPermissions(PERMISSIONS_MAP, PERMISSIONS_REQUEST_CODE); } } - @Override public void onRequestPermissionsResult(int permsRequestCode, @NonNull String[] permissions , @NonNull int[] grantResults) { switch (permsRequestCode) { case PERMISSIONS_REQUEST_CODE: - //downloadFile(); break; } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java index 0c627c7..0fbdfb8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java @@ -28,13 +28,13 @@ public abstract class BaseFragment extends Fragment { @Override public void onAttach(@NonNull Context context) { super.onAttach(context); - /*if (context instanceof FragmentInteractionListener) { + if (context instanceof FragmentInteractionListener) { fragmentInteractionListener = (FragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); - }*/ + } } @Override diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/IngredientSummary.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/IngredientSummary.java new file mode 100644 index 0000000..55c290f --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/IngredientSummary.java @@ -0,0 +1,19 @@ +package gr.auth.databases.flavours.model; + +public class IngredientSummary { + private String name; + private boolean hasAlcohol; + + public IngredientSummary(String name, boolean hasAlcohol) { + this.name = name; + this.hasAlcohol = hasAlcohol; + } + + public String getName() { + return name; + } + + public boolean hasAlcohol() { + return hasAlcohol; + } +} \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java index 8a24771..1c8363f 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java @@ -6,10 +6,12 @@ public class ItemSummary { } private String item; + private int id; private ItemType type; - public ItemSummary(String item, ItemType type) { + public ItemSummary(String item, int id, ItemType type) { this.item = item; + this.id = id; this.type = type; } @@ -17,6 +19,10 @@ public class ItemSummary { return item; } + public int getId() { + return id; + } + public ItemType getType() { return type; } 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 new file mode 100644 index 0000000..47042a1 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java @@ -0,0 +1,57 @@ +package gr.auth.databases.flavours.utils; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.model.IngredientSummary; + +public class IngredientItemAdapter extends RecyclerView.Adapter { + private final ArrayList ingredients; + private Context context; + + public IngredientItemAdapter(@NonNull Context context, ArrayList ingredients) { + this.ingredients = ingredients; + this.context = context; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()). + inflate(R.layout.ingredient_row, parent, false); + return new ItemViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) { + IngredientSummary ingredient = ingredients.get(position); + ItemViewHolder itemViewHolder = (ItemViewHolder) holder; + + itemViewHolder.name.setText(ingredient.getName()); + itemViewHolder.hasAlcohol.setText(context.getString(R.string.ingredient_has_alcohol, + ingredient.hasAlcohol() ? "YES" : "NO")); + } + + @Override + public int getItemCount() { + return ingredients == null ? 0 : ingredients.size(); + } + + private static class ItemViewHolder extends RecyclerView.ViewHolder { + TextView name, hasAlcohol; + + ItemViewHolder(View itemView) { + super(itemView); + name = itemView.findViewById(R.id.ingredient_name); + hasAlcohol = itemView.findViewById(R.id.ingredient_has_alcohol); + } + } +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_drink.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_drink.xml new file mode 100644 index 0000000..b166e59 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_drink.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_food.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_food.xml new file mode 100644 index 0000000..7d806a5 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_food.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..488f07b --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ 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 new file mode 100644 index 0000000..e091bd9 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml deleted file mode 100644 index a880c57..0000000 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml +++ /dev/null @@ -1,10 +0,0 @@ - - \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_info.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_info.xml index 7c186d4..52e79b3 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_info.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_info.xml @@ -8,6 +8,8 @@ android:id="@+id/restaurant_working_hours" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingStart="12dp" + android:paddingEnd="12dp" android:text="@string/restaurant_working_hours" /> + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml similarity index 79% rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml index 4004e7c..d2d98ce 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml @@ -1,6 +1,6 @@ Grade = %1$d/5 Accessibility = %1$s + + Food + Restaurant + Restaurant: %1$s + Food calories + Food calories: %1$d + Food description + + + Drink + Restaurant + Restaurant: %1$s + Drink has alcohol + Drink has alcohol: %1$s + Drink description + + + Ingredient name + Ingredient contains alcohol + Ingredient contains alcohol: %1$s + Add Restaurant Restaurant\'s name