From 42861f0b21d1b674a6f3e9547fff0c758e65d647 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Thu, 3 Jan 2019 17:38:20 +0200 Subject: [PATCH] Add AddDietActivity, Color fixes, Other minor fixes --- .../app/src/main/AndroidManifest.xml | 3 +- .../flavours/activities/AddDietActivity.java | 108 +++++++++++++++++ .../flavours/activities/AddItemActivity.java | 6 +- .../activities/diets/DietsActivity.java | 22 ++-- .../src/main/res/layout/activity_add_diet.xml | 113 ++++++++++++++++++ .../src/main/res/layout/activity_add_item.xml | 11 +- .../res/layout/activity_add_restaurant.xml | 7 +- .../src/main/res/layout/activity_diets.xml | 6 +- .../src/main/res/layout/activity_drink.xml | 2 +- .../app/src/main/res/layout/activity_food.xml | 2 +- .../app/src/main/res/layout/activity_main.xml | 6 +- .../src/main/res/layout/activity_profile.xml | 2 +- .../main/res/layout/activity_rate_item.xml | 8 +- .../res/layout/activity_rate_restaurant.xml | 8 +- .../main/res/layout/activity_restaurant.xml | 2 +- .../res/layout/fragment_restaurant_info.xml | 1 - .../res/layout/reusable_recycler_list.xml | 4 +- .../app/src/main/res/values/colors.xml | 8 +- .../app/src/main/res/values/strings.xml | 10 +- .../release/res/values/google_maps_api.xml | 2 +- 20 files changed, 279 insertions(+), 52 deletions(-) create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java create mode 100644 UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml index 5bb2dea..ce6f0c2 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ --> + @@ -56,6 +57,6 @@ + - \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java new file mode 100644 index 0000000..0932a82 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddDietActivity.java @@ -0,0 +1,108 @@ +package gr.auth.databases.flavours.activities; + +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; + +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.AppCompatButton; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.appcompat.widget.Toolbar; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.base.BaseActivity; +import gr.auth.databases.flavours.model.IngredientSummary; + +public class AddDietActivity extends BaseActivity { + private ArrayList ingredients = new ArrayList<>(); + private EditText dietNameInput, dietDescriptionInput; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_add_diet); + + Toolbar toolbar = findViewById(R.id.add_diet_toolbar); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + if (actionbar != null) { + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + } + + dietNameInput = findViewById(R.id.add_diet_name); + AppCompatButton addItemButton = findViewById(R.id.add_diet_add_btn); + final TextView ingredientsTitle = findViewById(R.id.add_diet_add_ingredient_title); + final EditText addIngredientInput = findViewById(R.id.add_diet_add_ingredient); + final LinearLayout ingredientsList = findViewById(R.id.add_diet_ingredients_list); + + addIngredientInput.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + ingredients.add(new IngredientSummary( + addIngredientInput.getText().toString(), false)); + + View ingredientRow = getLayoutInflater().inflate(R.layout.add_item_ingredient_row, ingredientsList, false); + TextView ingredientName = ingredientRow.findViewById(R.id.add_item_ingredient_name); + ingredientName.setText(ingredients.get(ingredients.size() - 1).getName()); + + AppCompatImageButton removeIngredientBtn = ingredientRow.findViewById(R.id.add_item_remove_ingredient); + removeIngredientBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int index = ingredientsList.indexOfChild((View) view.getParent()); + ingredients.remove(index); + ingredientsList.removeViewAt(index); + } + }); + + ingredientsList.addView(ingredientRow); + ingredientsTitle.setVisibility(View.VISIBLE); + ingredientsList.setVisibility(View.VISIBLE); + + addIngredientInput.setText(""); + return true; + } + return false; + } + }); + + addItemButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //TODO + } + }); + + createDrawer(); + drawer.setSelection(-1); + } + + @Override + public void onBackPressed() { + if (drawer.isDrawerOpen()) { + drawer.closeDrawer(); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == android.R.id.home) { + drawer.openDrawer(); + return true; + } + + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddItemActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddItemActivity.java index da86375..75155f8 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddItemActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddItemActivity.java @@ -10,6 +10,8 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; +import com.google.android.material.textfield.TextInputLayout; + import java.util.ArrayList; import androidx.appcompat.app.ActionBar; @@ -60,10 +62,10 @@ public class AddItemActivity extends BaseActivity { final LinearLayout ingredientsList = findViewById(R.id.add_item_ingredients_list); if (itemType == ItemSummary.ItemType.FOOD) { - itemNameInput.setHint(R.string.add_food_hint_name); + ((TextInputLayout) itemNameInput.getParent().getParent()).setHint(getString(R.string.add_food_hint_name)); addItemButton.setText(R.string.add_food_add_btn); } else if (itemType == ItemSummary.ItemType.DRINK) { - itemNameInput.setHint(R.string.add_drink_hint_name); + ((TextInputLayout) itemNameInput.getParent().getParent()).setHint(getString(R.string.add_drink_hint_name)); addItemButton.setText(R.string.add_drink_add_btn); } 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 index 9f1d88a..ff68b7b 100644 --- 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 @@ -1,6 +1,8 @@ package gr.auth.databases.flavours.activities.diets; +import android.content.Intent; import android.os.Bundle; +import android.view.MenuItem; import android.view.View; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -12,6 +14,7 @@ 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.activities.AddDietActivity; import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.model.Diet; @@ -39,8 +42,8 @@ public class DietsActivity extends BaseActivity { FAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class); - startActivity(intent);*/ + Intent intent = new Intent(view.getContext(), AddDietActivity.class); + startActivity(intent); } }); @@ -65,24 +68,15 @@ public class DietsActivity extends BaseActivity { } } - /*@Override + @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) { + if (id == android.R.id.home) { drawer.openDrawer(); return true; } return super.onOptionsItemSelected(item); - }*/ + } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml new file mode 100644 index 0000000..130c4e8 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_diet.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_item.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_item.xml index 92aa233..62e007f 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_item.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_item.xml @@ -4,27 +4,28 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> + android:theme="@style/ToolbarTheme"> + android:textStyle="bold" /> + android:theme="@style/ToolbarTheme"> + app:popupTheme="@style/ToolbarTheme" /> 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 index e767644..65df837 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_diets.xml @@ -10,14 +10,14 @@ android:id="@+id/diets_appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/Theme.AppCompat.Light"> + android:theme="@style/ToolbarTheme"> @@ -25,6 +25,8 @@ android:id="@+id/diets_list" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingTop="4dp" + android:paddingBottom="4dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 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 index 7d806a5..38f7091 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_food.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_food.xml @@ -3,7 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml index d5fdbb9..a533205 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml @@ -3,27 +3,27 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> + android:theme="@style/ToolbarTheme"> + app:popupTheme="@style/ToolbarTheme" /> diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml index f7dace8..70bda49 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml @@ -3,7 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_rate_item.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_rate_item.xml index 35c1f83..8bcc77c 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_rate_item.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_rate_item.xml @@ -4,27 +4,28 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/background_light" android:fitsSystemWindows="true"> + android:theme="@style/ToolbarTheme"> + android:theme="@style/ToolbarTheme"> 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 52e79b3..b86a709 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 @@ -45,6 +45,5 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="6dp" - android:layout_marginBottom="12dp" android:layout_weight="1" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml index d2d98ce..14914da 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/reusable_recycler_list.xml @@ -5,4 +5,6 @@ android:layout_height="match_parent" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:orientation="vertical" /> \ No newline at end of file + android:orientation="vertical" + android:paddingTop="4dp" + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/colors.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/colors.xml index 2a98221..f127af3 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/colors.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/colors.xml @@ -1,9 +1,9 @@ - #008577 - #00574B - #D81B60 - #DDDDDD + #4caf50 + #357a38 + #ff9100 + #EFEFEF #F6F8Fa #303030 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 9506933..a670927 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml @@ -118,9 +118,16 @@ ADD FOOD ADD DRINK + + Add Diet + Diet\'s title + Description + Prohibited ingredients: + Add prohibited ingredient + ADD DIET + Rate Restaurant - Rate %1$s Grade: Accessibility: Diet: @@ -129,7 +136,6 @@ Rate Item - Rate %1$s Grade: Portion size: Add some text to your rating diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/release/res/values/google_maps_api.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/release/res/values/google_maps_api.xml index 1ef79e9..9e76e81 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/release/res/values/google_maps_api.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/release/res/values/google_maps_api.xml @@ -16,5 +16,5 @@ Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file. --> - YOUR_KEY_HERE + AIzaSyApwRyyhtWE1zsCrSmtU6l9HG2dp-rzPqk