Sei sulla pagina 1di 110

Remember My Grocery Android App

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

Head of Computer Science Department:


Dr. Furqan Aziz
Remember My Grocery Android App

It is certified that we have studied this final dissertation by Muhammad Yousaf in


detail. We conclude that this dissertation is of sufficient standard to warrant its
acceptance by the Institute of Management Sciences for the award of the degree of
BS in Computer Science.

Supervisor
Signature:
Name:
Designation:
Institute:

External Examiner
Signature:
Name:
Designation:
Institute:

Internal Examiner
Signature:
Name:
Designation:
Institute:
DEDICATION

I dedicate my work to My Parents, My Family,

My Friends, My Respected Teachers who

motivated, supported and encouraged me

in every aspect of my life.


Declaration

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

any source or found to be reproduction of someone else, I shall stand by the

consequences.

Muhammad Yousaf

Signature ..
Date.
Acknowledgement

In the name of Almighty Allah, the most Merciful, Gracious, and


compassionate. His generosity and sanctions enabled me to accomplish this
task. I express my warm gratitude to my parents who were and are always with
me in thick and thin, my class fellows and friends who encouraged me not to
give up in hard jiffs. I am thankful to all family members for their prayers,
moral support and sincere wishes for the completion of my work.

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

Remember My Grocery Android App

Muhammad Yousaf

Institute of Management Sciences, Hayatabad, Peshawar

Yousafkh18@gmail.com

December 1st, 2014

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

more productivity and saving of time.

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

of product while at home or on the go.

1.2 Why Android?

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

include information from real bank account to create an expense history.

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

and save a lot of time for the users.

11
Chapter 2

Background Study

2.1 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

can use this app without losing any functionality.

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,

Profile Picture etc.

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

notes before they put the product into any list.

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

expense and what categories are the products from.

13
Product Information Retrieval: Users have the ability to search through a list of products

and select the desired product.

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

user can have all the latest prices of products.

2.3 Non Functional Requirement

i. Easy to use

ii. Reliable

iii. Robust to failure

iv. Better Responsiveness

2.4 Proposed Languages

Java

PHP

XML

HTML/CSS/SQL

2.5 Proposed Development Software


Android Studio

XAMP Server

14
Geany Text Editor

MySQL, SQLite

Android Operating System

15
Chapter 3

System Architecture and Design

3.1 System Architecture and Design

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.

3.2 System Design

3.2.1 Use Case Diagram

17
3.2.2 Expanded Uses Cases

Use Case UC1: Sign Up

UC1

Name SignUp

Actors User, Web Services

Purpose Register user.

Description On Launching the application, user is shown


the login screen along with Sign up Screen,
User have to sign up in order to login into the
application

Cross Reference None

Pre-Conditions None

Successful Post Conditions User account is successfully created

Typical Course of Events

Actor Action System Response

1 User clicks on Sign Up Button


Sign Up form is loaded into the Activity and
2 step 1 is shown to the user, waiting for the
user to enter data.
User enters Username, Email, Password
3 and then clicks Next Button
Step 2 is loaded and shown to user, waiting
4 for user input
User enters First Name, Last Name,
5 Gender and Phone Number and press
Next Button
Step 3 is Loaded and shown to the user
6
User enters Date Of Birth and Press
7 Next Button

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

Use Case UC2: LogIn

UC2

Name LogIn

Actors User, Web Services

Purpose Give users access to use the app features

Description Take username and password from user, verify


credentials and give access to the application

Cross Reference None

Pre-Conditions User must make an account (One time only)

Successful Post Conditions User is shown Home Screen to use the


application

Typical Course of Events

Actor Action System Response

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.

3 Home Screen is displayed

Alternate Scenario

Actor Action System Response

1* User enters wrong username or


password
An error message is shown to the user
2* requesting for correct username or password

2* Could not connect to the server, an error is


shown to the user.

Use Case UC3: View Products

UC3

Name View Products

Actors User, Web Services

Purpose Show Products to the user

Description User can see list of products through which


they can add their preferred products into lists.

Cross Reference None

Pre-Conditions Products must be loaded from MySQL

Successful Post Conditions List is inflated with all the products

Typical Course of Events

Actor Action System Response

20
1 User click on Products on Home screen
System checks if user is viewing the Products
2 Activity for the first time.

3 Products are loaded from MySQL or SQLite


based on viewing products Activity first time
or not.

4 Products activity is displayed to the user

Alternate Scenario

Actor Action System Response

2* If first time, Products are loaded from online


database(MySQL) and displayed to user
If not first time , products are loaded from
2* local database(SQLite) and shown to the user

21
Use Case UC4: View Categories

UC4

Name View Categories

Actors User

Purpose Show the categories to the user

Description User can see the products in different


categories, they can select any category to get
the products they want

Cross Reference None

Pre-Conditions Products must already be loaded into the


application.

User must visit the products page for one time


only to load all the products

Successful Post Conditions Categories are shown to the user in the


Activity, users can select products from
different categories

Typical Course of Events

Actor Action System Response

1 User click on Categories on Home


screen
Categories Activity is loaded from SQLite and
2 shown to the user.
User can select single or multiple
3 categories

4 System checks for selected categories and


inflate list-view with selected category
products

22
Alternate Scenario

Actor Action System Response

2* If first time, Products are loaded from online


database(MySQL) and displayed to user
If not first time , products are loaded from
2* local database(SQLite) and shown to the user

Use Case UC5: Products Synchronize


UC5

Name Products Synchronize

Actors Web Services

Purpose Load products data from server into the app

Description When new products are added to the online


database, this is used to load the new products
into the application

Cross Reference None

Pre-Conditions Product Activity must be launched.

Successful Post Conditions New Products from the server is successfully


loaded into the app

Typical Course of Events

Actor Action System Response

1 User click on Synchronize button in


Products Activity
System connects to online server
2

3 System checks for new products

4 Products are loaded into the SQLite database

23
Alternate Scenario

Actor Action System Response

1* User is not connected to the internet


Could not connect to the online server, an
2* error message is shown
There are no new products in the server, so
3* no new products are loaded into the
application

Use Case UC6: Lists Synchronize


UC6

Name Lists Synchronize

Actors Web Services

Purpose Load application data from server into the app

Description This sends all the user created lists to the


server, to be stored in MySQL database. Also it
checks if user have deleted any lists in SQLite
so that it also deletes the lists from online
MySQL

Cross Reference None

Pre-Conditions Lists Activity must be launched.

Successful Post Conditions User lists are synchronized with the server

Typical Course of Events

Actor Action System Response

1 User click on Synchronize button in


Lists Activity
System connects to online server
2

24
3 System sends all the deleted lists name to the
server.

4 System send the new lists that have been


created by the user

5 Lists are synchronized i.e. deleted from the


server and new lists are saved to the server
(MySQL)

Alternate Scenario

Actor Action System Response

1* User is not connected to the internet


Could not connect to the online server, an
2* error message is shown
There are no lists deleted by the user
3*
There are no lists created by the user
4*

Use Case UC7: Manage Lists


UC7 (Section Main)

Name Manage Lists

Actors User

Purpose To create, update or delete a list

Description Users can create, update or delete lists.

Cross Reference None

Pre-Conditions Lists Activity must be launched.

Successful Post Conditions Lists are successfully created, updated or


deleted.

25
UC7 (Section Add Lists)

Name Add Lists

Actors User

Purpose To create a new List

Description User can create a single or multiple lists with a


unique name for each list.

Cross Reference None

Pre-Conditions Lists Activity must be launched.

Successful Post Conditions Lists is successfully created.

Failure Post Conditions No New List is created

Typical Course of Events

Actor Action System Response

1 User clicks the Add Button


System opens a dialog box, waiting for user
2 to enter the list name

3 User enter the list name


System checks if name already exists
4
System creates the list with the given name
5 in SQLite database
System refresh the list view and the list is
6 shown to the user

Alternate Scenario

Actor Action System Response

1 User enters an invalid name


System checks if list with same name exists
2 an error is shown to the user if exists

26
3 User enters a list name then press
cancel button
System removes the dialog box and display
4 the current items in list

UC7 (Section Delete Lists)

Name Delete Lists

Actors User

Purpose To delete any List

Description User can delete any list they have created

Cross Reference None

Pre-Conditions Lists Activity must be launched.

Successful Post Conditions Lists is successfully deleted

Failure Post Conditions List is not deleted

Current lists are not effected

Typical Course of Events

Actor Action System Response

1 User long click any list


System shows a Context menu, showing
2 options to edit or delete the list.

3 User selects delete option


System creates a txt file, writes the name of
4 list to be deleted
System delete the list from SQLite
5
The List-view is refreshed and the remaining
6 lists are shown to the user

27
Alternate Scenario

Actor Action System Response

1 User opens a context menu, by long


clicking the any list item
Systems removes the context menu and show
2 the list of items

UC7 (Section Edit Lists)

Name Edit Lists

Actors User

Purpose To edit an already created list

Description User can edit a list by adding more items to the


list

Cross Reference None

Pre-Conditions Lists Activity must be launched.

Successful Post Conditions Lists is successfully edited.

Failure Post Conditions Lists are not modified.

There current state is preserved.

Typical Course of Events

Actor Action System Response

1 User long click any list


System shows a Context menu, showing
2 options to edit or delete the list.

3 User selects edit option

28
System launches the List Products Activity
4 and display it to the user

Alternate Scenario

Actor Action System Response

1 User opens a context menu, by long


clicking the any list item
Systems removes the context menu and show
2 the list of items

Use Case UC8: View List-Products


UC8

Name View List-Products

Actors User , Web Services

Purpose Show the products that are added in a


particular list

Description User can view all the products they have added
into a particular list

Cross Reference None

Pre-Conditions Products activity should be launched (Once)

Products should be selected

List must be created

Successful Post Conditions User can view the products they have added to
the list

Typical Course of Events

Actor Action System Response

1 User clicks on any 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

Actor Action System Response

1 User clicks on any list


There are no products available against that
2 list name
System loads the list products activity with no
3 items to show

Use Case UC9: Create List-Products


UC9

Name Create List-Products

Actors User , Web Services

Purpose Select products and add them to any list

Description User can select multiple products from Product


Activity and add them to any list.

Cross Reference None

Pre-Conditions Products activity should be launched (Once)

Products should be selected

List must be created

Successful Post Conditions List Products are created in SQLite

List Products are displayed to the user

30
Typical Course of Events

Actor Action System Response

1 User clicks Products in Home Screen

2 System load all the products from SQLite


and Launches the Products Activity

3 User selects single or multiple products

4 User press the Done button


System stores the selected products
5
System launches the List Activity
6

7 User clicks on any particular list


System saves the selected products in SQLite
7
System loads the List Product activity
8
All the selected products are inflated in the
9 list view and displayed to the user.

Alternate Scenario

Actor Action System Response

1 User selects multiple or single products

2 User does not press the done button and


closes the application or press the back
button
System shows the Home Screen activity
3

4 User selects product and press done


button, then closes the application or
press back button
System shows the Home Screen Activity
5

31
Use Case UC10: Edit Product Details
UC10

Name Edit Product Details

Actors User , Web Services

Purpose Set product quantity and set extra notes to take


with product

Description User can edit any product details such as the


quantity they want, they can select unit such as
grams, bottles, ounces etc.

Cross Reference None

Pre-Conditions Products activity should be launched (Once)

Products should be selected

Successful Post Conditions Product details are successfully updated in


SQLite and Activity

Typical Course of Events

Actor Action System Response

1 User Long Clicks any Product


System launches the edit product activity.
2 Display products to the user

3 User enters quantity, selects unit and


enter any extra notes

4 User press Done button


System saves the detail and launches the
5 Product Activity

32
Alternate Scenario

Actor Action System Response

1 User enters quantity, selects unit and


enter any extra notes

2 User presses cancel button


System launches the Product Activity and
3 display products to the user

4 User selects product and press done


button, then closes the application or
press back button
System shows the Home Screen Activity
5

Use Case UC11: View Expense History


UC11

Name View Expense History

Actors User

Purpose Display expense details of user

Description User can view all the products bought from


different categories, they can also view the
prices of categories they have spent money on

Cross Reference None

Pre-Conditions List must be created

Products should be added to the list

Successful Post Conditions Expense details are displayed to the user

33
Typical Course of Events

Actor Action System Response

1 User swipes the home screen on left


side, clicks on Expense History
System displays the expense history activity,
2 with three options This Month, Last Month
and Comparison

3 User selects This Month


System loads NavigateMonth Activity, and
4 displays two options Products Bough and
Products Prices

5 User Selects Products Bought option


System displays the pie graph which displays
6 all the details corresponding to products
Bought

7 User Selects Products Prices


System displays the bar graph which displays
8 all the details corresponding to products
prices

9 User selects Last Month


System loads NavigateMonth Activity, and
10 displays two options Products Bough and
Products Prices

11 User Selects Products Bought option


System displays the pie graph which displays
12 all the details corresponding to products
Bought

13 User Selects Products Prices


System displays the bar graph which displays
14 all the details corresponding to products
prices

15 User selects Comparison


System shows a comparison graph, it
16 calculates comparison data between last
month and this month

34
Alternate Scenario

Actor Action System Response

1 System have no lists to calculate list expense


data.

Use Case UC12: View/Edit Profile


UC12

Name View/Edit Profile

Actors User, Web Services

Purpose Display user profile information and let user


edit profile details

Description User can upload profile picture, change first


name, last name or password.

Cross Reference None

Pre-Conditions User must be registered

User must be logged in

Successful Post Conditions User can view profile details.

User profile details are successfully updated

Typical Course of Events

Actor Action System Response

1 User swipes the home screen from left


side, clicks on View Profile
System displays the edit Profile Activity
2

3 User enters first name, last name,


password or select a profile picture

35
4 User clicks the done button
System sends the data to online server
5
MySQL database is updated with the given
6 information

Use Case UC13: Log Out


UC13

Name Log Out

Actors User

Purpose User is signed off from the application

Description User is logged out of the application

Cross Reference None

Pre-Conditions User must be registered

User must be logged in

Successful Post Conditions Login screen is displayed to the user

Typical Course of Events

Actor Action System Response

1 User swipes the home screen on left


side, user selects the Log Out
System logs out the user
2
System displays the Log in Screen
3

Alternate Scenario

Actor Action System Response

1 System closes or the application crashes.

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

design in first normal form.

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

Android Framework Component


Android framework is composed of many different components, in this application we have used

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

on a single screen such as Buttons, TextViews, EditText etc., combination of different UI

elements can profile a user with a better user experience.

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

HomeScreen Activity and so on.

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

coded in JAVA file.

Heres an example of XML file for EditProfile Activity:

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">

<!-- The first child in the layout is for the main


Activity UI-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".HomeScreen"
android:background="#ffffffff">

<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/homescreen_listview"/>

</LinearLayout>

<!-- Side navigation drawer UI -->


<ListView
android:id="@+id/navList"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#ffeeeeee"/>

</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

permissions, intents, intent-filters and more.

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

for this application is given below:

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bcs.python.remembermygroceries">

<uses-permission android:name="android.permission.INTERNET" />


<!-- Include next permission if you want to allow UIL(universal image loader) to
cache images on SD card -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<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,

Android OS provides intents to use functionality of other apps.

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

from gallery. Example:

Implicit Intent

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,


MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);

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

dependencies and much more.

It provides a properties file to define all the above, the content of build.gradle file in our

application is defined below:

apply plugin: 'com.android.application'

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')
}

4.4 Web Services

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

android device itself.

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

into to the web service and adding all the functionalities.

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

return can easily be read or write from Shared Preferences API.

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.

Heres a code snippet of Shared Preferences:

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

such as INSERT, DELETE, UPDATE and CREATE etc.

Unlike other SQL platforms android does not support visual IDE for database, everything that

has to be included in the database has to be explicitly coded in Java.

Below is the simplified code to create a user in SQLite:

public void createUser(User u){

SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();

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.

1) Universal Image Loader

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:

DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()


.cacheOnDisc(true).cacheInMemory(true)
.imageScaleType(ImageScaleType.EXACTLY)
.displayer(new FadeInBitmapDisplayer(300)).build();

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(


getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.memoryCache(new WeakMemoryCache())
.discCacheSize(100 * 1024 * 1024).build();

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

password fields respectively to authenticate and use the application.

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

enter first name, last name, gender and phone number.

After user press the next button, step 3 will be displayed, requesting for date of birth, here user

must enter correct date of birth and then press next.

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

screen will be displayed to the user.

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.

6.1 Black box Testing

In black box testing we will be focusing on the inputs given and the outputs produced, we will

not be focusing on the internal organization of the system.

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.

Serial Number Test Case Description Expected Result Actual Result

1 Login Activity, On User will be Pass


input of username and successfully
password authenticated an
logged in to the
system

2 Login Activity, Username should not Pass


username and be more than 12
password EditText characters, similarly
character length password cannot
exceed 20 characters

3 Login Activity, If user is not Pass


connected to the
Internet connectivity internet they cannot
proceed from login
page

4 Login Activity, User will not be Pass


authenticated in case
Incorrect username or of wrong username or
password password

5 Signup Activity, User cannot proceed Pass


to next step of signup
Check username unless they check
their username

107
6 Signup Activity, User have to enter Pass
their password twice.
Password match They cannot proceed
of not same

7 Signup Activity, User needs to be Pass


connected to the
Internet connection internet to proceed
with the signup
process

8 Products Activity, User needs to be Pass


connected to the
Synchronization internet to
synchronize, on
successful sync new
products will be
added

9 Product Details On modifying product Pass


Activity, details such as
quantity or notes, user
Modifying the product will be prompted back
details to products page and
the product details
will be successfully
modified

10 List Activity, When creating a list, Pass


its name should not
List name characters exceed more than 2
length characters

11 List Activity, User should be Pass


connected to the
Synchronization internet to
synchronization, on
successful
synchronization, lists
will be sent to
MySQL database

108
12 List Products On List sync, user Pass
Synchronization created list-products
will be synchronized
with the online
MySQL database

13 List Products Activity, On clicking any items Pass


in List-Products
Products strike Activity, its view will
through successfully be
change to strike
through text

14 Edit Profile Activity, On successful entry of Pass


Firstname, Lastname,
Profile information Password and Profile
updating Picture. On clicking
the update profile
button, user profile
will successfully be
updated in Online
server

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

daily or monthly tasks.

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

users to use this application.

110

Potrebbero piacerti anche