Sei sulla pagina 1di 66

AETRIO-CARE SOLUTIONS A SOCIAL

SERVICE APP
A Major Project
Submitted in Partial fulfillment of the requirements for the
degree of Bachelor of Engineering in Computer Science

Submitted to

Rajiv Gandhi Proudyogiki Vishwavidhyalaya, Bhopal (M.P.)

Submitted By:

MANJEET SINGH 0126CS161050

Under the Guidance of


Mr. Sanjay Sharma
Head of Department
Department of Computer Science

\
ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL
Approved by AICTE New Delhi & Govt. of M.P.
Affiliated to Rajiv Gandhi Proudyogiki Vishwavidhyalaya, Bhopal (M.P.)
Session: Jan-May,2019
ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL
Approved by AICTE New Delhi & Govt. of M.P. & Affiliated to Rajiv
Gandhi Proudyogiki Vishwavidhyalaya Bhopal (M.P.)

DEPARTMENT OF COMPUTER SCIENCE

CERTIFICATE

This is to certify that the work embodied in this Minor Project entitled
as “AETRIO-CARE SOLUTIONS SOCIAL SERVICE” has been
satisfactorily completed by Manjeet Singh(0126CS161050) student of
B.E, III year, VII Sem.
It is a bonafide piece of work, carried out under my guidance in the
Computer Science And Engineering, Oriental College of Technology,
Bhopal for the partial fulfillment of the Bachelor of Engineering in
Computer Science degree during the academic session Jan-May, 2019.

Mr. Snajay
Sharma
Head of Department
Department of CSE
CANDIDATE DECLARATION

I hereby declare that the Minor Project work presented in the report entitled as
“Aetrio-Care Solutions Social service App” submitted in the partial fulfillment
of the requirements for the award of the degree of Bachelor of Engineering in
Computer Science of Oriental College of Technology is an authentic record of
my own work carried out at Oriental College of Technology, Bhopal.

I have not submitted the part and partial of this report for the award of any other
degree or diploma.

Date: Manjeet Singh (0126CS161050)

This is to certify that the above statement made by the candidate/s is correct to the
best the best of my knowledge.

Mr. Sanjay Sharma


Head of Department
Department of CSE

Countersigned by

Dr. D.P. Gupta


Director
OCT, Bhopal

ACKNOWLEDGMENT
I am heartily thankful to the Management of Oriental College of Technology for providing me
all the facilities and infrastructure to take my work to the final stage.

It is the constant supervision, moral support and proper guidance of our respected
Director Dr. D.P. Gupta, who motivated throughout the work.

I express deep sense of gratitude and respect to my learned guide Prof.Rakesh sir, Assistant
Professor in the Department of Computer Science during all phases of my work. Without her
enthusiasm and encouragement this dissertation would not have been completed. Her valuable
knowledge and innovative ideas helped me to take the work to the final stage. She has timely
suggested actions and procedures to follow for which I am really grateful and thankful to her.

I express my gratefulness to Dr.Farrah hannef, Head Computer Science Department for


providing all the facilities available in the department for his continuous support, advice, and
encouragement during this work and also help to extend my knowledge and proper guidelines.

I am thankful to all the faculty members and other non teaching staff of Computer Science
Department for their cooperation.

Constant help, moral and financial support of my loving parents motivated me to complete the
work. I express my heartily thanks to my all family members for their co-operation.

I really admire the fond support of my class-mates for their co-operation and constant help. It
gives immense pleasure to acknowledge the encouragement and support extended by them. Last
but not the least I am extremely thankful to all who have directly or indirectly helped me for the
completion of my work.

Manjeet Singh
(0126CS161050)
ABSTRACT

. National and international laws regarding taxi operations Aetrio-Care Solutions


does not adhere to the same driver trainings, safety measures, or pricing rules that
existing cabs must comply with. The taxi industry is fighting to place tighter
regulations on Aetrio-Care Solutions or ban Aetrio-Care Solutions altogether,
which has been the case in numerous locations worldwide. Despite these problems,
Aetrio-Care Solutions has elected to continue operations in some of these banned
locations. Additionally, most airports have strict policies for taxi licensing and fees,
keeping Aetrio-Care Solutions out of a large market of service.
Insurance of independent contract employees As Aetrio-Care Solutions is a
company that hires independent drivers, insurance may be an issue. The current
model reflects that Aetrio-Care Solutions does not want to be held responsible for
its drivers, yet drivers must have some degree of insurance in order to guarantee
medical safety and coverage. Balance between users and drivers in terms of
demand Operations in big cities allow Aetrio-Care Solutions to have a constant
flow of users and drivers, but this balance is not as smooth in all of its markets.
Imbalances cause dissatisfaction with both users and drivers, which may deter
operations in less prominent areas
And the technologies which is have used in making the app are Android for
app,Google Map Api for laction And Firebase as the database and for user and
driver authentication.
Keywords: Android , Internetworking , Firebase, Google Map Api
TABLE OF CONTENTS
S. No Contents Page No.

List of Figures I
List of Tables II
List of Graphs III
List Symbols and of Abbreviations IV

1 Introduction 1-07
1.1 Oerview 1
1.2 Advantages of Aetrio-Care Solutions 3
1.3 Disadvantages of Aetrio-Care Solutions 4
1.4 Opportunities for Aetrio-Care Solutions 7

2 Software Requirement Specification 08-9


2.1 Purpose 08
2.2 Technical Specification 10

3 System Documentation 9-14


3.1 Data Flow Diagram 9
3.2 ER Diagram 10
3.3 Class Diagram 11
3.4 Activity Diagram 12
3.5 Flow Diagram 13
3.6 User Case Diagram 14

4 Technical Details 15-24


4.1 Introduction and Guidelines 15
4.2 Technical Specification 19
4.3 Output Reports 21

5 Testing and Test Cases 21-22


6 Coding 23-37
6.1 user login 23
6.2.Driver Login 25
6.3Customer Activity 29
6.4 Driver Activity 32
6.5 Other Codes 35
7 Screenshots and working 45-55
8.1 App Screenshots 45
8.2 Database Screenshots 48
8.3 Authentication Screenshots 50

8 Conclusion and Future Work 56


9 Biblography 58-59
References
10 Appendix 29

LIST OF FIGURES
Figure 1 Er Diagram of Aetrio-Care Solutions 10
Figure 2 Photometric stereo image 09
Figure 3 Geometrical Facial Recognition 10
Figure 4 How Facial Identification works 13
I

INTRODUCTION
1

Objectives, Problems, and Opportunities Objectives

1. Price efficiency

2. Transparency

3. Ubiquity and brand recognition

4. Minimal red tape and regulations Problems

1. National and international laws regarding taxi operations Aetrio-Care Solutions does not
adhere to the same driver trainings, safety measures, or pricing rules that existing cabs must
comply with. The taxi industry is fighting to place tighter regulations on Aetrio-Care Solutions
or ban Aetrio-Care Solutions altogether, which has been the case in numerous locations
worldwide. Despite these problems, Aetrio-Care Solutions has elected to continue operations in
some of these banned locations. Additionally, most airports have strict policies for taxi licensing
and fees, keeping Aetrio-Care Solutions out of a large market of service.

2. Insurance of independent contract employees As Aetrio-Care Solutions is a company that


hires independent drivers, insurance may be an issue. The current model reflects that Aetrio-Care
Solutions does not want to be held responsible for its drivers, yet drivers must have some degree
of insurance in order to guarantee medical safety and coverage.

3. Balance between users and drivers in terms of demand Operations in big cities allow Aetrio-
Care Solutions to have a constant flow of users and drivers, but this balance is not as smooth in
all of its markets. Imbalances cause dissatisfaction with both users and drivers, which may deter
operations in less prominent areas.

4. Privacy concerns regarding secret tracking of customers Aetrio-Care Solutions has publicized
the unauthorized tracking of individuals using the “Godview” feature, which has raised concerns
of privacy and personal tracking among users. This problem has led to multiple lawsuits
disputing unlawful usage of user data and locational information. Privacy is a major problem
when it comes to Aetrio-Care Solutions’s brand and image users want to feel secured and not
stalked.

Strengths:-
User Experience
It offers services/features like reliable pickup, clear pricing, cashless and convenient
payment and splitting of fares, which in turn leads to an enhanced user experience.

First to the market


Has a significant head start in the areas of branding, infrastructure, and consumer trust.

Mobile platform
Cabs, perhaps more than any other service, are uniquely fitted to the mobile platform
because, well, they are mobile.

Mobile app design is thoughtful and user-friendly Glitches are minimal and
responsiveness from servers and system itself is exceptional (crucial, given cab riders
need to get somewhere fast)

DISADVANTAGES:-
Standard insurance and liability questions that plague most start-ups offering
services or community connections.

Lawsuits charging illegal cab practices from multiple cities including New York.
Established deals between cities and taxi companies, as well as union laws
associated with these, have led Aetrio-Care Solutions to be drawn into court
repeatedly in just its 3 year history.

Inconsistent Prices Aetrio-Care Solutions has a system in place which is called


surge pricing, under which Aetrio-Care Solutions rates increases
during the busiest times.

No Scheduling There is no option of pre-booking a cab.


Monetizing the idea; while there is always a proven demand for cabs, the overhead
and
potential legal costs required offer significant limitations to potential market cap

Opportunities:-

Expanding to new cities with seemingly boundless overseas markets for this service
(seriously, name me a city where you can’t grab some sort of cab) helps alleviate some
of
the legal and overhead limitations on market potential.

Introducing Novelty services:


Introducing services like Aetrio-Care Solutions Ice cream in other cities.
Aetrio-Care Solutions introduced Aetrio-Care Solutions Ice Cream in London, which
allows you the ability to summon one
of the company’s ice cream trucks to your location.
A novelty for sure, but that’s the kind
of innovative thinking that draws media and social attention to your brand and also
generates revenue.

Further improving customer experience by adding services like pre-booking a cab and
payment through cash (in atleast developing countries like India were the banking
habits
are really low).
6.

Chapter 2:-

Purpose:-

Aetrio-Care Solutions is social networking app which helps both the comman man in both the
way to earn and to provide and impore easy travel facilities in an area so you must take a great
sense of pride as such a app is being launched in the city of lakes (Bhopal).

The work of the app is designed in 2 simple phase one phase is that is a normal man want’s to
earn money then he could register himself as a driver on daily basis by paying a nominal fee of
Rs 10. And after that our database will show him as one of the drivers on the customers user
interface for the whole day and their after he could take as many rides as he want according to
his location and the users which would be available at his locality
.
Data Collection Methods Main data collection method is a questionnaire to local potential
partner businesses to discover the impact and adoption of the proposed business focused solution.
Targeting businesses that currently have delivery options, third party delivery, and new partner
businesses that could use our service, we aim to get a baseline for the desire and cost expectation
of our proposed solution.
These businesses may have different requirements than normal Aetrio-Care Solutions customers
and may be willing to tolerate higher costs for the convenience offered.
By deploying employees to interface with a diverse group of local business owners and
operators, we can gain a good sense of how to integrate their needs as well as price our product
competitively while ensuring it integrates into existing business processes seamlessly.

Secondary data collection will occur with the help of Aetrio-Care Solutions project managers
and existing develops. We aim to have a brief session with Aetrio-Care Solutions personnel
before launching our 12 month project cycle. Here we aim to understand current Aetrio-Care
Solutions practices and learn from the experiences of the current team.
While doing so, we will also endeavor to recruit existing team members to join the new project
in Raleigh in order to have a high level of familiarity with Aetrio-Care Solutions’s tools,
technologies, and business practices in order to speed development. Current budget projections
are for hiring of new staff, but does not preclude the option to repurpose existing staff in order to
cut development time.
By having a preliminary interview and data collection meeting with Aetrio-Care Solutions, we
hope to cut our time to market by learning the hurdles that have already been overcome and
make sure our project’s development is in line with standards.
In addition, this time period also permits informal recruiting and measuring the response from
developers and managers to the upcoming project and eliciting input regarding previous projects.
The Aetrio-Care Solutions app uses Machine learning algorithm
to track the drivers around the customer to book the driver which at the nearest location from the
customer so that it would be convenient for both the driver and the customer to book the ride .

7
Chapter 3:- (System documentation)

3.1 Data Flow Diagram of Aetrio-Care Solutions:-


The above diagram is the data flow diagram of the app designed by me which is
the Aetrio-Care Solutions app which shows how the data is being sent from user to
the database and then to the to driver which is the nearest to the customer so it uses
even uses lenear regression and way finder algorithms to find the distane between
the drivers which are present in the city of the customer.

8.
3.2 ER –Diagram:-

9.
3.3 Class Diagram:-

class diagram represents the different types of classes which are implemented in
the making of the app so that the required functionality of the app could be
fulfilled for the same.

Especially in my app proper authentication needs to be followed for both the


customer and driver to get themselves logged into the app .

A s, you can see in the diagram the app is divided into two internal parts so that
the driver can get login thorugh using his options while the customer can get
logged in the app by using his option i have used the trusted phone authentication
for designing the driver login while for the customer its the email and password
verification.

10.
3.4 Activity Diagram:-

The app uses the a total of 5 activity for the proper functioning of the app include
the user login and the driver login and the verification and the main activity which
uses the Google Api for its proper functioning and also it uses Firebase as its
realtime database for updating and retrieving the realtime location from the
database.

11.
3.5 Flow Chart:-

Flow control of the app is something like if one user want to book a ride then he
has to allow the location services in his app and then he needs to do the

 his is a very unique and useful feature that allows people to “pause” their
trips along the way. This means that a user will be able to stop to buy
items or to eat while their trip is on.
 When the Rider wants to stop the ride in the middle of the trip, they can
ask the driver to “Pause” the ride in the middle of the trip. During this
“pause” time, the Rider will be charged a separate waiting fee.
 This means that the trip charge and the waiting charge will be calculated
separately and then added cumulatively in the invoice at the end of the
trip. This gives you fair and unbiased billing each tim

12.
3.6 User_Case Diagram:-

13.
Chapter 4 (Techical Description):-

4.1 Introduction and Guideline:-

Aetrio-Care Solutions’s Dispatch system acts like a real-time


market platform that matches drivers with riders using mobile
phones.

So we need two services

1. Supply service
2. Demand service

going forward I will be using supply for cabs and demand for
riders while explaining

Supply service:

• The Supply Service tracks cars using geolocation (lat and lang)
Every cab which is active keep on sending lat-long to the server
every 5 sec once

• The state machines of all of the supply also kept in memory

• To track vehicles there are many attributes to model: number of


seats, type of vehicle, the presence of a car seat for children, can a
wheelchair be fit, and so on.

• Allocation needs to be tracked. A vehicle, for example, may have


three seats but two of those are occupied.
14.

Demand service

• The Demand Service tracks the GPS location of the user when
requested

• It tracks requirements of the orders like Does a rider require


small car/big car or pool etc

• demand requirements must be matched against supply


inventory.

Now we have supply and demand. all we need a service which


matches they demand to a supply and that service in AETRIO-
CARE SOLUTIONS is called as DISCO

DISCO — DISPATCH optimization

This service runs on hundreds of processes.

Core requirements of the dispatch system

1. reduce extra driving.


2. reduce waiting time
3. lowest overall ETA
15.

4.2 Software specification:-

How does the Dispatch system work??


How riders are matched to drivers ??
GPS/ location data is what drive dispatch system, that means we
have to model our maps and location data

1. The earth is a sphere. It’s hard to do summarization and


approximation based purely on longitude and latitude. So
Aetrio-Care Solutions divides the earth into tiny cells using the
Google S2 library. Each cell has a unique cell ID.
2. S2 can give the coverage for a shape. If you want to draw a
circle with a 1km radius centered on London, S2 can tell what
cells are needed to completely cover the shape

1. Since each cell has an ID the ID is used as a sharding key.


When a location comes in from supply the cell ID for the
location is determined. Using the cell ID as a shard key the
location of the supply is updated. It is then sent out to a few
replicas.
2. To match riders to drivers or just display cars on a map, DISCO
sends a request to geo by supply
16.

3. the system filters all cabs by rider’s GPS location data to get
nearby cabs that meet riders requirements Using the cell Ids
4. from the circle area all the relevant shards are contacted to
return supply data.
5. Then the list and requirements are sent to routing / ETA to
compute the ETA of how nearby they are not geographically,
but by the road system.
6. Sort by ETA then sends it back to supply system to offer it to a
driver.

How To Scale Dispatch System?

There are many ways you can build, but @ Aetrio-Care


Solutions

1. Dispatch is built using node.js the advantage with using node is


the asynchronous and event-based framework. also, it enables
you to send and receive messages over WebSockets
2. so anytime client can send the message to server or server can
send and whenever it wants to.
3. Now how to distribute dispatch computation on the same
machine and to multiple machines?
4. The solution to scaling is Node js with ringpop, it is faster
RPC protocol with gossip using SWIM protocol along with a
consistent hash ring.
5. Ringpop is a library that brings cooperation and coordination
to distributed applications. It maintains a consistent hash ring
on top of a membership protocol and provides request
forwarding as a routing convenience. It can be used to shard
your application in a way that’s scalable and fault tolerant
6. SWIM is used gossip/to know what node does what and who
takes which geo’s computation’s responsibility.
7. so with gossip it's easy to add and remove nodes and hence

16.

Gossip protocol SWIM also combines health checks with


membership changes as part of the same protocol.

How supply sends messages and saved?

Apache Kafka is used as the data hub

supply or cabs uses Kafka’s APIS to send there accurate GPS


locations to the datacenter.

Once the GPS locations are loaded to Kafka they are slowly
persisted to the respective worker notes main memory and also to
the DB when the trip is happening.

How do Maps and routing work?

Before Aetrio-Care Solutions launches operations in a new area,


we define and onboard a new region to our map technology stack.
Inside this map region, we define subregions labeled with grades
A, B, AB, and C, as follows:

Grade A: A subregion of Aetrio-Care Solutions Territory covering


urban centers and commute areas that makeup approximately 90
percent of all expected Aetrio-Care Solutions traffic. With that in
mind, it is of critical importance to ensure the highest map quality
of grade A map regions.

Grade B: A subregion of Aetrio-Care Solutions Territory covering


rural and suburban areas that might be less populated or less
traveled by Aetrio-Care Solutions customers.

Grade AB: A union of grade A and B subregions.


Grade C: A set of highway corridors connecting various Aetrio-
Care Solutions Territories.

18.

GeoSpatial design:

The earth is a sphere. It’s hard to do summarization and


approximation based purely on longitude and latitude.

So Aetrio-Care Solutions divides the earth into tiny cells using the
Google S2 library. Each cell has a unique cell ID.

When DISCO needs to find the supply near a location, a circle’s


worth of coverage is calculated centered on where the rider is
located.

The read load is scaled through the use of replicas. If more read
capacity is needed the replica factor can be increased.

How Aetrio-Care Solutions builds the Map?

1. Trace coverage: A comparative coverage metric, trace coverage


identifies missing road segments or incorrect road geometry.
The computation uses two inputs: map data under testing and
historic GPS traces of all Aetrio-Care Solutions rides taken over
a certain period of time. We overlay those GPS traces onto the
map, comparing and matching them with road segments. If we
find GPS traces where no road is shown, we can infer that our
map is missing a road segment and take steps to fix the
deficiency.
2. Preferred access (pick-up) point accuracy: Pick-up points are
an extremely important metric to the rider experience,
especially at large venues such as airports and stadiums. For
this metric, we compute the distance of an address or place’s
location, as shown by the map pin in Figure 4, below, from all
actual pick-up and drop-off points used by drivers. We then set
the closest actual location to be the preferred access point for
the said location pin. When a rider requests the location
indicated by the map pin, the map guides the driver to the
preferred access point. We continually compute this metric
with the latest actual pick-up and drop-off locations to ensure
the freshness and accuracy of the suggested preferred access
3. 19.

How ETAs are calculated?

that means disco should track the cabs available to ride the riders.

but IT shouldn’t just handle currently available supply, i.e. cabs


which are ready to ride customer but also tracks the cars about to
finish a ride.

for example:

1. a cab which is about to finish near the demand(rider) is better


than allocating the cab which is far away from the demand.
2. Sometimes revising a route of an ongoing trip because some
cab near to demand came online.

when Aetrio-Care Solutions started every cities data was separated


by creating separated tables/DB this was not easy

now all the cities computation happens in the same system, since
the workers the DBnodes are distributed by regions the demand
request will be sent to the nearest datacenter.

Routing and Calculating ETA is important component in Aetrio-


Care Solutions as it directly impacts ride matching and earnings.

so it uses historical travel times to calculate ETAs

you can use AI simulated algorithms or simple Dijkstra's also to


find the best route
Also you can use Driver’s app’s GPS location data to easily predict
traffic condition at any given road as there are so many Aetrio-
Care Solutions cars on the road which is sending GPS locations
every 4 seconds

The whole road network is modeled as a graph. Nodes represent


intersections, and edges represent road segments.

20.
00
The edge weights represent a metric of interest: often either the
road

segment distance or the time take it takes to travel through it.


Concepts such as one-way streets, turn restrictions, turn costs,
and speed limits are modeled in the graph as well.

One simple example you can try at home is the Dijkstra’s search
algorithm, which has become the foundation for most modern
routing algorithms today.

OSRM is based on contraction hierarchies. Systems based on


contraction hierarchies achieve fast performance — taking just a
few milliseconds to compute a route — by preprocessing the
routing graph.

Databases:

A lot of different databases are used. The oldest systems were


written in Postgres.

Redis is used a lot. Some are behind Twemproxy. Some are behind
a custom clustering system.

MySQL: Built on these requirements

 linearly add capacity by adding more servers (Horizontally


scalable )
 write availability with buffering using Redis
 Triggers should work when there is a change in theinstance
 No downtime for any operation (expanding storage, backup,
adding indexes, adding data, and so forth).

You can use, Google’s Bigtable like any schema-less database

Trip data Storage in Schemaless


21.

Aetrio-Care Solutions is building their own distributed column


store that’s orchestrating a bunch of MySQL instances called
schemaless

Schemaless is key-value store which allows you to save any JSON


data without strict schema validation in a schemaless fashion
(hence the name).

It has append-only sharded MySQL with buffered writes to


support failing MySQL masters and a publish-subscribe feature
for data change notification which we call triggers.

Schemaless supports global indexes over the data.

Trip data is generated at different points in time, from pickup


drop-off to billing, and these various pieces of info arrive
asynchronously as the people involved in the trip give their
feedback, or background processes execute.

A trip is driven by a partner, taken by a rider, and has a timestamp


for its beginning and end. This info constitutes the base trip, and
from this we calculate the cost of the trip (the fare), which is what
the rider is billed. After the trip ends, we might have to adjust the
fare, where we either credit or debit the rider. We might also add
notes to it, given feedback from the rider or driver (shown with
asterisks in the diagram above). Or, we might have to attempt to
bill multiple credit cards, in case the first is expired or denied.
Some of the Dispatch services are keeping state in Riak

22.
Chapter 6(Coding):-

6.1 User Login:-

Code:- package
com.eye_of_supreme_god.lord_radhekrishna.firebase_tester;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;

public class MainActivity extends AppCompatActivity


{
private EditText email,password;
private Button login,register;
private FirebaseAuth mauth;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mauth=FirebaseAuth.getInstance();
email=(EditText)findViewById(R.id.email);
password=(EditText)findViewById(R.id.password);
login=(Button)findViewById(R.id.register);
progressBar=(ProgressBar)findViewById(R.id.progressBar);
register=(Button)findViewById(R.id.login);

String decider=getIntent().getStringExtra("cus");
if(decider.equals("login"))
{
login.setVisibility(View.INVISIBLE);
login.setEnabled(false);
}
else
{
register.setVisibility(View.INVISIBLE);

23
register.setEnabled(true)
}

login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
String email2=email.getText().toString();
String pass=password.getText().toString();
progressBar.setVisibility(View.VISIBLE);
email.setEnabled(false);
password.setEnabled(false);
login.setEnabled(false);
register(email2,pass);

}
});
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
String email2=email.getText().toString();
String pass=password.getText().toString();
progressBar.setVisibility(View.VISIBLE);
email.setEnabled(false);
password.setEnabled(false);
register.setEnabled(false);
logger(email2,pass);
}
});
}
private void register(String email2,String password2)
{
if(password.length()<6)
{
email.setEnabled(true);
password.setEnabled(true);
password.setError("Password to weak");
login.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
}
if(email.length()<9)
{
email.setEnabled(true);
email.setError("Email invalid");
password.setEnabled(true);
password.setError("Password to weak");
login.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
}
else
{
mauth.createUserWithEmailAndPassword(email2,password2)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
{ 24
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if(task.isSuccessful())
{
Intent rk=new
Intent(MainActivity.this,MapsActivity_customer.class);

rk.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEA
R_TASK);
startActivity(rk);
Toast.makeText(MainActivity.this,"Registration
done",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(MainActivity.this,"Please try
again",Toast.LENGTH_SHORT).show();
email.setEnabled(true);
password.setEnabled(true);
login.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
}
}
});
}
}
public void logger(String email4,String password4)
{
if(password4.length()<6)
{
email.setEnabled(true);
password.setEnabled(true);
password.setError("Weak password");
password.setHint("password must be longer");
register.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
}
if(email4.length()<9)
{
email.setEnabled(true);
password.setEnabled(true);
register.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
email.setHint("Please enter valid email..");
email.setError("Not proper email");
}
else
{
mauth.signInWithEmailAndPassword(email4,password4)
.addOnCompleteListener(new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull
Task<AuthResult> task)

25.
{
if(task.isSuccessful())
{
Intent rk=new
Intent(MainActivity.this,MapsActivity_customer.class);

rk.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEA
R_TASK);
startActivity(rk);
Toast.makeText(MainActivity.this,"Logged in
congrats",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(MainActivity.this,"Some error in logging
in",Toast.LENGTH_SHORT).show();
email.setEnabled(true);
password.setEnabled(true);
progressBar.setVisibility(View.INVISIBLE);
}
}
});
}
}
}

6.2 Driver Login:-

Code:-

package com.eye_of_supreme_god.lord_radhekrishna.firebase_tester;

import android.content.Intent;
import android.os.Parcel;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskExecutors;
import com.google.firebase.FirebaseException;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import
com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;

26.
import java.util.concurrent.TimeUnit;

public class Driver_logger extends AppCompatActivity


{
private EditText phone_number,otp;
private Button login,submit;
private ProgressBar bar;
private FirebaseAuth mauth;
private String mVerificationId;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_driver_logger);

phone_number=(EditText)findViewById(R.id.phone_number);
otp=(EditText)findViewById(R.id.otp);
otp.setEnabled(false);
login=(Button)findViewById(R.id.loged_driver);
submit=(Button)findViewById(R.id.submit_2);
bar=(ProgressBar)findViewById(R.id.progressBar2);
mauth=FirebaseAuth.getInstance();

login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
String number="+91"+phone_number.getText().toString();
if(number.length()==13)
{
otp.setEnabled(true);
Toast.makeText(Driver_logger.this,"Now th next process will
occurr",Toast.LENGTH_SHORT).show();
submit.setVisibility(View.VISIBLE);
submit.setEnabled(true);
sendVerificationCode(number);
login.setVisibility(View.INVISIBLE);
login.setEnabled(false);
bar.setVisibility(View.VISIBLE);
}
else
{
phone_number.setError("please enter a valid number");
phone_number.requestFocus();
phone_number.setText("");
phone_number.setHint("Enter number without country code.");
}
}
});
submit.setEnabled(false);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{

27.
String otter=otp.getText().toString();
if(otter.length()<6)
{
otp.setError("Invalid otp");
otp.requestFocus();
otp.setText("");

return;
}
verifyVerificationCode(otter);
}
});
}
private void sendVerificationCode(String mobile)
{
PhoneAuthProvider.getInstance().verifyPhoneNumber(
mobile,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallbacks
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks
mCallbacks=new
PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential
phoneAuthCredential)
{
String code=phoneAuthCredential.getSmsCode();
if(code!=null)
{
otp.setText(code);
bar.setVisibility(View.VISIBLE);
verifyVerificationCode(code);
}
}

@Override
public void onVerificationFailed(FirebaseException e)
{
login.setVisibility(View.VISIBLE);
login.setEnabled(true);
submit.setEnabled(false);
submit.setVisibility(View.INVISIBLE);
otp.setEnabled(false);
bar.setVisibility(View.INVISIBLE);
Toast.makeText(Driver_logger.this,"Verification failed try
again",Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(String
s,PhoneAuthProvider.ForceResendingToken forceResendingToken)
{

28.
super.onCodeSent(s,forceResendingToken);
mVerificationId=s;
}
};
private void verifyVerificationCode(String otp)
{
PhoneAuthCredential
credential=PhoneAuthProvider.getCredential(mVerificationId,otp);
signInWithPhoneAuth(credential);
}
private void signInWithPhoneAuth(PhoneAuthCredential credential)
{
mauth.signInWithCredential(credential)
.addOnCompleteListener(Driver_logger.this, new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if(task.isSuccessful())
{
Intent rk=new
Intent(Driver_logger.this,MapsActivity.class);

rk.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEA
R_TASK);
startActivity(rk);
}
if(task.getException() instanceof
FirebaseAuthInvalidCredentialsException)
{
Toast.makeText(Driver_logger.this,"Invalid code
entered",Toast.LENGTH_SHORT).show();
otp.setText("");
otp.setHint("Invalid otp");

}
else
{
Toast.makeText(Driver_logger.this,"Something went wrong correct
again",Toast.LENGTH_SHORT).show();
login.setVisibility(View.VISIBLE);
login.setEnabled(true);
submit.setEnabled(false);
submit.setVisibility(View.INVISIBLE);
otp.setEnabled(false);
bar.setVisibility(View.INVISIBLE);
}
}
});
}
}

6.3MapsActivity Customer:-

29.
Code:-
package com.eye_of_supreme_god.lord_radhekrishna.firebase_tester;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
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.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.Dot;
import com.google.android.gms.maps.model.Gap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PatternItem;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.PolygonOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.iid.FirebaseInstanceId;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

30.
public class MapsActivity_customer extends FragmentActivity
implements OnMapReadyCallback
, GoogleApiClient.ConnectionCallbacks
, GoogleApiClient.OnConnectionFailedListener
,
com.google.android.gms.location.LocationListener,View.OnClickListen
er

,GoogleMap.OnPolylineClickListener,GoogleMap.OnPolygonClickListener
{

private GoogleMap mMap;


private GoogleApiClient googleApiClient;
private Location lastLocation;
private LocationRequest locationRequest;
private Button setting,logout;
private FirebaseAuth mauth;
private FirebaseUser currentUser;
private String uid2;
private EditText address;
private Boolean bob_the_builder=false;
private Button call_Car;
private Location location_destination ;
private LatLng lat_lang_dest;
private DatabaseReference
reference2,reference_destination,drivers2;
private Button goer;
//things for charge sheet
private RelativeLayout charger;
private BottomSheetBehavior behavior;
private TextView cost;
private Button confirm,decline;
private final int charge_per_km=15;
private ArrayList<distancer_class> distance_of_taxi;
private ArrayList<distancer_class> preference_drivers;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps_customer);
// 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);

setting=(Button)findViewById(R.id.setting2);
logout=(Button)findViewById(R.id.get_out2);
goer=(Button)findViewById(R.id.gogo);
goer.setOnClickListener(this);
mauth=FirebaseAuth.getInstance();
currentUser=mauth.getCurrentUser();
uid2=currentUser.getUid();

reference2=FirebaseDatabase.getInstance().getReference().child("Cus

31.
tomer Request");
reference_destination=FirebaseDatabase.getInstance().getReference()
.child("Destinations");

drivers2=FirebaseDatabase.getInstance().getReference().child("Drive
rs");

charger=(RelativeLayout)findViewById(R.id.charger45);
behavior=BottomSheetBehavior.from(charger);
cost=(TextView)findViewById(R.id.charger_taxi);
confirm=(Button)findViewById(R.id.accepter);
decline=(Button)findViewById(R.id.decliner);

distance_of_taxi=new ArrayList<>();
preference_drivers=new ArrayList<>();

confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
booker_driver();
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
address.setText("");
address.setError("destination denied..");
}
});
call_Car=(Button)findViewById(R.id.call_car);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
bob_the_builder=true;
Driver_logout();
mauth.signOut();
LogoutDriver();
}
});
call_Car.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
DatabaseReference reference3=reference2.child(uid2);
reference3.setValue(lastLocation);
LatLng latLng=new
LatLng(lastLocation.getLatitude(),lastLocation.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("I am
here"));
call_Car.setText("Getting you a taxi...");
}

32.
});

}
private void LogoutDriver()
{
Intent rk=new
Intent(MapsActivity_customer.this,mainScreen.class);

rk.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEA
R_TASK);
startActivity(rk);
finish();
}

/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or
move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the
user will be prompted to install
* it inside the SupportMapFragment. This method will only be
triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
try {
mMap = googleMap;

if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}
catch (Exception e)
{
Toast.makeText(MapsActivity_customer.this,"Some error
here 1",Toast.LENGTH_SHORT).show();
}

// Add a marker in Sydney and move the camera


}

@Override
public void onConnected(@Nullable Bundle bundle)
{
try{

33.
locationRequest = new LocationRequest();
locationRequest.setInterval(10000);
locationRequest.setFastestInterval(10000);

locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
;
dataReader();
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,

Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
//openSettings();
return;
}

LocationServices.FusedLocationApi.requestLocationUpdates(googleApiC
lient,
locationRequest, this);
}
catch (Exception e)
{
Toast.makeText(MapsActivity_customer.this,
"Some error in location
request",Toast.LENGTH_SHORT).show();
}

@Override
public void onConnectionSuspended(int i)
{

@Override
public void onConnectionFailed(@NonNull ConnectionResult
connectionResult)
{

@Override
public void onLocationChanged(Location location)
{
try {
lastLocation = location;
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(12));

String

34.
uid=FirebaseAuth.getInstance().getCurrentUser().getUid().toString()
;
DatabaseReference
databaseReference=FirebaseDatabase.getInstance().getReference()
.child("Customers");
DatabaseReference myRef=databaseReference.child(uid);
myRef.setValue(location);
// GeoFire geoFire=new GeoFire(databaseReference);
// geoFire.setLocation(uid,new
GeoLocation(location.getLatitude(),location.getLongitude()));
//
Toast.makeText(MapsActivity.this,uid,Toast.LENGTH_SHORT).show();

}
catch (Exception e)
{
// Toast.makeText(MapsActivity.this,"Some error here
3",Toast.LENGTH_SHORT).show();
//finish();
}
}

protected synchronized void buildGoogleApiClient()


{
try {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
googleApiClient.connect();
}
catch (Exception e)
{
Toast.makeText(MapsActivity_customer.this,"Some error
here",Toast.LENGTH_SHORT).show();
}
}

@Override
protected void onStop()
{
super.onStop();
if(!bob_the_builder)
{
Driver_logout();
}
}
private void Driver_logout()
{
String
uid=FirebaseAuth.getInstance().getCurrentUser().getUid().toString()
;
DatabaseReference
databaseReference=FirebaseDatabase.getInstance().getReference()

35.
.child("Customers");
DatabaseReference myRef=databaseReference.child(uid);
DatabaseReference childer=myRef.child("latitude");
childer.setValue("null");
}

@Override
public void onClick(View v)
{

switch (v.getId())
{
case R.id.gogo:
{
address=(EditText)findViewById(R.id.search_place);
if(TextUtils.isEmpty(address.getText().toString()))
{
return;
}
String address2=address.getText().toString();
if(address2.contains("Bhopal"))
{

}
else
{
address2=address2+",bhopal";
}
List<Address> addressList=null;
MarkerOptions markerOptions=new MarkerOptions();
Geocoder geocoder=new Geocoder(this);
mMap.clear();
try
{
addressList=geocoder.getFromLocationName(address2,7);
if(addressList!=null)
{
for(int i=0;i<addressList.size();i++)
{
Address address_user=addressList.get(i);
LatLng latLng_options=new
LatLng(address_user.getLatitude(),address_user.getLongitude());
lat_lang_dest=latLng_options;
markerOptions.title(address_user.toString());
markerOptions.position(latLng_options);

markerOptions.icon(BitmapDescriptorFactory.defaultMarker
(BitmapDescriptorFactory.HUE_ORANGE));

double dister=distance(((double)
lastLocation.getLatitude()),
((double)lastLocation.getLongitude()),

((double)latLng_options.latitude),((double)latLng_options.longitude
));

36.
LatLng last_latlng=new
LatLng(lastLocation.getLatitude(),lastLocation.getLongitude());

mMap.addMarker(markerOptions);

mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng_options));
mMap.animateCamera(CameraUpdateFactory.zoomTo(9));
drawPolyLine(latLng_options,last_latlng);
dataReader();
createDialoger(dister);
Toast.makeText(MapsActivity_customer.this,"Distance
is"+String.valueOf(dister),
Toast.LENGTH_LONG).show();
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}

}
}

private void createDialoger(double dister)


{
double cost_final=(double)charge_per_km*dister;
long cost_final2=(long)cost_final;
cost.setText("Rs"+String.valueOf(cost_final2));
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);

private void drawPolyLine(LatLng l1,LatLng l2)


{
Polyline polyline=mMap.addPolyline(new PolylineOptions()
.clickable(true).add(l1,l2));
polyline.setTag("travel route");
polyline.setColor(Color.GRAY);
PatternItem Dot=new Dot();
PatternItem gap=new Gap(12);
List<PatternItem> list=Arrays.asList(Dot,gap);
polyline.setPattern(list);

}
private double distance(double lat1,double lon1,double
lat2,double lon2)
{
double theta=lon1-lon2;
double dist=Math.sin(deg2rad(lat1))*Math.sin(deg2rad(lat2))+

Math.cos(deg2rad(lat1))*Math.cos(deg2rad(lat2))*Math.cos(deg2rad(th
eta));
dist=Math.acos(dist);

37.
dist=rad2deg(dist);
dist=dist*60*1.1515;
return (dist);
}
private double deg2rad(double deg)
{
return (deg*Math.PI/180.0);
}
private double rad2deg(double rad)
{
return (rad*180.0/Math.PI);
}

@Override
public void onPolygonClick(Polygon polygon) {

@Override
public void onPolylineClick(Polyline polyline) {

}
public void dataReader()
{
drivers2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot
dataSnapshot)
{
for(DataSnapshot snapshot:dataSnapshot.getChildren())
{
// String
latitude=snapshot.child("Latitude").getValue().toString();
String
latitude=snapshot.child("latitude").getValue().toString();
if(latitude.equals("null"))
{
continue;
}
String
logitude=snapshot.child("longitude").getValue().toString();
double latti=Double.valueOf(latitude);
double loggi=Double.valueOf(logitude);
LatLng latLnger=new
LatLng(lastLocation.getLatitude(),lastLocation.getLongitude());
double
distncer_between=distance(latti,loggi,lastLocation.getLatitude(),la
stLocation.getLongitude());
int final_distance=(int)distncer_between;
distance_of_taxi.add(new
distancer_class(final_distance,snapshot.getKey().toString(),latti,l
oggi));
customMarker(new LatLng(latti,loggi));

38.
Toast.makeText(MapsActivity_customer.this,String.valueOf(distance_o
f_taxi.size()),
Toast.LENGTH_SHORT).show();
}

@Override
public void onCancelled(@NonNull DatabaseError
databaseError) {
Toast.makeText(MapsActivity_customer.this,"Some error
occureed",
Toast.LENGTH_SHORT).show();

}
});
}
public void customMarker(LatLng latter)
{
mMap.addMarker(new MarkerOptions().position(latter)

.title("Driver").icon(BitmapDescriptorFactory.fromResource(R.drawab
le.taxi_taxi)));
}
public void booker_driver()
{
int i=0;
distancer_class ins=distance_of_taxi.get(i);
LatLng latLng_user=new
LatLng(lastLocation.getLatitude(),lastLocation.getLongitude());
LatLng latLng_driver=new
LatLng(ins.getLatitude(),ins.getLogitude());
Polyline polyline=mMap.addPolyline(new PolylineOptions()
.add(latLng_user,latLng_driver).clickable(true));
polyline.setTag("Distance between driver and user");
polyline.setColor(Color.RED);
PatternItem Dot=new Dot();
PatternItem gap=new Gap(12);
List<PatternItem> list=Arrays.asList(Dot,gap);
polyline.setPattern(list);

}
}

6.4MapsActivity Driver:-

Code:-
package com.eye_of_supreme_god.lord_radhekrishna.firebase_tester;

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;

39.
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.firebase.geofire.GeoFire;
import com.firebase.geofire.GeoLocation;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
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.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class MapsActivity extends FragmentActivity implements


OnMapReadyCallback
, GoogleApiClient.ConnectionCallbacks
, GoogleApiClient.OnConnectionFailedListener
, com.google.android.gms.location.LocationListener {
//current location od driver is not working yet using GeoFire check
that
private GoogleMap mMap;
private GoogleApiClient googleApiClient;
private Location lastLocation;
private LocationRequest locationRequest;
private Button setting,logout;
private FirebaseAuth mauth;
private FirebaseUser currentUser;
private Boolean bob_the_builder=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// 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);

setting=(Button)findViewById(R.id.setting);

40.
logout=(Button)findViewById(R.id.get_out);
mauth=FirebaseAuth.getInstance();
currentUser=mauth.getCurrentUser();

logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
bob_the_builder=true;

Driver_logout();

mauth.signOut();
LogoutDriver();
}
});
}
private void LogoutDriver()
{
Intent rk=new Intent(MapsActivity.this,mainScreen.class);

rk.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEA
R_TASK);
startActivity(rk);
finish();
}

/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or
move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the
user will be prompted to install
* it inside the SupportMapFragment. This method will only be
triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
try {
mMap = googleMap;

if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}

41.
catch (Exception e)
{
Toast.makeText(MapsActivity.this,"Some error here
1",Toast.LENGTH_SHORT).show();
}
}

@Override
public void onConnected(@Nullable Bundle bundle) {
try{
locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);

locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
;

if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION)
!=
PackageManager.PERMISSION_GRANTED) {
//openSettings();
return;
}

LocationServices.FusedLocationApi.requestLocationUpdates(googleApiC
lient,
locationRequest, this);
}
catch (Exception e)
{
Toast.makeText(MapsActivity.this,"Some error in location
request",Toast.LENGTH_SHORT).show();
}
}

@Override
public void onConnectionSuspended(int i) {

@Override
public void onConnectionFailed(@NonNull ConnectionResult
connectionResult) {

@Override
public void onLocationChanged(Location location)
{
try {
lastLocation = location;

42.
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(12));

String
uid=FirebaseAuth.getInstance().getCurrentUser().getUid().toString()
;
DatabaseReference
databaseReference=FirebaseDatabase.getInstance().getReference()
.child("Drivers");
DatabaseReference myRef=databaseReference.child(uid);
myRef.setValue(location);
// GeoFire geoFire=new GeoFire(databaseReference);
// geoFire.setLocation(uid,new
GeoLocation(location.getLatitude(),location.getLongitude()));
//
Toast.makeText(MapsActivity.this,uid,Toast.LENGTH_SHORT).show();

}
catch (Exception e)
{ Toast.makeText(MapsActivity.this,"Some error here
3",Toast.LENGTH_SHORT).show();
//finish();
}

}
protected synchronized void buildGoogleApiClient()
{
try {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
googleApiClient.connect();
}
catch (Exception e)
{
Toast.makeText(MapsActivity.this,"Some error
here",Toast.LENGTH_SHORT).show();
}
}

@Override
protected void onStop() {
super.onStop();

if(!bob_the_builder)
{
Driver_logout();
}
}
private void Driver_logout()

43.
{
String
uid=FirebaseAuth.getInstance().getCurrentUser().getUid().toString()
;
DatabaseReference
databaseReference=FirebaseDatabase.getInstance().getReference()
.child("Drivers");
DatabaseReference myRef=databaseReference.child(uid);
DatabaseReference childer=myRef.child("latitude");
childer.setValue("null");
googleApiClient.disconnect();
}

}
6.5Other codes:-

Code:-

package com.eye_of_supreme_god.lord_radhekrishna.firebase_tester;

public class distancer_class


{
int distance;
String key;
double latitude,logitude;
public distancer_class(int distance,String key,double
latitude,double logitude)
{
this.distance=distance;
this.key=key;
this.latitude=latitude;
this.logitude=logitude;
}

public int getDistance() {


return distance;
}

public double getLatitude() {


return latitude;
}

public double getLogitude() {


return logitude;
}

public String getKey() {


return key;
}
}

44.
Chapter 7 (ScreenShots):-

7.1 Database ScreenShots:-

1) Fire base realtime database screenshot:-

45.
2)Firebase authentication ScreenShot:-

7.2 App ScreenShots:-

46.
1.Opener Screen:-

47.
2.Login Driver Screen:-

48.
3.Login Customer Screen:-

49.
50.
51.
4.Verification Screen:-

52.
5.User MainActivity Screens:-

53.
6. Driver MainActivity Screens:-

54.
8. Other ScreenShots:-

55.
Chapter-8 (Future Enhancements):-

Currently Aetrio-Care Solutions is a native which has its scope limited to the
city of lakes.
Although their is no boundations on the vehicle part but i will try to
integrate the app to a server which is created by python in the near future
currently it is working on firebase as its database and it depends on it only
for the verification and all the purposes.

Also I would like make some more enhacements in the user interface of the
map give more choices to the user and also ulocking the options to eat while
having a ride .
When my app will be launched in some other states then their are even
greater plans in my mind about what modification i would like to make int
the app.

Currently it works on simple algorithms for its working but in the near
future it will be implementing more complex algorithms for its working .

Also I will be introducting a website of the app so that the persons which are
not having a android phone can instead use a website from any internet cafe
for the same purpose.

A couple of things. One is that I quickly realized that the future of Aetrio-
Care Solutions couldn’t be just about cars. That ultimately we had to
expand our scope from cars to broader mobility. And that cars in two
dimensions were at some point going to run out of scope for cities. And
that we have to really think about the solution in three dimensions and
with multi-modal [options].

So the switch for me was Aetrio-Care Solutions moving from being a


giant global car-sharing platform moving to a global A-to-B urban
mobility platform. And as I sat down with my team and looked at the
various solutions and the various projects that we had in order to really
drive urban mobility for the next 20, 30 years, we felt that verticalization
and adding a dimension to urban mobility was a necessary ingredient of
a number of ingredients, including how we got into Jump bikes and we’ll
see where else we go. So it is part of the equation here.
56.
Chapter 9 (Biblography):-

Aetrio-Care Solutions Technologies Inc. is a transportation network


company (TNC) headquartered in . Aetrio-Care Solutions offers services
including peer-to-peer ridesharing, ride service hailing, food delivery, and
a bicycle-sharing system. The company has operations in 785 metropolitan
areas worldwide.[2] Its platforms can be accessed via its websites
and mobile apps. Aetrio-Care Solutions has been so prominent in
the sharing economy that the changes in industries as a result of it have
been referred to as Aetrio-Care Solutionsisation,[4][5][6] and many startups
have described their products as "Aetrio-Care Solutions for X".[7][8][9]
The name "Aetrio-Care Solutions" is a reference to the common (and
somewhat colloquial) word Aetrio-Care Solutions, meaning "topmost" or
"super", and having its origins in the German word über, cognate with over,
meaning "above".[10]
Aetrio-Care Solutions is estimated to have 100 million worldwide
users[11] and a 67.3% market share in the United States.[12]
Aetrio-Care Solutions is a gold member of the Linux Foundation[13] and has
a five star privacy rating from the Electronic Frontier Foundation.[14]
Most jurisdictions regulate TNCs and TNCs are banned from operating in
some jurisdictions. For more information, see Legality of TNCs by
jurisdiction.
The company generates 15% of its bookings from rides to or from an
airport.[1]

The Aetrio-Care Solutions app gives riders a quote for the fare before
they commit to the ride.[15] Aetrio-Care Solutions uses a dynamic
pricing model; prices for the same route vary based on the supply
and demand for rides at the time the ride is requested.[16] At the end
of the ride, payment is made based on the rider's pre-selected
preferences, which could be a credit card on file, Google Pay, Apple
Pay, cash, or, in India, Airtel mobile wallet[17] or Unified Payments
Interface.[18] After the ride is over, the rider is given the option to
provide a gratuity to the driver, which is also billed to the rider's
payment method.[19] In some locations, if the driver has to wait more
than a few minutes after arriving to the pickup location, riders are
charged a wait time fee.[20]
Aetrio-Care SolutionsX, the basic level of service, provides a private ride in
a standard car with driver for up to four passengers. Rider service levels,
many of which are only available in certain cities, include:[21]

 Aetrio-Care SolutionsASSIST provides additional assistance to senior


citizens and passengers with a physical
57. disability, but cannot transport a
non-folding wheelchair (see Aetrio-Care SolutionsWAV for wheelchair-
accessible vehicles).
 Aetrio-Care SolutionsAUTO, available in India, Sri Lanka and Pakistan,
provides transportation by auto rickshaw.[22][23]
 Aetrio-Care SolutionsBike is a dockless bicycle-sharing system that
allows users to rent electric bicycles via Aetrio-Care Solutions
subsidiary Jump Bikes in 9 metropolitan areas in the United States
including San Francisco and Washington, D.C.[24][25] Aetrio-Care
Solutions users are also able to rent Lime scooters in 46 cities via the
Aetrio-Care Solutions mobile app.[26]
 Aetrio-Care SolutionsBLACK provides a black luxury vehicle.
 Aetrio-Care SolutionsBOAT, a water-taxi service, provides speedboats
in the summer to/from points on the coast of Croatia.[27] Aetrio-Care
SolutionsBOAT has also offered transport across Biscayne Bay during
Miami Art Week[28][29] and across the Bosporus strait in Istanbul in the
summer.[30]
 Aetrio-Care SolutionsChapchap, available in Nairobi, Kenya is a low-
cost service offering transport via a Suzuki Alto, a kei car. "Chapchap"
means "faster" in the Swahili language.[31]
 Aetrio-Care SolutionsESPAÑOL is a version of Aetrio-Care SolutionsX
(see below) that allows Spanish-speaking riders to request Spanish-
speaking drivers.[32]
 Aetrio-Care SolutionsFLASH, available in Singapore, is a service that
combines both private cars and ComfortDelGro taxis.[33]
 Aetrio-Care SolutionsGO, available in India and Sri Lanka, provides for
a ride in a hatchback.[34]
 Aetrio-Care SolutionsHealth is a HIPAA-compliant method for health
professionals to arrange

Chapter 10 (References):-

1. Firebase (www.firebase.com)
2. Android developers(www.android.co.us.com)
3. Google Map Api (www.google.com)
Thank you

58.

Potrebbero piacerti anche