In this assignment you will build an Android application. You will get familiar with common Android visual components and how to interact with them, how to build dynamic layout, how intents work, how to pass data between multiple activities and how to use setTag(). You will build a Pizza Store Application. Pizza Store Calculator This is a calculator that calculates the total price of the Pizza to be ordered, the app
Figure 1, Application Wireframe enables the user to add toppings, delete toppings, choose for home delivery option and clear the pizza of toppings. You will learn how to dynamically (programmatically) add visual components to your activity according to user actions. You will get familiar with intents and how to pass data between multiple activities. Breakdown of assignment is as follows: This assignment is composed of two activities namely: Main Activity and Order Activity. Part 1: Main Activity Layout Your app layout should strictly follow the wireframes provided in this document. You are free to use any type of layout components. You should setup the required layout properties to ensure that objects are displayed as required. The provided support files include all the required images. The images of the current toppings added to the pizza are displayed, and the pizza capacity (number of toppings on the pizza) is displayed at the bottom of the pizza as a progress bar. The “Add Topping” button enables adding new toppings to the pizza, and the “Clear Pizza” button enables clearing all the pizza’s toppings. A checkbox below the Pizza is checked if the User requires the pizza to be delivered. An empty pizza layout is shown in Figure 2.
! Figure 2, Initial empty Pizza. Table 1, Items unit prices Add Toppings Clicking “Add Topping” button should perform the following: • The pizza has a maximum capacity of 10 toppings. So, if the user tries to add more items, the app should not allow the addition of any new toppings and should display the following Toast message: “Maximum Topping capacity reached!”. Otherwise, perform the following steps. • Display an alert dialog displaying a list of items, as shown in Figure 3(b). For information on using alert dialog check http://developer.android.com/guide/topics/ui/ dialogs.html • When the user selects a topping: 1. Update the interface to display the icon for the selected item, as shown in Figure 3(c). The selected item should be added to the interface dynamically, i.e. your layout should not have the visual component that corresponds to the item at compile time. It should be added at run time. The Items should be centered horizontally relative to the pizza image. 2. Update the current pizza capacity according to the number of toppings added. 3. If there was 10 toppings added already, display a Toast message indicating “Maximum capacity!” • Note that there are two rows of pizza toppings, you should fill the upper row (5 items), then start adding toppings to the lower row, as shown in Figure 3(c).
(a) Tapping add topping (b) Alert Dialog topping list (c) Topping added to pizza Figure 3, Adding a Topping Remove Topping Clicking any currently added toppings should do the following: • Remove the topping from the app layout. Update pizza capacity to reflect the removal of the selected item from the pizza. (You can use tags or any other approach to maintain information in the UI component). • Note that there are two rows of toppings, the lower row is allowed to have toppings only if the top row is full (5 items). Deleting an item in the top row should push the left most item in the lower row to the top row to maintain this property. Please check Figure 4(a) and 4(b). Clear Pizza ( Clicking the “Clear Pizza” button should do the following: • Clear (Delete) all the current toppings from the app layout. • Reset the current pizza capacity progress bar to 0. Checkout Upon clicking the Checkout” button, the information about the number of toppings and Delivery option should be collected and then start the Order Activity and pass the information as part of the extras.
(a) Clicking an item (b) Pizza updated & checked Delivery box (c) Checkout Figure 4, Deleting Toppings & Checkout Part 2: Order Activity This activity displays the Order that is placed in the Main Activity. The interface should be created to match the user interface (UI) presented in Figure 5. To build the UI, please follow the following tasks: • This activity is started by the Main Activity. When the Order Activity is created it should retrieve the values sent from the Main Activity in the intent’s extras. • The base price of pizza remains fixed as shown in Table 1. • Number of Toppings are multiplied to its price and the total value is shown below the base price along with the toppings added in comma separated form. Note that the repeated toppings are also getting appended. • If the delivery option is checked as shown in Figure 4(b), its cost is added to the total else it is not supposed to be calculated and displayed. • Clicking on “Finish” button will end the Order Activity and will start the Main Activity.