Download as pdf or txt
Download as pdf or txt
You are on page 1of 125

Auto Parts Warehouse

By

Usama Naeem
2015-GCUF-14405

M. Muazam Tahir
2015-GCUF-14404

Project is submitted in partial fulfillment of


the requirements for the degree of

BACHELOR OF COMPUTER SCIENCES

DEPARTMENT OF COMPUTER SCIENCES


GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD
DECLARATION

The work reported in this project was carried out by us under the
supervision of Mr. Sami-Ullah, Lecturer Department of Computer
Sciences, Government College University Faisalabad, Pakistan.

We hereby declare that the “Auto Parts Warehouse” android


application and the contents of project is the product of our own research.
We further declare that this work has not been submitted for award of any
other degree/diploma. The university may take action if the information
provided is found inaccurate at any stage.

Name of Student: Usama Naeem


Registration No. 2015-GCUF-14405
Signature of Student: _____________

Name of Student: M.Muazam Tahir


Registration No. 2015-GCUF-14404
Signature of Student: _____________

ii | P a g e
CERTIFICATE BY THE PROJECT SUPERVISOR

This is to certify that Usama Naeem Roll No. 14405, Muazam Tahir Roll
No. 14404 has successfully completed the final year project named as:
Autoparts Warehouse, at the Department of Computer Sciences,
Government College University, Faisalabad, to fulfill the partial
requirement of the degree of BS (CS).

Supervisor
Name: Sami-Ullah

Signature: ______________________

Chairperson
Department of Computer Sciences
Government College University Faisalabad

iii | P a g e
Acknowledgements

In completing this undergraduate project, I have been fortunate to have


help, support and encouragement from many people. I would like to
acknowledge them for their cooperation.

First, I would like to thank my project supervisor Mr. Sami-Ullah, Lecturer


Government College University Faisalabad, for guiding me through each
step of the process with knowledge and support. Thank you for your
advice, guidance and assistance. He has been a constant source of guidance
throughout the course of this project. We are also thankful to our friends
and families whose silent support led us to complete our project.

1- Usama Naeem
2- M. Muazam Tahir

Date: June 25, 2019

iv | P a g e
Contents
LIST OF FIGURES ...................................................................................................................... VII
LIST OF TABLES .......................................................................................................................VIII
1 INTRODUCTION .................................................................................................................... 1
1 INTRODUCTION ................................................................................................................... 2
1.1 BACKGROUND .................................................................................................................... 2
1.2 THE PURPOSE OF THE PROJECT ............................................................................................ 3
1.3 THE SCOPE OF THE PRODUCT .............................................................................................. 3
1.4 REASONS TO DEVELOP THIS PRODUCT .................................................................................. 3
1.5 FEATURES OF DEVELOPED SYSTEM ..................................................................................... 4
1.6 OBJECTIVE ......................................................................................................................... 4
1.7 MISSION ............................................................................................................................. 5
1.8 DEVELOPED SYSTEM .......................................................................................................... 5
1.8.1 The User.................................................................................................................... 5
1.9 PROBLEM DEFINITION ......................................................................................................... 5
1.10 SUMMARY .......................................................................................................................... 6
2 REQUIREMENT SPECIFICATION & SYSTEM ANALYSIS ............................................. 7
2.1 THE HANDS-ON USERS OF THE PRODUCT ............................................................................ 8
2.2 PRODUCT USE CASES .......................................................................................................... 9
2.3 FUNCTIONAL AND DATA REQUIREMENTS........................................................................... 11
2.4 NONFUNCTIONAL REQUIREMENTS ..................................................................................... 15
2.4.1 Look and Feel Requirements ........................................................................................ 15
2.4.2 User interfaces............................................................................................................. 15
2.4.3 Hardware interfaces .................................................................................................... 15
2.4.4 Software interfaces ...................................................................................................... 16
2.4.5 Communications interfaces ...............................................Error! Bookmark not defined.
2.4.6 Usability and humanity requirements ........................................................................... 16
2.5 QUALITY REQUIREMENT OF THE PROJECT .......................................................................... 16
2.5.1 Legal Requirement ....................................................................................................... 16
2.5.1.1 Compliance Requirements................................................................................................. 16
2.5.1.2 Standards Requirements .................................................................................................... 16
2.5.2 Design Constraints ...................................................................................................... 17
2.5.3 Software System Attributes ........................................................................................... 17
2.5.4 Operational and Environmental Requirements ............................................................. 17
2.6 SECURITY REQUIREMENTS ................................................................................................ 18
2.7 CULTURAL AND POLITICAL REQUIREMENTS....................................................................... 20
2.7.1 Cultural Requirements ................................................................................................. 20
2.7.2 Political Requirements ................................................................................................. 20
2.8 TABLE MOST IMPORTANT REQUIREMENTS .......................................................................... 21
2.9 PRODUCT ..................................................................... ERROR! BOOKMARK NOT DEFINED.
2.10 SCOPE .............................................................................................................................. 21
2.11 HARDWARE ARCHITECTURE.............................................................................................. 22
2.12 SOFTWARE ARCHITECTURE ............................................................................................... 22
2.12.1 Database ................................................................................................................. 22
2.12.2 Web service ............................................................................................................. 22
2.12.3 Application Program ............................................................................................... 23
2.13 SYSTEM ARCHITECTURE ................................................................................................... 23

v|P ag e
2.14 SUMMARY: ....................................................................................................................... 23
3 SYSTEM DESIGN ................................................................................................................. 32
3.1 BLOCK DIAGRAM ............................................................................................................. 25
3.1.1 Solution Constraints: ................................................................................................... 26
3.2 IMPLEMENTATION ENVIRONMENT OF THE CURRENT SYSTEM: ............................................ 29
3.3 SCHEDULE CONSTRAINTS .................................................................................................. 29
3.4 BUDGET CONSTRAINTS ..................................................................................................... 39
3.5 NAMING CONVENTIONS AND DEFINITIONS ......................................................................... 29
3.5.1 Definitions of All Terms, Including Acronyms, Used in the Project................................ 29
3.6 WORK PARTITIONING ....................................................................................................... 31
3.7 CLASS DIAGRAM OF HOPE BACKEND SYSTEM: ........................................................... 32
3.8 SEQUENCE DIAGRAM OF COMPLETE PROJECT ...................................................... 36
3.9 ACTIVITY DIAGRAM: ........................................................................................................ 43
3.10 SUMMARY: ................................................................................................................... 57
4 IMPLEMENTATION ............................................................................................................ 58
4.1 MAIN ACTIVITY ........................................................................................................... 59
4.2 SIGN UP ACTIVITY ....................................................................................................... 63
4.3 ASK PHONE NUMBER ACTIVITY ............................................................................... 68
4.4 VERIFY PHONE NUMBER ACTIVITY ......................................................................... 76
4.5 INCOMING BLOOD REQUEST ACTIVITY .................................................................. 82
4.6 FIREBASE MESSAGING SERVICE ............................................................................... 89
4.7 MAPS ACTIVITY ................................................................................................................. 90
4.8 FIND BLOOD ACTIVITY ..................................................................................................... 100
4.9 HISTORY ACTIVITY .......................................................................................................... 105
4.10 SCHEDULE APPOINTMENT ACTIVITY ................................................................................. 105
4.11 SUMMARY .................................................................................................................. 118
5 USER MANUAL .................................................................................................................. 119
5.1 APPLICATION SCREENS ................................................................................................... 111
5.1.1 Splash Screen ............................................................................................................ 111
5.1.2 Home Screen.............................................................................................................. 122
5.1.3 Registeration Screen .................................................................................................. 123
5.1.4 User Details Screen ................................................................................................... 124
5.1.5 Maps Screen .............................................................................................................. 125
5.1.6 Search Blood Screen .................................................................................................. 126
5.2 SUMMARY ...................................................................................................................... 117

vi | P a g e
List of Figures
Figure 1: Use Case Diagram of System ................................................................................. 9
Figure 2: Block Diagram Of Interactive System .................................................................. 25
Figure 3: Block Diagram of Working Of System ................................................................. 28
Figure 4: Class Diagram...................................................................................................... 32
Figure 5: Become a Donor Sequence Diagram .................................................................... 46
Figure 6:Blood Banks Sequence Diagram ........................................................................... 48
Figure 7: Query Blood Sequence Diagram .......................................................................... 49
Figure 8: Activity Diagram ................................................................................................. 53
Figure 9: Splash Screen..................................................................................................... 121
Figure 10: Home Screen.................................................................................................... 122
Figure 11: Registration Screen .......................................................................................... 123
Figure 12: User Details Screen .......................................................................................... 124
Figure 13: Maps Screen .................................................................................................... 125
Figure 14: Search Blood Screen ........................................................................................ 126

vii | P a g e
List of Tables
Table 1: User Table............................................................................................................... 8
Table 2: Register User......................................................................................................... 13
Table 3: Log In ................................................................................................................... 13
Table 4: Search for Blood Bank .......................................................................................... 14
Table 5: Serach for Blood ................................................................................................... 14
Table 6: Manage History ..................................................................................................... 15
Table 7: Update Profile ....................................................................................................... 16
Table 8: Restore Data.......................................................................................................... 16
Table 9: Most Important requirements ................................................................................. 21
Table 10: All Terms, Including Acronyms Used .................................................................. 29
Table 11: Work Priorities .................................................................................................... 31
Table 12: Tools and Technology Used .............................................................................. 110

viii | P a g e
CHAPTER-1

INTRODUCTION

1
1 Introduction
It Auto-parts warehouse is a mobile application for spare parts of cars on
android platform,

This online retailing app offers over hundreds of auto-related products through its online
sales channel. By eliminating intermediaries common in most supply chains, Auto Parts
Warehouse is able to provide a broad selection of automotive parts and accessories.

If someone needs parts, first of all he searches it within his area stores, then nearest cities. If
they cannot manage parts in these ways, it is really hard for them to search it by going store to
store. That is the problem we want to solve through our application. So therefore the main
objective of this app is to provide a platform where the user can interact with app and easily
search the categories of auto parts and also gets the product details and price.

The Auto Parts Warehouse app is developed to give users of smart phones and other mobile
devices prompt access to parts and accessories in the retailer’s complete catalog listing. This
enables customized searches for auto-related products. Auto Parts app is designed to give
car owners instant and convenient access to the automotive products they need for
installation. The app enables instant parts search and shopping, as well as direct contact
with the Store.

1.1 Background

A blood donation occurs when a person voluntarily has blood drawn.


Donating blood may be of whole blood (WB), or of specific components directly. Blood
banks often participate in the collection of blood process as well as the procedures that
follow it.

Today in the developed world most blood donors are unpaid volunteers who donate
blood for a group supply. In poor countries accepted blood supplies are limited and
donors usually give blood when family or friends need a transfusion. Donors can also
have blood drawn for their own future use.

Today mobile based application have become a part of our daily life. With the
revolution in mobile computing many features were added to the field. This android

2
application is developed to easily search the blood donor nearby area at any emergency.
Those who have register in this app, their position along with the blood group detail
will be display using GPS(GLOBAL POSITIONING SYSTEM).

1.2 The Purpose of the Project


“Auto parts warehouse” one of the most important necessity of our life
in now-a-days. In our project we propose a new and efficient way to overcome such
outline.
Such as just touch the button user will be ask to enter an individual's details like name,
phone number,address etc. At the emergency time of blood needed we can check for
blood donor nearby by using GPS.
Once the app user enters the blood group which he/she needed it will automatically
show the donor nearby and send an alert message to the donor.
In case if the first donor is not available it will automatically search the next donor,
which is present in queue.
Blood donation app provide active donors in your city/area. Once the donor donates the
blood it will automatically disable the donor detail for next three months.

1.3 The Scope of the Product


The Scope of the project is that, in a very short span it provides user with
many facilities. It provides an elegant management of blood, blood banks and donors
online.

The main purpose of this project is to interconnect all the blood banks, hospitals, donors
into a single network, validation, store various data and information of blood and health
of each individual. This system is used to store data over a centralized server which
consist of database where the individual’s information cannot be accessed by a third
party.

1.4 Reasons to develop this product


The main aim of this project is to save lives of people by providing
blood. This project is developed by three perspectives i.e. hospital, blood bank and
patient/donor.

3
We have provided security for authenticated user as new user have to register according
to their type of perspective. This application, we are developing, helps to select the
nearby hospital online instantly by tracing its location using GPS.

1.5 Features of Developed System

Key features of the developed app are as follows:

 HOPE is free without any advertisement easy to use with awesome animation
and graphics with a little bit touch of Social Network Blood donation and
finder app.

 REGISTRATION: Registration is based on phone number, your phone


number will be keep private.

 USER PROFILE: Every user of HOPE has its own profile. other user can
access your profile after He/she interested to become a donor.

 HOPE MAP: Map is a Heart of HOPE, all the donors and the person who need
blood will be show on Map as map pin. There are two kinds of Pin in HOPE
app.

 TRACK RECORD: Keep track of total blood donations.


 BE ACTIVE ANYTIME: Become a Blood Donor any time by making
yourself Active.
 RATING: After Successful Donation rate the Donor out of five stars.

1.6 Objective

 To create an atmosphere to make available blood to all in the country collected


from non-remunerated voluntary blood donors.
 To co-ordinate and facilitate the relationships between voluntary blood donors
and receiver we are going to show nearby donors and giving opportunity to rate
the donor.
 To recruit new donor and create donors of tomorrow through motivational
programs in schools, campuses and youth groups.
 To create public awareness and disseminate information on voluntary blood
donation and safe blood.

4
1.7 Mission
Our mission is providing the complete details of our products so the user
can easily select the needy parts and can order it easily by using our application. due
to blood unavailability at right time and to recruit new donor and create donors of
tomorrow through motivational programs in schools, campuses and youth groups.

We want to create public awareness and disseminate information on voluntary blood


donation and safe blood and to co-ordinate and facilitate the relationships between
voluntary blood donors and receiver, thus promoting Blood Program in all over the
world.

1.8 Developed application

By developing this application, we want to create awareness among the


android users and motivate them to help the needful. This application will help the user
in all the possible ways helpful in blood donation.

1.8.1 The User done


User are also our main stakeholders of the project. The users will be use
the app that will help them to get details about desired parts. Users play an important
role in this project. Users will not be from the development depart. They are just using
the app and don’t know how the app is made.

1.9 Problem Definition


After a long research we found that there are no apps in the Google play
store which shows the autoparts . We found out that there is a requirement of an
application which is helpful for people in many ways.

As we all know that donating blood is a good deed but due to some misconceptions
people hesitate in donating blood. By going through the applications already available,
we found out that all the applications are lacking the feature of connecting the people
who are interested in either donating the blood or they urgently require the blood.

The main feature of our application is connectivity provided by us. The donors and
receivers can contact to each other depending on their needs.

5
Sometimes in urgency you may have thought of any platform from where we can get
the details of hospitals, blood banks. But we fail to get such an application or platform.
We found out that there are apps on internet but they are lacking some of utilities which
we had developed in our application.

1.10 Summary done

This application will help the android users to get information about
Spare Parts. The need of Parts and all the queries related to that. We had focused on the
productivity of the application by maintaining a database of the products containing
their details, so that we can make the most of it. We had designed the application in
such a way that it helps the user in all possible ways when he or she needs information.
If time will permit we will add more features and improve the productivity of the
application.

6
CHAPTER-2

Requirements Specification

&

System Analysis

7
2 Requirement Specification & System Analysis
In this chapter requirement specification is being carried out using UML
diagrams and separating functional and non-functional diagram. Business requirements
have also considered because this application is made for Google Play Store and for
international usage.

2.1 The Hands-On Users of the Product


Users are human beings who interface with the product in some way.
Users are also known as actors.

There is only one type of user that interact with the system

 Application Users

APPLICATION USER TABLE:

Table 1: User Table

User Name Application User.

User Role  Register


 Log In
 Become a Member
 Search for desired parts
 Add to cart / Order the Product
Subject matter Novice
experience

Technological Novice
experience

Use Case Diagram

8
Figure 1: Use Case Diagram of App

2.2 Product Use cases


# UseCase1

Use case Title: Download application free

Description: The user will download application free of cost from the play store that
will be already installed on the user’s mobile. The downloaded application will then be
installed on user’s mobile.

Primary Actor: User

Pre-Condition: The user should have application installed in his/her mobile.

# UseCase2

Use case Title: Register yourself

Description: The user will create an account to login to use the application. The user
will click on the option Register and a form to get user’s information shall be appeared.

Primary Actor: User

9
Pre-Condition: The user should have connect to the Internet..

Post-Condition: The user’s account has been created.

# UseCase3

Use case Title: Log in

Description: User has an account and log into the application by providing his/her
email and password.

Primary Actor: User

Pre-condition: User should have an account

Post-Condition: User has logged into the mobile application.

# UseCase4

Use Case Title: User can become a Consumer

Description: After log in user can register himself as a customer by giving the details
about his/her address, Phone number and Email id.

Primary Actor: System

Pre-Condition: The user should have connected to the internet.

Post-Condition: The user will be register as Customer.

# UseCase5

Use Case Title: Search for a desired parts

Description: The user can find his/her desired parts by simply enters product name in
search bar.

Primary Actor: User

10
# UseCase6

Use Case Title: Add to Cart / Order the product.

Description: The user can add his/her desired parts into cart if he/she wants to purchase
it after few days and the user can also order the product from the cart.

Primary Actor: Customer

Pre-Condition: He/she have account.

Post-Condition: User should have connected to the Internet.

2.3 Functional and Data Requirements

Software requirements document plays the significant role in the entire


software development process. To start with, it is needed in the project planning and
feasibility phase. In this phase, a good understanding of the requirements is needed to
determine the time and resources required to build the software. Because of this
analysis, the scope of the system may be reduced before embarking upon the software
development.

This section includes the requirements that specify all the fundamental actions of the
software system. There are

Section 1: Functional Requirement

Requirement Name: Register

Table 2: Register User

Requirement #: Req01 Requirement Functional


Type:

Description: User should have email password and his/her personal details
to enter in the application to register.

Rationale: To register every user.

11
Originator: User

Fit Criterion: User is registered in the system

Customer 10 Customer 1
Satisfaction: Dissatisfaction:

Requirement Name: Login

Table 3: Log In

Requirement #: Req02 Requirement Functional


Type:

Description: User should have email and password to enter in the website

Rationale: To login in to android application

Originator: User

Fit Criterion: User is logged in the system

Customer 8 Customer 2
Satisfaction: Dissatisfaction:

12
Requirement Name: Search for desired parts

Table 4: Search for parts

Requirement #: Req03 Requirement Functional


Type:

Description: user can search his/her desired parts from the app and fetch the
details about them like, product details and price.

Rationale: He/she will find auto parts .

Originator: User

Fit Criterion: User will find parts and fetch all details.

Customer 8 Customer 2
Satisfaction: Dissatisfaction:

Requirement Name: User should be able to add his/her desired parts in cart and
order.

Table 5: Add items into cart and order

Requirement #: Req04 Requirement Functional


Type:

Description: User can find desired parts from the application and user can also
add their needed parts into cart so he can have ordered it in future.
When user order item the cart will be automatically clear.

13
Rationale: He/she can add parts in cart and order it.

Originator: User

Fit Criterion: User must be logged in the application.

Customer 8 Customer 2
Satisfaction: Dissatisfaction:

##########Requirement Name: User should be able to restore his/her record if


he/she uninstall the application.

Table 8: Restore data

Requirement #: Req 07 Requirement Functional


Type:

Description: User Can get his/her personal data and cart items back even if
he/she uninstall the app.

Rationale: To get lost data.

Originator: User

Fit Criterion: User will be sure about his/her data security.

14
Customer 8 Customer 2
Satisfaction: Dissatisfaction:

2.4 Non Functional Requirements


Nonfunctional Requirement are given in this section.

2.4.1 Look and Feel Requirements


This section provides a detailed description of the hardware, software and
communication interfaces and provides basic prototypes of the user interface.

2.4.2 User interfaces


1. A first-time user of the mobile application should see Splash screen is just for 4
seconds

2. After that he will be able to choose two options Registers and Sign in if he is using
for the first time he will register first. But if he is not new he will only able to see
one option Login. In Login Screen user must provide registered number.

3. After Login user will see a Home page.

4. A slider will be shown at the top of Home screen. Which shows the deal of the
day if any deal is available otherwise this section will hide.

5. Different types of auto parts categories will be shown below the slider which will
contain different types of parts like brakes, tyres etc. By touching on any category
a new activity will be shown which contains the complete details of product with
price.

2.4.3 Hardware interfaces


It does not have any direct hardware interfaces. The physical storage is managed by the
local storage in the mobile phone and connection to the database is managed by the
underlying operating system on the mobile phone. No extra hardware is required. This
is simply a free to use application.

15
2.4.4 Software interfaces
The mobile application communicates with online web server to gain the data of user.
Users profile management will be placed upon online server. Application will fetch all
the data from online server when needed. When user ordered any product the product
will be place in real time database.

2.4.5 Usability and humanity requirements

1. The product will be user friendly. Product will be easy to use.


2. Icons and tool tips will have used for the help and guidance of user.
3. Accessibility of previous data is easily accessible if data is not deleted from the
database.
4. Application must show the correct address of users.
5. Reliability and Availability requirements:
a. Product will be reliable.
b. Product will be easily usable.
c. Product will work properly.
6. The functionality of the product can be enhanced with some advanced tools and
technologies in future.
7. Expected Lifetime of Product is until new such product with some latest
techniques is not introduced.

2.5 Quality Requirement of the project


2.5.1 Legal Requirement
No legal requirements are used in this project.

The standards are followed which are provided by the department.

2.5.1.1 Compliance Requirements


a) This application should not provide any information which will be
dangerous for security.
b) Registered data of user should be confidential.

2.5.1.2 Standards Requirements ??????????


Application should be developed using SDLC model.

16
2.5.2 Design Constraints
2.5.2.1 Phone’s local storage

2.5.2.2 Application memory usage

2.5.3 Software System Attributes


 Reliability

 Availability

 Security

 Maintainability

2.5.4 Operational and Environmental Requirements

Requirement #: Quality Requirement 1 Requirement type: Quality Requirement

Title: Internal storage

Description: The system should have internal storage of few MBs available for app.

Source: Developers team

Rationale: To use system storage.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

Requirement # Quality Requirement 2 Requirement type: Quality Requirement

Title: System Reliability

Description: The availability of the system when it is used. The system should give
accurate result every time.

17
Source: Developers team

Rationale: For application that the system is available for 24/7 hours.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

2.6 Security Requirements

Requirement #: Quality Requirement 3 Requirement type: Quality Requirement

Title: Login Security

Description: There should be secure log-in, so others cannot get user-name and
password.

Source: Developers team

Rationale: For user’s privacy.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

Requirement #: Quality Requirement 4 Requirement type: Quality Requirement

Title: User Login Account Security

Description: If a user tries to log in to the application with a non-existing account


then the User should not be logged in. The User should enter correct mobile number.

Rationale: For user security.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

18
Requirement #: Quality Requirement 5 Requirement type: Quality Requirement

Title: User Create Account Security

Description: User wants to create an account with only one user name

Source: Developers team

Rationale: For User Create Account Security.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

Requirement #: Quality Requirement 6 Requirement type: Quality Requirement

Title: Internal storage

Description: The system should have internal storage of few MBs available for app.

Source: Developers team

Rationale: To use system storage.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

19
Requirement # Quality Requirement 7 Requirement type: Quality Requirement

Title: System Reliability

Description: The availability of the system when it is used. The system should give
accurate result every time.

Source: Developers team

Rationale: For application that the system is available for 24/7 hours.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

Requirement #: Quality Requirement 8 Requirement type: Quality Requirement

Title: Login Security

Description: There should be secure log-in, so others cannot get user-name and
password.

Source: Developers team

Rationale: For user’s privacy.

Customer Satisfaction: 5 Customer Dissatisfaction: 1

Dependencies: None

2.7 Cultural and Political Requirements

2.7.1 Cultural Requirements


The application is providing English language for user convenience.

2.7.2 Political Requirements


i. This application should provide full functionality only to user.

20
2.8 Table most important requirements

Table 9: Most Important requirements

Requirement Title Requirement Type


ID

FR5 Register Functional

FR9 Sign In Functional

FR11 Become a user Functional

FR16 Search for desired parts Functional

QR7 Application Memory Usage Quality

QR11 Internet Connection Quality

QR15 User Login Account Security Quality

QR17 User Create Account Security Quality

System Analysis:

2.9 Scope
The application will work in the areas where internet is available and users are
connected to internet.

21
2.10 Hardware Architecture
It does not have any direct hardware interfaces. The physical storage is managed by the
internal memory in the mobile phone and the connection to the web service is managed
by the underlying operating system on the mobile phone.

There are no hardware specifications for this application. It can run on any type of smart
phone with any type of hardware. So, there is no specific hardware necessary for this
application.

2.11 Software Architecture


The mobile application communicates with the database in order to get the information
about the registered user. The communication between the database and the application
consists of operation concerning both reading and modifying the data, while the
communication between the database and the mobile application consists of only
reading operations.

This application will run on android operating system. Android version should be
greater than 4.2 KitKat. If a smart phone meets our software requirement, then he will
be able to run this application.

2.11.1 Database
In this application database is used to save data and user preferences. When a new user
register himself with an email and password his record is send in database to save for
next time login. Every product ordered by user is also save in database according to its
date and time. When user try to login his email and password is checked from database
if his data entered is correct then he will be logged in. The database for the web
application is used to store the user information.

2.11.2 Web service ????????


Web service consist of SQL server as a backend that is used as server in this application.
We can access this database from by accessing our connected cloud. This database is
real time with simple queries and accurate.

22
2.11.3 Application Program
This application is user friendly. User can easily download it from play store and install
it with simple installation process. There is no complexity level in this application. It is
easy to operate and use.

2.12 System Architecture


System architecture is based on software and hardware architecture. As no use of
hardware is required. Some specifications of software are applied. Both hardware and
software are required to run system. User should have an android device and cloud
database should be connected.

2.13 Summary:
In this chapter, analysis of system requirements is underscored that helps to
understand design and feature for this application. UML diagrams and analysis of
each requirement is performed to get into each requirement duly.

23
CHAPTER-3

System Design

24
3 System Design
In this chapter system design is considered to better understand system
design. It helps me to understand features and user interaction with these features, for
instance making such an application that will help you to promote the application at the
intermediate level. UML diagrams have drawn to better understand Autoparts android
application and how this interaction will be taken place.

3.1 Block Diagram


This is interactive system in which owners, users or relevant authorities
can interact with application to perform different functionalities.

Mobile App
User

Application

Cloud
Warehouse
Database

Figure 2: Block Diagram of Interactive System

25
This section describes constraints on the eventual design of the Product .

3.1.1 Solution Constraints:


These constraints specify different versions regarding Hope application
and appropriate version no. and their different constraints that must be required to meet
the solution in the way that the problem must be solved.

These constraints are described below.

Solution Constraint 1:

Description: The application shall run only on smart phone that have android
technology.

Rationale: Because it is android based mobile app. Therefore, it will only run on the

Smart phones that have android technology.

Solution Constraint 2:

Description: The application built and run on JDK (Java Development Kit) and
Android Studio.

Rationale: This app will be developed in android studio for android development. We
have concluded from survey that most used operating system in mobile phones is
android and most of the customer demands android app.

Solution Constraint 3:

Description: The application shall run on all versions of android.

Rationale: Customer demands that the app shall run on all versions of android from
4.1.3(Jelly bean) to 8.0(Oreo). Therefore, this app has backward compatibility.

26
Solution Constraint 4:

Description: The application can be downloaded from play store.

Rationale: This application will be developed in android. So, it will be uploaded on


play store and can be downloaded anywhere from play store.

Solution Constraint 5:

Description: Application will work when you are connected to internet connection.

Rationale: Cloud Computing can only work when internet is connected. And since the
application fetches data from the database over the Internet, it is very important that
there is an Internet connection for the application to function.

Solution Constraint 6:

Description: The application is only allowed to use maximum 20 megabytes of


memory.

Rationale: The app has 20 MB of memory.

Solution Constraint 7:

Description: User cannot log in to the mobile app without having an account.

Rationale: If user don’t have an account on this application he will not be able to use
it.

Solution Constraint 8:

Description: The application shall run only on smart phone that have android
technology.

Rationale: Because it is android based mobile app. Therefore, it will only run on the

Smart phones that have android technology

27
3.2 Implementation Environment of the Current System:

This describes the technological and physical environment in which the product is to
be installed. It includes automated, mechanical and other devices, along with the

nonhuman adjacent systems. The diagram below represents each hardware and
software component/subcomponent/device/building block that will be used to
implement the product.

HOPE- A PHP Database


blood backend
donation
app

Figure 3: Block Diagram of Working Of System

Anticipated workplace environment is the environment in which the users use the
product. Below some features of the workplace are described that could influence the
functionality of the product.
The user can use this application in any environment. For example, user can use this
application in any areas while travelling, at home or anytime, anywhere, anyone can
use.

28
3.3 Schedule Constraints
The deadline for the project is 10 July. Three different releases are made
for this project. The reason for this deadline is to meet scheduled releases to fulfill the
customer’s requirements.

The three different releases are planned so that each would work as a fully functional
application. If the deadline is not met, we shall have to face project failure as the
delivery is not made on time.

3.4 Budget Constraints


The estimated amount of the budget is 10,000Rs. So, our customer is
requested to pay the budget so that all the requirements may be fulfilled to make a
successful project delivery possible.

3.5 Naming Conventions and Definitions

3.5.1 Definitions of All Terms, Including Acronyms, Used in the Project


This glossary reflects the terminology in current use within the work
area containing the meanings of all names, acronyms and abbreviations used within the
requirements specification.

Table 10: All Terms, Including Acronyms Used

Term Definition

User A person who interacts with the mobile phone application.

29
Voluntry Donor A person who donates blood free of cost.

Blood Receiver A Person who needs blood of specific Blood Group.

Authorities Higher authorities that are responsible for Blood Donations, can use
this application.

Cloud Practice of using a network of remote servers hosted on the Internet to


computing store, manage, and process data, rather than a local server or a personal
computer.

Play Store An application pre-installed on android devices , allows users to


download and install application.

Stakeholder Any person who interacts with the system who is not a developer

DESC Description

RAT Rational(reasoned)

DEP Dependency

TAG A unique, persistent identifier contained in aPLanguage statement

MUST Something that should not be overlooked or missed.

PLAN An intention or descion about one is going to do.

30
3.6 Work Partitioning

The list below in the table showing all events to which the work responds. The

Response to each event is called a business use case (known as a BUC).

Table 11: Work Priorities

Event Name Input/output Summary of BUC

Nearby Blood Banks Sort out your nearby blood Organizing them in efficient
banks manner.

Event handler Handle different events All type of handling


regarding all the steps that
are performed in the
application.

Location viewer Shows exact location Location coordinates that


are available in database.

Notify Alert Generates Alert Sends Notification popup to


every member.

Update Profile Updates Information Records regarding the


profile in data base changes
according to additional
information.

31
3.7 Class Diagram of Backend System:

Figure 4: Class Diagram

This is the class diagram of our backend system. When a user is registered, his record
will be saved to Users Table, as this is our main storage table. If a user makes himself
a donor, then his details like id, location will be saved and updated continuously to
Online Table. After requesting the donors for blood, the system will select one user if
any, who has accepted the blood donation request. If someone accepts the request
then his details like

 Donor ID

 Schedule Date

 Schedule Time

 Accepter ID

 Location

Will be save to Selected Users Table, and at this point appointment will be made and
we will be able to check it in our application. When time and date of appointment
elapsed, then after 30 minutes we generate a notification to both users (donor and

32
acceptor) to give the results of appointment. We question the users if the appointment
was successful? If a user presses Yes button, then we populate record in History Table
with following details

 ID

 Type (Donated or Received)

 UID

 UID of second person (Donated or Received)

This is only working of backend system. Android application has a lot more features.

In android application user first installs application from Google Play Store. After
installing the application user will be navigated to register screen. Register Screen
contains one button “Register”. When a user clicks on that button application will be
navigated to Sign Up Activity. On Sign Up Activity (Screen) user will be asked to
enter the following details

 First Name

 Last Name

 Date of Birth

 Gender

 Blood Group

 Country

After providing these details, application will be navigated to Phone Number Screen

Which contains a textbox. User have to provide his/her phone number with country
code. After providing phone number our systems check into database whether this
number is already present in our database. As we want phone numbers to be unique.

If phone number will be not unique application will prompt to the user with message
that mobile number is not available. In that situation user have to provide a new
number. If mobile number is unique then we send a message to user’s mobile with
verification code. After sending verification code application will be navigated to
provide verification screen. User have to enter valid verification code. If a user fails to
provide valid verification code, he will not be able to sign up. So, user have to enter
valid verification code. After entering valid verification code application will be
navigated to Home Screen. Yes. That’s awesome. You have successfully Signed Up.

Now there are following important options for users.

33
Becoming a Donor

First a user will become a donor by enabling a switch in the details


screen. When a user has enabled the donor switch, his location will be recorded in real
time and seed to online databases after every 30 seconds.

Track location function records the user’s location in real time and update database
function updates the database after every 30 seconds. After updating the database, we
can query the blood from this table as this table contains active donors.

Blood Banks

User can get details of the nearest blood banks. User can fetch the
location, address, phone numbers, email address and other important information of
the nearest blood banks. User can also get directions from his location or another
location to a blood banks marked on map.

This is an important feature of our product. Without this feature, app will not be
completed. Execute query is the function that query the nearest blood banks details.
Set results is the function that set the results provided by execute query function.

Get results is the function that takes these results and show us on map in an elegant
way. There is a need for this feature. If a user does not find any donor in his area, then
he can contact with these blood banks.

Basic details of these blood banks are provided on the map. User can call these blood
banks or visit their web site to simply query the blood. On the other hand, user can get
directions to these blood banks.

Search Blood

This is the most important functionality of our system. As our whole


system lies on this activity. A blood donating app should have this feature.

Let’s discuss the scenario. A user install application in his mobile. After some time,
he become a donor. Becoming a donor is not a tedious task. You just have to press a
switch in order to become a donor. After you enabled the switch your location will be
tracked and monitored in real time. Your location will be saved in online database in
table named “Online Users”. When a person needs blood, he simply puts his search
parameter like

 Blood Group

 Blood Units

 Situation (emergency or normal wanting)

34
Into system. System will generate the query according to these parameters. In 25 km
radius, system will search active donors from online users table. If system finds any
user according to search criteria he will send 10 seconds beep to that user. If that user
accepts the request then their appointment will be made. For appointment acceptor
will select following details

 Location

 Date

 Time

And inserts the appointment in the database. This appointment will be shared to donor
also. After appointment time elapsed, we question both persons, if the appointment
was successful. If a user presses OK, then history table will be populated with a new
record with following details

 UID

 Date

 Time

 UID

 Donated or Accepted

There is also a feature of deleting history.

Appointments

Appointments are important features in our app. Appointment will be


made in that situation if an accepter search for blood and donor agrees on donating
blood. There is a need for this feature.

Let’s discuss the scenario. Suppose donor wants to donates and accepter wants to
receive the blood so where they should meet each other and contact with each other.
We have a solution for this problem. If an accepter search for blood and able to find a
donor, then on the accepter end an activity will be run and a screen will be shown to
the accepter that please select following details

 Date

 Time

 Location

35
 Remarks/Message

After selecting these details, these details will be forward to the donor end, if donor
agrees on that details, he can accept the details otherwise he can change it also.
Whatever the donor’s response, it will be send to the accepter end and he will have to
agree upon it. If user accepts these changes then an appointment will be made.

For appointment acceptor will select following details

 Location

 Date

 Time

And inserts the appointment in the database. This appointment will be shared to donor
also. After appointment time elapsed, we question both persons, if the appointment
was successful. If a user presses OK, then history table will be populated with a new
record with following details

 UID

 Date

 Time

 UID

 Donated or Accepted

There is also a feature of deleting history.

3.8 SEQUENCE DIAGRAM OF COMPLETE PROJECT

Become a donor

Scenario 1
Become donor

Enter the personal details

Add the record to the database

36
This is the diagram of Becoming a Donor. First a user will become a donor by
enabling a switch in the details screen. When a user has enabled the donor switch, his
location will be recorded in real time and seed to online databases after every 30
seconds. Track location function records the user’s location in real time and update
database function updates the database after every 30 seconds. After updating the
database, we can query the blood from this table as this table contains active donors.

Blood banks

Scenario 2
Execute Query

Set Results

Get Results

37
This is the diagram of nearest blood banks. User can get details of the nearest blood
banks. User can fetch the location, address, phone numbers, email address and other
important information of the nearest blood banks. User can also get directions from
his location or another location to a blood banks marked on map.

This is an important feature of our product. Without this feature, app will not be
completed. Execute query is the function that query the nearest blood banks details.
Set results is the function that set the results provided by execute query function. Get
results is the function that takes these results and show us on map in an elegant way.

There is a need for this feature. If a user does not find any donor in his area, then he
can contact with these blood banks. Basic details of these blood banks are provided

on the map. User can call these blood banks or visit their web site to simply query the
blood. On the other hand, user can get directions to these blood banks.

Search Blood
Scenario 3
Here builds a query

Execute the Query

Set Results

Get Results

38
This is the diagram of the search blood. This is the most important functionality of our
system. As our whole system lies on this activity. A blood donating app should have
this feature.

Let’s discuss the scenario. A user install application in his mobile. After some time,
he become a donor. Becoming a donor is not a tedious task. You just have to press a
switch in order to become a donor. After you enabled the switch your location will be
tracked and monitored in real time. Your location will be saved in online database in
table named “Online Users”. When a person needs blood, he simply puts his search
parameter like

 Blood Group

 Blood Units

 Situation (emergency or normal wanting)

Into system. System will generate the query according to these parameters. In 25 km
radius, system will search active donors from online users table. If system finds any
user according to search criteria he will send 10 seconds beep to that user. If that user
accepts the request then their appointment will be made.

Appointments are important features in our app. Appointment will be made in that
situation if an accepter search for blood and donor agrees on donating blood. There is
a need for this feature.

Let’s discuss the scenario. Suppose donor wants to donates and accepter wants to
receive the blood so where they should meet each other and contact with each other.
We have a solution for this problem. If an accepter search for blood and able to find a
donor, then on the accepter end an activity will be run and a screen will be shown to
the accepter that please select following details

39
 Date

 Time

 Location

 Remarks/Message

After selecting these details, these details will be forward to the donor end, if donor
agrees on that details, he can accept the details otherwise he can change it also.
Whatever the donor’s response, it will be send to the accepter end and he will have to
agree upon it. If user accepts these changes then an appointment will be made.

For appointment acceptor will select following details

 Location

 Date

 Time

And inserts the appointment in the database. This appointment will be shared to donor
also. After appointment time elapsed, we question both persons, if the appointment
was successful. If a user presses OK, then history table will be populated with a new
record with following details

 UID

 Date

 Time

 UID

 Donated or Accepted

There is also a feature of deleting history.

Send SMS

Scenario 4
Manager add the deal to the database

Enter the deal info

Ask for SMS notification

40
Accepted

Send SMS to the customers

Business
Manager Sms Dialouge SMS Service Customers

Add a deal

Ask For SMS Notification


Call SMS service Send SMS
Accepted

Scenario 5

Add the deal to the database

Enter the deal info

Ask for SMS info

Rejected

Cannot send SMS to the customers

41
Busine ss SMS
Manager Notification

Add a deal

Ask For Pus h Notification

Rejected

Return Mes sage can not s end sms

42
3.9 Activity Diagram:

This is the activity diagram of Hope.

In android application user first installs application from Google Play Store. After
installing the application user will be navigated to register screen. Register Screen
contains one button “Register”. When a user clicks on that button application will be
navigated to Sign Up Activity. On Sign Up Activity (Screen) user will be asked to
enter the following details

43
 First Name

 Last Name

 Date of Birth

 Gender

 Blood Group

 Country

After providing these details, application will be navigated to Phone Number Screen

Which contains a textbox. User have to provide his/her phone number with country
code. After providing phone number our systems check into database whether this
number is already present in our database. As we want phone numbers to be unique.

If phone number will be not unique application will prompt to the user with message
that mobile number is not available. In that situation user have to provide a new
number. If mobile number is unique then we send a message to user’s mobile with
verification code. After sending verification code application will be navigated to
provide verification screen. User have to enter valid verification code. If a user fails to
provide valid verification code, he will not be able to sign up. So, user have to enter
valid verification code. After entering valid verification code application will be
navigated to Home Screen. Yes. That’s awesome. You have successfully Signed Up.

Now there are following important options for users.

Become Donor

First a user will become a donor by enabling a switch in the details


screen. When a user has enabled the donor switch, his location will be recorded in real
time and seed to online databases after every 30 seconds.

Track location function records the user’s location in real time and update database
function updates the database after every 30 seconds. After updating the database, we
can query the blood from this table as this table contains active donors.

Nearest Blood Banks

User can get details of the nearest blood banks. User can fetch the
location, address, phone numbers, email address and other important information of
the nearest blood banks. User can also get directions from his location or another
location to a blood banks marked on map.

This is an important feature of our product. Without this feature, app will not be
completed. Execute query is the function that query the nearest blood banks details.
Set results is the function that set the results provided by execute query function.

44
Get results is the function that takes these results and show us on map in an elegant
way. There is a need for this feature. If a user does not find any donor in his area, then
he can contact with these blood banks.

Basic details of these blood banks are provided on the map. User can call these blood
banks or visit their web site to simply query the blood. On the other hand, user can get
directions to these blood banks.

Query (Search) Blood

This is the most important functionality of our system. As our whole


system lies on this activity. A blood donating app should have this feature.

Let’s discuss the scenario. A user install application in his mobile. After some time,
he become a donor. Becoming a donor is not a tedious task. You just have to press a
switch in order to become a donor. After you enabled the switch your location will be
tracked and monitored in real time. Your location will be saved in online database in
table named “Online Users”. When a person needs blood, he simply puts his search
parameter like

 Blood Group

 Blood Units

 Situation (emergency or normal wanting)

Into system. System will generate the query according to these parameters. In 25 km
radius, system will search active donors from online users table. If system finds any
user according to search criteria he will send 10 seconds beep to that user. If that user
accepts the request then their appointment will be made. For appointment acceptor
will select following details

 Location

 Date

 Time

And inserts the appointment in the database. This appointment will be shared to donor
also. After appointment time elapsed, we question both persons, if the appointment
was successful. If a user presses OK, then history table will be populated with a new
record with following details

 UID

 Date

 Time

45
 UID

 Donated or Accepted

There is also a feature of deleting history.

How Appointments works

Appointments are important features in our app. Appointment will be


made in that situation if an accepter search for blood and donor agrees on donating
blood. There is a need for this feature.

Let’s discuss the scenario. Suppose donor wants to donates and accepter wants to
receive the blood so where they should meet each other and contact with each other.
We have a solution for this problem. If an accepter search for blood and able to find a
donor, then on the accepter end an activity will be run and a screen will be shown to
the accepter that please select following details

 Date

 Time

 Location

 Remarks/Message

After selecting these details, these details will be forward to the donor end, if donor
agrees on that details, he can accept the details otherwise he can change it also.
Whatever the donor’s response, it will be send to the accepter end and he will have to
agree upon it. If user accepts these changes then an appointment will be made.

For appointment acceptor will select following details

 Location

 Date

 Time

And inserts the appointment in the database. This appointment will be shared to donor
also. After appointment time elapsed, we question both persons, if the appointment
was successful. If a user presses OK, then history table will be populated with a new
record with following details

 UID

 Date

46
 Time

 UID

 Donated or Accepted

There is also a feature of deleting history.

3.10 Summary

In this chapter, it is described in a very detail that what are the components in this
system, how they will interact with each other and what are the steps a user will take to
achieve his target using features and functions of this above system.

47
CHAPTER-4

Implementation

48
4 Implementation
In this chapter, language code of important function of the application is shared.

4.10Main Activity

package com.ztech.apps.hope;

import android.app.ProgressDialog;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.net.Uri;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.support.v7.widget.CardView;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.ArrayAdapter;

import android.widget.ImageView;

import android.widget.Spinner;

import android.widget.Toast;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;

import com.google.android.gms.common.GooglePlayServicesRepairableException;

import com.google.android.gms.location.places.*;

import com.google.android.gms.location.places.ui.PlacePicker;

import com.ztech.apps.hope.appointment.AppointmentActivity;

49
public class MainActivity extends AppCompatActivity {

SharedPreferences sp;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

SharedPreferences pref = getApplicationContext().getSharedPreferences("APP_PREF",


0);

String token = pref.getString("regId", "");

//Toast.makeText(MainActivity.this, "token: "+token, Toast.LENGTH_SHORT


).show();

public void becomeDonor(View view){

Intent intent = new Intent(this, AppointmentActivity.class);

startActivity(intent);

public void findBlood(View view){

Intent becomeDonorActivity = new Intent(MainActivity.this, FindBloodActivity.class);

startActivity(becomeDonorActivity);

public void history(View view){

Intent becomeDonorActivity = new Intent(MainActivity.this, HistoryActivity.class);

startActivity(becomeDonorActivity);

public void profile(View view){

50
Intent becomeDonorActivity = new Intent(MainActivity.this, UserProfile.class);

startActivity(becomeDonorActivity);

@Override

protected void onStart() {

super.onStart();

String name = sp.getString("uid", null);

int verif = sp.getInt("verificationCode", 0);

if(name == null)

if(verif != 0){

Intent i = new Intent(MainActivity.this, VerifyPhoneNumber.class);

startActivity(i);

finish();

}else{

Intent i = new Intent(MainActivity.this, LauncherActivity.class);

startActivity(i);

finish();

@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.main_activity_menu, menu);

return true;

51
@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()){

case R.id.menu_blood_banks:

Uri gmmIntentUri = Uri.parse("geo:0,0?q=Blood Banks");

Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);

mapIntent.setPackage("com.google.android.apps.maps");

startActivity(mapIntent);

return true;

4.11 Launcher Activity

package com.ztech.apps.hope;

import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

public class LauncherActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

52
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_launcher);

public void register(View view){

Intent signUpActivity = new Intent(LauncherActivity.this, SignUp.class);

startActivity(signUpActivity);

finish();

4.12 Sign Up Activity

package com.ztech.apps.hope;

import android.Manifest;

import android.app.DatePickerDialog;

import android.app.Dialog;

import android.app.DialogFragment;

import android.content.Context;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.os.AsyncTask;

import android.support.v4.app.ActivityCompat;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.telephony.TelephonyManager;

53
import android.view.View;

import android.content.SharedPreferences;

import android.widget.ArrayAdapter;

import android.widget.DatePicker;

import android.widget.EditText;

import android.widget.Spinner;

import android.widget.Toast;

import android.text.TextUtils;

import com.android.volley.AuthFailureError;

import com.android.volley.Request;

import com.android.volley.Response;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import java.io.UnsupportedEncodingException;

import java.util.Calendar;

import java.util.HashMap;

import java.util.Map;

public class SignUp extends AppCompatActivity {

Spinner country, blood_grp, gender;

static Context context;

EditText fName, lName;

static EditText dob;

static String dateOfBirth = "";

@Override

protected void onCreate(Bundle savedInstanceState) {

54
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sign_up);

country = (Spinner) findViewById(R.id.country);

blood_grp = (Spinner) findViewById(R.id.blood_grp);

gender = (Spinner) findViewById(R.id.gender);

fName = (EditText) findViewById(R.id.signup_fname);

lName = (EditText) findViewById(R.id.signup_lname);

dob = (EditText) findViewById(R.id.signup_dob);

context = this;

ArrayAdapter<CharSequence> countryAdapter =
ArrayAdapter.createFromResource(this,

R.array.countries_array, R.layout.spinner_item);

countryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_ite
m);

country.setAdapter(countryAdapter);

ArrayAdapter<CharSequence> bgAdapter = ArrayAdapter.createFromResource(this,

R.array.bgroup_array, R.layout.spinner_item);

bgAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

blood_grp.setAdapter(bgAdapter);

ArrayAdapter<CharSequence> genderAdapter =
ArrayAdapter.createFromResource(this,

R.array.gender_array, R.layout.spinner_item);

genderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_ite
m);

55
gender.setAdapter(genderAdapter);

public void showDatePickerDialog(View view) {

DialogFragment newFragment = new DatePickerFragment();

newFragment.show(getFragmentManager(), "datePicker");

public void signUp(View view) {

/*Intent i = new Intent(SignUp.this, FindBloodActivity.class);

startActivity(i);*/

if (TextUtils.isEmpty(fName.getText()) || TextUtils.isEmpty(lName.getText())

|| TextUtils.isEmpty(dob.getText())) {

Toast.makeText(SignUp.this, "Please fill in all fields!",


Toast.LENGTH_SHORT).show();

} else {

String cntry = country.getSelectedItem().toString();

String blood_g = blood_grp.getSelectedItem().toString();

String gendr = gender.getSelectedItem().toString();

String fname = fName.getText().toString();

String lname = lName.getText().toString();

String db = dob.getText().toString();

SharedPreferences sp = getSharedPreferences("USER_PREF",
Context.MODE_PRIVATE);

SharedPreferences.Editor editor = sp.edit();

editor.putBoolean("runningFirstTime", true);

56
editor.putString("firstName", fname);

editor.putString("lastName", lname);

editor.putString("dateOfBirth", db);

editor.putString("gender", gendr);

editor.putString("bloodGroup", blood_g);

editor.putString("country", cntry);

editor.apply();

Intent phoneNo = new Intent(SignUp.this, AskPhoneNumber.class);

startActivity(phoneNo);

finish();

public static class DatePickerFragment extends DialogFragment

implements DatePickerDialog.OnDateSetListener {

@Override

public Dialog onCreateDialog(Bundle savedInstanceState) {

// Use the current date as the default date in the picker

final Calendar c = Calendar.getInstance();

int year = c.get(Calendar.YEAR);

int month = c.get(Calendar.MONTH);

int day = c.get(Calendar.DAY_OF_MONTH);

// Create a new instance of DatePickerDialog and return it

return new DatePickerDialog(getActivity(), this, year, month, day);

57
public void onDateSet(DatePicker view, int year, int month, int day) {

// Do something with the date chosen by the user

month++;

dateOfBirth = ""+day+"-" + month + "-"+year;

dob.setText(dateOfBirth);

//Toast.makeText(context, ""+day+"-"+month+"-"+year,
Toast.LENGTH_SHORT).show();

4.13 Ask Phone Number Activity

package com.ztech.apps.hope;

import android.Manifest;

import android.app.PendingIntent;

import android.app.ProgressDialog;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.content.pm.PackageManager;

import android.os.AsyncTask;

import android.os.Build;

import android.support.annotation.NonNull;

import android.support.v4.app.ActivityCompat;

import android.support.v4.content.ContextCompat;

58
import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.telephony.SmsManager;

import android.telephony.SubscriptionInfo;

import android.telephony.SubscriptionManager;

import android.text.TextUtils;

import android.view.View;

import android.widget.EditText;

import android.widget.Toast;

import com.google.firebase.FirebaseException;

import com.google.firebase.auth.PhoneAuthCredential;

import com.google.firebase.auth.PhoneAuthProvider;

import com.android.volley.AuthFailureError;

import com.android.volley.Request;

import com.android.volley.Response;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import java.io.UnsupportedEncodingException;

import java.security.AuthProvider;

import java.util.HashMap;

import java.util.Map;

import java.util.Random;

import java.util.concurrent.TimeUnit;

public class AskPhoneNumber extends AppCompatActivity {

private final int PERMISSIONS_REQUEST = 23;

EditText phoneNo;

59
Context context;

SharedPreferences sp;

String SENT = "SMS_SENT";

String DELIVERED = "SMS_DELIVERED";

String phonenumber = "";

String serverUrl = "http://192.168.1.23/hope/verify_phone_number.php";

private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;

private ProgressDialog mProgress;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_ask_phone_number);

context = this;

phoneNo = (EditText)findViewById(R.id.phoneNumberInput);

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

@Override

public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {

mProgress.dismiss();

phonenumber = phoneNo.getText().toString();

SharedPreferences.Editor editor = sp.edit();

int code = Integer.parseInt(phoneAuthCredential.getSmsCode().toString());

editor.putInt("verificationCode", code);

editor.putString("phoneNumber", phonenumber);

editor.apply();

60
Intent verify = new Intent(AskPhoneNumber.this, VerifyPhoneNumber.class);

startActivity(verify);

finish();

@Override

public void onVerificationFailed(FirebaseException e) {

mProgress.dismiss();

Toast.makeText(AskPhoneNumber.this, "Something went Wrong. Please try


again.", Toast.LENGTH_SHORT).show();

@Override

public void onCodeAutoRetrievalTimeOut(String s) {

super.onCodeAutoRetrievalTimeOut(s);

mProgress.dismiss();

Toast.makeText(AskPhoneNumber.this, "Something went Wrong",


Toast.LENGTH_SHORT).show();

};

@Override

protected void onPause() {

super.onPause();

//mProgress.dismiss();

public void sendVerificationCode(View view){

61
if (TextUtils.isEmpty(phoneNo.getText())){

Toast.makeText(AskPhoneNumber.this, "Please enter phone number.",


Toast.LENGTH_SHORT).show();

}else{

if(phoneNo.getText().length() < 7){

Toast.makeText(AskPhoneNumber.this, "Please enter a valid Phone Number.",


Toast.LENGTH_SHORT).show();

}else{

if(DetectConnection.checkInternetConnection(AskPhoneNumber.this)) {

phonenumber = phoneNo.getText().toString();

Toast.makeText(AskPhoneNumber.this, phonenumber,
Toast.LENGTH_SHORT).show();

//verifyPhoneNumberFromServer(phonenumber);

mProgress = new ProgressDialog(AskPhoneNumber.this);

mProgress.setTitle("Sending Text");

mProgress.setMessage("Please wait while we send a message to your Mobile


Number");

mProgress.setCanceledOnTouchOutside(false);

//mProgress.show();

PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNo.getText().toString(), 60,

TimeUnit.SECONDS, AskPhoneNumber.this, mCallbacks);

phonenumber = phoneNo.getText().toString();

SharedPreferences.Editor editor = sp.edit();

//int code = Integer.parseInt(phoneAuthCredential.getSmsCode().toString());

//editor.putInt("verificationCode", code);

editor.putString("phoneNumber", phonenumber);

62
editor.apply();

Intent verify = new Intent(AskPhoneNumber.this, VerifyPhoneNumber.class);

startActivity(verify);

finish();

else {

Validations.alertDialogue("No Internet Connection",

"Please make sure your device is connected to Network.",


AskPhoneNumber.this);

private void verifyPhoneNumberFromServer(final String phoneNumber){

class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {

@Override

protected String doInBackground(String... params) {

StringRequest stringRequest = new StringRequest(Request.Method.POST,


serverUrl,

new Response.Listener<String>(){

@Override

public void onResponse(String response) {

if(response.contains("Available")){

Toast.makeText(AskPhoneNumber.this, "Available",
Toast.LENGTH_SHORT).show();

mProgress = new ProgressDialog(AskPhoneNumber.this);

mProgress.setTitle("Sending Text");

mProgress.setMessage("Please wait while we send a message to your


Mobile Number");

63
mProgress.setCanceledOnTouchOutside(false);

mProgress.show();

PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNo.getText().toString(), 60,

TimeUnit.SECONDS, AskPhoneNumber.this, mCallbacks);

}else{

//Toast.makeText(AskPhoneNumber.this, "Already Exists!",


Toast.LENGTH_SHORT).show();

Validations.alertDialogue("Phone Number already registered!",

"This phone number already registered with an account. Please try


another phone Number.",

context);

}, new Response.ErrorListener(){

@Override

public void onErrorResponse(VolleyError error) {

if (error == null || error.networkResponse == null) {

return;

String body= "";

//get status code here

final String statusCode = String.valueOf(error.networkResponse.statusCode);

//get response body and parse with appropriate encoding

try {

body = new String(error.networkResponse.data,"UTF-8");

} catch (UnsupportedEncodingException e) {

64
// exception

})

@Override

protected Map<String, String> getParams() throws AuthFailureError {

Map<String, String> params = new HashMap<String, String>();

params.put("phone_number", phoneNumber);

return params;

};

MySingleton.getmInstance(AskPhoneNumber.this).addToRequestQueue(stringRequest);

return "success";

@Override

protected void onPostExecute(String result) {

super.onPostExecute(result);

SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();

sendPostReqAsyncTask.execute();

65
4.14 Verify Phone Number Activity
package com.ztech.apps.hope;

import android.app.ProgressDialog;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.os.AsyncTask;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

import com.android.volley.AuthFailureError;

import com.android.volley.Request;

import com.android.volley.Response;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import java.io.UnsupportedEncodingException;

import java.util.HashMap;

import java.util.Map;

public class VerifyPhoneNumber extends AppCompatActivity {

SharedPreferences sp;

EditText verificationCodeinput;

TextView tv;

66
String serverUrl = "http://192.168.1.23/hope/register_user.php";

String fname, lname, dob, blood_grp, country, gender, device_token;

String phoneNo;

ProgressDialog mProgress;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_verify_phone_number);

tv = (TextView)findViewById(R.id.verifyText);

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

verificationCodeinput = (EditText)findViewById(R.id.codeInput);

phoneNo = sp.getString("phoneNumber", "");

tv.setText("Enter the 6-digit code that we sent to this number "+phoneNo);

fname = sp.getString("firstName", "");

lname = sp.getString("lastName", "");

dob = sp.getString("dateOfBirth", "");

gender = sp.getString("gender", "");

blood_grp = sp.getString("bloodGroup", "");

country = sp.getString("country", "");

device_token = sp.getString("regId", "");

Toast.makeText(VerifyPhoneNumber.this, "token: "+device_token,


Toast.LENGTH_SHORT).show();

public void resendCode(View view){

Intent askphoneNo = new Intent(VerifyPhoneNumber.this, AskPhoneNumber.class);

startActivity(askphoneNo);

67
finish();

public void verifyPhoneNo(View view){

if(DetectConnection.checkInternetConnection(this)) {

mProgress = new ProgressDialog(VerifyPhoneNumber.this);

mProgress.setTitle("Processing!");

mProgress.setCanceledOnTouchOutside(false);

mProgress.show();

//int code = sp.getInt("verificationCode", 0);

//int enteredCode = Integer.parseInt(verificationCodeinput.getText().toString());

// if (enteredCode == code) {

// sendUserDataToServer(fname, lname, dob, gender, phoneNo, blood_grp, country,


device_token);

//

// } else {

// mProgress.dismiss();

// Toast.makeText(VerifyPhoneNumber.this, "Incorrect code!.",


Toast.LENGTH_SHORT).show();

// }

sendUserDataToServer(fname, lname, dob, gender, phoneNo, blood_grp, country,


device_token);

}else {

Validations.alertDialogue("No Internet Connection",

"Please make sure your device is connected to Internet.",


VerifyPhoneNumber.this);

@Override

protected void onPause() {

68
super.onPause();

// mProgress.dismiss();

private void sendUserDataToServer(final String fName, final String lName, final String
dob,

final String gender, final String phoneNo, final String bloodGrp, final
String country, final String token){

class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {

@Override

protected String doInBackground(String... params) {

StringRequest stringRequest = new StringRequest(Request.Method.POST,


serverUrl,

new Response.Listener<String>(){

@Override

public void onResponse(String response) {

if(response.contains("error")){

if(DetectConnection.checkInternetConnection(VerifyPhoneNumber.this)) {

sendUserDataToServer(fname, lname, dob, gender, phoneNo,


blood_grp, country, token);

}else{

Validations.alertDialogue("No Internet Connection",

"Please make sure your device is connected to Internet and Try


again.", VerifyPhoneNumber.this);

}else{

mProgress.dismiss();

SharedPreferences.Editor editor = sp.edit();

editor.putString("uid", response);

69
editor.apply();

Intent mainActivity = new Intent(VerifyPhoneNumber.this,


MainActivity.class);

startActivity( mainActivity);

finish();

}, new Response.ErrorListener(){

@Override

public void onErrorResponse(VolleyError error) {

if (error == null || error.networkResponse == null) {

return;

String body= "";

//get status code here

final String statusCode = String.valueOf(error.networkResponse.statusCode);

//get response body and parse with appropriate encoding

try {

body = new String(error.networkResponse.data,"UTF-8");

} catch (UnsupportedEncodingException e) {

// exception

})

@Override

protected Map<String, String> getParams() throws AuthFailureError {

70
Map<String, String> params = new HashMap<String, String>();

params.put("fname", fName);

params.put("lname", lName);

params.put("dob", dob);

params.put("gender", gender);

params.put("phone_number", phoneNo);

params.put("blood_group", bloodGrp);

params.put("country", country);

params.put("device_token", token);

return params;

};

MySingleton.getmInstance(VerifyPhoneNumber.this).addToRequestQueue(stringRequest);

return "success";

@Override

protected void onPostExecute(String result) {

super.onPostExecute(result);

SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();

sendPostReqAsyncTask.execute();

71
4.15 Incoming Blood Request Activity

package com.ztech.apps.hope;

import android.content.Context;

import android.content.SharedPreferences;

import android.media.MediaPlayer;

import android.media.Ringtone;

import android.media.RingtoneManager;

import android.net.Uri;

import android.os.AsyncTask;

import android.os.Handler;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.view.WindowManager;

import android.widget.TextView;

import android.widget.Toast;

import com.android.volley.AuthFailureError;

import com.android.volley.Request;

import com.android.volley.Response;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import java.io.UnsupportedEncodingException;

72
import java.util.HashMap;

import java.util.Map;

public class IncomingBloodRequestActivity extends AppCompatActivity {

String user_id, name, blood_grp, requester_id, accepter_name = "";

String serverUrl = "http://192.168.1.23/hope/request_other_donors.php";

SharedPreferences sp;

TextView tv;

Ringtone r;

MediaPlayer mp;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_incoming_blood_request);

getWindow().addFlags(

WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON

+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD

| +WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED

| +WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

tv = (TextView)findViewById(R.id.requestText);

name = getIntent().getStringExtra("Requester");

blood_grp = getIntent().getStringExtra("BloodGroup");

73
requester_id = getIntent().getStringExtra("RequesterId");

tv.setText(name + " needs " + blood_grp + " near you."+requester_id);

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

user_id = sp.getString("uid", "");

accepter_name = sp.getString("firstName", "");

try {

Uri notification =
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);

if(notification==null){

notification =
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);

mp = MediaPlayer.create(getApplicationContext(), notification);

Toast.makeText(IncomingBloodRequestActivity.this, "Tone",
Toast.LENGTH_SHORT).show();

// r.play();

mp.setLooping(true);

mp.start();

} catch (Exception e) {

e.printStackTrace();

Handler handler = new Handler();

74
handler.postDelayed(new Runnable() {

public void run() {

if(mp!=null){

mp.stop();

//sendRequestResponseToServer(user_id, "decline", requester_id, name, blood_grp,


accepter_name);

NotificationUtil notificationUtil = new NotificationUtil();

notificationUtil.showNotification("Blood Required!", "You Missed a blood Request


from "+name, getApplicationContext());

finish();

}, 10000);

public void acceptBloodRequest(View view){

if(mp!=null){

mp.stop();

sendRequestResponseToServer(user_id, "accept", requester_id, name, blood_grp,


accepter_name);

finish();

public void declineBloodRequest(View view){

if(mp!=null){

75
mp.stop();

sendRequestResponseToServer(user_id, "decline", requester_id, name, blood_grp,


accepter_name);

finish();

private void sendRequestResponseToServer(final String uid, final String response, final


String requesterID,

final String requester_name, final String blood_group, final


String accepter_name){

class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {

@Override

protected String doInBackground(String... params) {

StringRequest stringRequest = new StringRequest(Request.Method.POST,


serverUrl,

new Response.Listener<String>(){

@Override

public void onResponse(String response) {

Toast.makeText(IncomingBloodRequestActivity.this, "response:
"+response, Toast.LENGTH_SHORT).show();

if(response.contains("error")){

if(DetectConnection.checkInternetConnection(IncomingBloodRequestActivity.this)) {

sendRequestResponseToServer(uid, response, requesterID,


requester_name, blood_group, accepter_name);

76
}

}else{

finish();

}, new Response.ErrorListener(){

@Override

public void onErrorResponse(VolleyError error) {

if (error == null || error.networkResponse == null) {

return;

String body= "";

//get status code here

final String statusCode = String.valueOf(error.networkResponse.statusCode);

//get response body and parse with appropriate encoding

try {

body = new String(error.networkResponse.data,"UTF-8");

} catch (UnsupportedEncodingException e) {

// exception

})

77
@Override

protected Map<String, String> getParams() throws AuthFailureError {

Map<String, String> params = new HashMap<String, String>();

params.put("uid", uid);

params.put("response", response);

params.put("requesterId", requesterID);

params.put("requesterName", requester_name);

params.put("bloodGroup", blood_group);

params.put("accepterName", accepter_name);

return params;

};

MySingleton.getmInstance(IncomingBloodRequestActivity.this).addToRequestQueue(string
Request);

return "success";

@Override

protected void onPostExecute(String result) {

super.onPostExecute(result);

SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();

sendPostReqAsyncTask.execute();

78
}

4.16 MyFirebaseMessagingService
package com.ztech.apps.hope;

import android.content.Intent;

import com.google.firebase.messaging.FirebaseMessagingService;

import com.google.firebase.messaging.RemoteMessage;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

@Override

public void onMessageReceived(RemoteMessage remoteMessage) {

String name = remoteMessage.getData().get("title");

String message = remoteMessage.getData().get("body");

String bloodgrp = remoteMessage.getData().get("bloodGrp");

String requester_id = remoteMessage.getData().get("requester_id");

//NotificationUtil notificationUtil = new NotificationUtil();

//notificationUtil.showNotification(name, message, getApplicationContext());

if(message.matches("needs_blood")) {

Intent i = new Intent(getApplicationContext(), IncomingBloodRequestActivity.class);

i.putExtra("Requester", name);

i.putExtra("BloodGroup", bloodgrp);

i.putExtra("RequesterId", requester_id);

i.addFlags(FLAG_ACTIVITY_NEW_TASK);

startActivity(i);

}if(message.matches("accept_blood")){

79
Intent i = new Intent(getApplicationContext(), ScheduleAppointment.class);

i.putExtra("Requester", name);

i.putExtra("BloodGroup", bloodgrp);

i.putExtra("RequesterId", requester_id);

i.addFlags(FLAG_ACTIVITY_NEW_TASK);

startActivity(i);

4.17 Maps Activity


package com.ztech.apps.hope;

import android.app.ProgressDialog;

import android.content.BroadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.content.IntentFilter;

import android.content.SharedPreferences;

import android.content.pm.PackageManager;

import android.graphics.Bitmap;

import android.location.Location;

import android.location.LocationListener;

import android.location.LocationManager;

import android.os.AsyncTask;

import android.support.v4.app.ActivityCompat;

import android.support.v4.app.FragmentActivity;

import android.os.Bundle;

import android.support.v4.content.ContextCompat;

80
import android.support.v7.app.AppCompatActivity;

import android.support.v7.widget.Toolbar;

import android.widget.Toast;

import com.android.volley.AuthFailureError;

import com.android.volley.Request;

import com.android.volley.Response;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import com.google.android.gms.maps.CameraUpdateFactory;

import com.google.android.gms.maps.GoogleMap;

import com.google.android.gms.maps.OnMapReadyCallback;

import com.google.android.gms.maps.SupportMapFragment;

import com.google.android.gms.maps.model.BitmapDescriptor;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;

import com.google.android.gms.maps.model.LatLng;

import com.google.android.gms.maps.model.MarkerOptions;

import java.io.UnsupportedEncodingException;

import java.util.HashMap;

import java.util.Map;

import java.util.concurrent.TimeUnit;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,


LocationListener {

private GoogleMap mMap;

private LocationManager locManager;

private Location location;

81
String serverUrl = "http://192.168.1.23/hope/find_blood.php";

String latitude = "";

String longitude = "";

String bloodUnits, bloodGroup, userId, userName;

boolean isSend = false;

boolean bloodCase;

ProgressDialog mProgress;

boolean start = false;

SharedPreferences sp;

private BroadcastReceiver gpsReceiver = new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

if
(intent.getAction().matches(LocationManager.PROVIDERS_CHANGED_ACTION)) {

//Do your stuff on GPS status change

if (locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) ||
locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {

GetLocation();

} else {

Toast.makeText(MapsActivity.this, "Location is Turned off",


Toast.LENGTH_SHORT).show();

};

@Override

82
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_maps);

bloodUnits = getIntent().getStringExtra("bloodUnits");

bloodGroup = getIntent().getStringExtra("bloodGroup");

userName = getIntent().getStringExtra("userName");

userId = getIntent().getStringExtra("userId");

bloodCase = getIntent().getBooleanExtra("bloodCase", false);

findDonorsFromServer("A+", "13", "31.415899","73.069604", userName);

// Obtain the SupportMapFragment and get notified when the map is ready to be used.

SupportMapFragment mapFragment = (SupportMapFragment)


getSupportFragmentManager()

.findFragmentById(R.id.map);

mapFragment.getMapAsync(this);

start = true;

@Override

public void onMapReady(GoogleMap googleMap) {

mMap = googleMap;

GetLocation();

@Override

protected void onResume() {

super.onResume();

83
if(start) {

registerReceiver(gpsReceiver, new
IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION));

@Override

protected void onPause() {

super.onPause();

if(mProgress!=null){

mProgress.dismiss();

public void GetLocation() {

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

isSend = sp.getBoolean("isRequestSend", false);

locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

boolean gps = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

boolean network =
locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

if (!gps || !network) {

Toast.makeText(this, "Location is not turned ON.", Toast.LENGTH_SHORT).show();

return;

84
if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {

return;

locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0,
this);

location = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

if(location != null){

LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

latitude = String.valueOf(location.getLatitude());

longitude = String.valueOf(location.getLatitude());

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));

if(!isSend) {

//findDonorsFromServer(bloodGroup, userId, latitude, longitude, userName);

addBlueMarker(latLng, "Current Location");

else{

locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
100, 0, this);

location =
locManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

if(location != null){

LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

latitude = String.valueOf(location.getLatitude());

longitude = String.valueOf(location.getLatitude());

85
if(!isSend) {

// findDonorsFromServer("A+", "13", "31.415899","73.069604", userName);

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));

addBlueMarker(latLng, "Current Location");

else {

Toast.makeText(this, "Couldn't Get Location", Toast.LENGTH_SHORT).show();

public void addBlueMarker(LatLng latLng, String title){

mMap.clear();

mMap.addMarker(new
MarkerOptions().position(latLng).title(title).icon(BitmapDescriptorFactory.defaultMarker(Bit
mapDescriptorFactory.HUE_BLUE)));

@Override

public void onLocationChanged(Location location) {

LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

float zoomLevel = mMap.getCameraPosition().zoom;

if(zoomLevel < 15)

zoomLevel = 15;

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel));

addBlueMarker(latLng, "Current Location");

86
@Override

public void onStatusChanged(String provider, int status, Bundle extras) {

@Override

public void onProviderEnabled(String provider) {

@Override

public void onProviderDisabled(String provider) {

private void findDonorsFromServer(final String blood_grp, final String user_id, final


String latitude, final String longitude, final String user_name){

class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {

@Override

protected String doInBackground(String... params) {

StringRequest stringRequest = new StringRequest(Request.Method.POST,


serverUrl,

new Response.Listener<String>(){

@Override

public void onResponse(String response) {

Toast.makeText(MapsActivity.this, response,
Toast.LENGTH_SHORT).show();

if(response.contains("error")){

Toast.makeText(MapsActivity.this, response,
Toast.LENGTH_SHORT).show();

87
Validations.alertDialogue("No Donors Available!", "No Donors
Available near your Location.", MapsActivity.this);

}else{

Toast.makeText(MapsActivity.this, "else",
Toast.LENGTH_SHORT).show();

mProgress = new ProgressDialog(MapsActivity.this);

mProgress.setTitle("Wait while Requesting Donors!");

mProgress.setMessage("Please wait until a donor accept your


request.");

mProgress.setCanceledOnTouchOutside(false);

mProgress.show();

//Toast.makeText(AskPhoneNumber.this, "Already Exists!",


Toast.LENGTH_SHORT).show();

}, new Response.ErrorListener(){

@Override

public void onErrorResponse(VolleyError error) {

if (error == null || error.networkResponse == null) {

return;

String body= "";

//get status code here

final String statusCode = String.valueOf(error.networkResponse.statusCode);

//get response body and parse with appropriate encoding

try {

body = new String(error.networkResponse.data,"UTF-8");

88
} catch (UnsupportedEncodingException e) {

// exception

})

@Override

protected Map<String, String> getParams() throws AuthFailureError {

Map<String, String> params = new HashMap<String, String>();

params.put("uid", user_id);

params.put("blood_group", blood_grp);

params.put("latitude", latitude);

params.put("longitude", longitude);

params.put("fname", user_name);

return params;

};

MySingleton.getmInstance(MapsActivity.this).addToRequestQueue(stringRequest);

return "success";

@Override

protected void onPostExecute(String result) {

super.onPostExecute(result);

89
}

SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();

sendPostReqAsyncTask.execute();

4.18 Find Blood Activity


package com.ztech.apps.hope;

import android.content.Context;

import android.content.Intent;

import android.content.Intent;

import android.content.SharedPreferences;

import android.content.pm.PackageManager;

import android.support.annotation.NonNull;

import android.support.design.widget.BottomSheetDialog;

import android.support.v4.app.ActivityCompat;

import android.support.v4.app.ActivityCompat;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.ArrayAdapter;

import android.widget.CheckBox;

import android.widget.RadioButton;

import android.widget.Spinner;

import android.widget.Toast;

90
public class FindBloodActivity extends AppCompatActivity {

Spinner findBloodGrp, bloodunits;

String blood_group, blood_units = "", user_name;

boolean blood_case = true;

RadioButton bloodCase;

Context context;

SharedPreferences sp;

private static final int LOCATION_PERMISSION_REQUEST = 123;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_find_blood);

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

user_name= sp.getString("firstName", "");

context = this;

bloodCase = (RadioButton) findViewById(R.id.emergency);

bloodCase.setChecked(true);

findBloodGrp = (Spinner) findViewById(R.id.findBlood_grp);

bloodunits = (Spinner) findViewById(R.id.bloodUnits);

ArrayAdapter<CharSequence> bloodgrpAdapter =
ArrayAdapter.createFromResource(this,

R.array.bgroup_array, R.layout.spinner_item_large);

bloodgrpAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it
em);

91
findBloodGrp.setAdapter(bloodgrpAdapter);

ArrayAdapter<CharSequence> blooduntAdapter =
ArrayAdapter.createFromResource(this,

R.array.units_array, R.layout.spinner_item);

blooduntAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it
em);

bloodunits.setAdapter(blooduntAdapter);

public void onRequestTypeSelected(View view) {

// Is the button now checked?

boolean checked = ((RadioButton) view).isChecked();

// Check which radio button was clicked

switch(view.getId()) {

case R.id.emergency:

if (checked)

// Pirates are the best

blood_case = true;

break;

case R.id.not_urgent:

if (checked)

// Ninjas rule

blood_case = false;

break;

92
public void searchBlood(View view){

blood_group = findBloodGrp.getSelectedItem().toString();

blood_units = bloodunits.getSelectedItem().toString();

if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) ==
PackageManager.PERMISSION_GRANTED

&& ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_COARSE_LOCATION) ==
PackageManager.PERMISSION_GRANTED) {

if (DetectConnection.checkInternetConnection(context)) {

Intent mapsActivity = new Intent(FindBloodActivity.this, MapsActivity.class);

mapsActivity.putExtra("bloodGroup", blood_group);

mapsActivity.putExtra("bloodUnits", blood_units);

mapsActivity.putExtra("bloodCase", blood_case);

mapsActivity.putExtra("userName", user_name);

SharedPreferences.Editor editor = sp.edit();

editor.putBoolean("isRequestSend", false);

editor.apply();

startActivity(mapsActivity);

} else {

Validations.alertDialogue("No Internet Connection!", "Make sure your device is


connected to internet.", context);

else{

ActivityCompat.requestPermissions(this,

new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},

LOCATION_PERMISSION_REQUEST);

93
}

@Override

public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,


@NonNull int[] grantResults) {

switch (requestCode) {

case LOCATION_PERMISSION_REQUEST: {

// If request is cancelled, the result arrays are empty.

if (grantResults.length > 0

&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {

// permission granted

Intent mapsActivity = new Intent(FindBloodActivity.this, MapsActivity.class);

mapsActivity.putExtra("bloodGroup", blood_group);

mapsActivity.putExtra("bloodUnits", blood_units);

mapsActivity.putExtra("bloodCase", blood_case);

startActivity(mapsActivity);

} else {

// permission denied

Validations.alertDialogue("Warning!", "Please allow required permission in


order to get your current location.", context);

94
4.19 History Activity
package com.ztech.apps.hope;

import android.support.design.widget.TabLayout;

import android.support.v4.view.ViewPager;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.support.v7.widget.DefaultItemAnimator;

import android.support.v7.widget.DividerItemDecoration;

import android.support.v7.widget.LinearLayoutManager;

import android.support.v7.widget.RecyclerView;

import android.support.v7.widget.Toolbar;

import android.widget.Toast;

import com.ztech.apps.hope.fragments.FirstFragment;

import com.ztech.apps.hope.fragments.SecondFragment;

import com.ztech.apps.hope.fragments.ViewPagerAdapter;

import java.util.ArrayList;

import java.util.List;

public class HistoryActivity extends AppCompatActivity {

private TabLayout tabLayout;

private ViewPager viewPager;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_history);

95
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);

setSupportActionBar(toolbar);

getSupportActionBar().setTitle("History");

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

viewPager = (ViewPager) findViewById(R.id.historyViewPager);

setupViewPager(viewPager);

tabLayout = (TabLayout) findViewById(R.id.historyTabs);

tabLayout.setupWithViewPager(viewPager);

private void setupViewPager(ViewPager viewPager) {

ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());

adapter.addFragment(new FirstFragment(), "Donated");

adapter.addFragment(new SecondFragment(), "Received");

viewPager.setAdapter(adapter);

4.20 Schedule Appointment Activity


package com.ztech.apps.hope;

import android.app.DatePickerDialog;

import android.app.Dialog;

import android.app.DialogFragment;

import android.app.TimePickerDialog;

96
import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.view.WindowManager;

import android.widget.DatePicker;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.TimePicker;

import android.widget.Toast;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;

import com.google.android.gms.common.GooglePlayServicesRepairableException;

import com.google.android.gms.location.places.Place;

import com.google.android.gms.location.places.ui.PlacePicker;

import java.util.Calendar;

import java.util.List;

public class ScheduleAppointment extends AppCompatActivity {

EditText time, location;

TextView Aname;

static EditText date;

String user_id, name, blood_grp, requester_id, accepter_name = "";

static String selectedDate = "";

String mTime, mDate, mLocation = "";

97
private static final int PLACE_PICKER_REQUEST_CODE = 40;

SharedPreferences sp;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_schedule_appointment);

getWindow().addFlags(

WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON

+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD

| +WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED

| +WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

name = getIntent().getStringExtra("Requester");

blood_grp = getIntent().getStringExtra("BloodGroup");

requester_id = getIntent().getStringExtra("RequesterId");

Aname = (TextView)findViewById(R.id.schedule_name_tv);

Aname.setText(name);

date = (EditText)findViewById(R.id.schedule_date_et);

time = (EditText)findViewById(R.id.schedule_time_et);

location = (EditText)findViewById(R.id.schedule_location_et);

location.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

PlacePicker.IntentBuilder placeBuilder = new PlacePicker.IntentBuilder();

try {

Intent intent = placeBuilder.build(ScheduleAppointment.this);

startActivityForResult(intent,PLACE_PICKER_REQUEST_CODE);

} catch (GooglePlayServicesRepairableException e) {

98
e.printStackTrace();

} catch (GooglePlayServicesNotAvailableException e) {

e.printStackTrace();

});

time.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

Calendar mcurrentTime = Calendar.getInstance();

int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);

int minute = mcurrentTime.get(Calendar.MINUTE);

TimePickerDialog mTimePicker;

mTimePicker = new TimePickerDialog(ScheduleAppointment.this, new


TimePickerDialog.OnTimeSetListener() {

@Override

public void onTimeSet(TimePicker timePicker, int selectedHour, int


selectedMinute) {

time.setText( selectedHour + ":" + selectedMinute);

}, hour, minute, true);//Yes 24 hour time

mTimePicker.setTitle("Select Time");

mTimePicker.show();

});

99
public void scheduleAppointment(View view){

mDate = date.getText().toString();

mLocation = location.getText().toString();

mTime = time.getText().toString();

sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);

SharedPreferences.Editor editor = sp.edit();

editor.putString("APName", "Zeeshan");

editor.putString("APDate", mDate);

editor.putString("APTime", mTime);

editor.putString("APAddress", mLocation);

editor.apply();

finish();

public void showDatePickerDialog(View view) {

DialogFragment newFragment = new DatePickerFragment();

newFragment.show(getFragmentManager(), "datePicker");

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

if(requestCode==PLACE_PICKER_REQUEST_CODE){

if(resultCode==RESULT_OK){

Place place = PlacePicker.getPlace(this, data);

String address = String.format("Place: %s", place.getAddress());

location.setText(address);

100
}

public static class DatePickerFragment extends DialogFragment

implements DatePickerDialog.OnDateSetListener {

@Override

public Dialog onCreateDialog(Bundle savedInstanceState) {

// Use the current date as the default date in the picker

final Calendar c = Calendar.getInstance();

int year = c.get(Calendar.YEAR);

int month = c.get(Calendar.MONTH);

int day = c.get(Calendar.DAY_OF_MONTH);

// Create a new instance of DatePickerDialog and return it

return new DatePickerDialog(getActivity(), this, year, month, day);

public void onDateSet(DatePicker view, int year, int month, int day) {

// Do something with the date chosen by the user

selectedDate = ""+day+"-"+month+"-"+year;

date.setText(selectedDate);

101
4.21 History Model
package com.ztech.apps.hope;

public class HistoryModel {

public String Name;

public String Date;

public HistoryModel(String name, String date){

this.Name = name;

this.Date = date;

public String getName() {

return Name;

public String getDate() {

return Date;

public void setName(String name){

this.Name = name;

public void setDate(String date){

this.Date = date;

102
}

4.22 First Fragment


package com.ztech.apps.hope.fragments;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.support.v7.widget.DefaultItemAnimator;

import android.support.v7.widget.DividerItemDecoration;

import android.support.v7.widget.LinearLayoutManager;

import android.support.v7.widget.RecyclerView;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.TextView;

import com.ztech.apps.hope.HistoryAdapter;

import com.ztech.apps.hope.HistoryModel;

import com.ztech.apps.hope.R;

import java.util.ArrayList;

import java.util.List;

/**

* A simple {@link Fragment} subclass.

*/

public class FirstFragment extends Fragment {

103
RecyclerView recyclerView;

HistoryAdapter adapter;

List<HistoryModel> models = new ArrayList<>();

public FirstFragment() {

// Required empty public constructor

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle


savedInstanceState) {

View view = inflater.inflate(R.layout.layout_first_fragment, container, false);

recyclerView = (RecyclerView)view.findViewById(R.id.historyfirstRecyclerView);

adapter = new HistoryAdapter(models);

RecyclerView.LayoutManager layoutManager = new


LinearLayoutManager(getActivity());

recyclerView.setLayoutManager(layoutManager);

//recyclerView.setItemAnimator(new DefaultItemAnimator());

//recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));

recyclerView.setAdapter(adapter);

GetData();

104
return view;

public void GetData()

HistoryModel model = new HistoryModel("Bilal", "31-02-2018");

HistoryModel model1 = new HistoryModel("Zubair", "01-04-2018");

HistoryModel model2 = new HistoryModel("Ahsan", "11-06-2018");

models.add(model);

adapter.notifyDataSetChanged();

models.add(model1);

adapter.notifyDataSetChanged();

models.add(model2);

adapter.notifyDataSetChanged();

4.23 Second Fragment

package com.ztech.apps.hope.fragments;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.support.v7.widget.LinearLayoutManager;

import android.support.v7.widget.RecyclerView;

105
import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.TextView;

import com.ztech.apps.hope.HistoryAdapter;

import com.ztech.apps.hope.HistoryModel;

import com.ztech.apps.hope.R;

import java.util.ArrayList;

import java.util.List;

/**

* A simple {@link Fragment} subclass.

*/

public class SecondFragment extends Fragment {

RecyclerView recyclerView;

HistoryAdapter adapter;

List<HistoryModel> models = new ArrayList<>();

public SecondFragment() {

// Required empty public constructor

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle


savedInstanceState) {

106
View view = inflater.inflate(R.layout.layout_second_fragment, container, false);

recyclerView = (RecyclerView)view.findViewById(R.id.historyfirstRecyclerView);

adapter = new HistoryAdapter(models);

RecyclerView.LayoutManager layoutManager = new


LinearLayoutManager(getActivity());

recyclerView.setLayoutManager(layoutManager);

//recyclerView.setItemAnimator(new DefaultItemAnimator());

//recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));

recyclerView.setAdapter(adapter);

GetData();

return view;

public void GetData()

HistoryModel model = new HistoryModel("Ahsan", "22-03-2018");

HistoryModel model1 = new HistoryModel("Zubair", "21-05-2018");

HistoryModel model2 = new HistoryModel("Awais", "10-07-2018");

models.add(model);

adapter.notifyDataSetChanged();

models.add(model1);

adapter.notifyDataSetChanged();

107
models.add(model2);

adapter.notifyDataSetChanged();

4.24 Summary
In this chapter, I share important code of application with others.

108
CHAPTER-5
User Manual

109
5 User Manual
Basic purpose of this chapter is to help you in understanding how this application
works. This chapter tells you, how to use this application in a better way with the help
of interfaces. You will be able to use Child Locator application easily after reading
this chapter.

Table 12: Tools and Technology Used

Tools and Technology


Android

Tools Versions

Android 4.1 – 8.0

SDK 27

Minimum API 19

Target API 21

Adobe Photoshop CS5

Android Studio Online

Firebase For SMS

110
5.10Application Screens
It contains information of all the screens of Child Locator that will help you in using
this application in a better way.

5.10.1 Splash Screen


When you will launch this application, the first screen that will appear is the splash
screen. This screen shows the name of application basically and it will take you the
Sign in/Sign up screen.

Figure 5: Splash Screen

111
5.10.2 Home Screen
Home screen provides you the options to perform different actions that are provided
by the application

Figure 6: Home Screen

112
5.10.3 Registration Screen
This screen allows you to register yourself before logging in to the application
because you can’t use this application if you are not registered. It will take different
details from and you will be registered easily.

Figure 7: Registration Screen

113
5.10.4 User Details Screen
This screen shows details of users so you can check own details and update them

Figure 8: Details Screen

114
5.10.5 Maps Screen

Figure 9: Maps Scree

115
5.10.6 Search Blood Screen

Figure 10: search blood Screen

116
5.11 Summary
In this chapter, focus was to help you to use this application, understand its interface
and save you from the inconvenience of not knowing how to use this application for
your own benefit. It will surely guide you and save your precious time.

117

You might also like