Test azimuth
This commit is contained in:
@@ -14,8 +14,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.BusRoute"
|
android:theme="@style/Theme.BusRoute">
|
||||||
tools:targetApi="31">
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.Manifest
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
@@ -31,6 +32,7 @@ import org.osmdroid.util.GeoPoint
|
|||||||
import org.osmdroid.views.MapView
|
import org.osmdroid.views.MapView
|
||||||
import org.osmdroid.views.overlay.Marker
|
import org.osmdroid.views.overlay.Marker
|
||||||
import org.osmdroid.views.overlay.compass.CompassOverlay
|
import org.osmdroid.views.overlay.compass.CompassOverlay
|
||||||
|
import org.osmdroid.views.overlay.compass.IOrientationProvider
|
||||||
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
|
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
|
||||||
import org.osmdroid.views.overlay.gestures.RotationGestureOverlay
|
import org.osmdroid.views.overlay.gestures.RotationGestureOverlay
|
||||||
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider
|
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider
|
||||||
@@ -53,6 +55,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private var latitude = 0.0
|
private var latitude = 0.0
|
||||||
private var longitude = 0.0
|
private var longitude = 0.0
|
||||||
|
private var navigationEnable = false
|
||||||
private var busStopList: ArrayList<BusStop> = ArrayList()
|
private var busStopList: ArrayList<BusStop> = ArrayList()
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
@@ -60,6 +63,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
isLocationPermissionGranted()
|
isLocationPermissionGranted()
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
val dbHelper = DbHelper(this)
|
val dbHelper = DbHelper(this)
|
||||||
val tts = TextToSpeech(this, TextToSpeech.OnInitListener{})
|
val tts = TextToSpeech(this, TextToSpeech.OnInitListener{})
|
||||||
tts.setVoice(Voice("French",
|
tts.setVoice(Voice("French",
|
||||||
@@ -142,6 +146,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
latitude = location.latitude
|
latitude = location.latitude
|
||||||
longitude = location.longitude
|
longitude = location.longitude
|
||||||
mapController.animateTo(GeoPoint(latitude, longitude))
|
mapController.animateTo(GeoPoint(latitude, longitude))
|
||||||
|
if(navigationEnable){
|
||||||
|
map.mapOrientation = -compassOverlay.azimuthOffset
|
||||||
|
}
|
||||||
|
|
||||||
findViewById<TextView>(R.id.accuracy).text = "${location.accuracy} %"
|
findViewById<TextView>(R.id.accuracy).text = "${location.accuracy} %"
|
||||||
}
|
}
|
||||||
@@ -151,8 +158,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
map.overlays.add(locationOverlay)
|
map.overlays.add(locationOverlay)
|
||||||
val roadButton = findViewById<Button>(R.id.road)
|
val roadButton = findViewById<Button>(R.id.road)
|
||||||
roadButton.setOnClickListener {
|
roadButton.setOnClickListener {
|
||||||
tts.speak("Dans 500 mètres, tourner à droite", TextToSpeech.QUEUE_FLUSH, null,"")
|
navigationEnable = true
|
||||||
locationOverlay.disableMyLocation()
|
tts.speak("Début de l'itinéraire", TextToSpeech.QUEUE_FLUSH, null,"")
|
||||||
RetrieveRoad(map, latitude,longitude, roadButton.context).execute()
|
RetrieveRoad(map, latitude,longitude, roadButton.context).execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,11 +67,12 @@ class RetrieveRoad(private var map: MapView,
|
|||||||
nodeMarker.title = "Step $i"
|
nodeMarker.title = "Step $i"
|
||||||
nodeMarker.snippet = node.mInstructions
|
nodeMarker.snippet = node.mInstructions
|
||||||
nodeMarker.subDescription = Road.getLengthDurationText(context, node.mLength, node.mDuration)
|
nodeMarker.subDescription = Road.getLengthDurationText(context, node.mLength, node.mDuration)
|
||||||
val id: Int? = icons.get(node.mManeuverType)
|
var id: Int? = icons.get(node.mManeuverType)
|
||||||
if (id != null){
|
if (id == null){
|
||||||
val icon: Drawable? = context.getDrawable(id)
|
id = icons.get(1)
|
||||||
nodeMarker.image = icon
|
|
||||||
}
|
}
|
||||||
|
val icon: Drawable? = context.getDrawable(id!!)
|
||||||
|
nodeMarker.image = icon
|
||||||
map.overlays.add(nodeMarker)
|
map.overlays.add(nodeMarker)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in New Issue
Block a user