Professional Documents
Culture Documents
Auto Parts Warehouse: Project Is Submitted in Partial Fulfillment of The Requirements For The Degree of
Auto Parts Warehouse: Project Is Submitted in Partial Fulfillment of The Requirements For The Degree of
By
Usama Naeem
2015-GCUF-14405
M. Muazam Tahir
2015-GCUF-14404
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.
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
1- Usama Naeem
2- M. Muazam Tahir
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
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).
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.
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.
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.
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.
1.6 Objective
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.
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.
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.
There is only one type of user that interact with the system
Application Users
Technological Novice
experience
8
Figure 1: Use Case Diagram of App
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.
# UseCase2
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.
9
Pre-Condition: The user should have connect to the Internet..
# UseCase3
Description: User has an account and log into the application by providing his/her
email and password.
# UseCase4
Description: After log in user can register himself as a customer by giving the details
about his/her address, Phone number and Email id.
# UseCase5
Description: The user can find his/her desired parts by simply enters product name in
search bar.
10
# UseCase6
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.
This section includes the requirements that specify all the fundamental actions of the
software system. There are
Description: User should have email password and his/her personal details
to enter in the application to register.
11
Originator: User
Customer 10 Customer 1
Satisfaction: Dissatisfaction:
Table 3: Log In
Description: User should have email and password to enter in the website
Originator: User
Customer 8 Customer 2
Satisfaction: Dissatisfaction:
12
Requirement Name: Search for desired parts
Description: user can search his/her desired parts from the app and fetch the
details about them like, product details and price.
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.
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
Customer 8 Customer 2
Satisfaction: Dissatisfaction:
Description: User Can get his/her personal data and cart items back even if
he/she uninstall the app.
Originator: User
14
Customer 8 Customer 2
Satisfaction: Dissatisfaction:
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.
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.
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.
16
2.5.2 Design Constraints
2.5.2.1 Phone’s local storage
Availability
Security
Maintainability
Description: The system should have internal storage of few MBs available for app.
Dependencies: None
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.
Dependencies: None
Description: There should be secure log-in, so others cannot get user-name and
password.
Dependencies: None
18
Requirement #: Quality Requirement 5 Requirement type: Quality Requirement
Description: User wants to create an account with only one user name
Dependencies: None
Description: The system should have internal storage of few MBs available for app.
Dependencies: None
19
Requirement # Quality Requirement 7 Requirement type: Quality Requirement
Description: The availability of the system when it is used. The system should give
accurate result every time.
Rationale: For application that the system is available for 24/7 hours.
Dependencies: None
Description: There should be secure log-in, so others cannot get user-name and
password.
Dependencies: None
20
2.8 Table most important requirements
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.
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.
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.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.
Mobile App
User
Application
Cloud
Warehouse
Database
25
This section describes constraints on the eventual design of the Product .
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
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:
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:
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:
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
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.
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.
Term Definition
29
Voluntry Donor A person who donates blood free of cost.
Authorities Higher authorities that are responsible for Blood Donations, can use
this application.
Stakeholder Any person who interacts with the system who is not a developer
DESC Description
RAT Rational(reasoned)
DEP Dependency
30
3.6 Work Partitioning
The list below in the table showing all events to which the work responds. The
Nearby Blood Banks Sort out your nearby blood Organizing them in efficient
banks manner.
31
3.7 Class Diagram of Backend System:
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
UID
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.
33
Becoming a Donor
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
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
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
Appointments
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.
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
Become a donor
Scenario 1
Become donor
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
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
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.
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
Send SMS
Scenario 4
Manager add the deal to the database
40
Accepted
Business
Manager Sms Dialouge SMS Service Customers
Add a deal
Scenario 5
Rejected
41
Busine ss SMS
Manager Notification
Add a deal
Rejected
42
3.9 Activity Diagram:
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.
Become Donor
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.
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.
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
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
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.
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
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 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
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);
startActivity(intent);
startActivity(becomeDonorActivity);
startActivity(becomeDonorActivity);
50
Intent becomeDonorActivity = new Intent(MainActivity.this, UserProfile.class);
startActivity(becomeDonorActivity);
@Override
super.onStart();
if(name == null)
if(verif != 0){
startActivity(i);
finish();
}else{
startActivity(i);
finish();
@Override
getMenuInflater().inflate(R.menu.main_activity_menu, menu);
return true;
51
@Override
switch (item.getItemId()){
case R.id.menu_blood_banks:
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
return true;
package com.ztech.apps.hope;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
@Override
52
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
startActivity(signUpActivity);
finish();
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;
@Override
54
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
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);
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);
newFragment.show(getFragmentManager(), "datePicker");
startActivity(i);*/
if (TextUtils.isEmpty(fName.getText()) || TextUtils.isEmpty(lName.getText())
|| TextUtils.isEmpty(dob.getText())) {
} else {
String db = dob.getText().toString();
SharedPreferences sp = getSharedPreferences("USER_PREF",
Context.MODE_PRIVATE);
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();
startActivity(phoneNo);
finish();
implements DatePickerDialog.OnDateSetListener {
@Override
57
public void onDateSet(DatePicker view, int year, int month, int day) {
month++;
dob.setText(dateOfBirth);
//Toast.makeText(context, ""+day+"-"+month+"-"+year,
Toast.LENGTH_SHORT).show();
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;
EditText phoneNo;
59
Context context;
SharedPreferences sp;
@Override
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);
@Override
mProgress.dismiss();
phonenumber = phoneNo.getText().toString();
editor.putInt("verificationCode", code);
editor.putString("phoneNumber", phonenumber);
editor.apply();
60
Intent verify = new Intent(AskPhoneNumber.this, VerifyPhoneNumber.class);
startActivity(verify);
finish();
@Override
mProgress.dismiss();
@Override
super.onCodeAutoRetrievalTimeOut(s);
mProgress.dismiss();
};
@Override
super.onPause();
//mProgress.dismiss();
61
if (TextUtils.isEmpty(phoneNo.getText())){
}else{
}else{
if(DetectConnection.checkInternetConnection(AskPhoneNumber.this)) {
phonenumber = phoneNo.getText().toString();
Toast.makeText(AskPhoneNumber.this, phonenumber,
Toast.LENGTH_SHORT).show();
//verifyPhoneNumberFromServer(phonenumber);
mProgress.setTitle("Sending Text");
mProgress.setCanceledOnTouchOutside(false);
//mProgress.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNo.getText().toString(), 60,
phonenumber = phoneNo.getText().toString();
//editor.putInt("verificationCode", code);
editor.putString("phoneNumber", phonenumber);
62
editor.apply();
startActivity(verify);
finish();
else {
@Override
new Response.Listener<String>(){
@Override
if(response.contains("Available")){
Toast.makeText(AskPhoneNumber.this, "Available",
Toast.LENGTH_SHORT).show();
mProgress.setTitle("Sending Text");
63
mProgress.setCanceledOnTouchOutside(false);
mProgress.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNo.getText().toString(), 60,
}else{
context);
}, new Response.ErrorListener(){
@Override
return;
try {
} catch (UnsupportedEncodingException e) {
64
// exception
})
@Override
params.put("phone_number", phoneNumber);
return params;
};
MySingleton.getmInstance(AskPhoneNumber.this).addToRequestQueue(stringRequest);
return "success";
@Override
super.onPostExecute(result);
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;
SharedPreferences sp;
EditText verificationCodeinput;
TextView tv;
66
String serverUrl = "http://192.168.1.23/hope/register_user.php";
String phoneNo;
ProgressDialog mProgress;
@Override
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);
startActivity(askphoneNo);
67
finish();
if(DetectConnection.checkInternetConnection(this)) {
mProgress.setTitle("Processing!");
mProgress.setCanceledOnTouchOutside(false);
mProgress.show();
// if (enteredCode == code) {
//
// } else {
// mProgress.dismiss();
// }
}else {
@Override
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){
@Override
new Response.Listener<String>(){
@Override
if(response.contains("error")){
if(DetectConnection.checkInternetConnection(VerifyPhoneNumber.this)) {
}else{
}else{
mProgress.dismiss();
editor.putString("uid", response);
69
editor.apply();
startActivity( mainActivity);
finish();
}, new Response.ErrorListener(){
@Override
return;
try {
} catch (UnsupportedEncodingException e) {
// exception
})
@Override
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
super.onPostExecute(result);
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;
SharedPreferences sp;
TextView tv;
Ringtone r;
MediaPlayer mp;
@Override
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");
sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);
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();
74
handler.postDelayed(new Runnable() {
if(mp!=null){
mp.stop();
finish();
}, 10000);
if(mp!=null){
mp.stop();
finish();
if(mp!=null){
75
mp.stop();
finish();
@Override
new Response.Listener<String>(){
@Override
Toast.makeText(IncomingBloodRequestActivity.this, "response:
"+response, Toast.LENGTH_SHORT).show();
if(response.contains("error")){
if(DetectConnection.checkInternetConnection(IncomingBloodRequestActivity.this)) {
76
}
}else{
finish();
}, new Response.ErrorListener(){
@Override
return;
try {
} catch (UnsupportedEncodingException e) {
// exception
})
77
@Override
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
super.onPostExecute(result);
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;
@Override
if(message.matches("needs_blood")) {
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);
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;
81
String serverUrl = "http://192.168.1.23/hope/find_blood.php";
boolean bloodCase;
ProgressDialog mProgress;
SharedPreferences sp;
@Override
if
(intent.getAction().matches(LocationManager.PROVIDERS_CHANGED_ACTION)) {
if (locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) ||
locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
GetLocation();
} else {
};
@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");
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
start = true;
@Override
mMap = googleMap;
GetLocation();
@Override
super.onResume();
83
if(start) {
registerReceiver(gpsReceiver, new
IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION));
@Override
super.onPause();
if(mProgress!=null){
mProgress.dismiss();
sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);
boolean network =
locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!gps || !network) {
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){
latitude = String.valueOf(location.getLatitude());
longitude = String.valueOf(location.getLatitude());
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
if(!isSend) {
else{
locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
100, 0, this);
location =
locManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if(location != null){
latitude = String.valueOf(location.getLatitude());
longitude = String.valueOf(location.getLatitude());
85
if(!isSend) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
else {
mMap.clear();
mMap.addMarker(new
MarkerOptions().position(latLng).title(title).icon(BitmapDescriptorFactory.defaultMarker(Bit
mapDescriptorFactory.HUE_BLUE)));
@Override
zoomLevel = 15;
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel));
86
@Override
@Override
@Override
@Override
new Response.Listener<String>(){
@Override
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.setCanceledOnTouchOutside(false);
mProgress.show();
}, new Response.ErrorListener(){
@Override
return;
try {
88
} catch (UnsupportedEncodingException e) {
// exception
})
@Override
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
super.onPostExecute(result);
89
}
sendPostReqAsyncTask.execute();
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 {
RadioButton bloodCase;
Context context;
SharedPreferences sp;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_blood);
sp = getSharedPreferences("USER_PREF", Context.MODE_PRIVATE);
context = this;
bloodCase.setChecked(true);
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);
switch(view.getId()) {
case R.id.emergency:
if (checked)
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)) {
mapsActivity.putExtra("bloodGroup", blood_group);
mapsActivity.putExtra("bloodUnits", blood_units);
mapsActivity.putExtra("bloodCase", blood_case);
mapsActivity.putExtra("userName", user_name);
editor.putBoolean("isRequestSend", false);
editor.apply();
startActivity(mapsActivity);
} else {
else{
ActivityCompat.requestPermissions(this,
new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},
LOCATION_PERMISSION_REQUEST);
93
}
@Override
switch (requestCode) {
case LOCATION_PERMISSION_REQUEST: {
if (grantResults.length > 0
// permission granted
mapsActivity.putExtra("bloodGroup", blood_group);
mapsActivity.putExtra("bloodUnits", blood_units);
mapsActivity.putExtra("bloodCase", blood_case);
startActivity(mapsActivity);
} else {
// permission denied
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;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
95
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("History");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setupViewPager(viewPager);
tabLayout.setupWithViewPager(viewPager);
viewPager.setAdapter(adapter);
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;
TextView Aname;
97
private static final int PLACE_PICKER_REQUEST_CODE = 40;
SharedPreferences sp;
@Override
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
try {
startActivityForResult(intent,PLACE_PICKER_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
98
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
});
time.setOnClickListener(new View.OnClickListener() {
@Override
TimePickerDialog mTimePicker;
@Override
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);
editor.putString("APName", "Zeeshan");
editor.putString("APDate", mDate);
editor.putString("APTime", mTime);
editor.putString("APAddress", mLocation);
editor.apply();
finish();
newFragment.show(getFragmentManager(), "datePicker");
@Override
if(requestCode==PLACE_PICKER_REQUEST_CODE){
if(resultCode==RESULT_OK){
location.setText(address);
100
}
implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
selectedDate = ""+day+"-"+month+"-"+year;
date.setText(selectedDate);
101
4.21 History Model
package com.ztech.apps.hope;
this.Name = name;
this.Date = date;
return Name;
return Date;
this.Name = name;
this.Date = date;
102
}
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;
/**
*/
103
RecyclerView recyclerView;
HistoryAdapter adapter;
public FirstFragment() {
@Override
recyclerView = (RecyclerView)view.findViewById(R.id.historyfirstRecyclerView);
recyclerView.setLayoutManager(layoutManager);
//recyclerView.setItemAnimator(new DefaultItemAnimator());
//recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(adapter);
GetData();
104
return view;
models.add(model);
adapter.notifyDataSetChanged();
models.add(model1);
adapter.notifyDataSetChanged();
models.add(model2);
adapter.notifyDataSetChanged();
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;
/**
*/
RecyclerView recyclerView;
HistoryAdapter adapter;
public SecondFragment() {
@Override
106
View view = inflater.inflate(R.layout.layout_second_fragment, container, false);
recyclerView = (RecyclerView)view.findViewById(R.id.historyfirstRecyclerView);
recyclerView.setLayoutManager(layoutManager);
//recyclerView.setItemAnimator(new DefaultItemAnimator());
//recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(adapter);
GetData();
return view;
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.
Tools Versions
SDK 27
Minimum API 19
Target API 21
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.
111
5.10.2 Home Screen
Home screen provides you the options to perform different actions that are provided
by the application
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.
113
5.10.4 User Details Screen
This screen shows details of users so you can check own details and update them
114
5.10.5 Maps Screen
115
5.10.6 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