Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
24 changes: 24 additions & 0 deletions app/src/debug/res/values/google_maps_api.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.

To get one, follow this link, follow the directions and press "Create" at the end:

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=55:E4:D9:41:CF:79:BD:0A:5F:BF:B2:C9:44:4A:D7:1E:4C:4C:DB:48%3Bcom.example.services

You can also add your credentials to an existing key, using these values:

Package name:
com.example.services

SHA-1 certificate fingerprint:
55:E4:D9:41:CF:79:BD:0A:5F:BF:B2:C9:44:4A:D7:1E:4C:4C:DB:48

Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key

Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyBC5wcRatVjF7pZ8jvEUl8sfau5bK0v0cI</string>
</resources>
47 changes: 33 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.services">

<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the "MyLocation" functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<application
android:allowBackup="true"
Expand All @@ -15,42 +21,55 @@
android:supportsRtl="true"
android:theme="@style/Theme.Services">

<service android:name=".FirebaseService"
android:permission= "com.google.android.c2dm.permission.SEND">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps"></activity>

<service
android:name=".FirebaseService"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>

<activity
android:name=".messages.ChatActivity"
android:windowSoftInputMode="adjustPan" />

<activity android:name=".CallWorkerActivity" />

<activity android:name=".WorkSelectActivity" />

<activity
android:name=".ProviderRegisterActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".HomeActivity" />

<activity android:name=".signInRegister.SignInActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".signInRegister.SignupActivity"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".account.Edit_profile"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".account.ContactUsActivity" />

<activity android:name=".account.Edit_profile"
android:windowSoftInputMode="adjustResize"/>
<activity android:name=".account.ContactUsActivity"/>
<service
android:name=".notification.MyFirebaseMessagingService"
android:exported="false">
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/example/services/CallWorkerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.google.firebase.database.FirebaseDatabase
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_call_worker.*
import java.util.*
import com.example.services.MapsActivity

class CallWorkerActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -27,7 +28,12 @@ class CallWorkerActivity : AppCompatActivity() {
}else{
Picasso.get().load(user.profileImgURL).into(user_pic)
}
user_city.setOnClickListener {

var intent=Intent(this,MapsActivity::class.java)
startActivity(intent)

}
worker_phone_call.setOnClickListener{
makeCall(user.phone)
}
Expand Down
150 changes: 150 additions & 0 deletions app/src/main/java/com/example/services/MapsActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.example.services

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.core.app.ActivityCompat

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.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import java.lang.Exception

class MapsActivity : AppCompatActivity(), OnMapReadyCallback {

private lateinit var mMap: GoogleMap

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_maps)
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
val mapFragment = supportFragmentManager
.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
getuserlocation()
}

/**
* 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 fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap

// Add a marker in Sydney and move the camera

}


fun getuserlocation(){
Toast.makeText(this,"PermissionGranted", Toast.LENGTH_LONG).show()
Toast.makeText(this,"Loading Real Time Location",Toast.LENGTH_LONG).show()
var mylocation=MylocationListner()
var locationmanger= getSystemService(Context.LOCATION_SERVICE) as LocationManager


if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return
}
locationmanger.requestLocationUpdates(LocationManager.GPS_PROVIDER,3,3f,mylocation)
var myth=myThread()
myth.start()
}


/**
* 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.
*/

var local: Location?=null
inner class MylocationListner: LocationListener {


constructor(){
local= Location("Start")
local!!.latitude=0.0
local!!.longitude=0.0

}


override fun onLocationChanged(location: Location) {

local=location

}

}
var oldlocation: Location?=null
inner class myThread:Thread{
constructor():super(){
oldlocation= Location("Start")
oldlocation!!.latitude=0.0
oldlocation!!.longitude=0.0
}

override fun run() {
while (true){
try {

if(oldlocation!!.distanceTo(local)==0f){
continue
}
oldlocation=local
runOnUiThread(){
mMap.clear()

var jhansi = LatLng(local!!.latitude, local!!.longitude)
mMap!!.addMarker(
MarkerOptions()
.position(jhansi)
.snippet("your location")
.title("me")

)
mMap.moveCamera (CameraUpdateFactory.newLatLngZoom(jhansi, 16f))

}
Thread.sleep(1000)
}
catch (ex: Exception){}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.example.services.signInRegister

import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Typeface.BOLD
import android.location.LocationManager
import android.os.Build
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableString
Expand All @@ -15,6 +20,7 @@ import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.example.services.R
import com.example.services.shared.GetCurrentUser
import com.google.firebase.auth.FirebaseAuth
Expand Down Expand Up @@ -50,8 +56,61 @@ class SignInActivity : AppCompatActivity() {
string.setSpan(click, 23, 30, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView6.text = string;
textView6.movementMethod = LinkMovementMethod.getInstance();
checkPermission()
}
var Accesslocation=0
fun checkPermission(){
if(Build.VERSION.SDK_INT>=23){
if (ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED){
requestPermissions(arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION),Accesslocation)
return
}
}
getuserlocation()


}
fun getuserlocation(){
Toast.makeText(this,"PermissionGranted", Toast.LENGTH_LONG).show()



if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return
}

}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
when(requestCode){
Accesslocation->{
if (grantResults[0]== PackageManager.PERMISSION_GRANTED){
getuserlocation()
}
else{
Toast.makeText(this,"User Location Access On", Toast.LENGTH_LONG).show()
}
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
private fun performLogin(){
val email = findViewById<EditText>(R.id.email_login).text
val password = findViewById<EditText>(R.id.password_login).text
Expand All @@ -70,6 +129,5 @@ class SignInActivity : AppCompatActivity() {
Toast.makeText(this, "Login Failed", Toast.LENGTH_LONG).show();
}
}

}

9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_maps.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
Loading