diff --git a/app/src/main/java/com/kouros/navigation/MainActivity.kt b/app/src/main/java/com/kouros/navigation/MainActivity.kt index d80ee0f..113c383 100644 --- a/app/src/main/java/com/kouros/navigation/MainActivity.kt +++ b/app/src/main/java/com/kouros/navigation/MainActivity.kt @@ -66,6 +66,8 @@ import org.koin.androidx.compose.koinViewModel import org.maplibre.compose.camera.CameraPosition import org.maplibre.compose.camera.rememberCameraState import org.maplibre.compose.expressions.dsl.const +import org.maplibre.compose.layers.Anchor +import org.maplibre.compose.layers.CircleLayer import org.maplibre.compose.layers.FillLayer import org.maplibre.compose.layers.LineLayer import org.maplibre.compose.location.DesiredAccuracy @@ -375,7 +377,7 @@ class MainActivity : ComponentActivity() { var snapedLocation = location var bearing: Double if (routeModel.isNavigating()) { - snapedLocation = snapLocation(location, routeModel.maneuverLocations()) + snapedLocation = snapLocation(location, routeModel.route.maneuverLocations()) bearing = routeModel.currentStep().bearing routeModel.updateLocation(snapedLocation) instruction.value = routeModel.currentStep() diff --git a/common/car/src/main/java/com/kouros/navigation/car/NavigationSession.kt b/common/car/src/main/java/com/kouros/navigation/car/NavigationSession.kt index dca58c3..4d62483 100644 --- a/common/car/src/main/java/com/kouros/navigation/car/NavigationSession.kt +++ b/common/car/src/main/java/com/kouros/navigation/car/NavigationSession.kt @@ -35,7 +35,7 @@ class NavigationSession : Session() { lateinit var surfaceRenderer: SurfaceRenderer var locationIndex = 0 - val test = false + val test = true var mLocationListener: LocationListenerCompat = LocationListenerCompat { location: Location? -> updateLocation(location) diff --git a/common/car/src/main/java/com/kouros/navigation/car/SurfaceRenderer.kt b/common/car/src/main/java/com/kouros/navigation/car/SurfaceRenderer.kt index 8f0aa54..2eedd57 100644 --- a/common/car/src/main/java/com/kouros/navigation/car/SurfaceRenderer.kt +++ b/common/car/src/main/java/com/kouros/navigation/car/SurfaceRenderer.kt @@ -27,18 +27,22 @@ import androidx.lifecycle.setViewTreeLifecycleOwner import androidx.savedstate.setViewTreeSavedStateRegistryOwner import com.kouros.navigation.car.navigation.RouteCarModel import com.kouros.navigation.data.Constants +import com.kouros.navigation.data.Constants.SHOW_THREED_BUILDING import com.kouros.navigation.model.RouteModel +import com.kouros.navigation.utils.NavigationUtils.getBooleanKeyValue import com.kouros.navigation.utils.NavigationUtils.snapLocation import com.kouros.navigation.utils.calculateZoom import org.maplibre.compose.camera.CameraPosition import org.maplibre.compose.camera.rememberCameraState import org.maplibre.compose.expressions.dsl.const +import org.maplibre.compose.layers.Anchor import org.maplibre.compose.layers.FillLayer import org.maplibre.compose.layers.LineLayer import org.maplibre.compose.location.LocationPuckColors import org.maplibre.compose.location.LocationPuckSizes import org.maplibre.compose.map.MaplibreMap import org.maplibre.compose.sources.GeoJsonData +import org.maplibre.compose.sources.Source import org.maplibre.compose.sources.getBaseSource import org.maplibre.compose.sources.rememberGeoJsonSource import org.maplibre.compose.style.BaseStyle @@ -176,7 +180,7 @@ class SurfaceRenderer( baseStyle = BaseStyle.Uri(Constants.STYLE), ) { getBaseSource(id = "openmaptiles")?.let { tiles -> - FillLayer(id = "example", visible = false, source = tiles, sourceLayer = "building") + BuildingLayer(tiles) RouteLayer(route, previewRoute) } @@ -219,6 +223,20 @@ class SurfaceRenderer( } } + @Composable + fun BuildingLayer(tiles: Source) { + if (!getBooleanKeyValue(context = mCarContext, SHOW_THREED_BUILDING)) { + Anchor.Replace("building-3d") { + FillLayer( + id = "remove-building", + visible = false, + source = tiles, + sourceLayer = "building" + ) + } + } + } + @Composable fun RouteLayer(routeData: String?, previewRoute: String?) { if (routeData!!.isNotEmpty()) { @@ -285,7 +303,7 @@ class SurfaceRenderer( var snapedLocation = location var bearing: Double if (routeModel.isNavigating()) { - snapedLocation = snapLocation(location, routeModel.maneuverLocations()) + snapedLocation = snapLocation(location, routeModel.route.maneuverLocations()) bearing = routeModel.currentStep().bearing } else { bearing = cameraPosition.value!!.bearing diff --git a/common/car/src/main/java/com/kouros/navigation/car/screen/DisplaySettings.kt b/common/car/src/main/java/com/kouros/navigation/car/screen/DisplaySettings.kt new file mode 100644 index 0000000..c150753 --- /dev/null +++ b/common/car/src/main/java/com/kouros/navigation/car/screen/DisplaySettings.kt @@ -0,0 +1,57 @@ +package com.kouros.navigation.car.screen + +import androidx.car.app.CarContext +import androidx.car.app.CarToast +import androidx.car.app.Screen +import androidx.car.app.model.Action +import androidx.car.app.model.Header +import androidx.car.app.model.ItemList +import androidx.car.app.model.ListTemplate +import androidx.car.app.model.Row +import androidx.car.app.model.Template +import androidx.car.app.model.Toggle +import com.kouros.android.cars.carappservice.R +import com.kouros.navigation.data.Constants.SHOW_THREED_BUILDING +import com.kouros.navigation.utils.NavigationUtils.getBooleanKeyValue +import com.kouros.navigation.utils.NavigationUtils.setBooleanKeyValue + +class DisplaySettings(private val carContext: CarContext) : Screen(carContext) { + + private var buildingToggleState = false + + init { + buildingToggleState = getBooleanKeyValue(carContext, SHOW_THREED_BUILDING) + } + + override fun onGetTemplate(): Template { + val listBuilder = ItemList.Builder() + val buildingToggle: Toggle = + Toggle.Builder { checked: Boolean -> + if (checked) { + setBooleanKeyValue(carContext, true, SHOW_THREED_BUILDING) + } else { + setBooleanKeyValue(carContext, false, SHOW_THREED_BUILDING) + } + buildingToggleState = !buildingToggleState + }.setChecked(buildingToggleState).build() + listBuilder.addItem(buildRowForTemplate(R.string.threed_building, buildingToggle)) + + return ListTemplate.Builder() + .setSingleList(listBuilder.build()) + .setHeader( + Header.Builder() + .setTitle(carContext.getString(R.string.content_limits)) + .setStartHeaderAction(Action.BACK) + .build() + ) + .build() + } + + + private fun buildRowForTemplate(title: Int, toggle: Toggle): Row { + return Row.Builder() + .setTitle(carContext.getString(title)) + .setToggle(toggle) + .build() + } +} \ No newline at end of file diff --git a/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationScreen.kt b/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationScreen.kt index b313d8c..e5a5bdf 100644 --- a/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationScreen.kt +++ b/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationScreen.kt @@ -61,6 +61,15 @@ class NavigationScreen( //.setFlags(Action.FLAG_IS_PERSISTENT) .build() ) + actionStripBuilder.addAction( + Action.Builder() + .setIcon(routeModel.createCarIcon(carContext, R.drawable.ic_favorite_white_24dp)) + .setOnClickListener { + screenManager.push(SettingsScreen(carContext)) + } + //.setFlags(Action.FLAG_IS_PERSISTENT) + .build() + ) return if (routeModel.isNavigating()) { getNavigationTemplate(actionStripBuilder) } else { @@ -187,6 +196,24 @@ class NavigationScreen( surfaceRenderer.handleScale(-1) } .build()) + if (surfaceRenderer.panView) + { + actionStripBuilder.addAction( + Action.Builder() + .setIcon( + CarIcon.Builder( + IconCompat.createWithResource( + carContext, + R.drawable.ic_pan_24 + ) + ) + .build() + ).setOnClickListener { + surfaceRenderer.panView = false + } + .build() + ) + } return actionStripBuilder } diff --git a/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationSettings.kt b/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationSettings.kt new file mode 100644 index 0000000..ae77cd4 --- /dev/null +++ b/common/car/src/main/java/com/kouros/navigation/car/screen/NavigationSettings.kt @@ -0,0 +1,58 @@ +package com.kouros.navigation.car.screen + +import androidx.car.app.CarContext +import androidx.car.app.CarToast +import androidx.car.app.Screen +import androidx.car.app.constraints.ConstraintManager +import androidx.car.app.model.Action +import androidx.car.app.model.Header +import androidx.car.app.model.ItemList +import androidx.car.app.model.ListTemplate +import androidx.car.app.model.Row +import androidx.car.app.model.Template +import androidx.car.app.model.Toggle +import androidx.lifecycle.DefaultLifecycleObserver +import com.kouros.android.cars.carappservice.R +import com.kouros.navigation.data.Constants.SHOW_THREED_BUILDING +import com.kouros.navigation.utils.NavigationUtils.getBooleanKeyValue +import com.kouros.navigation.utils.NavigationUtils.setBooleanKeyValue + + +class NavigationSettings(private val carContext: CarContext) : Screen(carContext) { + + + override fun onGetTemplate(): Template { + val listBuilder = ItemList.Builder() + + + listBuilder.addItem( + buildRowForTemplate( + R.string.list_limit, + ConstraintManager.CONTENT_LIMIT_TYPE_LIST + ) + ) + + return ListTemplate.Builder() + .setSingleList(listBuilder.build()) + .setHeader( + Header.Builder() + .setTitle(carContext.getString(R.string.content_limits)) + .setStartHeaderAction(Action.BACK) + .build() + ) + .build() + } + + private fun buildRowForTemplate(title: Int, contentLimitType: Int): Row { + return Row.Builder() + .setTitle(carContext.getString(title)) + .addText( + carContext + .getCarService(ConstraintManager::class.java) + .getContentLimit(contentLimitType).toString() + ) + .build() + } + + +} \ No newline at end of file diff --git a/common/car/src/main/java/com/kouros/navigation/car/screen/SettingsScreen.kt b/common/car/src/main/java/com/kouros/navigation/car/screen/SettingsScreen.kt new file mode 100644 index 0000000..c67824f --- /dev/null +++ b/common/car/src/main/java/com/kouros/navigation/car/screen/SettingsScreen.kt @@ -0,0 +1,74 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.kouros.navigation.car.screen + +import android.content.Context +import androidx.car.app.CarContext +import androidx.car.app.CarToast +import androidx.car.app.Screen +import androidx.car.app.model.Action +import androidx.car.app.model.Header +import androidx.car.app.model.ItemList +import androidx.car.app.model.ListTemplate +import androidx.car.app.model.Row +import androidx.car.app.model.Template +import androidx.car.app.model.Toggle +import androidx.core.content.edit +import com.kouros.android.cars.carappservice.R +import com.kouros.navigation.car.NavigationSession + +/** A screen demonstrating selectable lists. */ +class SettingsScreen( + carContext: CarContext, +) : Screen(carContext) { + + override fun onGetTemplate(): Template { + + val listBuilder = ItemList.Builder() + listBuilder.addItem( + buildRowForTemplate( + DisplaySettings(carContext), + R.string.display + ) + ) + listBuilder.addItem( + buildRowForTemplate( + NavigationSettings(carContext), + R.string.navigation_settings + ) + ) + + return ListTemplate.Builder() + .setSingleList(listBuilder.build()) + .setHeader( + Header.Builder() + .setTitle( + (carContext.getString(R.string.settings_action_title)) + ) + .setStartHeaderAction(Action.BACK) + .build() + ) + .build() + } + + private fun buildRowForTemplate(screen: Screen, title: Int): Row { + return Row.Builder() + .setTitle(carContext.getString(title)) + .setOnClickListener { screenManager.push(screen) } + .setBrowsable(true) + .build() + } +} diff --git a/common/car/src/main/res/values-de/strings.xml b/common/car/src/main/res/values-de/strings.xml index a22d14e..da3c299 100644 --- a/common/car/src/main/res/values-de/strings.xml +++ b/common/car/src/main/res/values-de/strings.xml @@ -351,8 +351,9 @@ "Textlabel" "Demo: Parken im Vergleich zu Fahren" "Displays in Autos." - "Neueste Funktionen" - "Laden aktiviert" + "Navigation" + Anzeige + "3D Gebäude" "Laden deaktiviert" "Ladebildschirm" "Schieberegler zum Hinzufügen/Entfernen von Farben" diff --git a/common/car/src/main/res/values/strings.xml b/common/car/src/main/res/values/strings.xml index 873dd7a..e2fe462 100644 --- a/common/car/src/main/res/values/strings.xml +++ b/common/car/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ - - - Navigation + Navigation - - BACK - HOME - Exit - Refresh - Close - Grant Access - Enable Location - Cancel - Stop - More - Call - Primary - Options - Search - Checked - Unchecked - On - Off - Settings - Accept - Reject - OK - Throw - Commute - Sign out - Try Anyway - Yes - No - Disable All Rows - Enable All Rows + + BACK + HOME + Exit + Refresh + Close + Grant Access + Enable Location + Cancel + Stop + More + Call + Primary + Options + Search + Checked + Unchecked + On + Off + Settings + Accept + Reject + OK + Throw + Commute + Sign out + Try Anyway + Yes + No + Disable All Rows + Enable All Rows - + Zoomed in - Zoomed out - Triggered + Zoomed out + Triggered Favorite! - Not a favorite! - Navigation Requested - Selected route - Visible routes + Not a favorite! + Navigation Requested + Selected route + Visible routes Clicked Settings - Parked action - Clicked More + Parked action + Clicked More Grant location Permission to see current location - Sign-in with Google starts here - Changed selection to index - Yes button pressed! - No button pressed! - Alert is timed out! + Sign-in with Google starts here + Changed selection to index + Yes button pressed! + No button pressed! + Alert is timed out! - - Row with a large image and long text long text long text long text long text - Text text text - Row title - Row text + + Row with a large image and long text long text long text long text long text + Text text text + Row title + Row text - - Navigate - Dial - Address - Phone + + Navigate + Dial + Address + Phone - - Failure starting navigation - Failure starting dialer - Car Hardware Demo + + Failure starting navigation + Failure starting dialer + Car Hardware Demo - - Car Hardware Information - Model Information - No Model Permission - Manufacturer unavailable - Model unavailable - Year unavailable - Energy Profile - No Energy Profile Permission - Fuel Types - Unavailable - EV Connector Types + + Car Hardware Information + Model Information + No Model Permission + Manufacturer unavailable + Model unavailable + Year unavailable + Energy Profile + No Energy Profile Permission + Fuel Types + Unavailable + EV Connector Types - - Example %d - This text has a red color - This text has a green color - This text has a blue color - This text has a yellow color - This text uses the primary color - This text uses the secondary color - Color Demo + + Example %d + This text has a red color + This text has a green color + This text has a blue color + This text has a yellow color + This text uses the primary color + This text uses the secondary color + Color Demo - - List Limit - Grid Limit - Pane Limit - Place List Limit - Route List Limit - Content Limits - Content Limits Demo + + List Limit + Grid Limit + Pane Limit + Place List Limit + Route List Limit + Content Limits + Content Limits Demo - - This will finish the app, and when you return it will pre-seed a permission screen - Finish App Demo - Pre-seed the Permission Screen on next run Demo - Pre-seed permission App Demo - Pre-seed the Permission Screen on next run Demo + + This will finish the app, and when you return it will pre-seed a permission screen + Finish App Demo + Pre-seed the Permission Screen on next run Demo + Pre-seed permission App Demo + Pre-seed the Permission Screen on next run Demo - - Loading Demo - Loading Complete! + + Loading Demo + Loading Complete! - - Pop to root - Pop to Misc Demo Marker - Push further in stack - Pop To - PopTo Demo + + Pop to root + Pop to Misc Demo Marker + Push further in stack + Pop To + PopTo Demo - - Package Not found. - All permissions have been granted. Please revoke permissions from Settings. - The app needs access to the following permissions:\n - Grant Permission on the phone screen - Enable Location Permissions on device - Enable location on the phone screen - Required Permissions - Request Permission Demo + + Package Not found. + All permissions have been granted. Please revoke permissions from Settings. + The app needs access to the following permissions:\n + Grant Permission on the phone screen + Enable Location Permissions on device + Enable location on the phone screen + Required Permissions + Request Permission Demo - - Cancel Reservation Screen - Reservation canceled + + Cancel Reservation Screen + Reservation canceled - - Result demo - This app was not started for result - This app was called for result from %s. Please select the result to send back to the caller + + Result demo + This app was not started for result + This app was called for result from %s. Please select the result to send back to the caller - - Arrived! + + Arrived! - - Roy st 520 - I5 Aurora Ave N + + Roy st 520 + I5 Aurora Ave N - Send a notification - Start notifications - Stop notifications - Notification - Importance - Category - Ongoing - Default - High - Low - Unknown - Notification Demo + Send a notification + Start notifications + Stop notifications + Notification + Importance + Category + Ongoing + Default + High + Low + Unknown + Notification Demo - - Misc Demos + + Misc Demos - - Navigating Demo - Arrived Demo - Junction Image Demo - Navigation Template Demos + + Navigating Demo + Arrived Demo + Junction Image Demo + Navigation Template Demos - - Map Template with Pane Demo - Map Template with List Demo + + Map Template with Pane Demo + Map Template with List Demo - - Start Notification - Stop Notification - Navigation Notification Demo + + Start Notification + Stop Notification + Navigation Notification Demo - - Go Straight - Turn Right - Take 520 - Gas Station + + Go Straight + Turn Right + Take 520 + Gas Station - - Short route - Less busy - HOV friendly - Long route - Continue to start navigation - Continue to route - Routes + + Short route + Less busy + HOV friendly + Long route + Continue to start navigation + Continue to route + Routes - - Place List Navigation Template Demo - Route Preview Template Demo - Notification Template Demo - Navigation Template with map only Demo - Navigation Demos - Still a speed trap? - Reported 10m ago + + Place List Navigation Template Demo + Route Preview Template Demo + Notification Template Demo + Navigation Template with map only Demo + Navigation Demos + Still a speed trap? + Reported 10m ago - - No TollCard Permission. - No EnergyLevel Permission. - No Speed Permission. - No Mileage Permission. - No EV status Permission. - No Accelerometer Permission. - No Gyroscope Permission. - No Compass Permission. - No CarHardwareLocation Permission. - Fetching Toll information. - Fetching Energy Level. - Fetching Speed. - Fetching Mileage. - Fetching EV status. - Fetching Accelerometer. - Fetching Gyroscope. - Fetching Compass. - Fetching Location. - Toll card state - Low energy - Range - Fuel - Battery - Display Speed - Raw Speed - Unit - Odometer - Ev Charge Port Connected - Ev Charge Port Open - Accelerometer - Gyroscope - Compass - Car Hardware Location + + No TollCard Permission. + No EnergyLevel Permission. + No Speed Permission. + No Mileage Permission. + No EV status Permission. + No Accelerometer Permission. + No Gyroscope Permission. + No Compass Permission. + No CarHardwareLocation Permission. + Fetching Toll information. + Fetching Energy Level. + Fetching Speed. + Fetching Mileage. + Fetching EV status. + Fetching Accelerometer. + Fetching Gyroscope. + Fetching Compass. + Fetching Location. + Toll card state + Low energy + Range + Fuel + Battery + Display Speed + Raw Speed + Unit + Odometer + Ev Charge Port Connected + Ev Charge Port Open + Accelerometer + Gyroscope + Compass + Car Hardware Location - - Non-actionable - Second Item - Third Item - Fourth Item - Fifth Item has a long title set - Sixth Item has a long title set - Grid Template Demo + + Non-actionable + Second Item + Third Item + Fourth Item + Fifth Item has a long title set + Sixth Item has a long title set + Grid Template Demo - - Parked Only Title - More Parked only text. - Clicked row - First line of text - Second line of text - This subtext can fully display in unrestricted mode (ex. parking mode, restricted low speed mode). But this will truncate to only two lines while in restricted mode (ex. driving mode). For testing purposes, this subtext is super super super super super long - Title - List Template Demo + + Parked Only Title + More Parked only text. + Clicked row + First line of text + Second line of text + This subtext can fully display in unrestricted mode (ex. parking mode, restricted low speed mode). But this will truncate to only two lines while in restricted mode (ex. driving mode). For testing purposes, this subtext is super super super super super long + Title + List Template Demo - - Long Message Template Demo - Lorem ipsum dolor sit amet, consectetur adipiscing elit. \nAliquam laoreet ac metus eu commodo. Sed a congue diam, sed dictum lectus. Nam nec\ntristique dolor, quis sodales arcu. Etiam at metus eu nulla auctor varius. \nInteger dolor lorem, placerat sit amet lacus in, imperdiet semper dui. Vestibulum \nante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \nQuisque gravida fermentum egestas.\n\n\n\nUt ut sodales mi. Aenean porta vel ipsum sed lacinia. Morbi odio ipsum, hendrerit \neu est et, sollicitudin finibus diam. Nunc sit amet felis elit. Orci varius \nnatoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed \nvestibulum, tellus a rutrum auctor, diam arcu vestibulum purus, nec mollis ligula \nnisi in nisi. Donec sem tortor, pharetra sed fermentum sit amet, ullamcorper nec \nsapien. Aliquam risus arcu, porttitor eu dui nec, vulputate tempus libero. \nCurabitur sit amet tristique orci. Suspendisse et odio tempus, tempus turpis quis,\n euismod est.\n\n\n\nVestibulum mauris ante, luctus viverra nisi eget, blandit facilisis nulla. \nPhasellus ex lorem, semper in vestibulum nec, aliquet vel elit. Aliquam vitae \nligula nec enim dictum lobortis. Sed varius turpis quis nisi tempus varius. Sed \nnon sollicitudin magna, at mattis tortor. Curabitur quis ligula eget lorem mattis \ntincidunt et in sapien. Curabitur a elit nisi. Aliquam ex arcu, hendrerit eget \nturpis vitae, bibendum vulputate nibh. Fusce vitae ex aliquet, tristique magna eu,\n vulputate dui. Aenean tempor viverra tortor non pharetra. Pellentesque convallis \nnec risus a auctor. Praesent non sem non eros tincidunt ullamcorper efficitur non \nlacus.\n\n\n\nSuspendisse accumsan ultricies egestas. Aenean leo ligula, congue ac erat eu, \nlobortis ultricies lorem. Nulla finibus, arcu sed tincidunt lobortis, magna justo \nrutrum ligula, et mattis felis turpis vel ex. Morbi ac auctor ex, at bibendum sem.\n Vestibulum a tortor iaculis, viverra felis vitae, lobortis est. Duis sit amet \ncondimentum sem. Ut molestie, dolor pretium imperdiet maximus, enim orci porta \nquam, id gravida enim nunc vitae lacus. Pellentesque habitant morbi tristique \nsenectus et netus et malesuada fames ac turpis egestas. Nullam vel justo eu risus \nlobortis dignissim sit amet ullamcorper nulla. Donec finibus cursus purus \nporttitor pellentesque.\n\n\n\nDonec at vehicula ante. Suspendisse rutrum nisl quis metus faucibus lacinia. \nVestibulum eros sapien, eleifend nec accumsan a, interdum sed nisi. Aenean posuere\n ultrices lorem non pharetra. Nulla non porta ligula. Maecenas at elit diam. \nNullam gravida augue et semper eleifend. Fusce venenatis ac arcu et luctus. Mauris\n ultricies urna non dui interdum, vel hendrerit est aliquam. Fusce id dictum leo, \nfringilla egestas ipsum. - Your host doesn\'t support Long Message template - Incompatible host + + Long Message Template Demo + Lorem ipsum dolor sit amet, consectetur adipiscing elit. \nAliquam laoreet ac metus eu commodo. Sed a congue diam, sed dictum lectus. Nam nec\ntristique dolor, quis sodales arcu. Etiam at metus eu nulla auctor varius. \nInteger dolor lorem, placerat sit amet lacus in, imperdiet semper dui. Vestibulum \nante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \nQuisque gravida fermentum egestas.\n\n\n\nUt ut sodales mi. Aenean porta vel ipsum sed lacinia. Morbi odio ipsum, hendrerit \neu est et, sollicitudin finibus diam. Nunc sit amet felis elit. Orci varius \nnatoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed \nvestibulum, tellus a rutrum auctor, diam arcu vestibulum purus, nec mollis ligula \nnisi in nisi. Donec sem tortor, pharetra sed fermentum sit amet, ullamcorper nec \nsapien. Aliquam risus arcu, porttitor eu dui nec, vulputate tempus libero. \nCurabitur sit amet tristique orci. Suspendisse et odio tempus, tempus turpis quis,\n euismod est.\n\n\n\nVestibulum mauris ante, luctus viverra nisi eget, blandit facilisis nulla. \nPhasellus ex lorem, semper in vestibulum nec, aliquet vel elit. Aliquam vitae \nligula nec enim dictum lobortis. Sed varius turpis quis nisi tempus varius. Sed \nnon sollicitudin magna, at mattis tortor. Curabitur quis ligula eget lorem mattis \ntincidunt et in sapien. Curabitur a elit nisi. Aliquam ex arcu, hendrerit eget \nturpis vitae, bibendum vulputate nibh. Fusce vitae ex aliquet, tristique magna eu,\n vulputate dui. Aenean tempor viverra tortor non pharetra. Pellentesque convallis \nnec risus a auctor. Praesent non sem non eros tincidunt ullamcorper efficitur non \nlacus.\n\n\n\nSuspendisse accumsan ultricies egestas. Aenean leo ligula, congue ac erat eu, \nlobortis ultricies lorem. Nulla finibus, arcu sed tincidunt lobortis, magna justo \nrutrum ligula, et mattis felis turpis vel ex. Morbi ac auctor ex, at bibendum sem.\n Vestibulum a tortor iaculis, viverra felis vitae, lobortis est. Duis sit amet \ncondimentum sem. Ut molestie, dolor pretium imperdiet maximus, enim orci porta \nquam, id gravida enim nunc vitae lacus. Pellentesque habitant morbi tristique \nsenectus et netus et malesuada fames ac turpis egestas. Nullam vel justo eu risus \nlobortis dignissim sit amet ullamcorper nulla. Donec finibus cursus purus \nporttitor pellentesque.\n\n\n\nDonec at vehicula ante. Suspendisse rutrum nisl quis metus faucibus lacinia. \nVestibulum eros sapien, eleifend nec accumsan a, interdum sed nisi. Aenean posuere\n ultrices lorem non pharetra. Nulla non porta ligula. Maecenas at elit diam. \nNullam gravida augue et semper eleifend. Fusce venenatis ac arcu et luctus. Mauris\n ultricies urna non dui interdum, vel hendrerit est aliquam. Fusce id dictum leo, \nfringilla egestas ipsum. + Your host doesn\'t support Long Message template + Incompatible host - - Message Template Demo - Message goes here.\nMore text on second line. - Short Message Template Demo + + Message Template Demo + Message goes here.\nMore text on second line. + Short Message Template Demo - - Sectioned Item Template Demo - Radio Button Section - Toggle Section - Lots of Rows Section - Grid Item Section + + Sectioned Item Template Demo + Radio Button Section + Toggle Section + Lots of Rows Section + Grid Item Section - - Pane Template Demo + + Pane Template Demo - - Place List Template Demo - Browse Places + + Place List Template Demo + Browse Places - - Search Template Demo - Search here + + Search Template Demo + Search here - - Please review our terms of service - Google sign-in - Use PIN - QR Code - Your host doesn\'t support Sign In template - Incompatible host - Email - Sign in - Enter your credentials - User name must be a valid email address - User name must be at least %s characters long - Invalid password - password - Username - Type this PIN in your phone - Scan QR Code to sign in - Sign in with Google - Use this button to complete your Google sign-in - You are signed in! - Sign in completed - Sign In Template Demo + + Please review our terms of service + Google sign-in + Use PIN + QR Code + Your host doesn\'t support Sign In template + Incompatible host + Email + Sign in + Enter your credentials + User name must be a valid email address + User name must be at least %s characters long + Invalid password + password + Username + Type this PIN in your phone + Scan QR Code to sign in + Sign in with Google + Use this button to complete your Google sign-in + You are signed in! + Sign in completed + Sign In Template Demo - - Tab Template Demos - Tab Template Demo - Message Tab - Pane Tab - List Tab - Grid Tab with Long Tab Title - Search Tab - Loading Tab - Tab Template Loading Demo - Tab Template No Tabs Demo + + Tab Template Demos + Tab Template Demo + Message Tab + Pane Tab + List Tab + Grid Tab with Long Tab Title + Search Tab + Loading Tab + Tab Template Loading Demo + Tab Template No Tabs Demo - - Images cannot be displayed for an unknown host - Icon - Content Provider Icons Demo + + Images cannot be displayed for an unknown host + Icon + Content Provider Icons Demo - - Icons Demo - The app icon - A vector drawable, without a tint - A vector drawable, with a tint - A vector drawable, with an app\'s theme attribute for its color - A PNG, sent as a resource - A PNG, sent as a bitmap + + Icons Demo + The app icon + A vector drawable, without a tint + A vector drawable, with a tint + A vector drawable, with an app\'s theme attribute for its color + A PNG, sent as a resource + A PNG, sent as a bitmap - - Just a title - Title with app icon - Title with resource ID image - Title with SVG image - Colored secondary text - Title with multiple secondary text lines - Err and err and err again, but less and less and less. - - Piet Hein - Rows Demo + + Just a title + Title with app icon + Title with resource ID image + Title with SVG image + Colored secondary text + Title with multiple secondary text lines + Err and err and err again, but less and less and less. + - Piet Hein + Rows Demo - - Text and Icons Demos - Rows with Text and Icons Demo + + Text and Icons Demos + Rows with Text and Icons Demo - - Radio Button Lists Demo - Selectable Lists Demo - Option 1 - Option 2 - Option 3 - Row with Radio Button - Row with Radio Button and Icon - Row with Radio Button and Icon and Colored Text - Some additional text - Sample selectable list + + Radio Button Lists Demo + Selectable Lists Demo + Option 1 + Option 2 + Option 3 + Row with Radio Button + Row with Radio Button and Icon + Row with Radio Button and Icon and Colored Text + Some additional text + Sample selectable list - - Task Restriction Demo - This will overflow the step count, and lead you to a new screen. - Task step %1$d of %2$d - Click to go forward - Please visit the different templates and ensure the car is in driving mode + + Task Restriction Demo + This will overflow the step count, and lead you to a new screen. + Task step %1$d of %2$d + Click to go forward + Please visit the different templates and ensure the car is in driving mode - - Toggle Button Demo - Toggle test - Stateful changes are allowed - Enable Toggle Test - Check this one to enable the toggle test - Toggle test - Stateful changes are allowed - Image test - Image changes are allowed - Additional Data - Updates allowed on back operations. - Toggle Test Enabled - Toggle Test Disabled + + Toggle Button Demo + Toggle test + Stateful changes are allowed + Enable Toggle Test + Check this one to enable the toggle test + Toggle test + Stateful changes are allowed + Image test + Image changes are allowed + Additional Data + Updates allowed on back operations. + Toggle Test Enabled + Toggle Test Disabled - - Secondary Action and Decoration Demo - Secondary Action Test - Only the secondary action can be selected - Decoration Test - Secondary Actions and Decoration - Row with Secondary Actions and Decoration with a really long title - The row can also be selected - Place deleted - Row primary action is selected + + Secondary Action and Decoration Demo + Secondary Action Test + Only the secondary action can be selected + Decoration Test + Secondary Actions and Decoration + Row with Secondary Actions and Decoration with a really long title + The row can also be selected + Place deleted + Row primary action is selected - - Sectioned Item List Demo - List 1 - List 2 - Subtext under each list + + Sectioned Item List Demo + List 1 + List 2 + Subtext under each list - - Empty List Demo - The list is empty + + Empty List Demo + The list is empty - - Misc Templates Demos - CAL API Level: %d - Showcase Demos - Template Layout Demos - Grid Template Demos + + Misc Templates Demos + CAL API Level: %d + Showcase Demos + Template Layout Demos + Grid Template Demos - - Voice Access Demo Screen - User Interactions - Request Permissions Demos + + Voice Access Demo Screen + User Interactions + Request Permissions Demos - - Application Overflow Validator - Please test the following templates while changing - the vehicle from parked to driving state + + Application Overflow Validator + Please test the following templates while changing + the vehicle from parked to driving state - - Permission Group - Permission Group for Showcase App - Access to Fine Location - Permission for Access to Fine Location - Access to Coarse Location - Permission for Access to Coarse Location - Access to Record Audio - Permission for Access to Record Audio + + Permission Group + Permission Group for Showcase App + Access to Fine Location + Permission for Access to Fine Location + Access to Coarse Location + Permission for Access to Coarse Location + Access to Record Audio + Permission for Access to Record Audio - - Google Kirkland - 747 6th St South, Kirkland, WA 98033 - Tinted resource vector - +14257395600 - Google Bellevue - 1120 112th Ave NE, Bellevue, WA 98004 - Image resource bitmap - +14252301301 - Google South Lake Union - 1021 Valley St, Seattle, WA 98109 - Colored text marker - +12065311800 - Google Seattle - 601 N 34th St, Seattle, WA 98103 - Image bitmap - +12068761800 - 1600 Amphitheatre Pkwy, Mountain View, CA 94043 - +16502530000 - Google Bothell - 11831 North Creek Pkwy, Bothell, WA 98011 - Seward Park - 5900 Lake Washington Blvd S, Seattle, WA 98118 - Luther Burbank Park - 2040 84th Ave SE, Mercer Island, WA 98040 - Heritage Park - 111 Waverly Way, Kirkland, WA 98033 - Text label - n/a + + Google Kirkland + 747 6th St South, Kirkland, WA 98033 + Tinted resource vector + +14257395600 + Google Bellevue + 1120 112th Ave NE, Bellevue, WA 98004 + Image resource bitmap + +14252301301 + Google South Lake Union + 1021 Valley St, Seattle, WA 98109 + Colored text marker + +12065311800 + Google Seattle + 601 N 34th St, Seattle, WA 98103 + Image bitmap + +12068761800 + 1600 Amphitheatre Pkwy, Mountain View, CA 94043 + +16502530000 + Google Bothell + 11831 North Creek Pkwy, Bothell, WA 98011 + Seward Park + 5900 Lake Washington Blvd S, Seattle, WA 98118 + Luther Burbank Park + 2040 84th Ave SE, Mercer Island, WA 98040 + Heritage Park + 111 Waverly Way, Kirkland, WA 98033 + Text label + n/a - Parking Vs Driving Demo - Cluster Displays in cars! - Latest Features - Loading enabled - Loading disabled - Loading screen - Toggle to add/remove color + Parking Vs Driving Demo + Cluster Displays in cars! + Navigation + Display + 3D Building + Loading disabled + Loading screen + Toggle to add/remove color Map Template with Toggles - Avoid tolls + Avoid tolls Route options - Avoid highways - Avoid ferry - Map Demos - Map With Content Demos - Map With Message Template Demo - Map With Grid Template Demo + Avoid highways + Avoid ferry + Map Demos + Map With Content Demos + Map With Message Template Demo + Map With Grid Template Demo Routes Recent Contacts diff --git a/common/data/src/main/java/com/kouros/navigation/data/Data.kt b/common/data/src/main/java/com/kouros/navigation/data/Data.kt index 7251cc7..a10fcb8 100644 --- a/common/data/src/main/java/com/kouros/navigation/data/Data.kt +++ b/common/data/src/main/java/com/kouros/navigation/data/Data.kt @@ -118,7 +118,7 @@ data class ValhallaLocation ( object Constants { - const val STYLE: String = "https://kouros-online.de/liberty2" + const val STYLE: String = "https://kouros-online.de/liberty.json" //baseStyle = BaseStyle.Uri("https://tiles.openfreemap.org/styles/liberty"), const val TAG: String = "Navigation" @@ -138,6 +138,11 @@ object Constants { home2Location.latitude = 48.1164817 home2Location.longitude = 11.594322 } + + const val SHARED_PREF_KEY = "NavigationPrefs" + + const val SHOW_THREED_BUILDING = "Show3D" + } diff --git a/common/data/src/main/java/com/kouros/navigation/data/Route.kt b/common/data/src/main/java/com/kouros/navigation/data/Route.kt index 6040c90..edf52a6 100644 --- a/common/data/src/main/java/com/kouros/navigation/data/Route.kt +++ b/common/data/src/main/java/com/kouros/navigation/data/Route.kt @@ -16,7 +16,7 @@ data class Route ( * * @since 1.0.0 */ - val maneuvers: List, + var maneuvers: List, /** * The distance traveled from origin to destination. @@ -43,8 +43,6 @@ data class Route ( val time: Double, - var routingManeuvers : List, - var routeGeoJson : String, var currentIndex: Int @@ -63,8 +61,6 @@ data class Route ( private lateinit var trip : Trip - private lateinit var routingManeuvers: List - private var routeGeoJson = "" fun route (route: String ) = apply { @@ -87,21 +83,22 @@ data class Route ( points.add(point) } pointLocations = points - val routings = mutableListOf() - for (maneuver in maneuvers) { - routings.add(maneuver) - } - this.routingManeuvers = routings this.routeGeoJson = createGeoJson(waypoints) return Route( - maneuvers, distance, waypoints, pointLocations, summary, trip, time, routingManeuvers, routeGeoJson, 0 + maneuvers, distance, waypoints, pointLocations, summary, trip, time, routeGeoJson, 0 ) } } + fun maneuverLocations(): List { + val beginShapeIndex = currentManeuver().beginShapeIndex + val endShapeIndex = currentManeuver().endShapeIndex + return pointLocations.subList(beginShapeIndex, endShapeIndex) + } + fun clear() { waypoints = mutableListOf() - routingManeuvers = mutableListOf() + maneuvers = mutableListOf() routeGeoJson = "" } diff --git a/common/data/src/main/java/com/kouros/navigation/model/RouteModel.kt b/common/data/src/main/java/com/kouros/navigation/model/RouteModel.kt index ad82a3f..d78a5e5 100644 --- a/common/data/src/main/java/com/kouros/navigation/model/RouteModel.kt +++ b/common/data/src/main/java/com/kouros/navigation/model/RouteModel.kt @@ -81,7 +81,6 @@ open class RouteModel() { fun currentStep(): StepData { val maneuver = route.currentManeuver() var text = "" - println("Maneuver $maneuver") if (maneuver.streetNames != null && maneuver.streetNames.isNotEmpty()) { text = maneuver.streetNames[0] } @@ -156,16 +155,10 @@ open class RouteModel() { return nearestLocation } - fun maneuverLocations(): List { - val beginShapeIndex = route.currentManeuver().beginShapeIndex - val endShapeIndex = route.currentManeuver().endShapeIndex - return route.pointLocations.subList(beginShapeIndex, endShapeIndex) - } - fun travelLeftTime(): Double { var timeLeft = 0.0 - for (i in route.currentIndex + 1.. 0) { @@ -180,7 +173,7 @@ open class RouteModel() { /** Returns the current [Step] left distance in km. */ fun leftStepDistance(): Double { - val maneuver = route.routingManeuvers[route.currentIndex] + val maneuver = route.currentManeuver() var leftDistance = maneuver.length if (endIndex > 0) { leftDistance = (distanceToStepEnd / 1000).toDouble() @@ -190,12 +183,12 @@ open class RouteModel() { fun travelLeftDistance(): Double { var leftDistance = 0.0 - for (i in route.currentIndex + 1.. 0) { - val maneuver = route.routingManeuvers[route.currentIndex] + val maneuver = route.currentManeuver() val curDistance = maneuver.length val percent = 100 * (endIndex - currentIndex) / (endIndex - beginIndex) val time = curDistance * percent / 100 @@ -215,7 +208,6 @@ open class RouteModel() { fun stopNavigation() { route.clear() navigating = false - //maneuverIndex = 0 currentIndex = 0 distanceToStepEnd = 0F beginIndex = 0 diff --git a/common/data/src/main/java/com/kouros/navigation/utils/NavigationUtils.kt b/common/data/src/main/java/com/kouros/navigation/utils/NavigationUtils.kt index a4d1081..3d8fca6 100644 --- a/common/data/src/main/java/com/kouros/navigation/utils/NavigationUtils.kt +++ b/common/data/src/main/java/com/kouros/navigation/utils/NavigationUtils.kt @@ -1,7 +1,11 @@ package com.kouros.navigation.utils +import android.content.Context import android.location.Location import android.location.LocationManager +import androidx.core.content.edit +import com.kouros.navigation.data.Constants.SHARED_PREF_KEY +import com.kouros.navigation.data.Constants.SHOW_THREED_BUILDING import com.kouros.navigation.data.GeoJsonFeature import com.kouros.navigation.data.GeoJsonFeatureCollection import com.kouros.navigation.data.GeoJsonLineString @@ -25,6 +29,28 @@ import kotlin.math.sin object NavigationUtils { + fun getBooleanKeyValue(context: Context, key: String) : Boolean { + return context + .getSharedPreferences( + SHARED_PREF_KEY, + Context.MODE_PRIVATE + ) + .getBoolean(key, false) + } + + fun setBooleanKeyValue(context: Context, `val`: Boolean, key: String) { + context + .getSharedPreferences( + SHARED_PREF_KEY, + Context.MODE_PRIVATE + ) + .edit { + putBoolean( + key, `val` + ) + apply() + } + } fun snapLocation(location: Location, stepCoordinates: List): Location { val oldPoint = Point.fromLngLat(location.longitude, location.latitude) if (stepCoordinates.size > 1) {