Before TomTom Routing
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
||||
applicationId = "com.kouros.navigation"
|
||||
minSdk = 33
|
||||
targetSdk = 36
|
||||
versionCode = 28
|
||||
versionName = "0.1.3.28"
|
||||
versionCode = 32
|
||||
versionName = "0.1.3.32"
|
||||
base.archivesName = "navi-$versionName"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kouros.navigation.di
|
||||
|
||||
import com.kouros.navigation.data.NavigationRepository
|
||||
import com.kouros.navigation.data.osrm.OsrmRepository
|
||||
import com.kouros.navigation.data.tomtom.TomTomRepository
|
||||
import com.kouros.navigation.data.valhalla.ValhallaRepository
|
||||
import com.kouros.navigation.model.BaseStyleModel
|
||||
import com.kouros.navigation.model.ViewModel
|
||||
@@ -14,4 +15,5 @@ val appModule = module {
|
||||
viewModelOf(::ViewModel)
|
||||
singleOf(::ValhallaRepository)
|
||||
singleOf(::OsrmRepository)
|
||||
singleOf(::TomTomRepository)
|
||||
}
|
||||
@@ -78,6 +78,8 @@ class MainActivity : ComponentActivity() {
|
||||
val routeModel = RouteModel()
|
||||
var tilt = 50.0
|
||||
val useMock = false
|
||||
|
||||
var currentIndex = 0
|
||||
val stepData: MutableLiveData<StepData> by lazy {
|
||||
MutableLiveData<StepData>()
|
||||
}
|
||||
@@ -113,7 +115,7 @@ class MainActivity : ComponentActivity() {
|
||||
lateinit var baseStyle: BaseStyle.Json
|
||||
|
||||
init {
|
||||
navigationViewModel.route.observe(this, observer)
|
||||
|
||||
}
|
||||
|
||||
@RequiresPermission(allOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION])
|
||||
@@ -127,13 +129,14 @@ class MainActivity : ComponentActivity() {
|
||||
locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
|
||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
||||
fusedLocationClient.lastLocation
|
||||
.addOnSuccessListener { location: android.location.Location? ->
|
||||
.addOnSuccessListener { _: android.location.Location? ->
|
||||
if (useMock) {
|
||||
mock = MockLocation(locationManager)
|
||||
mock.setMockLocation(
|
||||
homeHohenwaldeck.latitude,
|
||||
homeHohenwaldeck.longitude
|
||||
homeVogelhart.latitude,
|
||||
homeVogelhart.longitude
|
||||
)
|
||||
navigationViewModel.route.observe(this, observer)
|
||||
}
|
||||
}
|
||||
enableEdgeToEdge()
|
||||
@@ -156,7 +159,12 @@ class MainActivity : ComponentActivity() {
|
||||
Content()
|
||||
// auto navigate
|
||||
if (useMock) {
|
||||
navigationViewModel.loadRoute(applicationContext, homeHohenwaldeck, homeVogelhart, 0F)
|
||||
navigationViewModel.loadRoute(
|
||||
applicationContext,
|
||||
homeVogelhart,
|
||||
homeHohenwaldeck,
|
||||
0F
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -177,7 +185,7 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
val userLocationState = rememberUserLocationState(locationProvider)
|
||||
val locationState = locationProvider.location.collectAsState()
|
||||
updateLocation(locationState.value)
|
||||
updateLocation(locationState.value)
|
||||
var latitude by remember { mutableDoubleStateOf(0.0) }
|
||||
if (locationState.value != null) {
|
||||
latitude = locationState.value!!.position.latitude
|
||||
@@ -249,6 +257,9 @@ class MainActivity : ComponentActivity() {
|
||||
&& lastLocation.longitude != location.position.longitude
|
||||
) {
|
||||
val currentLocation = location(location.position.longitude, location.position.latitude)
|
||||
// if (currentIndex == 0)
|
||||
// navigationViewModel.loadTraffic(applicationContext, currentLocation, 0f)
|
||||
// currentIndex = 1
|
||||
val bearing = bearing(lastLocation, currentLocation, cameraPosition.value!!.bearing)
|
||||
with(routeModel) {
|
||||
if (isNavigating()) {
|
||||
@@ -326,7 +337,7 @@ class MainActivity : ComponentActivity() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
for ((index, waypoint) in routeModel.curRoute.waypoints.withIndex()) {
|
||||
if (routeModel.isNavigating()) {
|
||||
var deviation = 0.0
|
||||
val deviation = 0.0
|
||||
if (index in 0..routeModel.curRoute.waypoints.size) {
|
||||
mock.setMockLocation(waypoint[1] + deviation, waypoint[0])
|
||||
delay(500L) //
|
||||
@@ -359,9 +370,10 @@ class MainActivity : ComponentActivity() {
|
||||
fun test2() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
// Balanstr.
|
||||
mock.setMockLocation( 48.119357, 11.599130)
|
||||
mock.setMockLocation(48.119357, 11.599130)
|
||||
}
|
||||
}
|
||||
|
||||
fun gpx(context: Context) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val parser = GPXParser()
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.kouros.navigation.car.map.MapLibre
|
||||
import com.kouros.navigation.car.map.NavigationImage
|
||||
import com.kouros.navigation.car.map.rememberBaseStyle
|
||||
import com.kouros.navigation.data.StepData
|
||||
import com.kouros.navigation.data.tomtom.TrafficData
|
||||
import org.maplibre.compose.camera.CameraPosition
|
||||
import org.maplibre.compose.camera.rememberCameraState
|
||||
import org.maplibre.compose.location.LocationTrackingEffect
|
||||
@@ -65,6 +66,7 @@ fun MapView(
|
||||
cameraState,
|
||||
rememberBaseStyle,
|
||||
route,
|
||||
emptyMap(),
|
||||
ViewStyle.VIEW
|
||||
)
|
||||
LocationTrackingEffect(
|
||||
|
||||
@@ -28,6 +28,10 @@ fun NavigationInfo(step: StepData?, nextStep: StepData?) {
|
||||
contentDescription = stringResource(id = R.string.accept_action_title),
|
||||
modifier = Modifier.size(48.dp, 48.dp),
|
||||
)
|
||||
if (step.currentManeuverType == 46
|
||||
|| step.currentManeuverType == 45) {
|
||||
Text(text ="Exit ${step.exitNumber}", fontSize = 20.sp)
|
||||
}
|
||||
Column {
|
||||
if (step.leftStepDistance < 1000) {
|
||||
Text(text = "${step.leftStepDistance.toInt()} m", fontSize = 25.sp)
|
||||
|
||||
@@ -57,6 +57,15 @@ fun NavigationSheet(
|
||||
modifier = Modifier.size(24.dp, 24.dp),
|
||||
)
|
||||
}
|
||||
Button(onClick = {
|
||||
simulateNavigation()
|
||||
}) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_zoom_in_24),
|
||||
"Stop",
|
||||
modifier = Modifier.size(24.dp, 24.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.size(30.dp))
|
||||
if (!routeModel.isNavigating()) {
|
||||
|
||||
Reference in New Issue
Block a user