Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SERVICE APP
A Major Project
Submitted in Partial fulfillment of the requirements for the
degree of Bachelor of Engineering in Computer Science
Submitted to
Submitted By:
\
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.)
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.
This is to certify that the above statement made by the candidate/s is correct to the
best the best of my knowledge.
Countersigned by
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 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
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
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
1. Price efficiency
2. Transparency
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.
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.
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.
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.
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)
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.
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):-
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
Demand service
• The Demand Service tracks the GPS location of the user when
requested
DISCO — DISPATCH optimization
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.
16.
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.
18.
GeoSpatial design:
So Aetrio-Care Solutions divides the earth into tiny cells using the
Google S2 library. Each cell has a unique cell ID.
The read load is scaled through the use of replicas. If more read
capacity is needed the replica factor can be increased.
that means disco should track the cabs available to ride the riders.
for example:
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.
20.
00
The edge weights represent a metric of interest: often either the
road
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.
Databases:
Redis is used a lot. Some are behind Twemproxy. Some are behind
a custom clustering system.
22.
Chapter 6(Coding):-
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;
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);
}
}
});
}
}
}
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;
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
{
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();
}
@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();
}
}
@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 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;
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;
44.
Chapter 7 (ScreenShots):-
45.
2)Firebase authentication ScreenShot:-
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].
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]
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.