diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
index 9840a27..5bb2dea 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
@@ -55,6 +55,7 @@
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsActivity.java
new file mode 100644
index 0000000..9f1d88a
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsActivity.java
@@ -0,0 +1,88 @@
+package gr.auth.databases.flavours.activities.diets;
+
+import android.os.Bundle;
+import android.view.View;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+
+import java.util.ArrayList;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.widget.Toolbar;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.base.BaseActivity;
+import gr.auth.databases.flavours.model.Diet;
+
+public class DietsActivity extends BaseActivity {
+ private FloatingActionButton FAB;
+ private ArrayList diets = new ArrayList<>();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_diets);
+
+ Toolbar toolbar = findViewById(R.id.diets_toolbar);
+ toolbar.setTitle(getString(R.string.diets_toolbar_title));
+ setSupportActionBar(toolbar);
+ ActionBar actionbar = getSupportActionBar();
+ if (actionbar != null) {
+ actionbar.setDisplayHomeAsUpEnabled(true);
+ actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp);
+ }
+
+ createDrawer();
+
+ FAB = findViewById(R.id.diets_fab);
+ FAB.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class);
+ startActivity(intent);*/
+ }
+ });
+
+ RecyclerView recyclerView = findViewById(R.id.diets_list);
+ recyclerView.setHasFixedSize(true);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(this);
+ recyclerView.setLayoutManager(layoutManager);
+
+ diets.add(new Diet(1, "Μόνο κρέας", "Τρώς πολύ κρέας.", false));
+ diets.add(new Diet(2, "Σχεδόν μόνο κρέας", "Τρώς αρκετό κρέας.", true));
+
+ DietsAdapter dietsAdapter = new DietsAdapter(diets);
+ recyclerView.setAdapter(dietsAdapter);
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (drawer.isDrawerOpen()) {
+ drawer.closeDrawer();
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+ /*@Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+
+ if (id == R.id.main_toolbar_menu_filter) {
+ return true;
+ } else if (id == R.id.main_toolbar_menu_map) {
+ if (viewPager.getCurrentItem() == 0) {
+ viewPager.setCurrentItem(1);
+ } else if (viewPager.getCurrentItem() == 1) {
+ viewPager.setCurrentItem(0);
+ }
+ return true;
+ } else if (id == android.R.id.home) {
+ drawer.openDrawer();
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }*/
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsAdapter.java
new file mode 100644
index 0000000..a3a1dd9
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/diets/DietsAdapter.java
@@ -0,0 +1,56 @@
+package gr.auth.databases.flavours.activities.diets;
+
+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.appcompat.widget.AppCompatImageButton;
+import androidx.recyclerview.widget.RecyclerView;
+import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.model.Diet;
+
+public class DietsAdapter extends RecyclerView.Adapter {
+ private ArrayList diets;
+
+ DietsAdapter(ArrayList diets) {
+ this.diets = diets;
+ }
+
+ @NonNull
+ @Override
+ public DietsAdapter.DietViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
+ int viewType) {
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.diets_row, parent, false);
+ return new DietViewHolder(v);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull DietViewHolder holder, int position) {
+ holder.name.setText(diets.get(position).getName());
+ holder.description.setText(diets.get(position).getDescription());
+ if (diets.get(position).isFollowedByUser()) {
+ holder.addDietButton.setImageResource(R.drawable.ic_delete_black_18dp);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return diets.size();
+ }
+
+ static class DietViewHolder extends RecyclerView.ViewHolder {
+ TextView name, description;
+ AppCompatImageButton addDietButton;
+
+ DietViewHolder(View v) {
+ super(v);
+ name = v.findViewById(R.id.diets_diet_name);
+ description = v.findViewById(R.id.diets_diet_description);
+ addDietButton = v.findViewById(R.id.diets_diet_subscribe);
+ }
+ }
+}
\ No newline at end of file
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 dd95e9a..e65db03 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
@@ -26,6 +26,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.activities.diets.DietsActivity;
import gr.auth.databases.flavours.activities.LoginActivity;
import gr.auth.databases.flavours.activities.main.MainActivity;
import gr.auth.databases.flavours.activities.profile.ProfileActivity;
@@ -93,6 +94,7 @@ public abstract class BaseActivity extends AppCompatActivity {
//------------------------------------------DRAWER STUFF----------------------------------------
protected static final int HOME_ID = 0;
+ protected static final int DIETS_ID = 1;
protected static final int LOG_ID = 4;
private AccountHeader accountHeader;
@@ -104,8 +106,8 @@ public abstract class BaseActivity extends AppCompatActivity {
final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark);
final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.iron);
- PrimaryDrawerItem homeItem;
- IconicsDrawable homeIcon, homeIconSelected;
+ PrimaryDrawerItem homeItem, dietsItem;
+ IconicsDrawable homeIcon, homeIconSelected, dietsIcon, dietsIconSelected;
//Drawer Icons
homeIcon = new IconicsDrawable(this)
@@ -116,6 +118,14 @@ public abstract class BaseActivity extends AppCompatActivity {
.icon(GoogleMaterial.Icon.gmd_home)
.color(selectedSecondaryColor);
+ dietsIcon = new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_donut_small)
+ .color(primaryColor);
+
+ dietsIconSelected = new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_donut_small)
+ .color(selectedSecondaryColor);
+
IconicsDrawable loginIcon = new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_sign_in)
.color(primaryColor);
@@ -134,6 +144,15 @@ public abstract class BaseActivity extends AppCompatActivity {
.withIcon(homeIcon)
.withSelectedIcon(homeIconSelected);
+ dietsItem = new PrimaryDrawerItem()
+ .withTextColor(primaryColor)
+ .withSelectedColor(selectedPrimaryColor)
+ .withSelectedTextColor(selectedSecondaryColor)
+ .withIdentifier(DIETS_ID)
+ .withName(R.string.drawer_diets)
+ .withIcon(dietsIcon)
+ .withSelectedIcon(dietsIconSelected);
+
if (sessionManager.isLoggedIn()) {
loginLogoutItem = new PrimaryDrawerItem()
.withTextColor(primaryColor)
@@ -166,14 +185,14 @@ public abstract class BaseActivity extends AppCompatActivity {
@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
+ 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;
@@ -195,6 +214,9 @@ public abstract class BaseActivity extends AppCompatActivity {
Intent intent = new Intent(BaseActivity.this, MainActivity.class);
startActivity(intent);
}
+ } else if (drawerItem.equals(DIETS_ID)) {
+ Intent intent = new Intent(BaseActivity.this, DietsActivity.class);
+ startActivity(intent);
} else if (drawerItem.equals(LOG_ID)) {
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
startLoginActivity();
@@ -207,7 +229,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
});
- drawerBuilder.addDrawerItems(homeItem, loginLogoutItem);
+ drawerBuilder.addDrawerItems(homeItem, dietsItem, loginLogoutItem);
drawer = drawerBuilder.build();
/*if (!isMainActivity)
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Diet.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Diet.java
new file mode 100644
index 0000000..feedb78
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Diet.java
@@ -0,0 +1,30 @@
+package gr.auth.databases.flavours.model;
+
+public class Diet {
+ private int id;
+ private String name, description;
+ private boolean isFollowedByUser;
+
+ public Diet(int id, String name, String description, boolean isFollowedByUser) {
+ this.id = id;
+ this.name = name;
+ this.description = description;
+ this.isFollowedByUser = isFollowedByUser;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean isFollowedByUser() {
+ return isFollowedByUser;
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_black_18dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_black_18dp.png
new file mode 100644
index 0000000..fb8c689
Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_black_18dp.png differ
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_black_18dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_black_18dp.png
new file mode 100644
index 0000000..8291449
Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_black_18dp.png differ
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_black_18dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_black_18dp.png
new file mode 100644
index 0000000..08769ac
Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_black_18dp.png differ
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_black_18dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_black_18dp.png
new file mode 100644
index 0000000..bb8c846
Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_black_18dp.png differ
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_black_18dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_black_18dp.png
new file mode 100644
index 0000000..b5732cd
Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_black_18dp.png differ
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml
new file mode 100644
index 0000000..e767644
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/diets_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/diets_row.xml
new file mode 100644
index 0000000..07f8f82
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/diets_row.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 b4e8512..9506933 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
@@ -20,6 +20,7 @@
Home
+ Diets
Logout
Login
@@ -86,6 +87,11 @@
Owns the restaurant: %1$s
Diets:
+
+ Diets
+ Diet name
+ Diet description
+
Ingredient name
Ingredient contains alcohol