Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Muhammad Yousaf
017
BCS (H)
Session 2011-2015
Department of Computer Science
Institute of Management Sciences
Peshawar, Pakistan
December 1, 2014
Remember My Grocery Android App
This Project Report is submitted in partial fulfillment of requirements for the degree
of Bachelor in Computer Science to the Department of Computer Science, Institute of
Management Sciences as on Dec 1st, 2014.
Research Scholar:
Muhammad Yousaf
Supervisor:
Ms. Huma Samin
Supervisor
Signature:
Name:
Designation:
Institute:
External Examiner
Signature:
Name:
Designation:
Institute:
Internal Examiner
Signature:
Name:
Designation:
Institute:
DEDICATION
I hereby declare that this App is neither as whole nor as a part has been copied out
from any source. It is further declared that I have developed this App and
accompanied report entirely on the basis of my personal effort, under the sincere
guidance of my teachers. If any part of this system is proved to be copied out from
consequences.
Muhammad Yousaf
Signature ..
Date.
Acknowledgement
At the end I want to thank Madam Huma Samin who didn't let any stone
unturned in helping me regarding each and every stage of my final year project.
Muhammad Yousaf
INSERT TABLE OF CONTENTS HERE
7
Insert List of Figures Here
8
Abstract
Muhammad Yousaf
Yousafkh18@gmail.com
The purpose of this project is to facilitate and give people the ability to keep track of the
groceries they are buying off market. Buying of groceries is a daily or weekly task for most of
the people, the problem here is; people tend to forget or cannot keep track of what they are
buying, they use traditional techniques of pen and paper to remember the groceries they have to
buy. I have solved the problem by providing the digital inventory of products to choose from
before going to the market and also keep track of what they have previously purchased on the go
i.e. providing all these features on their android smartphone. This will result in people having
9
Chapter 1
Introduction
1.1 Introduction
Buying of groceries is a periodic task which has to be done on daily, weekly or monthly basis.
This project helps in assisting these tasks by providing a user friendly interface to create list of
items they want to buy and keep track of their purchases all within the android app. This app
provides the latest prices off the market. This will give users the convenience to know the prices
Android is the most widely used mobile operating system in the market, there are thousands of
devices made by different vendors which are supported by different versions of Android OS,
there are millions of users around the globe who uses the android platform. Other than that
Android provides a lot of features through different smartphones which attract a lot of users.
Android also provides a good API (Application Programming Interface) with complete
documentation, which assists when developing apps for android. So In conclusion, Android
having such a large user-base and a lot of features means a lot of people will use this app and get
advantages from it, thats why I have used android to develop my application.
10
1.3 Scope
1.3.1 Scope-In
Scope of this project includes giving users the ability to make lists of products they want to buy
off the market. Users can find the latest prices of products within the app. Users can create
multiple list of products on the basis of their need. Users can see their purchase history (aka
expense history) such that they can keep track of what theyve bought previously.
1.3.2 Scope-Out
This project doesnt give users the ability to buy a product from a shop (online). It doesnt
1.4 Objective
The purpose of this project is to give convenience of having all the product prices available on
the hand before buying something from market. Thus creating a list of items with updated prices
of products, and also calculating the expenses. It will give more productivity to its users in return
11
Chapter 2
Background Study
I have conducted a theoretical background study relating this problem before designing the
application. I took into account the problem people face while buying their groceries and keeping
track of their expenditure on this category of expenses. People often use to forget the items they
have to buy; they dont know the prices of products beforehand i.e. without visiting a grocery
shop or market.
On the other hand there are a lot of users with android smartphones which uses apps like to-do
lists etc. which doesnt actually help them in assisting this task rather give them more overhead
to research for products prices and insert them into to-lists app manually.
There are majority of android users (36.6%) who use android KitKat version, so I have
developed my application on this version of android to give support to most users. But the app
compatibility is not just limited to KitKat version, users with older versions or newer versions
12
2.2 Functional Requirements
Functional requirement describes the functions on the basis of which the app has been
developed, these are functional features users can have while using the app.
User Login / Registration: Before using any functionality of the app, User must create an
account at first, this functionality is available within the app. User have to provide username,
email, password and other optional information related to user such as Name, Date of Birth,
Lists Creation / Deletion: User can manage the lists they create, they can add items, remove
items from a particular list at any time. Users can also delete any list they have created.
Lists Price calculation: Once a user creates a list, this app automatically calculates the
prices of products in that list and show the sum of product prices and the number of products
in that list.
Products Information processing: When selecting a product from a large list of products
user can edit information such as they can change the amount they want to buy or add some
Products Categorization: Users can select products from a list based on different categories.
User can select any category and they will only see products from that particular category.
Expenses Calculation: Expense calculator gets all the lists user have created on a particular
date and shows user a history of how many items user have bought and what was the total
13
Product Information Retrieval: Users have the ability to search through a list of products
Synchronization: This app provides user to use the app both online and offline such that if
the user is online, the online database can be synchronized with the local database such that
i. Easy to use
ii. Reliable
Java
PHP
XML
HTML/CSS/SQL
XAMP Server
14
Geany Text Editor
MySQL, SQLite
15
Chapter 3
Android Operating system is composed of different layers; each layer gives support/services to
the layers above it. Its kernel is built over Linux which gives hardware support for upper layers.
16
Android uses Dalvik Virtual Machine to compile the Java code to Dalvik Byte code which is
then executed in the Dalvik VM. Android core libraries are written in C Language. For local
Database Android uses SQLite, in which relevant data, related to applications, can be stored and
retrieved easily.
17
3.2.2 Expanded Uses Cases
UC1
Name SignUp
Pre-Conditions None
18
Step 4 is loaded and shown to the user
8
User can choose a profile photo to
9 upload or they can skip this step by
pressing the Finish Button
All the user information is processed and sent
10 to web service to be uploaded to MySQL
server
Login Screen is shown to the user
11
Alternate Scenarios
10* Cannot connect to the server, user is shown the login screen
3* Username does not exists, user must enter correct username that is not taken already
UC2
Name LogIn
19
1 User enter username, password and
press Sign In Button
Username and password sent to web service to
2 verify authenticity from online database.
Alternate Scenario
UC3
20
1 User click on Products on Home screen
System checks if user is viewing the Products
2 Activity for the first time.
Alternate Scenario
21
Use Case UC4: View Categories
UC4
Actors User
22
Alternate Scenario
23
Alternate Scenario
Successful Post Conditions User lists are synchronized with the server
24
3 System sends all the deleted lists name to the
server.
Alternate Scenario
Actors User
25
UC7 (Section Add Lists)
Actors User
Alternate Scenario
26
3 User enters a list name then press
cancel button
System removes the dialog box and display
4 the current items in list
Actors User
27
Alternate Scenario
Actors User
28
System launches the List Products Activity
4 and display it to the user
Alternate Scenario
Description User can view all the products they have added
into a particular list
Successful Post Conditions User can view the products they have added to
the list
29
System launches the List Product Activity
2
System Loads the products of particular list
3 from SQLite.
List-View is inflated with the following
4 products and shown to the user.
Alternate Scenario
30
Typical Course of Events
Alternate Scenario
31
Use Case UC10: Edit Product Details
UC10
32
Alternate Scenario
Actors User
33
Typical Course of Events
34
Alternate Scenario
35
4 User clicks the done button
System sends the data to online server
5
MySQL database is updated with the given
6 information
Actors User
Alternate Scenario
36
3.2.3 System Design Sequence Diagrams
UC1
37
UC2
UC3
38
UC4
39
UC5
UC6
40
UC7
41
UC8
UC9
42
UC10
UC11
43
UC12
UC13
44
3.2.4 Sequence Diagram
UC1
45
UC2
46
UC3
47
UC4
48
UC5
49
UC6
50
UC7 (Section Add)
51
UC7 (Section Delete)
52
UC7 (Section Edit)
53
UC8
54
UC9
55
UC10
UC11 (Comparison)
56
UC11 (Products Bought)
57
UC11 (Products Prices)
58
UC12
59
UC13
60
3.2.5 Data Flow Diagram (DFD)
Level 0 DFD
Level 1 DFD
61
3.2.6 Entity Relationship Diagram (ERD)
62
3.2.6.1 Normalization
First Normal Form (1NF)
The above conceptual design represent that none of the table has multi valued attributes so the
63
Second Normal Form (2NF)
In the above diagram it can be seen that there are primary keys defined which on which all the
other attributes are dependent. Therefore the table is in Second Normal Form.
64
Third Normal Form (3NF)
In the above diagram it can be seen that, each of the non key attributes are functionally directly
dependent on each candidate of the relation i.e. it does not contain any transitive dependencies.
65
3.2.7 Class Diagram
66
Chapter 4
some core components which we will discuss in this chapter. Other than that we have used some
external libraries with in our application we will also discuss those libraries. <Use Passive
Voice>
4.1 Activity
Activities in android are the building blocks of creating basic or more advanced applications. An
Activity defines a single screen in an android device. It defines all the UI elements to be shown
User can move from one Activity to another as defined in the application such as in this
application user is presented with Login Activity, after successful authentication user is shown a
User Interface for a single Activity is defined in an XML file, which provides a very easy drag
and drop interface to add UI elements to an activity. All the logic behind each UI element is
67
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/homescreen_listview"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
68
4.2 Android Manifest
Android Manifest is another core feature of Android framework. Android provides an XML file
with every application in which all the metadata related to the application is stored. Data such as
Android Manifest file is also used by Google Play Store to list the app according to its
specification. For example if an App has camera permissions, Google will not show the app to
the users who does not have a camera on their phone. The content of Android Manifest XML file
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".LoginScreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
69
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeScreen"
android:label="@string/title_activity_home_screen" />
<activity
android:name=".GroceryList"
android:label="@string/title_activity_grocery_list" />
<activity
android:name=".GroceryItems"
android:label="@string/title_activity_grocery_items"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".ProductDetails"
android:label="ProductDetails" />
<activity
android:name=".Test"
android:label="@string/title_activity_test"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".SignUpScreen"
android:label="@string/title_activity_sign_up_screen"
android:theme="@style/AppTheme.AppBarOverlay"
android:uiOptions="splitActionBarWhenNarrow" />
<activity android:name=".Category" />
<activity android:name=".ProcessSignUp" />
<activity android:name=".ProductsList" />
<activity android:name=".ExpenseHistory" />
<activity android:name=".ProductsPieGraph" />
<activity android:name=".PriceBarGraph" />
<activity android:name=".NavigateMonth" />
<activity android:name=".ComparisonGraph" />
<activity android:name=".EditProfile"></activity>
</application>
</manifest>
70
4.3 Intents
There are two different types of Intents in Android i.e. Implicit Intents and Explicit Intents.
Android Framework allows you to call any component as long it is available, so if any
application needs Google map functionality and doesnt want the overhead to write all the code,
Implicit Intents are used to use the functionality of other applications or let other applications use
some of your app functionalities. In our application we have used implicit intents to fetch images
Implicit Intent
Explicit Intents on the other hand are used within the application to call different components of
the same application, such as we use explicit intents to call another activity. Example:
Explicit Intent
Intent passIntent = new Intent(GroceryList.this,ProductsList.class);
passIntent.putExtra("ListNumber",allLists.get(i).getUserlistno());
startActivity(passIntent);
71
4.4 Gradle
Gradle is the new build system for Android, it comes with any install of Android Studio. This
new build system is used to package, test or run the applications. This system gives much more
robustness to android applications such as it lets you define minimum sdk, target sdk, external
It provides a properties file to define all the above, the content of build.gradle file in our
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.bcs.python.remembermygroceries"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-
rules.pro'
}
}
}
72
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.android.support:design:22.2.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile files('libs/mpandroidchartlibrary-2-1-6.jar')
}
Web Services provides some external support the Application. One simple example of Web
Services is the Cloud system, through which user can save, retrieve or edit their files without
worrying about how they are stored or on what operating system they are stored. Web Services
provides functionality to process the data related to application without using a processor of the
Apache and MySQL is one form of providing web services to the applications. In our case we
have used these web services to keep the entire user data synchronized with the application, no
matter which device they log on to, their data will always be available due to web service
functionality. On the other hand we have used the web service to update application data such as
adding new products or updating current product prices. All these can be done by simply logging
73
4.5 Shared Preferences
Android provides multiple APIs to store data in the Android device, one of them is Shared
Preferences, which is an efficient way to store application settings in an XML file, which in
In this application Shared Preferences have been used to store the user session data such as, if
user signs in his data will be stored in a Shared preferences file which will remain static for the
session, when user signs out the data from session will be removed.
SharedPreferences pref;
Editor editor;
pref = _context.getSharedPreferences("com.bcs.python.UserSessionMgmt", PRIVATE_MODE);
editor = pref.edit();
editor.putInt("uid",u.getUid());
editor.putString("username",u.getUsername());
editor.putString("firstname",u.getFirstName());
editor.commit();
pref.getInt("uid",-1);
74
4.6 SQLite Database
Android provides a version of very popular SQL database. SQLite in android is used to store and
organize data which cannot be done through simple flat files or XML. SQLite in android
provides an easy to use API through which almost all of the SQL commands can be executed
Unlike other SQL platforms android does not support visual IDE for database, everything that
SQLiteDatabase db = this.getWritableDatabase();
values.put(GrocerySchema.GroceryUsers._USERNAME,u.getUsername());
values.put(GrocerySchema.GroceryUsers._PASSWORD,u.getPassword());
75
4.7 External Libraries
We have used some external libraries in our application to support some new features. Here we
will discuss some of the libraries that are included in this application.
This library gives a very easy to use Application Programming Interface (API) which allows us
to download and display images from the internet with just writing a few lines of code. We dont
have to worry about the overhead of making http requests, making connections to the online
server etc. Heres a simple code snippet from this application to fetch an image from URL:
ImageLoader.getInstance().init(config);
String s = product.get(position).getPpic();
String url = "http://"+SERVERIP+"/remembermygroceries/uploads/"+s;
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(url, groceryProductPicture);
76
Chapter 5 Implementation
5.1 Screenshots
1) Login Screen
2) Signup Screen
3) Home Screen
4) View Products
5) View Product Details
6) View Categories
7) View Lists
8) Create List
9) View List Products
10) View Expense History
11) This Month Expense History
12) Comparison
77
1) Login Screen
Login Screen is the first screen visible to the user when the application is launched. If its first
time for a user then they have to sign up or they can put their credentials in username and
78
2) Signup Screen
If User presses sign up button on login screen they will be presented with a 4 step signup form.
This is the first step where user have to enter mandatory data such as email, username and
password. Users username must always be unique, two users with same username cannot exists.
79
User must enter a username and click the check username button, if user with same username
exists an error icon will be shown, else available icon will be displayed.
80
Once user fills out step 1 and press Next button, application will display step 2, where user will
After user press the next button, step 3 will be displayed, requesting for date of birth, here user
81
This is the last step of signup process where user will be asked to choose a profile picture, they
can either choose a picture or skip this step by pressing finish button.
After finish button is clicked, application will display a successful signup message and login
82
3) Home Screen
Home Screen is the activity that will be displayed when user signs in to the application. From
here user can navigate to any part of the application. Such as Products, Categories, Lists.
Users can press the add button on the top right of the screen to create a new list.
User can also swipe the screen from left side in result of which a separate menu will appear
where user can edit or view their profile, view expense history or logout.
83
4) View Products
User can view products activity by clicking the Products options from Home Screen. Here user
can see a wide list of products and their prices, user can select multiple products from this
activity and press the Done button on the top right of the screen. User can also press the
Synchronize button on the top of the screen to synchronize the products with the server as the
84
result of which, new products will be added to the Products page if there are new products added
on the server.
85
5) View Product Details
On the Products Screen, User can long click any product to launch a detailed screen of product,
where user can enter product quantity according to their requirement or they can add extra notes
if they want to take with them while buying products. Once done updating the product details,
user can press the Done button on the top right of the screen, or user can skip adding details and
press the Cancel button to go back to the Products Page.
86
6) View Categories
Categories Screen can be launched from the home screen. Here user can select products in a
more organized form. They can choose products from different categories according to their
need.
87
7) View Lists
List is launched from the home screen. Here user can create multiple list, they can also manage
their lists by long tapping any list, which displays a context menu through which user can delete
or edit a list.
88
8) Create Lists
On the List screen, user can click the Add Button on the top right of the screen, which will
display a dialog box, where user can enter a unique name for their list and press Ok Button, or
they can press Cancel button to skip the dialog box and display the List screen.
89
9) View List Products
List Products Screen can be launched by clicking on any list in the List screen. Here user can
view their products i.e. the products they have added to any particular list.
They can click on any item to mark it as bought. They can also long click on any product to view
the details they have set for this product such as quantity or notes.
90
10) View Expense History
Expense History is launched from the home screen, here user is displayed with three options i.e.
This Month, Last Month and Comparison. User can select any of the given option to view
expense history.
91
11) This Month Expense History
Here user have two options to select from, Products bought and Products Prices, which
categorizes the expense history according to products bought and total price of the products
respectively.
92
By selecting Simple Products Bought, user will be displayed a simple overview of the products
they have bought this month or last month (shown on the basis of option selected from Expense
History Screen).
If user selects Simple Products Prices option, they will be displayed a simple overview of all the
products prices bought this month or last month.
93
By selecting Products Bought, user will be displayed a Pie graph of the products they have
bought this month or last month (shown on the basis of option selected from Expense History
Screen).
If user selects Products Prices option, they will be displayed a Bar Graph which defines all the
products prices bought this month or last month.
94
12) Comparison Screen
Comparison screen shows the comparison between the total of products prices bought in last
month and the current (this) month.
95
Chapter 6 Software Testing
Software testing is a mandatory requirement for approving final software. It verifies if software
is bug or error free. Software testing ensures the reliability, stability, security and better
performance of a system. There are two ways to test the system i.e. black box testing and white
box testing; here our main focus will be on black box testing.
In black box testing we will be focusing on the inputs given and the outputs produced, we will
96
6.1.1 Login Test Case
In Login Activity, there are 2 EditTexts and 2 Buttons. One of the EditText defines the username
and the other one password. There is a login button and a signup button. User have to enter
username that can be up to 15 characters long and password that can be up to 20 characters long.
On the click of the login Button user will be successfully logged in to the system. If user does not
enter either of EditTexts, System will prompt a Toast to enter the username or password. If user
enter wrong username or password, System will display a Toast with a wrong username or
password message. If User is not connected to the internet and press login button, System will
prompt a Toast message, connect to the internet. If the system could not connect to server a
Toast message will be displayed Cant connect to the server, try again after few seconds.
97
98
6.1.2 Signup Test Case
Signup Activity is a 4 step process, in step 1 there are 4 EditTexts and 2 Buttons. Each of the
EditText takes an individual input i.e. email, username, password and retype password. One of
the Button checks whether a username is available or not and the other Button takes the user to
next step. If a user enters a username that already exists, System will prompt a Toast message,
Username already exists. If user enters a username and does not click the check button, System
will prompt a toast message, check the username first. If the user is not connected to the
internet, System will display a toast message, Connect to the Internet. If a user checks their
input username, if the username exists, System will display a correct icon otherwise System will
display a wrong icon. If any of the EditText is empty, System will show a toast message, Fill out
the Form. If user enters two different passwords in EditTexts, System will show a toast message,
Password does not match. On correct inputs user will be prompted to step 2 and step 1 details
will successfully be saved.
99
100
101
102
6.1.3 Products Test Case
GroceryItems Activity has a ListView and 2 Options Menu Buttons. One Button has
functionality of Synchronization and other Button is used to add items to the list. If a user does
not select any item from the listview and press the select Button, System will display a toast
message, Select at least one item. If a user is not connected to the internet and press the
Synchronization Button, System will display a toast message, Connect to the internet. On
correct input products will be successfully synchronized and items will be added to the list.
103
6.1.4 Product Details Test Case
In Product Detail Activity, There are 2 EditTexts, 1 Spinner, 2 TextViews and ImageView.
ImageView displays a product picture, one of the EditText takes quantity as input and other takes
product notes as input. Products Quantity only takes Integer as input, therefore user cannot input
any alphabet in the quantity EditText. On correct input the product details will successfully be
modified.
104
6.1.5 Lists Test Case
In List Activity, There are 2 Context Menu Buttons, 2 Options Menu Buttons, ListView and
Dialog Box. ListView shows all the lists, One of the Options menu Button is used for
Synchronization, user cannot user the Synchronization if they are not connected to the internet,
System will display a toast message, Connect to the internet to synchronize. The other Options
menu Button is used to create a new list, when clicked it shows a dialog box to enter the name of
the list, user cannot create a list with the same name, if they enter the same name in the dialog
box, System will show a toast message, List with same name exists. If the System is not able to
connect to the server a toast message will be displayed, Cannot connect to the server, try again
later. On successful entry of list name, a toast message will be displayed, and List will be
created in SQLite.
105
106
6.2 Unit Testing
In unit testing each module will be tested for given input and output produced.
107
6 Signup Activity, User have to enter Pass
their password twice.
Password match They cannot proceed
of not same
108
12 List Products On List sync, user Pass
Synchronization created list-products
will be synchronized
with the online
MySQL database
109
Chapter 7
Conclusion
The main purpose of this application is to give user a service for which the user has to make a lot
of effort. Through this application a lot of tasks are automated which saves the user a lot of time
and they can increase their productivity by using this application, In a way that they can find all
the latest prices of products on the tip of their finger, they can create multiple lists, and more than
that they can keep track of what they are buying by keeping an eye on expense history. Another
feature that the user enjoys is the Synchronization process through which they can access their
created lists on any device they logged into. Overall this application helps users in a lot of their
Future Work
This application is in an always evolving process, As there are new versions of Androids are
released this application will be modified accordingly with the new features that will be available
along in the new versions. This application will also be developed for iOS which will let more
110