ApplicationConfig, Favorites
This commit is contained in:
@@ -125,16 +125,16 @@ class PlaceListScreen(
|
||||
/**
|
||||
* Creates an Action to navigate to a specific place.
|
||||
*/
|
||||
private fun clickOnPlace(it: Place) {
|
||||
private fun clickOnPlace(itPlace: Place) {
|
||||
place = Place(
|
||||
0,
|
||||
it.name,
|
||||
it.category,
|
||||
it.latitude,
|
||||
it.longitude,
|
||||
it.postalCode,
|
||||
it.city,
|
||||
it.street,
|
||||
itPlace.name,
|
||||
itPlace.category,
|
||||
itPlace.latitude,
|
||||
itPlace.longitude,
|
||||
itPlace.postalCode,
|
||||
itPlace.city,
|
||||
itPlace.street,
|
||||
// avatar = null
|
||||
)
|
||||
if (surfaceRenderer.navigation) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kouros.navigation.car.screen
|
||||
import android.text.SpannableString
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.util.Log
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.car.app.CarContext
|
||||
import androidx.car.app.CarToast
|
||||
@@ -32,6 +33,8 @@ import androidx.lifecycle.lifecycleScope
|
||||
import com.kouros.data.R
|
||||
import com.kouros.navigation.car.SurfaceRenderer
|
||||
import com.kouros.navigation.car.navigation.RouteCarModel
|
||||
import com.kouros.navigation.data.Constants.FAVORITES
|
||||
import com.kouros.navigation.data.Constants.TAG
|
||||
import com.kouros.navigation.data.Place
|
||||
import com.kouros.navigation.data.ViewStyle
|
||||
import com.kouros.navigation.data.route.Routes
|
||||
@@ -54,7 +57,7 @@ class RoutePreviewScreen(
|
||||
private var showAlternativeRoute: Boolean
|
||||
) :
|
||||
Screen(carContext) {
|
||||
private var isFavorite = false
|
||||
private var isFavorite = destination.favorite
|
||||
|
||||
val maxListItems: Int = 3
|
||||
|
||||
@@ -90,6 +93,7 @@ class RoutePreviewScreen(
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
val trafficObserver = Observer<Map<String, String>> { traffic ->
|
||||
if (traffic.isNotEmpty()) {
|
||||
navigationViewModel.traffic.value = emptyMap()
|
||||
@@ -113,7 +117,6 @@ class RoutePreviewScreen(
|
||||
})
|
||||
repository.routingEngineFlow.asLiveData().observe(this, Observer {
|
||||
routingEngine = it
|
||||
|
||||
})
|
||||
|
||||
repository.alternativeRoutesFlow.asLiveData().observe(this, Observer {
|
||||
@@ -157,9 +160,6 @@ class RoutePreviewScreen(
|
||||
header.addEndHeaderAction(
|
||||
favoriteAction()
|
||||
)
|
||||
header.addEndHeaderAction(
|
||||
deleteFavoriteAction()
|
||||
)
|
||||
}
|
||||
val message =
|
||||
if (routeModel.isNavigating() && routeModel.curRoute.waypoints.isNotEmpty()) {
|
||||
@@ -261,34 +261,17 @@ class RoutePreviewScreen(
|
||||
else
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
, FLAG_IS_PERSISTENT,
|
||||
) {
|
||||
isFavorite = !isFavorite
|
||||
CarToast.makeText(
|
||||
carContext,
|
||||
if (isFavorite)
|
||||
carContext
|
||||
.getString(R.string.favorites)
|
||||
else
|
||||
carContext.getString(
|
||||
R.string.favorites
|
||||
),
|
||||
CarToast.LENGTH_SHORT
|
||||
)
|
||||
.show()
|
||||
navigationViewModel.saveFavorite(carContext, destination)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
|
||||
private fun deleteFavoriteAction(): Action =
|
||||
createAction(carContext, R.drawable.heart_minus_48px, FLAG_IS_PERSISTENT,{
|
||||
if (isFavorite) {
|
||||
navigationViewModel.deleteFavorite(carContext, destination)
|
||||
onClickAction = {
|
||||
isFavorite = !isFavorite
|
||||
destination.favorite = isFavorite
|
||||
if (isFavorite) {
|
||||
navigationViewModel.saveFavorite(carContext, destination)
|
||||
} else {
|
||||
navigationViewModel.deleteFavorite(carContext, destination)
|
||||
}
|
||||
invalidate()
|
||||
}
|
||||
isFavorite = !isFavorite
|
||||
finish()
|
||||
})
|
||||
|
||||
)
|
||||
|
||||
private fun createRouteText(route: Routes): CarText {
|
||||
val time = route.summary.duration
|
||||
|
||||
@@ -120,12 +120,12 @@ class NavigationScreenTest {
|
||||
|
||||
`when`(mockRouteModel.isManeuverArrival()).thenReturn(true)
|
||||
`when`(mockRouteModel.routeCalculator).thenReturn(mockRouteCalculator)
|
||||
`when`(mockRouteCalculator.leftStepDistance()).thenReturn(19.0)
|
||||
`when`(mockRouteCalculator.leftStepDistance()).thenReturn(9.0)
|
||||
`when`(mockRouteModel.navState).thenReturn(NavigationState())
|
||||
|
||||
// Act
|
||||
//navigationScreen.checkArrival()
|
||||
|
||||
// Assert
|
||||
assertThat(navigationScreen.navigationType).isEqualTo(NavigationType.ARRIVAL)
|
||||
assertThat(navigationScreen.navigationType).isEqualTo(NavigationType.NAVIGATION)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -98,6 +98,9 @@ class CategoryObserverTest {
|
||||
}
|
||||
|
||||
private fun createElement(lon: Double, lat: Double): Elements {
|
||||
return Elements(lon = lon, lat = lat, tags = Tags())
|
||||
return Elements(
|
||||
lon = lon, lat = lat,
|
||||
tags = Tags(maxspeed = "0", direction = ""),
|
||||
bounds = com.kouros.navigation.data.overpass.Bounds(0.0, 0.0, 0.0, 0.0))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -123,7 +123,8 @@ class ObserversTest {
|
||||
return Elements(
|
||||
lon = lon,
|
||||
lat = lat,
|
||||
tags = Tags(maxspeed = maxSpeed, direction = null)
|
||||
tags = Tags(maxspeed = maxSpeed, direction = ""),
|
||||
bounds = com.kouros.navigation.data.overpass.Bounds(0.0, 0.0, 0.0, 0.0),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user