Let's create this app according to requirements, list down activities we need to created for this
"COM594 2023-24 CRN: 49642
Page 2 of 12
CW2 – Description
You are required to implement an Android application using Java described by the
specifications below.
The application developed will be helping users with meal preparation.
The application will be using the https://www.themealdb.com/api.php/ Web service and the
Room Library to save information about meals.
When the application starts, it presents the user with 3 buttons labelled Add Meals to
DB, Search for Meals By Ingredient and Search for Meals.
(3 marks)
Clicking on the Add Meals to DB button saves all the details of a few meals in an SQLite
database local to the mobile device using the Room library. The specific information
of the meals which will be saved is shown below:
"Meal":"Sweet and Sour Pork",
"DrinkAlternate":null,
"Category":"Pork",
"Area":"Chinese",
"MealThumb":"https://www.themealdb.com/images/media/meals/15294423
16.jpg",
"Tags":"Sweet",
"Youtube":"https://www.youtube.com/watch?v=mdaBIhgEAMo",
"Ingredient1":"Pork",
"Ingredient2":"Egg",
"Ingredient3":"Water",
"Ingredient4":"Salt",
"Ingredient5":"Sugar",
"Ingredient6":"Soy Sauce",
"Ingredient7":"Starch",
"Ingredient8":"Tomato Puree",
"Ingredient9":"Vinegar",
"Ingredient11":"",
"Ingredient12":"",
"Ingredient13":"",
"Ingredient14":"",
"Ingredient15":"",
"Ingredient16":"",
"Ingredient17":"",
"Ingredient18":"",
"Ingredient19":"",
"Ingredient20":"",
"Measure1":"200g",
"Measure2":"1",
"Measure3":"Dash",
"Measure4":"1/2 tsp",
"Measure5":"1 tsp ",
"Measure6":"10g",
"Measure7":"10g",
"Measure8":"30g",
"Measure9":"10g",
"Measure10":"Dash",
COM594 2023-24 CRN: 49642
Page 3 of 12
"Measure12":"",
"Measure13":"",
"Measure14":"",
"Measure15":"",
"Measure16":"",
"Measure17":"",
"Measure18":"",
"Measure19":"",
"Measure20":"",
"Source":"https://www.chinahighlights.com/travelguide/chinesefood/cooking/sweet-sour-pork.htm",
"ImageSource":null,
"CreativeCommonsConfirmed":null,
"dateModified":null
"Meal":"Chicken Marengo",
"DrinkAlternate":null,
"Category":"Chicken",
"Area":"French",
"MealThumb":"https://www.themealdb.com/images/media/meals/qpxvuq15
11798906.jpg",
"Tags":null,
"Youtube":"https://www.youtube.com/watch?v=U33HYUr-0Fw",
"Ingredient1":"Olive Oil",
"Ingredient2":"Mushrooms",
"Ingredient3":"Chicken Legs",
"Ingredient4":"Passata",
"Ingredient5":"Chicken Stock Cube",
"Ingredient6":"Black Olives",
"Ingredient7":"Parsley",
"Ingredient8":"",
"Ingredient9":"",
"Ingredient11":"",
"Ingredient12":"",
"Ingredient13":"",
"Ingredient14":"",
"Ingredient15":"",
"Ingredient16":"",
"Ingredient17":"",
"Ingredient18":"",
"Ingredient19":"",
"Ingredient20":"",
"Measure1":"1 tbs",
"Measure2":"300g",
"Measure3":"4",
"Measure4":"500g",
"Measure5":"1",
"Measure6":"100g ",
"Measure7":"Chopped",
"Measure8":"",
"Measure9":"",
"Measure10":"",
"Measure12":"",
"Measure13":"",
"Measure14":"",
"Measure15":"",
"Measure16":"",
"Measure17":"",
"Measure18":"",
"Measure19":"",
"Measure20":"",
COM594 2023-24 CRN: 49642
Page 4 of 12
"Source":"",
"ImageSource":null,
"CreativeCommonsConfirmed":null,
"dateModified":null
An appropriate database with appropriate tables should be created and populated by
your application, based on the above data.
(20 marks — 10 marks for the creation of the database and 10 marks for its population)
The application is using the following Web service:
https://www.themealdb.com/api.php/
The documentation of how to use the Web service is in the above web page. For
example, the following request (type this in your web browser):
https://www.themealdb.com/api/json/v1/1/search.php?s=Arrabiata
will give you back the results (in JSON format) of searching the meal with name
“Arrabiata”:
{"meals":[{"idMeal":"52771","strMeal":"Spicy Arrabiata
Penne","strDrinkAlternate":null,"strCategory":"Vegetarian","strArea":"It
alian","strInstructions":"Bring a large pot of water to a boil. Add
kosher salt to the boiling water, then add the pasta. Cook according to
the package instructions, about 9 minutes.\r\nIn a large skillet over
medium-high heat, add the olive oil and heat until the oil starts to
shimmer. Add the garlic and cook, stirring, until fragrant, 1 to 2
minutes. Add the chopped tomatoes, red chile flakes, Italian seasoning
and salt and pepper to taste. Bring to a boil and cook for 5 minutes.
Remove from the heat and add the chopped basil.\r\nDrain the pasta and
add it to the sauce. Garnish with Parmigiano-Reggiano flakes and more
basil and serve
warm.","strMealThumb":"https://www.themealdb.com/images/media/meals
/ustsqw1468250014.jpg","strTags":"Pasta,Curry","strYoutube":"https://
www.youtube.com/watch?v=1IszT_guI08","strIngredient1":"penne
rigate","strIngredient2":"olive
oil","strIngredient3":"garlic","strIngredient4":"chopped
tomatoes","strIngredient5":"red chile flakes","strIngredient6":"italian
seasoning","strIngredient7":"basil","strIngredient8":"ParmigianoReggiano","strIngredient9":"","strIngredient10":"","strIngredient11":"",
"strIngredient12":"","strIngredient13":"","strIngredient14":"","strIngre
dient15":"","strIngredient16":null,"strIngredient17":null,"strIngredient
18":null,"strIngredient19":null,"strIngredient20":null,"strMeasure1":"1
pound","strMeasure2":"1/4 cup","strMeasure3":"3
cloves","strMeasure4":"1 tin ","strMeasure5":"1/2
teaspoon","strMeasure6":"1/2 teaspoon","strMeasure7":"6
leaves","strMeasure8":"spinkling","strMeasure9":"","strMeasure10":"","st
rMeasure11":"","strMeasure12":"","strMeasure13":"","strMeasure14":"","st
rMeasure15":"","strMeasure16":null,"strMeasure17":null,"strMeasure18":nu
ll,"strMeasure19":null,"strMeasure20":null,"strSource":null,"strImageSou
rce":null,"strCreativeCommonsConfirmed":null,"dateModified":null}]}
Clicking on the Search for Meals By Ingredient button will present the user with a
screen displaying a single textbox and 2 buttons Retrieve Meals and Save meals to
Database.
COM594 2023-24 CRN: 49642
Page 5 of 12
The user will be using the textbox to type the name of an ingredient and click the
Retrieve Meals button to retrieve all the details of all the meals containing this
ingredient from the Web service. The details of each meal will be displayed as part of
the same screen of the application in the following format, for example if the user
searches for “chicken” as an ingredient:
"Meal":"Brown Stew Chicken",
"DrinkAlternate":null,
"Category":"Chicken",
"Area":"Jamaican",
“MealThumb":"https://www.themealdb.com/images/media/meals/sypxpx151
5365095.jpg",
"Tags":"Stew",
"Youtube":"https://www.youtube.com/watch?v=_gFB1fkNhXs",
"Ingredient1":"Chicken",
"Ingredient2":"Tomato",
"Ingredient3":"Onions",
"Ingredient4":"Garlic Clove",
"Ingredient5":"Red Pepper",
"Ingredient6":"Carrots",
"Ingredient7":"Lime",
"Ingredient8":"Thyme",
"Ingredient9":"Allspice",
"Ingredient10":"Soy Sauce",
"Ingredient11":"Cornstarch",
"Ingredient12":"Coconut Milk",
"Ingredient13":"Vegetable Oil",
"Ingredient14":"",
"Ingredient15":"",
"Ingredient16":"",
"Ingredient17":"",
"Ingredient18":"",
"Ingredient19":"",
"Ingredient20":"",
"Measure1":"1 whole",
"Measure2":"1 chopped",
"Measure3":"2 chopped",
"Measure4":"2 chopped",
"Measure5":"1 chopped",
"Measure6":"1 chopped",
"Measure7":"1",
"Measure8":"2 tsp",
"Measure9":"1 tsp ",
"Measure10":"2 tbs",
"Measure11":"2 tsp",
"Measure12":"2 cups ",
COM594 2023-24 CRN: 49642
Page 6 of 12
"Measure13":"1 tbs",
"Source":"http://www.geniuskitchen.com/recipe/authentic-jamaican-brownstew-chicken-347996",
"ImageSource":null,
"CreativeCommonsConfirmed":null,
"dateModified":null
"Meal":"Chicken & mushroom Hotpot",
"DrinkAlternate":null,
"Category":"Chicken",
"Area":"British",
“MealThumb":"https://www.themealdb.com/images/media/meals/uuuspp151
1297945.jpg",
"Tags":null,
"Youtube":"https://www.youtube.com/watch?v=bXKWu4GojNI",
"Ingredient1":"Butter",
"Ingredient2":"Onion",
"Ingredient3":"Mushrooms",
"Ingredient4":"Plain Flour",
"Ingredient5":"Chicken Stock Cube",
"Ingredient6":"Nutmeg",
"Ingredient7":"Mustard Powder",
"Ingredient8":"Chicken",
"Ingredient9":"Sweetcorn",
"Ingredient10":"Potatoes",
"Ingredient11":"Butter",
"Ingredient12":"",
"Ingredient13":"",
"Ingredient14":"",
"Ingredient15":"",
"Ingredient16":"",
"Ingredient17":"",
"Ingredient18":"",
"Ingredient19":"",
"Ingredient20":"",
"Measure1":"50g",
"Measure2":"1 chopped",
"Measure3":"100g ",
"Measure4":"40g",
"Measure5":"1",
"Measure6":"pinch",
"Measure7":"pinch",
"Measure8":"250g",
"Measure9":"2 Handfuls",
"Measure10":"2 large",
COM594 2023-24 CRN: 49642
Page 7 of 12
"Measure11":"1 knob",
"Measure12":"",
"Measure13":"",
"Measure14":"",
"Measure15":"",
"Measure16":"",
"Measure17":"",
"Measure18":"",
"Measure19":"",
"Measure20":"",
"Source":"https://www.bbcgoodfood.com/recipes/chicken-mushroom-hot-pot",
"ImageSource":null,
"CreativeCommonsConfirmed":null,
"dateModified":null
"Meal":"Chicken Alfredo Primavera",
"DrinkAlternate":null,
"Category":"Chicken",
"Area":"Italian",
“MealThumb":"https://www.themealdb.com/images/media/meals/syqypv148
6981727.jpg",
"Tags":"Pasta,Meat,Dairy",
"Youtube":"https://www.youtube.com/watch?v=qCIbq8HywpQ",
"Ingredient1":"Butter",
"Ingredient2":"Olive Oil",
"Ingredient3":"Chicken",
"Ingredient4":"Salt",
"Ingredient5":"Squash",
"Ingredient6":"Broccoli",
"Ingredient7":"mushrooms",
"Ingredient8":"Pepper",
"Ingredient9":"onion",
"Ingredient10":"garlic",
"Ingredient11":"red pepper flakes",
"Ingredient12":"white wine",
"Ingredient13":"milk",
"Ingredient14":"heavy cream",
"Ingredient15":"Parmesan cheese",
"Ingredient16":"bowtie pasta",
"Ingredient17":"Salt",
"Ingredient18":"Pepper",
"Ingredient19":"Parsley",
"Ingredient20":"",
"Measure1":"2 tablespoons",
"Measure2":"3 tablespoons",
"Measure3":"5 boneless",
COM594 2023-24 CRN: 49642
Page 8 of 12
"Measure4":"1 teaspoon",
"Measure5":"1 cut into 1/2-inch cubes",
"Measure6":"1 Head chopped",
"Measure7":"8-ounce sliced",
"Measure8":"1 red",
"Measure9":"1 chopped",
"Measure10":"3 cloves",
"Measure11":"1/2 teaspoon",
"Measure12":"1/2 cup",
"Measure13":"1/2 cup",
"Measure14":"1/2 cup",
"Measure15":"1 cup grated",
"Measure16":"16 ounces",
"Measure17":"pinch",
"Measure18":"pinch ",
"Measure19":"chopped",
"Measure20":"",
"Source":"",
"ImageSource":null,
"CreativeCommonsConfirmed":null,
"dateModified":null
(20 marks — 10 marks for search and 10 marks for connectivity)
Following this, if the user clicks on the second button Save meals to Database all the
retrieved details of all the retrieved meals will be saved to the SQLite database of the
device (using the Room library), by using the same tables which were utilised in the
previous subquestion.
(10 marks)
Clicking on the Search for Meals button will display the user with a screen which
contains a single textbox and a Search button.
The user can type in the textbox any string which is part of any the name of an meal
or an ingredient for a meal and subsequently press the Search button to display ALL
the meals in the database which contain the typed string in the Name or Ingredients
fields of the meal in the corresponding table containing this information.
The search should be case insensitive, and a match does not have to be a complete
match but partial. I.e., if the user types the string “pEp” the displayed meal(s) could
be, a meal which contains “Roasted Peppers” or “red pepper” in the list of meals
(names or ingredients of meals).
(14 marks — 9 marks for search and 5 marks for case insensitivity)
Extend the application so that when the user clicks on the Search for Meals button
(in the last subquestion) all the meals displayed are also displaying their image (it could
be a small thumbnail image)
(9 marks)
COM594 2023-24 CRN: 49642
Page 9 of 12
For all the tasks, the application should behave in a user-friendly manner when the
device is rotated from portrait to landscape and back to portrait mode. I.e., the
application should resume from exactly the same point (same screen and data) when
the orientation changes. The rotation of the device should not change what was the
user was seeing before the rotation.
(12 marks)
Extend the application so that the initial screen contains an additional button which
the user can press and subsequently type a string. All meals containing the string as
part of their name will be retrieved directly from the Web service (NOT THE DATABASE)
and displayed to the user.
For example, if the user types “CHi” all of the meals in the TheMealDB Web service
containing this substring in their name will be retrieved and displayed to the user.
These could be “The Chicken Kiev”, “cHicken French”, etc.
(12 marks)
Marking Scheme: The marks achieved for each part of the program are indicated in the
description of the task above. This will contribute to 70% of the overall marks. In addition to
this the following will be taken into account:
Quality of the UI and UX (e.g., quality, efficiency, look and feel of the application,
based on fonts, colours, etc.): 15%
Testing (Be resilient to failures such as loss of network connectivity, Debugging,
Profiling and Unit Testing): 15%
COM594 2023-24 CRN: 49642
Page 10 of 12
Assessment of Demo: (CW2)
It will be assessed on:
Raw Marks
(Out of
Multiply
by
Actual
Marks
Quality of the UI and
UX
15%
quality, efficiency, look and feel of the application, based on fonts,
colours, etc. 0.15
Functional
Demonstration of App
70%
You must demonstrate a functioning app. The App should work from
beginning to end as explained in 1, 2, 3, 4, 5, 6 and 7.
0.70
Testing
15%
Debugging, Profiling, Unit Testing and be resilient to failures such as
loss of network connectivity. 0.15
Total
COM594 2023-24 CRN: 49642
Page 11 of 12
Each element on the CW2 criteria will be awarded marks according to the following:
0 - 39 40 - 49 50 - 59 60 - 69 70 - 100
Quality of the
UI and UX
None of the
necessary elements
are implemented.
Some of the
necessary elements
are poorly
implemented.
No technical errors or
errors of layout. XML
runs as designed.
However, the XML
does not deviate
from basic layout.
All required elements
are implemented. App,
providing a wide
selection of features
such as button, text
box, etc.
All required elements
are implemented, and
XML interface are
visually pleasing and
add creativity and
functionality to the App.
Functional
Demonstration
of App
The marks awarded based on the functionality implemented as shown in the CW2 description.
Testing No testing provided Debugging details
provided
Debugging and
Profiling details are
provided
Debugging, profiling
and Unit testing details
are provided.
Debugging, profiling,
Unit testing and be
resilient to failures such
as loss of network
connectivity details are
provided."
Creating the Android application according to the provided requirements involves several key activities. Here's a breakdown of the activities along with the corresponding steps:
Activities and Steps
1. Setup Android Project
Create a new Android project in Android Studio.
Name the project (e.g., "MealPrepApp").
Set the programming language to Java.
Choose a minimum SDK that supports the Room library and networking functionalities.
Add required dependencies to build.gradle.
Room library
Retrofit or another HTTP client library.
Gson for JSON Parsing (if necessary).
Glide or Picasso for image loading.
Any other UI or utility libraries you might need.
2. Design UI Components
Main Activity Layout (activity_main.xml)
Three buttons: Add Meals to DB, Search for Meals By Ingredient, and Search for Meals.
Activity for Adding Meals to DB
Simple UI to inform that meals are being added (optional).
Activity for Searching Meals by Ingredient (search_by_ingredient.xml)
Textbox for entering the ingredient.
Two buttons: Retrieve Meals and Save Meals to Database.
RecyclerView to display the list of meals.
Activity for Searching Meals by Name or Ingredient (search_meals.xml)
Textbox for entering search string.
Button: Search.
RecyclerView to display the list of meals with images.
Additional Activity for extended search from the web (search_from_web.xml)
Textbox for entering the string.
Button: Search.
RecyclerView to display meals retrieved from the web.
3. Implement Database using Room
Create Entity Classes for Meal
Define classes with annotations for Room (e.g., @Entity, @PrimaryKey, @ColumnInfo).
Create DAO Interfaces
Define data access methods (e.g., insert, query).
Create Database Class
Annotate with @Database and include entities and version.
Create Repository Class
Abstracts access to multiple data sources.
4. Implement Network Client and Data Models
Set Up Retrofit
Define base URL and create retrofit instance.
Define API interface for @GET requests to fetch meal data.
Create Data Models
Define models to match JSON structure from the MealDB API.
5. Add Functionality to Add Meals to DB
Button Click Listener in MainActivity
Fetch predefined meals and store them using Room.
6. Implement Meal Search by Ingredient Activity
Retrieve Meal Data
On Retrieve Meals button click, fetch data from MealDB API using Retrofit.
Parse JSON response and display in RecyclerView.
Save Retrieved Meals to Database
On Save Meals to Database button click, save fetched meals to Room database.
7. Implement Meal Search Functionality
Search Meals by Name or Ingredient
On Search button click, filter meals in the Room database.
Display results in RecyclerView with images.
Display Thumbnails
Use Glide/Picasso to load and display images in RecyclerView items.
8. Handle Orientation Changes
Ensure UI/State Persistence
Save UI state using ViewModel, LiveData, or savedInstanceState.
Restore state on rotation.
9. Implement Search from Web Service
Extend MainActivity
Add an additional button for searching directly from the web service.
Implement the functionality to retrieve and display meals from the web service.
10. Enhance UI and UX
Improve Layouts
Utilize Material Design components.
Ensure consistency in fonts, colors, and button styles.
Test different screen sizes and orientations.
11. Testing and Quality Assurance
Unit Tests
Write unit tests for critical components like database operations and network requests.
Integration Tests
Ensure that the application handles network failures gracefully.
Use debugging and profiling tools to optimize the app's performance.
Test the application for edge cases and ensure it performs well under various conditions.
Implementation Steps
Setup Project: Create a project and add dependencies.
Design UI: Create XML layouts for Activities.
Implement Database: Set up Room with entities, DAOs, and the database.
Network Client: Implement Retrofit client and data models.
Core Functionalities: Add meals to the database, search by ingredient, and search by meal.
Enhance UI: Ensure the UI is user-friendly and aesthetically pleasing.
Handle Orientations: Manage state persistence across orientation changes.
Additional Search: Implement search directly from the web.
Testing: Perform thorough testing, including unit, integration, and UI tests.
By following these activities and steps, you can systematically develop the required Android application that meets the specified requirements.