Open gpesquero opened 2 weeks ago
This looks nicely done, but I do think it's preferable to keep as much logic as possible in the core, otherwise every platform will end up with its own implementation & it'll be a pain to maintain
(you might fancy working on https://github.com/organicmaps/organicmaps/issues/3676 with your knowledge of the units implementation though!)
This looks nicely done, but I do think it's preferable to keep as much logic as possible in the core, otherwise every platform will end up with its own implementation & it'll be a pain to maintain
We're always going to have a trade-off between the different approaches. You're right that keeping the implementation in the core will be easier to maintain.
(you might fancy working on #3676 with your knowledge of the units implementation though!)
I will take note of this issue/feature request and see if I have time in the future to work on it. In any case, if we want to implement this new feature in the future (i.e. mixing miles with meters), I'd be easier if we have the distance/speed formatting in the core.
PR that adds a static Speed class for formatting speed values to strings in Android, instead of using JNI calls.
This is just a draft PR to compare the current c++/JNI string formatting approach vs speed formatting to string in Android, as discussed in https://github.com/organicmaps/organicmaps/pull/7779#discussion_r1552523638.
This PR runs both speed string formatting implementations (c++/JNI vs Android) in NavMenu.java, logging the time elapsed for each call (measurements have been made on a real Android 9 device via USB debugging):
Android/Java implementation takes 3-4 times longer than the current JNI one, so actually the current implementation seems to be the best approach performance-wise.
The question here is: shall we keep the current approach?, or shall we start to implement speed and distance formatting in Android and remove JNI calls? This second option would also imply to add unit testing for Java/Android.
My opinion: to keep the current approach (string formatting in c++/JNI).
Any feedback in welcome...