-
-
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
Conversation
app/src/main/java/org/maplibre/navigation/android/example/MockNavigationActivity.kt
Show resolved
Hide resolved
...ion/src/main/java/org/maplibre/navigation/android/navigation/v5/offroute/OffRouteDetector.kt
Outdated
Show resolved
Hide resolved
...java/org/maplibre/navigation/android/navigation/v5/navigation/MapLibreNavigationOptions.java
Show resolved
Hide resolved
...d-navigation/src/main/java/org/maplibre/navigation/android/navigation/v5/snap/SnapToRoute.kt
Outdated
Show resolved
Hide resolved
As discussed, I added the |
Round 2️⃣ Latest changes are ready now for a review. |
const val NON_NULL_APPLICATION_CONTEXT_REQUIRED: String = | ||
"Non-null application context required." | ||
|
||
val WAYNAME_OFFSET: Array<Float> = arrayOf(0.0f, 40.0f) |
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.
Could we add @JvmField
here to improve the kotlin -> java interop?
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.
Added ✅
* | ||
* @since 3.0.0 | ||
*/ | ||
val maxSpeed: List<MaxSpeed>?, |
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.
Before maxSpeed was:
public abstract List<MaxSpeed> maxspeed();
Reading this value from json doesn't work anymore.
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.
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.
Ahh, that was my bad. Thanks for finding this!
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.
JSON name is changed ✅
CHANGELOG.md
Outdated
@@ -4,6 +4,9 @@ Maplibre welcomes participation and contributions from everyone. | |||
|
|||
### unreleased | |||
|
|||
**BREAKING CHANGES:** | |||
- Convert module `libandroid-navigation` to Kotlin. See description of PR [#xxx] to get informed about all breaking changes |
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 ✅
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.
Just two small changes from my side and then this should be good to merge. The changelog and the serial name of the maxspeed. I haven't found any other issues so far.
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.
LGTM, thanks for working on this 👍
This PR will convert the module
libandroid-navigation
to Kotlin.I used Android Studio's converting tool and try my best to refactore the generated Kotlin code.
There are still classes that I didn't refactor, because the logic itself was already very complicated and ugly in Java. For this classes I think seperated follow up PRs make sense. Additional all Auto Models now data classes. Also I removed all unused classes from this module.
I tested the changes against the example app, and fix all occuring issues. But I suspect that I do not catched all.
I note following..
Breaking changes
org.maplibre.navigation.android.core.connectivity.* --> Removed. Not used internally. Make for me no sense to keep this.
org.maplibre.navigation.android.core.crashreporter.* --> Removed. Not used internally. Make for me no sense to keep this.
org.maplibre.navigation.android.core.FileUtils --> Removed. Only used by CrashReport
org.maplibre.navigation.android.navigation.v5.milestone.Milestone --> Remove Builder, use named arguments in constructor instead.
org.maplibre.navigation.android.navigation.v5.routeprogress.* --> Convert all @autovalue classes to Kotlin data classes. (Also Builder pattern is not used here anymore)
org.maplibre.navigation.android.navigation.v5.models.* -->
- Convert all @autovalue classes to Kotlin data classes. (Also Builder pattern is not used here anymore). Using KotlinX instead of GSON for JSON parsing.
- Convert annotation types to enums
- Using Kotlinx serialization instead of GSON for JSON parsing
- Remove classes MapLibreStreetsV8, DirectionsJsonObject, DirectionsAdapterFactory
org.maplibre.navigation.android.navigation.v5.models.utils.* --> Removed. Not used internally.
org.maplibre.navigation.android.navigation.v5.utils.abbreviation.* --> Removed. Not used internally. I think it is also not used by developers.
org.maplibre.navigation.android.navigation.v5.utils.TextUtils --> Removed. Can be replaced by Android's TextUtils or by Kotlin language functions.
org.maplibre.navigation.android.navigation.v5.utils.RouteUtils --> Now static (object) class.
org.maplibre.navigation.android.navigation.v5.navigation.NavigationLifecycleMonitor --> Removed. Not used internal.
org.maplibre.navigation.android.navigation.v5.navigation.NavigationMapRoute --> Deprecated/Removed. In UI package a newer version is available.
org.maplibre.navigation.android.navigation.v5.navigation.SdkVersionChecker --> Deprecated/Removed. Make no sense, use plain java/kotlin code.
org.maplibre.navigation.android.navigation.v5.navigation.NavigationTimeFormat --> Move to MapLibreNavigationOptions and migrate to enum class.
org.maplibre.navigation.android.navigation.v5.route.MapRouteProgressChangeListener --> Deprecated/Removed. In UI package a newer version is available.
org.maplibre.navigation.android.navigation.v5.route.OnRouteSelectionChangeListener --> Deprecated/Removed. In UI package a newer version is available.
org.maplibre.navigation.android.navigation.v5.location.MetricsLocation --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.GpxParser --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.ParseGpxTask --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.ReplayJsonRouteDto --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.ReplayJsonRouteLocationMapper --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.ReplayLocationDto --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.location.replay.TimestampAdapter --> Removed. Seems not used.
org.maplibre.navigation.android.navigation.v5.navigation.camera.RouteInformation --> Remove Builder, use named arguments in constructor instead.
org.maplibre.navigation.android.navigation.v5.navigation.camera.Camera --> Remove function
target
, because it's not used anywhere.org.maplibre.navigation.android.navigation.v5.models.RouteOptions --> Remove
*list
functions. Seems not used anywhere.org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigationOptions --> Remove
isFromNavigationUi
, because seems not used anywhere.org.maplibre.navigation.android.navigation.v5.navigation.MapLibreNavigationOptions -->
minimumDistanceBeforeRerouting
is splitt up to two new options.offRouteMinimumDistanceMetersAfterReroute
minimum meters after a reroute needs passedoffRouteThresholdRadiusMeters
a fixed threshold, that will cause a off-route state, when passed.Refactor later
org.maplibre.navigation.android.navigation.v5.milestone.TriggerProperty --> Seems too complicated. Create a fresh new re-write.
org.maplibre.navigation.android.navigation.v5.location.replay.* --> Hard to refactor in clean Kotlin. Also seems too complicated. Create a fresh new re-write.
Add adapters or use DTOs instead of parsing directly to models that can be replaces by developers to use other API engines
org.maplibre.navigation.android.navigation.v5.utils.time.* --> Seems too complicated. Create a simpler version.
org.maplibre.navigation.android.navigation.v5.utils.RouteUtils --> Seems too complicated. Create simpler versions of util functions.
Rename engines to name with ending
engine
. And also choose a standardized naming for implementations.- Camera --> CameraEngine
- Snap --> SnapEngine
- OffRoute --> OffRouteEngine
- FasterRoute --> FasterRouteEngine
Discuss
Can
LegAnnotation
used without distance field? If not, we should thinking about to make the distance list non-null