Test, Lanes
This commit is contained in:
@@ -13,8 +13,8 @@ android {
|
||||
applicationId = "com.kouros.navigation"
|
||||
minSdk = 33
|
||||
targetSdk = 36
|
||||
versionCode = 56
|
||||
versionName = "0.2.0.56"
|
||||
versionCode = 57
|
||||
versionName = "0.2.0.57"
|
||||
base.archivesName = "navi-$versionName"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -49,7 +50,9 @@ import com.google.android.gms.location.FusedLocationProviderClient
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.kouros.data.R
|
||||
import com.kouros.navigation.MainApplication.Companion.navigationViewModel
|
||||
import com.kouros.navigation.data.Constants
|
||||
import com.kouros.navigation.data.Constants.DESTINATION_ARRIVAL_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.TILT
|
||||
import com.kouros.navigation.data.Constants.homeVogelhart
|
||||
import com.kouros.navigation.data.StepData
|
||||
import com.kouros.navigation.model.BaseStyleModel
|
||||
@@ -84,10 +87,9 @@ import kotlin.time.Duration.Companion.seconds
|
||||
class MainActivity : ComponentActivity() {
|
||||
val routeData = MutableLiveData("")
|
||||
val routeModel = RouteModel()
|
||||
var tilt = 50.0
|
||||
var tilt = TILT
|
||||
val useMock = false
|
||||
val type = SimulationType.SIMULATE
|
||||
|
||||
val stepData: MutableLiveData<StepData> by lazy {
|
||||
MutableLiveData()
|
||||
}
|
||||
@@ -148,9 +150,8 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
getSettingsViewModel(applicationContext).routingEngine.collect {
|
||||
|
||||
}
|
||||
getSettingsViewModel(applicationContext).routingEngine.first()
|
||||
getSettingsViewModel(applicationContext).recentPlaces.first()
|
||||
}
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
@@ -169,21 +170,11 @@ class MainActivity : ComponentActivity() {
|
||||
permissions = permissions,
|
||||
requiredPermissions = listOf(permissions.first()),
|
||||
onGranted = {
|
||||
App()
|
||||
// auto navigate
|
||||
if (useMock) {
|
||||
// navigationViewModel.loadRoute(
|
||||
// applicationContext,
|
||||
// homeVogelhart,
|
||||
// homeHohenwaldeck,
|
||||
// 0F
|
||||
// )
|
||||
}
|
||||
Application()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun StartScreen(
|
||||
@@ -193,7 +184,6 @@ class MainActivity : ComponentActivity() {
|
||||
val appViewModel: AppViewModel = appViewModel()
|
||||
val darkMode by appViewModel.darkMode.collectAsState()
|
||||
|
||||
|
||||
val baseStyle = BaseStyleModel().readStyle(applicationContext, darkMode, darkMode == 1)
|
||||
val scaffoldState = rememberBottomSheetScaffoldState()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
@@ -207,10 +197,6 @@ class MainActivity : ComponentActivity() {
|
||||
val userLocationState = rememberUserLocationState(locationProvider)
|
||||
val locationState = locationProvider.location.collectAsState()
|
||||
updateLocation(locationState.value)
|
||||
var latitude by remember { mutableDoubleStateOf(0.0) }
|
||||
if (locationState.value != null) {
|
||||
latitude = locationState.value!!.position.latitude
|
||||
}
|
||||
val step: StepData? by stepData.observeAsState()
|
||||
val nextStep: StepData? by nextStepData.observeAsState()
|
||||
fun closeSheet() {
|
||||
@@ -227,7 +213,7 @@ class MainActivity : ComponentActivity() {
|
||||
scaffoldState = scaffoldState,
|
||||
sheetPeekHeight = sheetPeekHeightState.value,
|
||||
sheetContent = {
|
||||
SheetContent(latitude, step, nextStep) { closeSheet() }
|
||||
SheetContent(step, nextStep) { closeSheet() }
|
||||
},
|
||||
) { innerPadding ->
|
||||
Box(
|
||||
@@ -255,7 +241,7 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun App() {
|
||||
fun Application() {
|
||||
val appViewModel: AppViewModel = appViewModel()
|
||||
val lastRoute by appViewModel.lastRoute.collectAsState()
|
||||
if (lastRoute.isNotEmpty()) {
|
||||
@@ -286,12 +272,12 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
@Composable
|
||||
fun SheetContent(
|
||||
locationState: Double, step: StepData?, nextStep: StepData?, closeSheet: () -> Unit
|
||||
step: StepData?, nextStep: StepData?, closeSheet: () -> Unit
|
||||
) {
|
||||
if (!routeModel.isNavigating()) {
|
||||
SearchSheet(applicationContext, navigationViewModel, lastLocation) { closeSheet() }
|
||||
} else {
|
||||
if (step != null && nextStep != null) {
|
||||
if (step != null) {
|
||||
NavigationSheet(
|
||||
applicationContext,
|
||||
routeModel,
|
||||
@@ -301,8 +287,6 @@ class MainActivity : ComponentActivity() {
|
||||
{ simulateNavigation() })
|
||||
}
|
||||
}
|
||||
// For recomposition!
|
||||
Text("$locationState", fontSize = 12.sp)
|
||||
}
|
||||
|
||||
fun updateLocation(location: Location?) {
|
||||
@@ -314,7 +298,7 @@ class MainActivity : ComponentActivity() {
|
||||
if (routeModel.isNavigating()) {
|
||||
val snapedLocation =
|
||||
snapLocation(currentLocation, routeModel.route.maneuverLocations())
|
||||
updateLocationInternal(snapedLocation, location)
|
||||
updateLocationInternal(currentLocation, location)
|
||||
} else {
|
||||
updateLocationInternal(currentLocation, location)
|
||||
}
|
||||
@@ -335,7 +319,9 @@ class MainActivity : ComponentActivity() {
|
||||
if (isNavigating()) {
|
||||
updateLocation( currentLocation, navigationViewModel)
|
||||
stepData.value = currentStep()
|
||||
nextStepData.value = nextStep()
|
||||
if (navState.nextStep) {
|
||||
nextStepData.value = nextStep()
|
||||
}
|
||||
if (navState.maneuverType in 39..42 && routeCalculator.leftStepDistance() < DESTINATION_ARRIVAL_DISTANCE) {
|
||||
// stopNavigation()
|
||||
navState = navState.copy(arrived = true)
|
||||
@@ -367,7 +353,7 @@ class MainActivity : ComponentActivity() {
|
||||
mock.setMockLocation(latitude, longitude, 0F)
|
||||
}
|
||||
routeData.value = ""
|
||||
stepData.value = StepData("", 0.0, 0, 0, 0, 0.0)
|
||||
stepData.value = StepData("", "",0.0, 0, 0, 0, 0.0)
|
||||
}
|
||||
|
||||
fun simulateNavigation() {
|
||||
|
||||
@@ -60,6 +60,7 @@ fun MapView(
|
||||
|
||||
val appViewModel: AppViewModel = appViewModel()
|
||||
val showBuildings by appViewModel.show3D.collectAsState()
|
||||
val darkMode by appViewModel.darkMode.collectAsState()
|
||||
|
||||
Column {
|
||||
NavigationInfo(step, nextStep)
|
||||
@@ -87,7 +88,7 @@ fun MapView(
|
||||
duration = 1.seconds
|
||||
)
|
||||
}
|
||||
NavigationImage(paddingValues, width, height / 6)
|
||||
NavigationImage(paddingValues, width, height / 6, "", darkMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,19 @@ fun NavigationInfo(
|
||||
modifier = Modifier.padding(CardPadding),
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(currentStep.icon),
|
||||
contentDescription = stringResource(id = R.string.navigation_icon_description),
|
||||
modifier = Modifier.size(IconSize),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(top = ElementSpacing)
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(currentStep.icon),
|
||||
contentDescription = stringResource(id = R.string.navigation_icon_description),
|
||||
modifier = Modifier.size(IconSize),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(horizontal = SpacerWidth))
|
||||
DistanceText(distance = currentStep.leftStepDistance)
|
||||
}
|
||||
|
||||
if (currentStep.isExitManeuver) {
|
||||
Text(
|
||||
@@ -72,8 +79,6 @@ fun NavigationInfo(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(top = ElementSpacing)
|
||||
) {
|
||||
DistanceText(distance = currentStep.leftStepDistance)
|
||||
Spacer(modifier = Modifier.padding(horizontal = SpacerWidth))
|
||||
Text(
|
||||
text = currentStep.instruction,
|
||||
fontSize = PrimaryTextSize,
|
||||
|
||||
@@ -27,16 +27,12 @@ fun NavigationSheet(
|
||||
applicationContext: Context,
|
||||
routeModel: RouteModel,
|
||||
step: StepData,
|
||||
nextStep: StepData,
|
||||
nextStep: StepData?,
|
||||
stopNavigation: () -> Unit,
|
||||
simulateNavigation: () -> Unit,
|
||||
) {
|
||||
val distance = (step.leftDistance / 1000).round(1)
|
||||
|
||||
if (step.lane.isNotEmpty()) {
|
||||
// routeModel.navState.iconMapper.addLanes( step)
|
||||
}
|
||||
|
||||
Column {
|
||||
FlowRow(horizontalArrangement = Arrangement.SpaceEvenly) {
|
||||
Text(formatDateTime(step.arrivalTime), fontSize = 22.sp)
|
||||
|
||||
@@ -2,14 +2,6 @@ package com.kouros.navigation.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
//val Purple80 = Color(0xFFD0BCFF)
|
||||
//val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
//val Pink80 = Color(0xFFEFB8C8)
|
||||
//
|
||||
//val Purple40 = Color(0xFF6650a4)
|
||||
//val PurpleGrey40 = Color(0xFF625b71)
|
||||
//val Pink40 = Color(0xFF7D5260)
|
||||
|
||||
val md_theme_light_primary = Color(0xFF825500)
|
||||
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_primaryContainer = Color(0xFFFFDDB3)
|
||||
|
||||
Reference in New Issue
Block a user