This commit is contained in:
Dimitris
2025-12-01 07:14:23 +01:00
parent c353a1d74e
commit da209a4354
4 changed files with 15 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ android {
minSdk = 30
targetSdk = 36
versionCode = 1
versionName = "0.1.2"
versionName = "0.1.3"
setProperty("archivesBaseName", "navi-$versionName")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@@ -114,13 +115,13 @@ fun BuildingLayer(tiles: Source) {
}
@Composable
fun DrawImage(width: Int, height: Int, location: Location) {
NavigationImage(height)
fun DrawImage(width: Int, height: Int, location: Location, street: String) {
NavigationImage(height, street)
Speed(width, height, location)
}
@Composable
fun NavigationImage(height: Int) {
fun NavigationImage(height: Int, street: String) {
val vector = ImageVector.vectorResource(id = R.drawable.assistant_navigation_48px)
val color = remember { NavigationColor }
BadgedBox(
@@ -137,6 +138,8 @@ fun NavigationImage(height: Int) {
contentDescription = "Navigation",
tint = color
)
if (street.isNotEmpty())
Text(text=street)
}
}
@Composable

View File

@@ -7,7 +7,9 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.location.Location
import android.location.LocationManager
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.car.app.CarContext
import androidx.car.app.Screen
import androidx.car.app.ScreenManager
@@ -85,6 +87,7 @@ class NavigationSession : Session(), NavigationScreen.Listener {
lifecycle.addObserver(mLifeCycleObserver)
}
@RequiresApi(Build.VERSION_CODES.M)
override fun onCreateScreen(intent: Intent): Screen {
routeModel = RouteCarModel()

View File

@@ -13,7 +13,6 @@ import androidx.car.app.AppManager
import androidx.car.app.CarContext
import androidx.car.app.SurfaceCallback
import androidx.car.app.SurfaceContainer
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -197,7 +196,11 @@ class SurfaceRenderer(
var target = position.target
var localTilt = tilt
if (!preview) {
DrawImage(width, height,lastLocation)
if (routeModel.isNavigating()) {
DrawImage(width, height, lastLocation, "")
} else {
DrawImage(width, height, lastLocation, "")
}
} else {
bearing = 0.0
zoom = previewZoom()