Post on 17-Oct-2020
Academic Year 2011/2012 Warsaw University of Technology
Faculty of Electronics and Information Technology Electrical and Computer Engineering
BACHELOR OF SCIENCE THESIS
Tomasz Adamiec
Product Ingredients Analyser
Supervisor Robert Bembenik, Ph.D
Evaluation: .............................................
................................................................
Signature of the Head of Examination Committee
Electrical and Computer Engineering
Date of Birth: 1988.09.08
Starting Date of Studies: 2008.10.01
Curriculum Vitae
I was born on 8th September 1988 in Warsaw. In years 2004 – 2008 I have attended bilingual class in XXXIV High School named Miguel de Cervantes in Warsaw. During the undergraduate studies on Warsaw University of Technology I have received scholarship for seventh semester. I have also worked as an outsourcing manager assistant in ZTE Corporation for one year.
....................................................... Signature of the Student
Bachelor of Science Examination
Examination was held on: ................................................................................................... 2012
With the result: ............................................................................................................................
Final Result of the Studies: .........................................................................................................
Suggestions and Remarks of the B.Sc. Examination Committee: ..............................................
......................................................................................................................................................
......................................................................................................................................................
SUMMARY
The goal of this thesis is to create a mobile device application presenting the substance content of a scanned foodstuff. Information displayed to the user is taken from the database. It is a result of a SQL query and a barcode number obtained in the scanning process. User has an ability to read on the device’s screen the foodstuff’s contents and check possible negative health impact of a product computed by an algorithm designed especially for this purpose.
The program is a Java application written for Android 4.0 (industry codename: Ice Cream Sandwich) or higher. Database is running on a remote server. The whole communication process is done through HTTP and JSON protocols.
Thesis contains information on mobile platforms, databases and programming tools. Everything is explained at the level necessary to understand important concepts. A detailed project description is presented. It contains application structure, architecture, design goals and their realisation. Application code was evaluated by Sonar – a web application deployed on a server. Obtained metrics are presented and explained.
Keywords: Mobile Application, Android, Database, PostgreSQL, server, Tomcat, Jetty, JSON, barcode, Sonar, Jenkins, ZXing
STRESZCZENIE
Celem pracy jest stworzenie aplikacji mobilnej wyświetlającej skład zeskanowanego produktu spożywczego. Źródłem informacji jest baza danych przeszukiwana przez zapytania SQL wraz z informacją o kodzie kreskowym zeskanowanego produktu. Użytkownikowi zostaje wyświetlona informacjia na temat zawartości szkodliwych substancji i ich wpływu na zdrowie człowieka.
Aplikacja jest napisana na system Android 4.0 (Ice Cream Sanditch) lub nowszy. Baza danych działa na zdalnym serwerze. Proces komunikacji został oparty o protokoły HTTP jak i JSON.
Praca zawiera informacje o mobilnych systemach operacyjnych, bazach danych i narzedziach programistycznych. Wszystkie definicje zostały przedstawione na poziomie niezbędnym do zrozumienia teamtyki.
Szczegółowy opis projektu zawiera: strukturę, cele projektowe i ich realizację. Kod applikacji został ocenionu przez aplikacje internetową Sonar.
Słowa kluczowe: Aplikacja Mobilna, Android, bazy danych, PostgreSQL, serwer, Tomcat, Jetty, JSON, kod kreskowy, Sonar, Jenkins, ZXing
1
Product Ingredients Analyser
Table of Contents
1. Introduction ..................................................................................................................................... 4
1.1 Goal ......................................................................................................................................... 4
1.2 Thesis structure ........................................................................................................................ 5
2 Technical overview ......................................................................................................................... 6
2.1 Mobile platforms ..................................................................................................................... 6
2.1.1 Android ............................................................................................................................ 6
2.1.2 iOS ................................................................................................................................... 7
2.1.3 Windows Phone ............................................................................................................... 7
2.1.4 Symbian ........................................................................................................................... 8
2.1.5 Market shares .................................................................................................................. 8
2.2 Databases ............................................................................................................................... 11
2.2.1 PostgreSQL ................................................................................................................... 11
2.2.2 MySQL .......................................................................................................................... 12
2.2.3 Oracle Database ............................................................................................................. 12
2.2.4 Popularity comparison ................................................................................................... 13
2.3 Programming Environment ................................................................................................... 14
2.3.1 IDE Eclipse .................................................................................................................... 14
2.3.2 Android Emulator .......................................................................................................... 14
2.3.3 Apache Tomcat .............................................................................................................. 15
2.3.4 Jetty ............................................................................................................................... 15
2.3.5 GlassFish ....................................................................................................................... 15
2.3.6 Servlet container popularity .......................................................................................... 16
2.4 Programming Tools ............................................................................................................... 16
2.4.1 Mercurial ....................................................................................................................... 16
2.4.2 Hibernate ....................................................................................................................... 19
2
2.4.3 Apache Ant .................................................................................................................... 19
2.4.4 Jenkins ........................................................................................................................... 19
2.4.5 Sonar .............................................................................................................................. 20
2.5 Communication ..................................................................................................................... 20
2.5.1 JSON protocol ............................................................................................................... 20
2.5.2 GSON ............................................................................................................................ 21
2.5.3 Apache HttpClient ......................................................................................................... 21
2.6 Programming language .......................................................................................................... 21
2.6.1 JAVA ............................................................................................................................. 21
2.6.2 XML .............................................................................................................................. 22
3 Foodstuff research ......................................................................................................................... 23
3.1 What does the product label contain? .................................................................................... 23
3.2 E numbers .............................................................................................................................. 24
4 Barcodes ........................................................................................................................................ 31
5 System design ................................................................................................................................ 33
5.1 General architecture .............................................................................................................. 33
5.1.1 The server side ............................................................................................................... 33
5.1.2 The client side ............................................................................................................... 35
5.2 Application design ................................................................................................................. 36
5.2.1 End users ....................................................................................................................... 36
5.2.2 Usage example .............................................................................................................. 36
5.3 System goals .......................................................................................................................... 36
5.3.1 Functional requirements ................................................................................................ 36
5.3.2 Non-functional requirements ......................................................................................... 37
5.4 Algorithm .............................................................................................................................. 37
5.5 Diagrams representing application structure ......................................................................... 39
5.5.1 Use-case diagram........................................................................................................... 40
5.5.2 Sequence diagram .......................................................................................................... 40
3
5.6 Code Metrics ......................................................................................................................... 41
5.7 Design problems and solutions .............................................................................................. 44
5.7.1 SharedPreferences ......................................................................................................... 44
5.7.2 UTF-8 encoding ............................................................................................................ 45
5.7.3 View Configuration ....................................................................................................... 45
5.7.4 AndroidManifest.xml settings ....................................................................................... 46
5.7.5 ZXing integration .......................................................................................................... 46
6 Testing ........................................................................................................................................... 49
6.1 Functional tests ...................................................................................................................... 49
6.2 Unit tests ................................................................................................................................ 50
6.2.1 JUnit .............................................................................................................................. 51
6.2.2 Mockito ......................................................................................................................... 52
6.2.3 Application test example ............................................................................................... 52
7 Summary ....................................................................................................................................... 55
7.1 Applied technologies ............................................................................................................. 55
7.2 Future development ............................................................................................................... 55
7.3 Conclusion ............................................................................................................................. 56
8 References ..................................................................................................................................... 57
9 Appendices .................................................................................................................................... 59
9.1 User Manual .......................................................................................................................... 59
9.1.1 Welcome screen............................................................................................................. 59
9.1.2 Menu .............................................................................................................................. 60
9.1.3 Details ............................................................................................................................ 61
9.1.4 Evaluation ...................................................................................................................... 63
9.1.5 Scanning ........................................................................................................................ 63
9.1.6 Errors ............................................................................................................................. 64
4
1. Introduction
In the last years people started to “live faster”. Such a change was influenced by the
information accessibility and its circulation speed. Nowadays everyone wants to have access
to the latest news. Before the best information media were newspapers, but with the
technology development the electronic devices such as tablets or smartphones started to
replace them. Components of electronic devices are getting smaller and more computationally
efficient each year. Today’s smartphones can compete with few years old computers.
The technological advance has influence on human’s habits. Now we want to know
everything. What the current weather is, what the latest news is or what our friends actually
do. In today’s world the information is a key. Combining these observations with the
smartphone market rapid growth, one concludes – from computer science point of view - that
the best way to succeed is to write a mobile application having informative nature.
Application should be useful in everyday life, facilitating common activities. Such an activity
could for example be shopping.
Everyday most of us buy food. Food producers have to add many substances to their products.
Although those substances are admitted to use some of them may be dangerous for specified
groups of people, especially for infants and children. Substances’ exemplary negative effects
may be: insomnia, neck and shoulder stiffen or rapid heartbeat; they also may be toxic for:
kidneys, circulatory system or nervous system. Their consumption can be secure if it is not
too frequent. To protect from the negative consequences consumer needs to know what to
avoid. Product Ingredient Analyser provides such functionality. The user does not need to
know the E code numbers specified on the label. He or she will receive detailed information
after scanning the barcode.
1.1 Goal
The goal of the application is to evaluate the information about foodstuff of a selected
product. Information about the product should be searched based on product’s barcode. Such
a barcode may be processed with the usage of external libraries. The information found in the
process of reading the barcode should be used to search the database of products. Database
must contain product name, barcode number and the list of product ingredients. Such data will
be used by an algorithm calculating the possible negative impact of a product on human
5
health. Data used for the evaluation process should be gathered after deep study of research
results done on foodstuff components.
1.2 Thesis structure
The remainder of the thesis is organized in following manner.
Chapter 2 is a technical overview and describes the most popular mobile operating systems
and databases. It includes information about used tools and development environment as well
as communication protocols and techniques.
Chapter 3 describes system design which consists of: server and client side features, end
customer, application’s usage example, functional and non-functional requirements,
algorithm, use case or sequence diagrams code metric and finally design problems and
solutions.
Chapter 4 presents technical information about product barcode coding methods.
Chapter 5 is a foodstuff research chapter that contains comprehensive data about food
ingredients. A detailed explanation of product label and e code list is presented herein.
Chapter 6 describes testing procedure that has been divided into two main parts: functional
tests have been done on a mobile device as well as on an emulator and unit tests have been
implemented in code.
Chapter 7 contains a brief conclusion of the work result. Achieved goals and future
application development possibility are presented in this chapter.
Thesis is closed by bibliography and an Appendix – User Manual.
6
2 Technical overview
The following chapter presents technologies, systems and programming tools used in the
development process.
2.1 Mobile platforms
This section is a mobile operating systems overview including brief descriptions as well as
popularity comparisons. Below presented information contains main features of the most
popular solutions.
2.1.1 Android
Android is a mobile operating system originating from Linux. Its main targets are mobile
devices, although it has been adopted also to network equipment and smart TV systems.
System initially was created by Android Inc. from the beginning Google supported financially
Android Inc. and took control of it in 2005. In 2007 Open Handset Alliance was established –
a consortium that gathers main companies involved in development of mobile market. The
products of such alliance are technologies applied to Android mobile device platform.
One of the main advantages of this system is that it is an open source project. This results in
huge amount of applications created by large community of developers. In the first half of
2012 there were around 600,000 apps in Android Market available and the total number of
downloads reached 20 billion since Android creation. "There Are Now 1.3 Million Android
Device Activations Per Day". [1] Since 2010 Android started to be the world most popular
Smartphone OS.
Android Open Source Projects main goal is to develop and maintain Android. Maintenance
and development includes Software Development Kit. Platform bases on Linux kernel 2.6 and
uses Dalvik virtual machine. Dalvik VM is software that allows running applications on
Android system. It is a integral part of the platform. Applications are written by developers in
JAVA and then compiled to byte code. The next step is to convert it to suitable for system
Dalvik Executable (.dex) format.
7
From security reasons Android is equipped with Sandbox. Sandbox is an isolated part of OS
set not having any granted permissions to access other system resources. This part of a system
is dedicated for applications.
In the past few years companies like Apple, Oracle and Microsoft sued Google for patent
infringement. In order to protect for the future in 2011 Google purchased Motorola due to its
17 000 patents. Additionally Google come into possession of 1000 IBM patents.
2.1.2 iOS
Apple’s operating system iOS originally called iPhone OS was released in 2007. This
software is designated only for Apple Inc. products such as iPhone, iPod Touch, iPad and
Apple TV. Company is not sharing it with other hardware manufacturers. In 2012 there were
about 410 million active Apple’s products operating on iOS.
User interface consists of interactive components characterized by fluid work and modern
layout. In the early days the iOS system was innovative because of device shake or rotation
gesture recognition (today most mainstream operating systems offer such functionality). “In
iOS, there are four abstraction layers: the Core OS layer, the Core Services layer, the Media
layer, and the Cocoa Touch layer.” [2]
The Software development Kit was released in 2008. It allows creating applications and
testing them on a simulator. According to Apple’s policies if one wants to load an application
on the target device they have to pay fee to the iPhone Developer. Standard fee is annual and
equals 99$ per developer.
2.1.3 Windows Phone
Windows Phone was launched in 2010 and is the next generation of Windows Mobile system.
It is developed and maintained by Microsoft Corporation. With the new OS Microsoft
invented innovative user interface called Metro. The developers managed to combine fancy
layout with low hardware requirements. Windows Phone is not compatible with its
predecessor. First partners of Microsoft which created devices for Windows Phone 7 where:
HTC, LG, Dell and Samsung, after WP 7.5 revision this list was extended by Acer, Fujitsu
and ZTE.
8
One of the advantages of WP 7 is low hardware requirement. The Tango release made it
possible to run the system on the device equipped with CPU of frequency equal to 800MHZ
and 256 RAM of memory. Marketplace is able to block installation of application demanding
high computational power on lower performance devices.
In 2011 Microsoft product became the primary OS for Nokia. Such movement was the answer
for the market situation where Android and iOS became most important players. Gartner
source states WP has around 1.9% of the market share.[3]
2.1.4 Symbian
Symbian is an operating system created in cooperation of Nokia, Sony Ericsson, Symbian
Ltd. and NTT DoCoMo. Now the system is maintained by Accenture outsourcing company.
Target devices are Nokia Smartphones. In 2011 Nokia changed its software policy and
decided to start partnership with Microsoft. As a result Nokia top model devices run on
Windows Phone 7 operating system. Symbian will be supported only till 2016. In February
2010 Nokia published Symbian code to open source. It was the largest codebase published to
open source in history.
Since 2010 the main SDK is Qt programmable in C++ language. Official development
environments are: Qt creator and Carbide. Alternatively Python language may be used.
System comprises of packages. Behind each package stands a technology. This structural
model encourages the community to gather around package of their choice in order to develop
it. Applications consist of three main classes defined by the architecture: application class,
application UI class and a document class.
As of present day around 400 million devices operating Nokia’s system had been shipped.
Symbian was the most popular system till 2010. With the marker growth, Symbian lost its
share.
2.1.5 Market shares
Nowadays operating system mobile market is divided into six main producers. Although some
of the operating systems are created for a specific type of customer such as Research in
Motion’s (RIM) OS - for business, the other ones compete in the same field. In the past the
situation changed completely. Symbian
its market share and become third powe
Figure 1. World-wide smartphones operating systems popularity comparison.
http://en.wikipedia.org/wiki/File:World_Wide_Smartp hone_Sales.png
Figure 1 presents the market share changes over past few years. We can see rapid popularity
growth of Android OS and lost if Symbian. Additionally the graph presents the overall mobile
market development situation. Overall in 2011 there were much more devices sold than in
2010.
Marked share depends on the country. Symbian is designed for cheaper devices mostly
popular in Africa or Asia. When we see the situation on the biggest market
the situation looks differently.
completely. Symbian - being for many years the unquestionable leader, lost
share and become third power, continuously losing popularity.
wide smartphones operating systems popularity comparison. (Source:
http://en.wikipedia.org/wiki/File:World_Wide_Smartp hone_Sales.png)
presents the market share changes over past few years. We can see rapid popularity
growth of Android OS and lost if Symbian. Additionally the graph presents the overall mobile
ent situation. Overall in 2011 there were much more devices sold than in
Marked share depends on the country. Symbian is designed for cheaper devices mostly
popular in Africa or Asia. When we see the situation on the biggest market
the situation looks differently. United States market Share is presented in the
9
being for many years the unquestionable leader, lost
presents the market share changes over past few years. We can see rapid popularity
growth of Android OS and lost if Symbian. Additionally the graph presents the overall mobile
ent situation. Overall in 2011 there were much more devices sold than in
Marked share depends on the country. Symbian is designed for cheaper devices mostly
popular in Africa or Asia. When we see the situation on the biggest market – United States -
United States market Share is presented in the Figure 2.
Figure 2. United States mobile operating systems market share. (Source: (
mobile-subscribers-smartphone-owners/
We can see that in United States
the world. Here we can see a much better result for
the fact that Apple is an American company
Additionally Apple’s products are much more expensive than
As United States citizens are relatively rich the price is not that important factor while
choosing a new phone.
Another very important statistic is how much stati
operating system is the most popular for this task.
Figure 3. Almost 50% of QR code scans are
United States mobile operating systems market share. (Source: (http://blog.mobileroadie.com/2012/05/study
owners/)
in United States cheap devices are not as much popular as in other regions
much better result for Apple. The reason for it can come from
Apple is an American company and people prefer to buy local products.
products are much more expensive than products from other producers.
As United States citizens are relatively rich the price is not that important factor while
Another very important statistic is how much statistically users do scan codes and which
operating system is the most popular for this task. Graphical comparison is presented in
Almost 50% of QR code scans are done by United States citizens
10
http://blog.mobileroadie.com/2012/05/study-
devices are not as much popular as in other regions of
it can come from
and people prefer to buy local products.
from other producers.
As United States citizens are relatively rich the price is not that important factor while
cally users do scan codes and which
Graphical comparison is presented in
done by United States citizens [4]
11
Figure 3. QR code scan statistics. (Source: http://www.qrstuff.com/blog/2012/04/08/q1-2012-qr-code-trends)
Although Android currently is losing in this comparison, its growing popularity assures that it
might change in the future. However QR codes are not the topic of this thesis, these statistics
are interesting in order to observe that usage of the phone as code scanning device is common
and very popular.
2.2 Databases
With the dynamic internet and IT development databases became to play bigger role in
everyday life. Databases are data collections stored according to specified rules. “Every
sorted information set is called a database”. [5] This section presents the most popular
solutions and their popularity comparison.
2.2.1 PostgreSQL
PostgreSQL have its beginning at the University of California at Berkeley. It has been built on
the basis of its predecessor project “Ingres”. System is developed and maintained by
PostgreSQL Global Development Group.
PostgresSQL is an open source object-relational database system. Within 15 years of
development architecture become reliable, integral and correct. It can be run on all
contemporary systems and architectures. PostgreSQL standard procedural languages are: PL/
12
pgSQL, PL/Tcl, PL/Perl and PL/Python. There can be used also other languages such as
PL/JAVA, PL/PHP developed outside main distribution. Procedural languages are mainly
used to create customized functions (subroutines, triggers). “PostgreSQL manages database
access permissions using the concept of roles. A role can be thought of as either a database
user, or a group of database users, depending on how the role is set up.” [6]
PostgreSQL database may be managed by different type of frontends. The primary one is psql
command-line program. One can type the SQL queries or run them from a file. PgAdmin is an
open source GUI able to run on all of the most popular operating systems. The most recent
version (III) was written in C++. Other available front ends are: web based phpPgAdmin,
OpenOffice.org Base, DaDaBIK and pgFouine.
2.2.2 MySQL
MySQL is the world most used open source database. Source is publicized under GNU
license however there are commercial editions as well. MySQL is now owned by Oracle
Corporation. “The MySQL database has become the world's most popular open source
database because of its high performance, high reliability and ease of use. It is also the
database of choice for a new generation of applications built on the LAMP stack (Linux,
Apache, MySQL, PHP / Perl / Python).” [7]
System is created in C and C++ languages. As well as in other database systems user may
choose among several frontends. Besides the command line one, the most popular is the
official MySQL workbench. It allows managing the system graphically. Third-party popular
front ends are: DaDaBIK, HeidiSQL, LibreOffice Base, OpenOffice.org Base, phpMyAdmin
and many others. MySQL is root system for community developed MariaDB and Drizzle.
2.2.3 Oracle Database
Oracle Database is object relational database management system created by Oracle
Corporation. Oracle product bases on a group of processes working simultaneously realizing
different processes such as queuing, archive, log management, memory monitor, etc.
Oracle Database is a commercial one. Its main competitors are IMB’s DB2 and Microsoft
SQL Server. Unlike Microsoft, IMB and Oracle compete on the same platforms UNIX and
Linux.
There are several editions differentiated by customer demands. The price of th
be counted in hounded thousands of euro. Due to this fact, Oracle’s software’s targets are only
huge companies and corporations.
2.2.4 Popularity comparison
Market can be divided into open source and commercial database systems. The most popular
commercial solutions are following: Oracle Database, IMB’s DB2 and Microsoft SQL Server,
while open source ones are: MySQL and Postgres. Commercial and open source solutions are
dedicated for other types of clients
groups and not between them.
of the thesis application, there were only open source systems taken into account. Their
popularity is presented in Figure
Figure 4. Open Source database popularity. (Source:
business-intelligence/open-source-solutions.aspx?page=6
It is clearly presented that MySQL and Postgres are the most popular ones with MySQL being
on the lead. Both of these database systems were developed over many years what resulted in
stability and functionality of both
MySQL was taken because of found internet sources and administrator guides available for
the first one.
There are several editions differentiated by customer demands. The price of th
be counted in hounded thousands of euro. Due to this fact, Oracle’s software’s targets are only
huge companies and corporations.
Popularity comparison
Market can be divided into open source and commercial database systems. The most popular
ommercial solutions are following: Oracle Database, IMB’s DB2 and Microsoft SQL Server,
while open source ones are: MySQL and Postgres. Commercial and open source solutions are
clients hence the main competition has its place
Because of the economical reasons in the purpose of creation
of the thesis application, there were only open source systems taken into account. Their
Figure 4.
Open Source database popularity. (Source: http://www.dashboardinsight.com/articles/new
solutions.aspx?page=6)
It is clearly presented that MySQL and Postgres are the most popular ones with MySQL being
database systems were developed over many years what resulted in
stability and functionality of both of these products. The decision to use Postgres over
MySQL was taken because of found internet sources and administrator guides available for
13
There are several editions differentiated by customer demands. The price of the software may
be counted in hounded thousands of euro. Due to this fact, Oracle’s software’s targets are only
Market can be divided into open source and commercial database systems. The most popular
ommercial solutions are following: Oracle Database, IMB’s DB2 and Microsoft SQL Server,
while open source ones are: MySQL and Postgres. Commercial and open source solutions are
its place within those two
purpose of creation
of the thesis application, there were only open source systems taken into account. Their
http://www.dashboardinsight.com/articles/new-concepts-in-
It is clearly presented that MySQL and Postgres are the most popular ones with MySQL being
database systems were developed over many years what resulted in
these products. The decision to use Postgres over
MySQL was taken because of found internet sources and administrator guides available for
14
2.3 Programming Environment
Programming environment is the set of tools created for specific language that might be
helpful for a software developer at work. This section presents programming environment
with the most important plug-ins used in purpose of writing this thesis.
2.3.1 IDE Eclipse
An integrated development environment is software dedicated for programmers, consisting of
source code editor, debugger and tools for automatic building. Usually one IDE is dedicated
to specific programming language. In many cases installation of additional packages allows to
use one IDE for other languages as well. There are also multi languages IDEs like: Eclipse,
Microsoft Visual Studio, NetBeans and Xcode. Some IDEs offer visual programming
possibility. They base on graphical interface, where programmer visually creates a program
from blocks.
Programmers which are using IDEs are much more efficient. Some repetitious work can be
automated. Programming environments offer also useful hints while writing a code or adding
new repositories. Code is continuously parsed which helps to reduce syntax errors already in
typing process. Additionally one can install useful tools extending IDEs functionality like
mercurial or maven.
Everything what programmer can create using Integrated Programming Environment is
achievable from command line POSIX tools. Programming approach depends mostly on the
program target and programming language used. However traditional method is much more
time consuming.
2.3.2 Android Emulator
Software Development Kit supplied for Android includes mobile device emulator. It is virtual
representation of mobile device. Emulator gives the possibility to test application without a
usage of phone. It can be started from AVD Manager or from command line tools. AVD
Manager is a user friendly interface allowing intuitive configuration. An AVD has four main
components: hardware profile, mapping to a system image, additional options and dedicated
storage area. Hardware profile defines hardware specification. All features like: physical
keyboard, camera, memory can be specified. Mapping to a system image allows running and
15
testing any version of Android. Additional options including emulator skin, emulated SD
card. The last part is dedicated storage area containing user information (applications,
settings).
Developer can create any number of devices depending of his will. Proper application test are
done on each VD configuration model the application can operate on. While creating the
AVD the developer should choose the minimal API level on which application is able to run.
2.3.3 Apache Tomcat
“Apache Tomcat is an open source software implementation of the Java Servlet and
JavaServer Pages technologies.” [8] It is developed by the Apache Software Foundation. The
main components are Catalina, Coyote and Jasper. Catalina is a servlet container which
function is to load, initialize and execute servlets. Coyote HTTP/1.1 Connector is an element
for HTTP/1.1 protocol support. Specific part of Coyote has the function of listening for
connection on selected port number. Jasper is a JSP Engine. Function of this component is to
parse JSP files in order to compile them into Java code as servlets.
2.3.4 Jetty
“Jetty provides an HTTP server, HTTP client, and javax.servlet container. These components
are open source and available for commercial use and distribution.” [9] It is widely used in
any devices, tools application servers and clusters. Jetty’s core is developed and maintained
by Eclipse Foundation. Any accessories and extensions are provided by codehouse.
2.3.5 GlassFish
Glassfish Server is and open source server having the ability to develop Java Platform,
Enterprise Edition applications. It bases on source code belonging to Sun and Oracle. Servlet
container is derived from Apache Tomcat extended by own Grizzly component. “The Grizzly
NIO and Web framework has been designed to help developers to take advantage of the
Java™ NIO API.” [10] Its New IO goal is to help in writing scalable server applications in
Java. NIO library offers different way of working with IO where data is processed in blocks.
16
2.3.6 Servlet container popularity
Open source Java servers are getting more popular with the rising popularity of Java language
and internet solutions. It is already a big market with the products supporting most of the
mobile applications.
Figure 5. Open Source Java server popularity. (Source: http://blog.jelastic.com/2012/01/30/java-application-servers-
market-share-january-2012/)
Figure 5 shows clearly the domination of Oracle Corporation products (Tomcat 7/ Tomcat 6/
GlassFish) with total popularity of 86%. For the mobile application created for this thesis
there were jetty 7 as well as Tomcat 6 used. Jetty supports Jenkins and Sonar web applications
and Tomcat with the extended functionality by VMware Company is supporting the server
side of Product Ingredient Analyser.
2.4 Programming Tools
The following section presents programming tools which were used in the application’s
development process. There are both plug-ins and standalone web applications.
2.4.1 Mercurial
Mercurial is a distributed source control management tool. It is implemented with the usage of
Python with additional C implementation. Mercurial offers cross platform functionality able
to operate on Windows, UNIX, Linux, FreeBSD and Mac OS X. It can be managed with the
usage of graphical interfaces (Tortoise Hg), command line or directly from IDE as a plug-in
17
(Eclipse). All operations are executed as arguments of its hg driver program. It is extendible
open source software.
Mercurial is a tool for building decentralized code repositories. Mercurial is completely
distributed. It gives each programmer a local copy of whole project history. It is independent
of network access and central servers. Main functions are: commit, push, pull, branch and
merge. Its functionality is presented on below figure.
Figure 6. Mercurial functionality. (Source:
http://en.wikipedia.org/wiki/File:Mercurial_command d_and_their_relations.png)
Figure 6 presents all the functionality of Mercurial available for developer. It is an important
piece of software used by all professional developers.
Mercurial functionality. (Source:
http://en.wikipedia.org/wiki/File:Mercurial_command d_and_their_relations.png)
presents all the functionality of Mercurial available for developer. It is an important
piece of software used by all professional developers.
18
presents all the functionality of Mercurial available for developer. It is an important
19
2.4.1.1 Bitbucket
Bitbucket is a site offering hosting services for distributed source control tolls such as
Mercurial or Git. This website is offering wiki, issue tracker and integration with popular web
services.
2.4.2 Hibernate
Hibernate is a collection of related projects which facilitates storage and retrieval database
data. It is a framework written in Java language enabling object-relational mapping of
relational database objects.
Database mapping is done through Java annotations or the configuration of an XML file.
Hibernate can create Java code from an XML file or vice versa. With hibernate it is easy to
create inter class relationships such as: one-to-many and many-to-one.
Hibernate operates SQL based query language – HQL. This language is designed to
manipulate Hibernate’s data objects. Database configuration is stored in hibernate.cfg.xml
file. It is the place where the connection with database is specified. Thanks to database
independent application model applications which are using hibernate, may be easily migrated
to any database system at any time. The only thing the developer has to modify is the
previously mentioned hibernate.cfg.xml file.
2.4.3 Apache Ant
“Apache Ant is a Java library and command-line tool whose mission is to drive processes
described in build files as targets and extension points dependent upon each other. The main
known usage of Ant is the build of Java applications.” [11] It uses the idea of Makefiles, but
the implementation is Java based. Ant configuration is done by XML files, where processes
and their dependencies are described. It is open source software supporting build tasks. It
allows to compile, assemble, test and run Java projects. It can be used though command line
or as an IDE plug-in.
2.4.4 Jenkins
Jenkins is open source software dedicated for continuous integration. Continuous integrations
goal is to improve codes quality. In order to run it needs to be deployed in a servlet container
20
(Jetty/Tomcat). It can execute project management tools (Ant, Maven), shell scripts and
Windows batch commands. Originally Jenkins was developed under the name Hudson.
There are several ways of starting a build on a server. The most popular is to trigger it by
committing a code change in a code version control system (Mercurial, Git).
2.4.5 Sonar
Sonar is open source quality management platform. After detailed code evaluation it extracts
metrics using code analysis tools. It enables to control code quality. The resulting report
contains information about the structure, useful statistics and general information. It can be
compared to other reports obtained in history.
As well as Jenkins it is web based application. It means that it requires a dedicated servlet
container to run. Primarily it is a tool specially dedicated for Java programming language.
However through additional plug-ins other languages support such as: C, C#, PHP, PL/SQL,
Visual Basic and many more may be added.
2.5 Communication
Nowadays data transmission is an important part of almost each application. Data exchange
became an integral part of our life. The following section describes the most important
technologies used for data transmission in the Product Ingredients Analyser application.
2.5.1 JSON protocol
JSON (JavaScript Object Notation) is a data exchange format. It is lightweight and human
readable open standard. JSON is language independent with available parsers for many
languages. Its main purpose is to transmit serialized data over the Internet.
It bases on two structures: collection of name/value pairs and ordered list of values. Set of
name/value pairs creates a JSON object. This structure is surrounded by “{” and ”}”
characters. Each name is followed by “:” and a value after it. Each pair is separated by
comma. Ex. {name1:value1, name2, value2}, whereas the array syntax looks: [value1,
value2].
21
2.5.2 GSON
GSON is open source library written in JAVA language. It is maintained and developed by
Google Corporation. “Gson is a Java library that can be used to convert Java Objects into
their JSON representation.” [12]
GSON helps to deserialize JSON object directly to specified class. Programmer does not have
to take values manually. It can handle collections, generic types and nested classes. It ignores
extra input fields which do not correspond to the specified class structure.
2.5.3 Apache HttpClient
Apache HttpClient library describes HTTP protocol request handling. Data is exchanged
through the usage of HttpClient class and its object DefaultClient. HttpClient is using
SingleClientConnManager class to process HTTP connections. Classes HttpPost and
HttpResponse are responsible of sending and receiving transmitted information.
2.6 Programming language
Programming language is a basis for each piece of software. Language selection is the most
important technical aspect of each project. Every language has its specific properties. Some
are used because of their speed and reliability (assembler) and others because of the comfort
of use, available software and tools. The following section presents an overview of the
languages chosen for this thesis.
2.6.1 JAVA
Java is an object oriented programming language. It is characterized by cross platform
functionality. “Java’s obvious advantage is platform independent programming environment
in which application are executed.” [13] The big part of the syntax is derived from C and
C++. JAVA code is compiled into system independent bytecode executed by the virtual
machine of particular OS. JAVA bytecode is an intermediate language’s representation for
which JAVA Virtual Machine stands as execution environment. JAVA is the most popular
language (around 19%) with great support and extensive documentation.
The owner and main developer of JAVA is Oracle Corporation. There are two package
distributions: JDK and JRE. JDK (Java Development Kit) is dedicated for programmers. It
includes: compiler, Javadoc, Jar and debugger. JRE (Java Runtime
package enabling to run programs written in JAVA.
Figure 7. Programming language popularity over last 10 years. (Source:
http://blog.revolutionanalytics.com/2012/01/r
There are almost as many languages as the software types.
comparison. Each language has its own domain. Java is the most popular language for web
based mobile applications. It is constantly developed and offers up to date solutions
facilitating programmers work.
2.6.2 XML
XML (Extensible Markup Language) defines rules for document encoding. It advantage is to
be human and machine readable.
(XML 1.0). XML is a free and open standard mostly used in configuration files
network communication. This textual data format was used to build application which is the
subject of this Thesis in files: Android configuration, Hibernate Configuration and Ant’s build
configuration.
XML document is represented as a string of Unicode characters.
two types of structures: “markup” and “content”. Markup are substrings surrounded by <
> or & and ; characters, while conte
includes: compiler, Javadoc, Jar and debugger. JRE (Java Runtime Environment
to run programs written in JAVA.
Programming language popularity over last 10 years. (Source:
http://blog.revolutionanalytics.com/2012/01/r-jumps-from-25-to-19-in-tiobe-rankings.html)
There are almost as many languages as the software types. Figure 7 presents
Each language has its own domain. Java is the most popular language for web
based mobile applications. It is constantly developed and offers up to date solutions
facilitating programmers work.
Language) defines rules for document encoding. It advantage is to
be human and machine readable. The standard is provided by World Wide Web Consortium
XML is a free and open standard mostly used in configuration files
This textual data format was used to build application which is the
subject of this Thesis in files: Android configuration, Hibernate Configuration and Ant’s build
XML document is represented as a string of Unicode characters. Such a docu
two types of structures: “markup” and “content”. Markup are substrings surrounded by <
, while content is the rest left in between.
22
Environment) is a smaller
presents their popularity
Each language has its own domain. Java is the most popular language for web
based mobile applications. It is constantly developed and offers up to date solutions
Language) defines rules for document encoding. It advantage is to
The standard is provided by World Wide Web Consortium
XML is a free and open standard mostly used in configuration files and in
This textual data format was used to build application which is the
subject of this Thesis in files: Android configuration, Hibernate Configuration and Ant’s build
Such a document contains
two types of structures: “markup” and “content”. Markup are substrings surrounded by < and
23
3 Foodstuff research
Development of Product Ingredient Analyser required comprehensive nourishment field
research. Important information gathered is presented in the following chapter.
3.1 What does the product label contain?
Labelling rules have been introduced by European Union. It helps customers to be aware of
what exactly is the product that they are buying. In Poland there are three documents
concerning food labelling methods.
• Resolution from 25.08.06 regarding food and nourishment safety. (Dz. U. No. 171,
pos. 1225).
• Minister of Agriculture and Countryside Development regulation from 10.07
regarding foodstuffs labelling (Dz. U. No. 137, pos 966)
• Regulation of Minister of Health from 25.07.2007 regarding product labelling with the
nutritional value. (Dz. U. No. 137, pos. 967).
Aforementioned regulations determine what the product label should include.
The basic information is the manufactured goods name. It should be presented in the intuitive
way, clearly stating what actually the product is.
Another obligatory data is foodstuff content information. It is a list of all components used in
the manufacture process. It must be given starting from the prevailing one down to least used.
It is manufacturer’s duty to include additional substances used in production process. Such
components have international codes. Producer has a right to specify only the substance code
(E XXX) and its technical function. [14] Exemplary substance is a pigment, caustic sulphite
caramel having the international code of 150b. In such case should appear following
information: E150b-pigment.
In the European Union territory on the product boxes there must be information regarding
allergens, nutritional value, expiration date, storage conditions, manufacturer’s data,
production place, net weight or the number of units in the box, series number and the
information if the product is ecological.
24
Figure 8. Exemplary label (Source: http://www.idat.com/printertest.html)
Figure 1 presents exemplary product label. The foodstuff content is presented on the right side
of the illustration.
3.2 E numbers
E codes placed in the foodstuff content lists are substances which are concerned as safe and
admitted to consumption by the Science Committee of Nourishment Technology. Committee
is creating a list which has to be approved by European Parliament. Such a list contains
natural as well as artificial food components. It may be extended when there is a proven
technological substance usage necessity and when this substance is not dangerous for human
health.
E number has a following form:
E XXX
E – Continent name shortcut (Europe)
XXX – three numbers representing foodstuff complement.
Example:
E414 – Gum Arabic
E numbers may have different functions. Number segregation is presented in Table 1.
25
Table 1 Foodstuff numbering
E 100 – E 199 Pigments
E 200 – E 299 Preservative
E 300 – E 399 Anti oxidants and acidity regulators
E 400 – E 499 Thickeners, stabilizers and emulsifiers
E 500 – E 599 pH regulators and anti caking agents
E 600 – E 699 Flavour and smell enhancers
E 700 – E 799 Antibiotics
E 900 – E 999 Various
E 1000 – E 1599 Additional chemical compounds
According to Health Minister Regulation from 22.11.10 in Poland, such as in whole European
Union there are 321 supplements admitted to use.
There are many ambiguities and controversies according supplements admitted by Science
Committee of Nourishment Technology. Many of them consumed in excessive number may
cause allergic reactions, headaches (E 927b - Carbamide), diarrhoea (E 415 – Xanthan Gum),
aerenterectasia, insomnia, neck and shoulder stiffen, rapid heartbeat and tiredness (E 620 –
glutamic acid, E 624 - monoammonium glutamate, E 625 - Magnesium Diglutamate).
Furthermore many supplements may disturb correct assimilation of: phosphor, magnesium,
calcium and iron (E 338 – Phosphoric acid, E 402 – Potassium alginate, E 403 –Ammonium
alginate, E 416 –Karaya Gum, E 1413 –Phosphateddistarch phosphate).
Some products shouldn’t be consumed by people suffering specific illnesses such as gouty
arthritis (E 628 - DipotassiumGuanylate). Many supplements are harmful for infants (E 1420
– Acetylatedstarch, E 1422 – Acetylateddistarchadipate) or not recommended for children (E
296 – Malic acid, E 270 – Lacticacid, E 325 – Sodiumlactate, E 326 – Potasiumlactate, E 327
– Calciumlactate) what should be aware of. There are substances, which may contribute in
disease development such as: Alzheimer’s disease (E 173 – Aluminium). Moreover there are
reports that some components may be toxic for kidneys (E 285 –Sodiumtetraborate, E 536 –
Potassiumferrocyanide), circulatory system (E 173 – Aluminium) or nervous system (E 210 –
Benzoicacid). On the permitted E code list there are nourishment supplements having
26
carcinogenic activity (E 128 – Red 2G, E 231 – Orthophenylphenol, E 239 –
Hexamethylenetetramine). Some of them are prohibited in Unites States (E 151 – Brilliant
Black BN), Australia (E 131 – Patent Blue V) and Japan (E 104 – QuinolineYellow). [15]
After e codes analysis the database was populated with data belonging to five categories
according to their impact on human’s health. Those categories are following.
• Positively influencing
• Safe
• Should be limited
• Should be avoided
• Dangerous
Firs group is represented by the vitamin sources such as C (E 101 Riboflavin) or vitamin A (E
160e – Beta-apo-8’carotenal). Positive impact has also cellulose (E 460) – it is a source of
fibre. Exemplary records of substances positively influencing human’s health stored in the
database are presented in Table 2.
Table 2 Substances with negative impact evaluation score 0
E-code Name Side effect Evaluation
E163 Anthocyanins Reduces fragility of blood vessels.
Reduces the risk of developing atherosclerosis.
Positive effects on vision.
0
E160e Beta-apo-
8'carotenal
(C30)
Source of vitamin A. 0
E460 Cellulose Source of fibre. 0
E322 Lecithin Natural component of the cell walls. 0
E160d Lycopene It has antioxidant properties, prevents cancer cells
(recommended for the fight against cancer).
0
E161b Lutein Positive effect on the functioning of the eye. 0
E101 Riboflavin Source of vitamin B2. 0
E300 Ascorbid Acid Source of vitamin C. 0
27
Next category is represented by harmless substances commonly used in nourishment
products. Such ingredients do not have side effects (see Table 3)
Table 3 Substances with negative impact evaluation score 1
E-code Name Side effect Evaluation
E357 Potassium
adipate
Considered harmless for humans. 1
E356 Sodium
adipate
Considered harmless for humans. 1
E307 Alpha-
tocopherol
Considered harmless for humans. 1
E938 Argon Considered harmless for humans. 1
E941 Nitrogen Considered harmless for humans. 1
E459 Beta -
Cyclodextrin
Considered harmless for humans. 1
E301 Sodium
ascorbate
Considered harmless for humans. 1
Third category consists of elements which excess may bring harmful effect. However it is
difficult to overdose those ingredients because they are mostly used in small quantities. Any
consequences that may arise are onerous but not dangerous. Exemplary database records are
presented in Table 4.
28
Table 4 Substances with negative impact evaluation score 2
E-code Name Side effect Evaluation
E1422 Acetylated
distarch
adipate
It can be harmful for infants. 2
E406 Agar May cause allergic reactions. 2
E403 Ammonium
alginate
The excess can interfere with the proper conduct of
iron absorption.
2
E402 Potassium
alginate
The excess can interfere with the proper conduct of
iron absorption.
2
E160b Annato May cause: allergies, hives, low blood pressure
(adults), headache (children).
2
E309 Delta-
tocopherol
The excess can lead to fatigue of the organism,
headache and muscle weakness.
2
E625 Magnesium
diglutamate
Excess can cause: insomnia, headaches, increased
heart rate, and feeling of weakness, nausea, stiff
neck and shoulders.
2
E465 Ethyl methyl
cellulose
The excess can cause: diarrhea, constipation. 2
To fourth category belong substances which at any quantity may cause side effects.
Consequences of eating them can be toxic causing poisoning or other diseases. Items
presented in Table 5 should be avoided.
Table 5 Substances with negative impact evaluation score 3
E-code Name Side effect Evaluation
E173 Aluminium Toxic to the blood stream. This contributes to the
development of Alzheimer's disease. Excess
intensifies the symptoms of kidney disease.
3
E251 Sodium
nitrate
Excess causes: toxicity (dyspnea, cyanosis of the
skin), asthma, nephritis, dizziness, headache. Not
allowed for children less than one year of age.
3
E252 potassium Excess causes: toxicity (dyspnea, cyanosis of the 3
29
nitrate skin), asthma, nephritis, dizziness, headache. Not
allowed for children less than one year of age.
E131 Patent Blue
V
May cause: allergic reactions (pruritus, urticaria),
hypotension, nausea, anaphylactic shock (rare). Banned
in Norway, Australia and the USA.
3
E221 sodium
sulphite
Destroys the vitamins contained in the food. 3
E172 Iron oxides
and
hydroxides
The excess is toxic.
3
E227 Calcium
hydrogensulph
ite
May cause: irritation of the stomach, the
development of asthma, liver problems, lung
problems, kidney problems.
3
E104 Quinoline
Yellow
May cause: inflammation of the skin, hyperactivity
(children). Banned in the USA and Japan.
3
To the last category belong elements dangerous for human life. These substances are
carcinogenic and toxic. In many countries some of them are prohibited (see Table 6).
30
Table 6 Substances with negative impact evaluation score 4
E-code Name Side effect Evaluation
E123 Amaranth Carcinogenic, teratogenic! May cause: rhinitis,
fertility problems, kidney problems, liver problems.
Illegal for pregnant women.
4
E943a Butane May cause: depression. It is neurotoxic. 4
E320 Butylated
hydroxyl
anisole(BHA
)
In combination with vitamin C can lead to DNA
damage.
4
E128 Red 2G Carcinogenic, mutagenic. It can cause anemia. 4
E127 Erythrosine Carcinogen. May cause: learning difficulties,
photophobia, liver problems, heart problems, thyroid
problems, reproductive problems, stomach problems.
4
E239 Hexamethzle
netetramine
Carcinogen. May cause: kidney damage, diarrhea,
contact dermatitis. Banned in many countries.
4
E952 Cyclamates Carcinogenic (excess � lung cancer) can lead to
fertility problems.
4
Above described side effects of supplement application are exemplary. Whole E codes list
with their side effects which they may cause was used to populate application’s database.
31
4 Barcodes
Barcode is a graphical representation of information through combination of dark and bright
elements. It consists of many bars differentiated by their width. Primary method to read
barcode requires a photosensor. Such sensor converts a barcode into an electrical signal while
moving across it. In the next step scanner compares measured relative widths of bars and
spaces. Result of such operations is translated using appropriate code pattern into characters.
Nowadays are becoming more popular scanners and interpretive software running on
Smartphones and desktop printers. Such software named ZXing is used in the application
which is the topic of this thesis.
Each barcode starts and ends with special characters and some of them may also include
checksum one. There are different barcode symbologies. Symbology is a mapping between
message and barcode.
Most popular barcodes are: EAN-8, EAN-13 and UPC-A, UPC-E. EAN-8 and EAN-13 are
international codes basing on UPC system. At the beginning it was introduced in Europe and
then in the rest of the World. UPC codes are standard used in United States and Canada. Since
2005 both countries adopted EAN symbologies. EAN-8 and UPC-E are shortened version of
EAN-8 and UPC-A respectively.
EAN-13 (European article number) code requires high printing precision. It is built from 12
digits and one for checksum.
Figure 9 Barcode example (Source: http://www.barcodeisland.com/ean13.phtml)
Presented in Figure 9. EAN-13 Barcode construction is following:
• Start digit
• 6 digits from set of numerical characters A and B
32
• Separation digit
• 6 digits from C character set
• Stop digit
A, B and C character set coding presents Table 7.
Table 7 Coding method description
Character Coding method
Left side Coding method
right side
A B C
0 0001101 0100111 1110010
1 0011001 0110011 1100110
2 0010011 0011011 1101100
3 0111101 0100001 1000010
4 0100011 0011101 1011100
5 0110001 0111001 1001110
6 0101111 0000101 1010000
7 0111011 0010001 1000100
8 0110111 0001001 1001000
9 0001011 0010111 1110100
EAN- contains 8 digits including checksum one. Used mostly for small boxes where EAN-13
would be too large. The size of a code may vary from 0,2 till 2 times of standard size
enlargement.
33
5 System design
This chapter contains information concerning architecture, design goals, algorithm, diagrams
representing application structure, code metrics and design problems and solutions of the
Product Ingredients Analyser.
5.1 General architecture
Application is divided into two main parts - server side and client side. The most interesting
features of both of them are presented in this section.
5.1.1 The server side
Application servlet is running on VMware vFabric tc Server Developer Edition v2.6 which is
an enhanced Tomcat project. As a database system PostgreSQL database was selected
because of this system stability and well proved failure proof architecture. Servlet uses
deployed [PIA] Database Controller package in order to connect with PostgreSQL database.
The connection is done through Hibernate framework.
Hibernate framework global configuration is placed in hibernate.cfg.xml file. The
configuration file used in the project is presented in Code example 1.
34
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration> <session-factory>
<property
name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">amdant8</property>
<property
name="hibernate.connection.url">jdbc:postgresql://localhost:5432/KodyE</property>
<property name="hibernate.connection.username">postgres</property> <property
name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property> <property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property> <mapping resource="com/hibernate/db/Product.hbm.xml"/>
<mapping resource="com/hibernate/db/ECodeData.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Code example 1. Hibernate.cfg.xml file used in the project configuration
Configuraiton describes the driver, server url, database user (role in PostgreSQL) and the
dialect.
Connections are listened on 8080 port number. In the communication process with the client
device all data is packed into DataObjects serialized to JSON format. DataObject fields are
presented in Code example 2
private long productId;
private String productName;
private List<String> details;
private ArrayList<Pair<String, String, String, Integer>> pairList;
Code example 2. Data Object Fields.
DataObject is a class designed for ordered data exchange. It gives an easy access to any stored
information through getter and setter methods.
In communication process the most important parts are doGet and doPost functions serving
client requests. Client request assumed to be a barcode number presented as a string. Such a
string is processed into long data type by function presented in Code example 3.
35
private long getNumberFromRequest(String text) {
JSONObject json = (JSONObject) JSONSerializer.toJSON(text);
long number = json.optLong("number");
return number;
}
Code example 3. Function getNumberFromRequest.
Text is serialized into JSON data type. After that stored under “number” name long type value
is extracted from JSON object.
The next step is the database query realized with the Hibernate function. Function
selectProduct belonging to Database Controller package takes as an argument the barcode
number and returns a DataObject object. After addition of necessary code information the
data is ready for sending to Client.
5.1.2 The client side
Client Layout bases on fragment technology introduced since Android 3.0. This technology is
backward not compatible. However it offers great interface scalability for any screen size. It
became especially important after appear of tablets sharing the same operating system as
Smartphones. Apart from other differences tablet and Smartphones mostly differ by screen
size. Previously it was very difficult to create application looking good on both tablet and
Smartphone screens. It changed with the introduction of Fragment approach.
Fragments have their own lifecycles and can be considered as activity modules. As the
Fragment is embedded in activity it shares its state. One of the most important features is also
that activity’s appearance build with Fragments can be modified during runtime. “For
example, when the activity is paused, so are all fragments in it, and when the activity is
destroyed, so are all fragments.” [16]
Another very important applied technology was Intents. Their most important functionality is
to start new activities. It was useful in the portrait configuration mode where additional data
have to appear in new window.
Dialogs are mostly small windows causing the currently running activity to lose the focus.
Dialogs serves mostly to present notification and any kind of prompts information.
36
Client has the possibility to call an external code scanning application – Zxing. “ZXing
(pronounced "zebra crossing") is an open-source, multi-format 1D/2D barcode image
processing library implemented in Java, with ports to other languages.”[17]
5.2 Application design
The following section presents the application end users and usage example.
5.2.1 End users
Target users are people who are concerned with their health. Those are mostly people having
children, suffering some diseases or people interested in fit way of live. As the application
will operate only on Android environment, the OS possession creates also another limitation
for the target user group.
5.2.2 Usage example
An exemplary user of application could be young mother willing to buy some chocolate for
her children. Such mother is aware of food producer habits of adding preservatives to food
content. She is able to read their names on the package but there is no explanation concerning
them. List of “E” content is not saying anything to an average person. Such a mother can use
the application to scan a product barcode and obtain clearly presented detailed information
which she need. She does not even need to read the foodstuff content. List of preservatives is
taken from the database. Users not willing to read the description may go directly to the
product evaluation screen and rely on computed result.
5.3 System goals
The following section presents final application functionality targets. It is divided into
functional and non-functional requirements.
5.3.1 Functional requirements
• User should have the possibility to take a photo of a barcode. Program will use device
camera which is a required hardware component for running the application.
• There should be a possibility to check program evaluation of desired product.
37
• Users willing to go into detail of negative preservatives influence should have
possibility to read the description.
• Scanning of a new product should be possible without restarting the application.
5.3.2 Non-functional requirements
• In order to run the application Android 4 (Ice Cream Sandwich) or higher operating
system version is required.
• While scanning the barcode some data need to be exchanged through the internet,
hence the internet access is obligatory.
• Application should have simple, intuitive and modern layout.
• Information presented to the user needs to be comprehensive and precise.
• Application layout should be presentable in portrait and landscape view.
5.4 Algorithm
The algorithm is specially designed for the application purposes. It operates on the scientific
reports results. Studied sources contain brief information of each substance’s negative impact
on human health. Substances (E-codes) were classified into five categories providing an input
for algorithm calculations.
Application’s algorithm is designed for users to facilitate product evaluation. The result is
presented as a dialog box informing of possible product negative impact on consumer’s
health. Some people do not want to bother to go into the product details willing to obtain
quick information. For people who want to read more about foodstuff content detailed
information is available.
Algorithm takes the product evaluation score obtained from the database. Such evaluation is
presented in pseudo-code presented in Code example 4.
38
CASE note OF 0 : INCREMENT zeroSummary 1 : INCREMENT oneSummary 2 : INCREMENT twoSummary 3 : INCREMENT threeSummary 4 : INCREMENT fourSummary
ENDCASE
IF oneSummary % 5 != oneSummary THEN oneSummary = 10
ELSE oneSummary = oneSummary * 10 / 5;
ENDIF
IF twoSummary % 5 != twoSummary THEN twoSummary = 30
ELSE twoSummary = twoSummary * 30 / 5
ENDIF
IF threeSummary % 3 != threeSummary THEN threeSummary = 60
ELSE threeSummary = threeSummary * 60 / 3
ENDIF
IF fourSummary % 2 != fourSummary THEN fourSummary = 100
ELSE fourSummary = fourSummary * 100 / 2
ENDIF
result = oneSummary + twoSummary + threeSummary + fourSummary
IF result > 100 THEN result = 100
ENDIF
Code example 4. Pseudo-code of the Algorithm
The algorithm operates in the following way. First substances are divided into groups
according to the evaluation number. Then the quantity of each group members is calculated
and multiplied by proper ratios (see Table 8). If the result exceeds group maximum number its
value is set to the limit. After that summary of every obtained in previous step result is done.
If the number is greater than 100 it is changed to 100.
Each group of E-codes differs by evaluation score. According to this number multiply ratio
and limit are adjusted. Data used for computation is presented in Table 8.
39
Table 8 Evaluation, multiply ratio and percentage limits.
Evaluation Ratio Limit
0 0 0
1 2 10
2 6 30
3 20 60
4 50 100
The results obtained by algorithm may be an integer value in range of 0 up to 100. These
numbers present the estimated negative impact of selected product on human’s health.
Results are classified in three groups. The dialog bar colour changes according to the result
classification (see Table 9). Groups are following: Green, Yellow and Red.
Table 9 Group classification
Colour Percentage [%] Description
Green 0-25 Not harmful
Yellow 26-45 Should be avoided
Red 46-100 Harmful
If the result is between 0 and 25 the dialog bar has a green colour. It is yellow with 26 - 45
results and red in other cases.
5.5 Diagrams representing application structure
The following section presents use case and sequence diagrams of Product Ingredients
Analyser application. Diagrams present the possibilities the users have while using the
application and the processes standing behind it.
40
5.5.1 Use-case diagram
Figure 10. Use case diagram
Diagram in Figure 1 presents the user perspective (Actor1) when running the application. On
the initial screen there is only one option to choose – barcode scanning. After successful scan
user is directed to other activity. Now they can choose to show product evaluation, content
description or to scan a new item’s code.
5.5.2 Sequence diagram
Figure 11. Sequence diagram
41
Figure 11 is a sequence diagram presenting the consecutive actions during usual application
run. When user scans the product its barcode is processed into some string result (number).
Such string is transferred from client (mobile device) into a servlet container running on the
web server. Received barcode number is used to query database in order to receive product
data stored under such a number. Product data is packed on the server side into DataObjects.
DataObject is an object from DataObject class having all necessary fields required in
communication process. Such DataObject is transferred in JSON format into the client device
and then processed.
5.6 Code Metrics
Code metrics are designed for informative purposes. They present code statistics in an easy to
interpret way. They describe code quality, complexity and some functionality.
For the purpose of this application in order to obtain code metrics Jenkins and Sonar web
applications (described in more detail in 2.4.4 and 2.4.5) deployed on Jetty server were used.
Jenkins is configured in the following way:
• It is a maven2/3 project.
• It is customized to use Mercurial source located in Bitbucket server.
• Builds are triggered whenever a SNAPSHOT dependency is built.
• Post build steps are set to run regardless of build result.
• After a build Sonar standalone analysis is invoked.
Exemplary project properties:
sonar.projectKey=PIA DC
sonar.projectName=PIA Database Controller
sonar.projectVersion=1.0
sources= main
Java Virtual Machine options:
-XX:+CMSPermGenSweepingEnabled
-XX:PermSize=64M
-XX:MaxPermSize=128M
-XX:+CMSClassUnloadingEnabled
42
Above configuration allows pulling repository from Bitbucket server and after a successful
Jenkins build to push it to a Sonar quality management platform. Code metrics of two of the
application components (Client and Database Controller) are presented in Figure 12 and
Figure 13.
Figure 12 [PIA] Client metrics generated by Sonar
43
Figure 13 [PIA] Database Controller metrics generated by Sonar
Sonar output webpage presents:
• Statistics as lines of codes, statements, files, classes and methods. In above presented
examples these values are presented in the top of the figures.
• Violation with a list of problem levels (Blocker, Critical, Major, Minor, Info). These
violations are listed starting with the most important one. Whereas Blocker causes the
program to stop Info level does not influence program run.
• Rules Compliance. “The RCI is a second-level metric calculated by Sonar. It gives a
ratio between weighted violations and the number of lines of code.”[18] Obtained
results: 86,2%, 91,7% may be considered as good results.
44
• Comments number and code complexity per method class and file. Results 13,2% and
2% present the comments number difference between two tested modules. Comments
do have only descriptive function and serve for readability comfort.
Described data is very useful in code improvement process.
5.7 Design problems and solutions
The following section presents problems encountered during the development phase. Also
presented solutions which were used in order to deal with them are discussed.
5.7.1 SharedPreferences
One of the problems was to build a structure able to preserve its data over the class calls. Data
received from the server side should be saved to be accessible in any class running on client
side. The goal was to download the data once and store it locally for any further usage. Such
functionality is offered by SharedPreferences interface.
SharedPreferences interface is designed for access and modification of data available for all
clients. In order to ensure data consistency all changes upon the content may be done only
through SharedPreferences Editor Object. In the data retrieval process
getSharedPreferences(String name, int mode) function is used. Example from the application
code is presented in Code example 1.
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
String jsonText = sharedPreferences.getString("jsonText", "default");
Code example 5. Shared Preferences
Code example 5 presents extraction of String data from previously created instant of
SharedPreferences. SharedPreferences use similar to JSON name value pair structure.
Variable jsonText is initialized with value stored under “jsonText” name. If such a name
would not exist jsonText would get “default” value.
45
5.7.2 UTF-8 encoding
Database records may contain any characters belonging to Unicode character set. During the
data transmission one has to specify what type of encoding should be used during the
communication. For application purposes UTF-8 encoding was used.
UTF-8 (UCS Transformation Format – 8 bit) is an encoding technique able to represent every
Unicode set of characters.
Server side UTF-8 coding is presented in Code example 6.
response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter();
Code example 6. UTF-8 coding (server side).
HTTP response is ser to use UTF-8. After that it is transferred to Client.
Client side UTF-8 coding explains Code example 7.
StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8); entity.setContentType("application/json"); post.setEntity(entity); HttpResponse response = client.execute(post);
HttpEntity entity2 = response.getEntity(); text = EntityUtils.toString(entity2, HTTP.UTF_8);
Code example 7. UTF-8 coding (client side).
On Client side coding configuration (for both communication ways) is done on the entity
level. To decode the message EntityUtils class is used.
5.7.3 View Configuration
Android operating system offers possibility to use the device in portrait as well as landscape
view configuration. The same functionality is demanded of the applications designed for this
system. In case of portrait mode the additional information have to be displayed in a new
window. When the device is in landscape mode the data is presented on the same layout. It
creates a necessity to build two layouts and a mechanism to switch between them. Code
designed for configuration switching is presented in Code example 8.
46
if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.activity_item_list);
}
if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.activity_item_twopane);
}
Code example 8. View configuration.
SetContentView() function sets the application activity layout according to the configuration.
This code fragment is responsible for switching layouts on orientation configuration change.
It is placed in onCreate Activity’s method.
5.7.4 AndroidManifest.xml settings
Some of application components where not compatible with used Android version. The
minimal and target version settings are specified in AndroidManifest.xml document which
describes whole application. Exact SDK requirement configuration is presented in Code
example 9.
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
Code example 9 AndroidManifest.xml SDK settings.
Because of Android system security features all applications are located in separated Sandbox
area. For the application to be able to use system resources it needs to receive permissions for
it. Such situation appears when there appears a need of an internet access
<uses-permission android:name="android.permission.INTERNET" />
Code example 10. Permissions
Code example 10 presents permission-granting method.
5.7.5 ZXing integration
There are 2 main ways for integrating barcode scanner with a developed application.
47
• An integrated solution
• Calling an instance of separately working scanner
Both of these methods provide expected functionality. First one is very comfortable because
user does not have to bother to install an additional application. Scanner in such a situation is
application’s internal part. Unfortunately there may appear problems with stability resulting
with pitfalls. Sean Owen – one of the ZXing developers claims that the developers should use
the second approach. This information was taken into account while writing this thesis
application and the scanner is not an integral part of the created software. [19]
Barcode scanner is started through intents technique. Additionally if there is no scanner
installed on the device user will receive an offer to install it via Android Market.
if (targetAppPackage == null) {
return showDownloadDialog();
}
Code example 11. ZXing automatic installation.
The piece of code presented in Code example 11 is checking whether there is a ZXing
application instance already installed on the device. This code is located in initateScan
function and in its return statement calls the method showDownloadDialog() presented in
Code example 12. ShowDownloadDialog() starts download dialog which offers the user to
download the barcode scanning application. If user agrees for it new intent is launched and in
case of available android market application the installation process is started.
48
private AlertDialog showDownloadDialog() {
AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
downloadDialog.setTitle(title);
downloadDialog.setMessage(message);
downloadDialog.setPositiveButton(buttonYes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
Uri uri = Uri
.parse("market://details?id=" + BS_PACKAGE);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException anfe) {
// Hmm, market is not installed
Log.w(TAG,
"Android Market is not installed; cannot install
Barcode Scanner");
}
}
});
downloadDialog.setNegativeButton(buttonNo,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
}
});
return downloadDialog.show();
}
Code example 12. ShowDownloadDialog function.
ShowDownloadDialog function is written by ZXing team and it is a piece of code for starting
ZXing application download in case of its absence in the device.
49
6 Testing
After development stage application should be properly tested. There are several testing
techniques belonging to two main groups: black and white box tests. First group bases on tests
done by a person not knowing the internal structure of software. Such person is aware of the
logical purpose of the software instead. Having those information tester is trying to detect
defect in any way “destroying” the application. The advantage of such tests is the detection of
untypical user behaviours. Disadvantage of this approach is the level of automation. It
requires having large personnel to pass all the tests manually.
Second group – white box tests are done usually by the programmer team. They can be
performed on the whole modules or small software pieces. In case of testing methods or
classes they are called Unit Tests.
6.1 Functional tests
The following section presents Black Box tests performed on the application. The
methodology was as follows:
• Testing of standard activities.
• Testing the application behaviour during unusual actions – stability testing.
Tests performed on the application were done twice, first time for the portrait and second one
for landscape view. Test steps are following.
Standard activities are presented in Table 10.
Table 10 Functional tests 1
Action Function
Pressing of the scan button Check if the application properly scans the
products
Check if after the scanning process user is
redirected to a menu screen populated with the
correct product data
In case of scanning product not available in the
database check if proper information is displayed
50
Showing the evaluation Check if popup dialog is displayed correctly
Showing details Check if proper data is displayed
Scanning of a new product Check if the new product is scanned correctly
Standard activities are those presenting regular use. It simulates user’s correct actions.
Stability testing explains Table 11.
Table 11 Functional tests 2
Scanning cancellation Check if scanning the application is stable after
unusual return from code scanning
Frequent change of view configuration Check the application’s speed and stability
Repeating the same actions several times Stability test
Stability testing relies on unusual approach to the application. It describes possible irregular
actions.
6.2 Unit tests
Unit tests are for checking small pieces of code. Such code pieces are mostly methods. Tests
are organized into sets covering the classes. There are several methods for test performance.
One called “weak debugging” relies on printing on standard output system state in specific
places. It allows checking the state during the method runtime. Such approach can be
substituted by the usage of debugger. The advantage of it is the frequent compilation
requirement. Java does not allow compiling code without providing all dependencies. It
means that during the tests code needs to have all dependencies set. With each test change
whole module need to be recompiled.
The other method relies on writing small application calling several times tested code and at
the end analyzing the results. This approach gives the possibility of test automation.
Programmer instead of writing such an application may use already existing tool such as
JUnit library.
51
6.2.1 JUnit
JUnit is a library designed for automation of unit testing. It possesses mechanisms for
preparation, running and verification of the test results. In order to have test transparency only
public methods should be tested. Public methods are the only one accessible from outside so
there is no need to focus on private ones. However there is also other popular approach – to
test everything. The second option provides compatibility where the first option could fail.
The access to private methods in this case is done through references. The main disadvantage
is the tests complexity.
Tests done with the JUnit library should satisfy following requirements.
• Independence
Different test should not influence each other. The execution order should be
irrelevant.
• Repeatability
Tests should be run able at any moment with the stability guarantee. Repeatability
means that test will return the same results with each execution.
• Unambiguity
It should be clear what is being tested and what does the result mean.
• Unity
Tests should not check more than one thing. Only one piece of code should be tested
in at once. Otherwise in case of failure the result would not be clear.
Using JUnit library the developer extend abstract class junit.framework.TestCase. The name
of the test method must start from “test” word. Before each test there is setUp() method
started and tearDown() after it.
The following table presents test methods.
Table 12. JUnit test methods
Statement Description
fail(String) Let the method fail. Might be used to check that a
certain part of the code is not reached. Or to have
failing test before the test code is implemented.
52
assertTrue(true) / assertTrue(false) Will always be true / false. Can be used to
predefine a test result, if the test is not yet
implemented.
assertTrue([message], boolean condition) Checks that the Boolean condition is true.
assertsEquals([String message], expected,
actual)
Tests that two values are the same. Note: for
arrays the reference is checked not the content of
the arrays.
assertsEquals([String message], expected,
actual, tolerance)
Test that float or double values match. The
tolerance is the number of decimals which must
be the same.
assertNull([message], object) Checks that the object is null.
assertNotNull([message], object) Checks that the object is not null.
assertSame([String], expected, actual) Checks that both variables refer to the same
object.
assertNotSame([String], expected, actual Checks that both variables refer to different
objects.
Programmer can use above listed methods to check if the object of his choice does exist or
have some value. After test run testing environment returns information about results.
6.2.2 Mockito
During the tests writing process frequently there appears necessity of using mocking/stubbing
of classes. It relies on creating class object with partially changed behaviour. In this way we
can create fully controlled and known test conditions. The easiest way to obtain such
functionality is to use dedicated frameworks. Such a framework is Mockito. For the purpose
of this application this framework was not used, but it is important to mention it when
describing JUnit library.
6.2.3 Application test example
The following section presents tests done on Database Controller with the usage of JUnit
framework.
53
@Before
public void setUp() throws Exception {
main = new Main();
}
Code Example 13 SetUp method
SetUp method initializes new object of the Main type. It will be necessary for tests.
@Test
public void testSaveProduct() {
barcodeNumber = 15436;
main.saveProduct("Coffe", barcodeNumber);
DataObject dataObject = new DataObject();
dataObject = main.selectProduct(barcodeNumber);
assertNotNull(dataObject);
assertEquals("Product name", "Coffe", dataObject.getProductName());
}
Code Example 14
Above example tests the product data insertion mechanism to the database. In this case
DataObject is created and initialized with the return value of selectProduct() function.
Function assertNotNull() tests if obtained object is not null.
@Test
public void testSelectProduct() {
DataObject dataObject = new DataObject();
barcodeNumber = 1;
dataObject = main.selectProduct(barcodeNumber);
assertNotNull(dataObject);
assertEquals("Product name", "Milk", dataObject.getProductName());
}
Code Example 15
TestSelectProduct() verifies the functionality of product selection from the database. This test
example presents if there are proper values extracted from the database.
54
@Test
public void testUpdateProduct() {
DataObject dataObject = new DataObject(); barcodeNumber = 15436;
dataObject = main.selectProduct(barcodeNumber); assertNotNull(dataObject);
assertEquals("Product name", "Coffe", dataObject.getProductName());
main.updateProduct(dataObject.getProductId(), "updated Coffe");
assertEquals("Product name", "updated Coffe", main.selectProduct(barcodeNumber).getProductName());
assertNotSame("Product name", "Coffe", dataObject.getProductName()); }
Code Example 16
TestUpdateProduct() is created for database record update. This function verifies is the update
procedure is properly working. Function assertNotSame() checks if the update works.
@Test
public void testDeleteProduct() {
DataObject dataObject = new DataObject();
barcodeNumber = 15436;
dataObject = main.selectProduct(barcodeNumber);
assertNotNull(dataObject);
assertEquals("Product name", "updated Coffe",
dataObject.getProductName());
while (main.selectProduct(barcodeNumber).getProductName() != null) {
main.deleteProduct(main.selectProduct(barcodeNumber).getProductId());
}
assertNull(main.selectProduct(barcodeNumber).getProductName());
}
Code Example 17
TestDeleteProduct() check if the mechanism for product removal works properly. After
product removal function assertNull() verifies if the product was deleted.
Above examples present usage of methods listed in Table 12 such as assertEquals or
assertNull.
55
7 Summary
The subject of the thesis was very interesting. It involved knowledge and technologies from
many IT branches. I have learned how to use many of programming tools and techniques.
Choice of the mobile device platform was made after deep research of Android popularity and
functionality. It is the fastest developing mobile operating system with even better prognoses
for the future.
7.1 Applied technologies
Client application layout was supported by fragments technique offering great scalability over
screen sizes. Among many available on the market communication protocols for the
application purposes JSON protocol was chosen. JSON is both human and machine readable
string representation build from name value pairs.
Regarding application server side there was Java servlet running on customized by VMware
Company Tomcat servlet container used. Tomcat is the most popular open-source solution
offering great functionality. Servlet is bind with PostgreSQL database through hibernate
framework. Decision to use PostgreSQL database was taken because of this system stability
and well proved failure proof architecture.
Besides the technical aspects this thesis required very detailed research on the nourishment
field. There were many sources analyzed which referred influence of preservatives and other
substances on human health. The database contains hundreds of records. Records consist of
name, code number and precise substance description.
7.2 Future development
Although the application is finished, there are many ways in which it can be further
developed. The most challenging one is to create a module for data extraction from any
source in internet. Such software would populate the database with information concerning
any products available on the market. Web services would be searched with the help of most
popular browsers such as Google and Bing. Specially designed mechanism would extract data
from all encountered sites regarding wanted product. The application maintaining team would
not have to do it manually.
56
Another way of development comes from application portability. The one created for the
purpose of this thesis is designed for Android 4.0 or higher OS. In order to make it more
popular iOS as well as Windows Phone versions may be created.
There is also important functionality which could be introduced in the future. Application
requires constant internet connection for the communication with the database. Such situation
makes it not useful for users not having internet packages included in their mobile contract.
The solution of this problem can be creation light local database which would be periodically
updated.
7.3 Conclusion
Summing up mobile market is developing very fast. It is very important to know existing
techniques and solutions. It is one of the most important pillars of today’s IT business. The
application development demanded to get knowledge from database, internet communication
as well as programming fields. It was a very educative subject.
57
8 References
1. Android activations. [Online] [Cited: 26 08 2012.] http://techcrunch.com/2012/09/05/eric-
schmidt-there-are-now-1-3-million-android-device-activations-per-day/.
2. iOS. [Online] [Cited: 26 08 2012.] http://www.askmobiapps.com/iphone.php.
3. Windows Phone. [Online] [Cited: 26 08 2012.]
http://www.gartner.com/it/page.jsp?id=1924314.
4. code scanning popularity. [Online] [Cited: 01 09 2012.]
http://www.qrstuff.com/blog/2012/04/08/q1-2012-qr-code-trends.
5. Pelikant, Adam. Bazy danych pierwsze starcie. s.l. : Helion, 2009.
6. PostgreSQL role. [Online] [Cited: 26 08 2012.]
http://www.postgresql.org/docs/8.1/static/user-manag.html.
7. MySQL. [Online] [Cited: 27 08 2012.] http://www.mysql.com/why-mysql/.
8. Tomcat. [Online] [Cited: 27 08 2012.] http://tomcat.apache.org/.
9. Jetty. [Online] [Cited: 27 08 2012.] http://www.eclipse.org/jetty/.
10. Glassfish. [Online] [Cited: 27 08 2012.] http://docs.oracle.com.
11. Ant. [Online] [Cited: 27 08 2012.] http://ant.apache.org/.
12. GSON. [Online] [Cited: 28 08 2012.] http://code.google.com/p/google-gson/.
13. Cay S. Horstmann, Gary Cornell. core Java 2 Podstawy. s.l. : Helion.
14. Health, Minister of. Rozporządzenie ministra zdrowia z dnia 22 listopada 2010 r. w
sprawie dozwolonych substancji dodatkowych, załącznik nr 1 . s.l. : 22.11.2010.
15. Rychik E., Jarosz M. Co nam mówią etykiety produktów spożywczych?; [w] Zasady
prawidłowego żywienia dzieci i młodzieży oraz wskazówki dotyczące zdrowego stylu życia.
Warsaw : Instytut żywności i żywienia, 2008.
58
16. Fragments. [Online] [Cited: 01 09 2012.]
http://developer.android.com/guide/components/fragments.html.
17. Zxing description. [Online] [Cited: 06 09 2012.] http://code.google.com/p/zxing/.
18. Sonar RCI. [Online] [Cited: 06 09 2012.]
http://docs.codehaus.org/display/SONAR/Browsing+a+Project.
19. ZXing. [Online] [Cited: 30 08 2012.]
http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-
android-app-natively-using-eclipse/.
9 Appendices
This additional thesis chapter presents application’s user manual.
9.1 User Manual
User manual describes main application functionality. At software start welcome screen is
presented.
9.1.1 Welcome screen
In this point user has only the possibility to scan a barcode of selected product.
Application screenshot 1. Welcome screen.
dditional thesis chapter presents application’s user manual.
User manual describes main application functionality. At software start welcome screen is
In this point user has only the possibility to scan a barcode of selected product.
. Welcome screen.
59
User manual describes main application functionality. At software start welcome screen is
In this point user has only the possibility to scan a barcode of selected product.
After pressing the “Skanuj produkt
the ZXing application is not available on the device, please accept its installation process.
9.1.2 Menu
After a successful scan, application menu will be shown
Application screenshot 2. Menu
In case of running application in horizontal mode Menu screen is presented on
screenshot 3.
Skanuj produkt” button, ZXing code scanning module will be l
the ZXing application is not available on the device, please accept its installation process.
After a successful scan, application menu will be shown (see Application screenshot
In case of running application in horizontal mode Menu screen is presented on
60
ZXing code scanning module will be launched. If
the ZXing application is not available on the device, please accept its installation process.
Application screenshot 2).
In case of running application in horizontal mode Menu screen is presented on Application
Application screenshot 3. Menu horizontal
Menu allows checking product evaluation, details
name is presented above the menu list.
9.1.3 Details
Details present scanned product ingredients information. It is a list o
descriptions. Each substance is displayed with the
stored in the database (see Application screenshot
. Menu horizontal
Menu allows checking product evaluation, details or to scan another item. Scanned product
name is presented above the menu list.
Details present scanned product ingredients information. It is a list of code numbers and
descriptions. Each substance is displayed with the colour depending on its evaluation number
Application screenshot 4 and Application screenshot
61
Scanned product
f code numbers and
depending on its evaluation number
Application screenshot 5).
Application screenshot 4. Product details
Application screenshot 5 Product details
Product details - vertical
Product details - horizontal
62
9.1.4 Evaluation
Evaluation is presented on the horizontal ProgressBar. Progressbar colour changes ac
to the product negative impact level
safe product presented.
Application screenshot 6. Evaluation screen
9.1.5 Scanning
Scanning process is done through ZXing module
presented in the Application screenshot
Evaluation is presented on the horizontal ProgressBar. Progressbar colour changes ac
impact level. On the Application screenshot 6 there is evaluation of a
. Evaluation screen
Scanning process is done through ZXing module. Process of taking a picture of a code is
Application screenshot 7.
63
Evaluation is presented on the horizontal ProgressBar. Progressbar colour changes according
there is evaluation of a
. Process of taking a picture of a code is
Application screenshot 7. Code scanning
9.1.6 Errors
In case of connection problems with the database server user will be informed about it with
the message presented in Application screenshot
scanning
In case of connection problems with the database server user will be informed about it with
Application screenshot 8.
64
In case of connection problems with the database server user will be informed about it with
Application screenshot 8. Error message
Errors may also appear if the scanned product is not available in the database.
Error message
Errors may also appear if the scanned product is not available in the database.
65
Errors may also appear if the scanned product is not available in the database.