-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert core module to Kotlin #127
Merged
Merged
Changes from 36 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8904370
Convert milestone logic to Kotlin
Fabi755 8bc4fe0
Convert route progress models
Fabi755 b9aea76
Convert tests to dirty Kotlin
Fabi755 aa7c687
Make milestone logic work against tests
Fabi755 c414bd4
Fix converted tests
Fabi755 1751b60
Convert models
Fabi755 7c8e514
Use Kotlin serialization for JSON parsing
Fabi755 810e4f4
Remove abbreviation utils
Fabi755 67429eb
Remove unused text utils
Fabi755 0d1dea8
Convert utils
Fabi755 330f931
Convert route snapping logic
Fabi755 adcaa25
Convert most of the navigation logic
Fabi755 0ddc212
Convert route logic
Fabi755 870874d
Convert exception and instruction
Fabi755 2bd5de7
Convert off route logic
Fabi755 7f4b220
Replace Mockito by mockk
Fabi755 94fa153
Convert location logic
Fabi755 d91e014
Convert notification classes
Fabi755 abafb63
Remove core package
Fabi755 cc486b8
Convert route utils
Fabi755 4212b30
Convert camera logic
Fabi755 ae011c8
Remove unused and outdated classes
Fabi755 1028d0b
Lint clean up
Fabi755 72db91f
Adjust UI module to new changes
Fabi755 edf07ad
Adjust example app to new changes
Fabi755 56cc90b
Solve open todos
Fabi755 1cec87e
Clean test code
Fabi755 b71ad54
Solve open todos
Fabi755 8b45098
Initialize NavigationMapRoute after style has applied
Fabi755 1b8cb83
Fix crashes
Fabi755 89ade36
Solve issues
Fabi755 99e1f7e
Add changelog entry
Fabi755 e558075
Fix missing tests
Fabi755 4b102b8
Clean up
Fabi755 fc7e838
Remove auto values dependency, Add new libraries to centeral file
Fabi755 0dd9561
Handle possible NULL values on instruction list
Fabi755 57d2180
Fix Kotlin JSON serialization notation
Fabi755 ea2c012
Enable lenient option for JSON
Fabi755 5966952
Change off route interface to SAM interface
Fabi755 3161668
Make list items non-null
Fabi755 538f01b
Make default implementations open to inheritances
Fabi755 2d56e3f
Split `minimumDistanceBeforeRerouting` to two options
Fabi755 f298dca
Replace string enum by native enum
Fabi755 94b9f50
Fix protected companion constants
Fabi755 42a458f
Remove my notes
Fabi755 c63f5d4
Reduce singleton usage, to allow extend and inject these classes
Fabi755 4a74f7c
Set more classes to public
Fabi755 ac57fee
Add `findCurrentBannerText` again
Fabi755 e33ff84
Add camera target function again
Fabi755 137fea2
Add possible SAM interfaces
Fabi755 a664a04
Add PR link to changelog
Fabi755 0d1b908
Fix maxspeed JSON key
Fabi755 d8c2dce
Add missing JvmField annotation
Fabi755 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ import org.maplibre.android.maps.MapLibreMap | |
import org.maplibre.android.maps.OnMapReadyCallback | ||
import org.maplibre.android.maps.Style | ||
import org.maplibre.navigation.android.navigation.ui.v5.route.NavigationRoute | ||
import org.maplibre.navigation.android.navigation.v5.instruction.Instruction | ||
import org.maplibre.navigation.android.navigation.v5.location.replay.ReplayRouteLocationEngine | ||
import org.maplibre.navigation.android.navigation.v5.models.DirectionsCriteria | ||
import org.maplibre.navigation.android.navigation.v5.models.DirectionsRoute | ||
|
@@ -35,6 +34,8 @@ import org.maplibre.turf.TurfConstants | |
import org.maplibre.turf.TurfMeasurement | ||
import okhttp3.Request | ||
import org.maplibre.navigation.android.example.databinding.ActivityMockNavigationBinding | ||
import org.maplibre.navigation.android.navigation.ui.v5.route.NavigationMapRoute | ||
Fabi755 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import org.maplibre.navigation.android.navigation.v5.instruction.Instruction | ||
import org.maplibre.navigation.android.navigation.v5.milestone.Milestone | ||
import org.maplibre.navigation.android.navigation.v5.milestone.MilestoneEventListener | ||
import org.maplibre.navigation.android.navigation.v5.milestone.RouteMilestone | ||
|
@@ -43,7 +44,6 @@ import org.maplibre.navigation.android.navigation.v5.milestone.TriggerProperty | |
import org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigation | ||
import org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigationOptions | ||
import org.maplibre.navigation.android.navigation.v5.navigation.NavigationEventListener | ||
import org.maplibre.navigation.android.navigation.v5.navigation.NavigationMapRoute | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
@@ -91,9 +91,7 @@ class MockNavigationActivity : | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
customNotification.createNotificationChannel(this) | ||
} | ||
val options = MapLibreNavigationOptions.builder() | ||
.navigationNotification(customNotification) | ||
.build() | ||
val options = MapLibreNavigationOptions(navigationNotification = customNotification) | ||
|
||
navigation = | ||
MapLibreNavigation( | ||
|
@@ -102,19 +100,21 @@ class MockNavigationActivity : | |
) | ||
|
||
navigation.addMilestone( | ||
RouteMilestone.Builder() | ||
.setIdentifier(BEGIN_ROUTE_MILESTONE) | ||
.setInstruction(BeginRouteInstruction()) | ||
.setTrigger( | ||
Trigger.all( | ||
Trigger.lt( | ||
TriggerProperty.STEP_INDEX, 3), | ||
Trigger.gt( | ||
TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 200), | ||
Trigger.gte( | ||
TriggerProperty.STEP_DISTANCE_TRAVELED_METERS, 75), | ||
RouteMilestone( | ||
identifier = BEGIN_ROUTE_MILESTONE, | ||
instruction = BeginRouteInstruction(), | ||
trigger = Trigger.all( | ||
Trigger.lt( | ||
TriggerProperty.STEP_INDEX, 3 | ||
), | ||
Trigger.gt( | ||
TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 200 | ||
), | ||
).build(), | ||
Trigger.gte( | ||
TriggerProperty.STEP_DISTANCE_TRAVELED_METERS, 75 | ||
), | ||
), | ||
) | ||
) | ||
customNotification.register(MyBroadcastReceiver(navigation), context) | ||
|
||
|
@@ -161,25 +161,21 @@ class MockNavigationActivity : | |
|
||
override fun onMapReady(mapLibreMap: MapLibreMap) { | ||
this.mapLibreMap = mapLibreMap | ||
mapLibreMap.setStyle(Style.Builder().fromUri(getString(R.string.map_style_light))) { style -> | ||
mapLibreMap.setStyle( | ||
Style.Builder().fromUri(getString(R.string.map_style_light)) | ||
) { style -> | ||
enableLocationComponent(style) | ||
} | ||
|
||
navigationMapRoute = | ||
NavigationMapRoute( | ||
navigation, | ||
binding.mapView, | ||
mapLibreMap | ||
) | ||
navigationMapRoute = NavigationMapRoute(navigation, binding.mapView, mapLibreMap) | ||
|
||
mapLibreMap.addOnMapClickListener(this) | ||
Snackbar.make( | ||
findViewById(R.id.container), | ||
"Tap map to place waypoint", | ||
Snackbar.LENGTH_LONG, | ||
).show() | ||
mapLibreMap.addOnMapClickListener(this) | ||
Snackbar.make( | ||
findViewById(R.id.container), | ||
"Tap map to place waypoint", | ||
Snackbar.LENGTH_LONG, | ||
).show() | ||
|
||
newOrigin() | ||
newOrigin() | ||
} | ||
} | ||
|
||
@SuppressWarnings("MissingPermission") | ||
|
@@ -261,11 +257,11 @@ class MockNavigationActivity : | |
) { | ||
Timber.d("Url: %s", (call.request() as Request).url.toString()) | ||
response.body()?.let { response -> | ||
if (response.routes().isNotEmpty()) { | ||
if (response.routes.isNotEmpty()) { | ||
val maplibreResponse = DirectionsResponse.fromJson(response.toJson()); | ||
val directionsRoute = maplibreResponse.routes().first() | ||
val directionsRoute = maplibreResponse.routes.first() | ||
[email protected] = directionsRoute | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes()) | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes) | ||
} | ||
} | ||
} | ||
|
@@ -276,23 +272,23 @@ class MockNavigationActivity : | |
}) | ||
} | ||
|
||
override fun onProgressChange(location: Location?, routeProgress: RouteProgress?) { | ||
override fun onProgressChange(location: Location, routeProgress: RouteProgress) { | ||
} | ||
|
||
override fun onRunning(running: Boolean) { | ||
} | ||
|
||
override fun onMilestoneEvent( | ||
routeProgress: RouteProgress?, | ||
routeProgress: RouteProgress, | ||
instruction: String?, | ||
milestone: Milestone?, | ||
milestone: Milestone, | ||
) { | ||
} | ||
|
||
override fun userOffRoute(location: Location?) { | ||
override fun userOffRoute(location: Location) { | ||
} | ||
|
||
private class BeginRouteInstruction : Instruction() { | ||
private class BeginRouteInstruction : Instruction { | ||
|
||
override fun buildInstruction(routeProgress: RouteProgress): String { | ||
return "Have a safe trip!" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import org.maplibre.turf.TurfConstants | |
import org.maplibre.turf.TurfMeasurement | ||
import okhttp3.Request | ||
import org.maplibre.navigation.android.example.databinding.ActivityNavigationUiBinding | ||
import org.maplibre.navigation.android.navigation.v5.navigation.NavigationMapRoute | ||
import org.maplibre.navigation.android.navigation.ui.v5.route.NavigationMapRoute | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
@@ -72,7 +72,10 @@ class NavigationUIActivity : | |
val options = NavigationLauncherOptions.builder() | ||
.directionsRoute(route) | ||
.shouldSimulateRoute(simulateRoute) | ||
.initialMapCameraPosition(CameraPosition.Builder().target(LatLng(userLocation.latitude, userLocation.longitude)).build()) | ||
.initialMapCameraPosition( | ||
CameraPosition.Builder() | ||
.target(LatLng(userLocation.latitude, userLocation.longitude)).build() | ||
) | ||
.lightThemeResId(R.style.TestNavigationViewLight) | ||
.darkThemeResId(R.style.TestNavigationViewDark) | ||
.build() | ||
|
@@ -102,22 +105,20 @@ class NavigationUIActivity : | |
|
||
override fun onMapReady(mapLibreMap: MapLibreMap) { | ||
this.mapLibreMap = mapLibreMap | ||
mapLibreMap.setStyle(Style.Builder().fromUri(getString(R.string.map_style_light))) { style -> | ||
mapLibreMap.setStyle( | ||
Style.Builder().fromUri(getString(R.string.map_style_light)) | ||
) { style -> | ||
enableLocationComponent(style) | ||
} | ||
navigationMapRoute = NavigationMapRoute(binding.mapView, mapLibreMap) | ||
|
||
navigationMapRoute = | ||
NavigationMapRoute( | ||
binding.mapView, | ||
mapLibreMap | ||
) | ||
mapLibreMap.addOnMapClickListener(this) | ||
|
||
mapLibreMap.addOnMapClickListener(this) | ||
Snackbar.make( | ||
findViewById(R.id.container), | ||
"Tap map to place waypoint", | ||
Snackbar.LENGTH_LONG, | ||
).show() | ||
Snackbar.make( | ||
findViewById(R.id.container), | ||
"Tap map to place waypoint", | ||
Snackbar.LENGTH_LONG, | ||
).show() | ||
} | ||
} | ||
|
||
@SuppressWarnings("MissingPermission") | ||
|
@@ -199,10 +200,10 @@ class NavigationUIActivity : | |
) { | ||
Timber.d("Url: %s", (call.request() as Request).url.toString()) | ||
response.body()?.let { response -> | ||
if (response.routes().isNotEmpty()) { | ||
if (response.routes.isNotEmpty()) { | ||
val maplibreResponse = DirectionsResponse.fromJson(response.toJson()); | ||
[email protected] = maplibreResponse.routes().first() | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes()) | ||
[email protected] = maplibreResponse.routes.first() | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes) | ||
binding.startRouteLayout.visibility = View.VISIBLE | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,10 @@ import org.maplibre.navigation.android.navigation.v5.routeprogress.RouteProgress | |
import org.maplibre.navigation.android.navigation.v5.snap.SnapToRoute | ||
import okhttp3.Request | ||
import org.maplibre.navigation.android.example.databinding.ActivitySnapToRouteNavigationBinding | ||
import org.maplibre.navigation.android.navigation.ui.v5.route.NavigationMapRoute | ||
import org.maplibre.navigation.android.navigation.v5.models.DirectionsCriteria | ||
import org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigation | ||
import org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigationOptions | ||
import org.maplibre.navigation.android.navigation.v5.navigation.NavigationMapRoute | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
|
@@ -59,9 +59,7 @@ class SnapToRouteNavigationActivity : AppCompatActivity(), OnMapReadyCallback, | |
|
||
navigation = MapLibreNavigation( | ||
this, | ||
MapLibreNavigationOptions.builder() | ||
.snapToRoute(true) | ||
.build() | ||
MapLibreNavigationOptions(snapToRoute = true) | ||
).apply { | ||
snapEngine | ||
addProgressChangeListener(this@SnapToRouteNavigationActivity) | ||
|
@@ -83,15 +81,9 @@ class SnapToRouteNavigationActivity : AppCompatActivity(), OnMapReadyCallback, | |
this.mapLibreMap = mapLibreMap | ||
mapLibreMap.setStyle(Style.Builder().fromUri(getString(R.string.map_style_light))) { style -> | ||
enableLocationComponent(style) | ||
navigationMapRoute = NavigationMapRoute(navigation, binding.mapView, mapLibreMap) | ||
calculateRouteAndStartNavigation() | ||
} | ||
|
||
navigationMapRoute = | ||
NavigationMapRoute( | ||
navigation, | ||
binding.mapView, | ||
mapLibreMap | ||
) | ||
calculateRouteAndStartNavigation() | ||
} | ||
|
||
@SuppressWarnings("MissingPermission") | ||
|
@@ -149,11 +141,11 @@ class SnapToRouteNavigationActivity : AppCompatActivity(), OnMapReadyCallback, | |
) { | ||
Timber.d("Url: %s", (call.request() as Request).url.toString()) | ||
response.body()?.let { responseBody -> | ||
if (responseBody.routes().isNotEmpty()) { | ||
if (responseBody.routes.isNotEmpty()) { | ||
val maplibreResponse = DirectionsResponse.fromJson(responseBody.toJson()); | ||
val directionsRoute = maplibreResponse.routes().first() | ||
val directionsRoute = maplibreResponse.routes.first() | ||
[email protected] = directionsRoute | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes()) | ||
navigationMapRoute?.addRoutes(maplibreResponse.routes) | ||
|
||
startNavigation() | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to fix the Changelog here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the xxx right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR link added ✅