Compare commits
4 Commits
90010d91b7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ca450cd10 | ||
|
|
94d6d6d311 | ||
|
|
d81d33df43 | ||
|
|
5317a14fb3 |
@@ -17,8 +17,8 @@ android {
|
|||||||
applicationId = "com.kouros.navigation"
|
applicationId = "com.kouros.navigation"
|
||||||
minSdk = 33
|
minSdk = 33
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 84
|
versionCode = 87
|
||||||
versionName = "0.2.0.84"
|
versionName = "0.2.0.87"
|
||||||
base.archivesName = "navi-$versionName"
|
base.archivesName = "navi-$versionName"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,13 +472,13 @@ class NavigationSession : Session(), NavigationListener, NavigationObserverCallb
|
|||||||
val streetName = routeModel.currentStep().street
|
val streetName = routeModel.currentStep().street
|
||||||
val currentDate = LocalDateTime.now(ZoneOffset.UTC)
|
val currentDate = LocalDateTime.now(ZoneOffset.UTC)
|
||||||
|
|
||||||
|
snapLocation(location, streetName)
|
||||||
|
|
||||||
checkTraffic(currentDate, location)
|
checkTraffic(currentDate, location)
|
||||||
updateSpeedCamera(location)
|
updateSpeedCamera(location)
|
||||||
checkRoute(currentDate, location)
|
checkRoute(currentDate, location)
|
||||||
checkArrival()
|
|
||||||
updateNavigationScreen()
|
updateNavigationScreen()
|
||||||
|
checkArrival()
|
||||||
snapLocation(location, streetName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -508,7 +508,7 @@ class NavigationSession : Session(), NavigationListener, NavigationObserverCallb
|
|||||||
* Updates the navigation screen with new trip information.
|
* Updates the navigation screen with new trip information.
|
||||||
*/
|
*/
|
||||||
fun updateNavigationScreen() {
|
fun updateNavigationScreen() {
|
||||||
if (routeModel.navState.destination.name.isEmpty()
|
if (routeModel.isNavigating() && routeModel.navState.destination.name.isEmpty()
|
||||||
&& routeModel.navState.destination.street.isEmpty()) {
|
&& routeModel.navState.destination.street.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -568,6 +568,8 @@ class NavigationSession : Session(), NavigationListener, NavigationObserverCallb
|
|||||||
settingsViewModel.onLastRouteChanged("")
|
settingsViewModel.onLastRouteChanged("")
|
||||||
routeModel.navState = routeModel.navState.copy(arrived = true)
|
routeModel.navState = routeModel.navState.copy(arrived = true)
|
||||||
surfaceRenderer.routeData.value = ""
|
surfaceRenderer.routeData.value = ""
|
||||||
|
navigationScreen.navigationType = NavigationType.ARRIVAL
|
||||||
|
invalidateScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Simulation {
|
|||||||
if (routeModel.navState.route.isRouteValid()) {
|
if (routeModel.navState.route.isRouteValid()) {
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
gpxSimulation(routeModel, lifecycleScope, updateLocation)
|
gpxSimulation(routeModel, lifecycleScope, updateLocation)
|
||||||
|
//currentSimulation(routeModel, lifecycleScope, updateLocation)
|
||||||
} else {
|
} else {
|
||||||
currentSimulation(routeModel, lifecycleScope, updateLocation)
|
currentSimulation(routeModel, lifecycleScope, updateLocation)
|
||||||
}
|
}
|
||||||
@@ -46,24 +47,26 @@ class Simulation {
|
|||||||
var lastLocation = Location(LocationManager.FUSED_PROVIDER)
|
var lastLocation = Location(LocationManager.FUSED_PROVIDER)
|
||||||
var curBearing = 0f
|
var curBearing = 0f
|
||||||
simulationJob = lifecycleScope.launch {
|
simulationJob = lifecycleScope.launch {
|
||||||
for (point in points) {
|
for ((index, point) in points.withIndex()) {
|
||||||
val fakeLocation = Location(LocationManager.FUSED_PROVIDER).apply {
|
if (index >= 0) {
|
||||||
latitude = point[1]
|
val fakeLocation = Location(LocationManager.FUSED_PROVIDER).apply {
|
||||||
longitude = point[0]
|
latitude = point[1]
|
||||||
bearing = curBearing
|
longitude = point[0]
|
||||||
speedAccuracyMetersPerSecond = 1.0f // ~1 m/s
|
bearing = curBearing
|
||||||
speed = 13.0f // ~50 km/h
|
speedAccuracyMetersPerSecond = 1.0f // ~1 m/s
|
||||||
time = System.currentTimeMillis()
|
speed = 13.0f // ~50 km/h
|
||||||
elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos()
|
time = System.currentTimeMillis()
|
||||||
|
elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos()
|
||||||
|
}
|
||||||
|
curBearing = lastLocation.bearingTo(fakeLocation)
|
||||||
|
// Update your app's state as if a real GPS update occurred
|
||||||
|
updateLocation(fakeLocation)
|
||||||
|
// Wait before moving to the next point (e.g., every 1 second)
|
||||||
|
delay(1000)
|
||||||
|
lastLocation = fakeLocation
|
||||||
}
|
}
|
||||||
curBearing = lastLocation.bearingTo(fakeLocation)
|
|
||||||
// Update your app's state as if a real GPS update occurred
|
|
||||||
updateLocation(fakeLocation)
|
|
||||||
// Wait before moving to the next point (e.g., every 1 second)
|
|
||||||
delay(1000)
|
|
||||||
lastLocation = fakeLocation
|
|
||||||
}
|
}
|
||||||
routeModel.stopNavigation()
|
// routeModel.stopNavigation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +120,7 @@ class Simulation {
|
|||||||
if (duration > 100) {
|
if (duration > 100) {
|
||||||
// delay(duration / 4)
|
// delay(duration / 4)
|
||||||
}
|
}
|
||||||
delay(1000)
|
delay(500)
|
||||||
lastTime = p.time
|
lastTime = p.time
|
||||||
lastLocation = fakeLocation
|
lastLocation = fakeLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
package com.kouros.navigation.car.screen
|
package com.kouros.navigation.car.screen
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.location.Location
|
|
||||||
import android.location.LocationManager
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Build.VERSION_CODES
|
|
||||||
import android.os.CountDownTimer
|
import android.os.CountDownTimer
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import androidx.car.app.CarContext
|
import androidx.car.app.CarContext
|
||||||
@@ -35,7 +29,6 @@ import androidx.lifecycle.Observer
|
|||||||
import androidx.lifecycle.asLiveData
|
import androidx.lifecycle.asLiveData
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.kouros.data.R
|
import com.kouros.data.R
|
||||||
import com.kouros.navigation.car.NavigationNotificationService
|
|
||||||
import com.kouros.navigation.car.SurfaceRenderer
|
import com.kouros.navigation.car.SurfaceRenderer
|
||||||
import com.kouros.navigation.car.screen.settings.SettingsScreen
|
import com.kouros.navigation.car.screen.settings.SettingsScreen
|
||||||
import com.kouros.navigation.data.Constants
|
import com.kouros.navigation.data.Constants
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.graphics.Bitmap
|
|||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
|
import android.graphics.Paint
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.car.app.model.CarIcon
|
import androidx.car.app.model.CarIcon
|
||||||
import androidx.car.app.navigation.model.LaneDirection
|
import androidx.car.app.navigation.model.LaneDirection
|
||||||
@@ -181,13 +182,17 @@ class IconMapper {
|
|||||||
bitmaps.first().height,
|
bitmaps.first().height,
|
||||||
bitmaps.first().config!!
|
bitmaps.first().config!!
|
||||||
)
|
)
|
||||||
|
val paint = Paint().apply {
|
||||||
|
color = android.graphics.Color.YELLOW
|
||||||
|
}
|
||||||
val canvas = Canvas(bmOverlay)
|
val canvas = Canvas(bmOverlay)
|
||||||
canvas.drawBitmap(bitmaps.first(), matrix, null)
|
canvas.drawBitmap(bitmaps.first(), matrix, paint)
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
||||||
bitmaps.forEach { bitmap ->
|
bitmaps.forEach { bitmap ->
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
matrix.setTranslate(i * 45F, 0F)
|
matrix.setTranslate(i * 45F, 0F)
|
||||||
canvas.drawBitmap(bitmap, matrix, null)
|
canvas.drawBitmap(bitmap, matrix, paint)
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ fun duration(
|
|||||||
val cameraDuration = if ((lastBearing - bearing).absoluteValue > 20.0) {
|
val cameraDuration = if ((lastBearing - bearing).absoluteValue > 20.0) {
|
||||||
2.seconds
|
2.seconds
|
||||||
} else {
|
} else {
|
||||||
1.2.seconds
|
3.seconds
|
||||||
//val updateDuration = java.time.Duration.between(LocalDateTime.now(), lastLocationUpdate)
|
//val updateDuration = java.time.Duration.between(LocalDateTime.now(), lastLocationUpdate)
|
||||||
//((updateDuration!!.toMillis().absoluteValue * 1.2).toDuration(DurationUnit.MILLISECONDS))
|
//((updateDuration!!.toMillis().absoluteValue * 1.2).toDuration(DurationUnit.MILLISECONDS))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user