Repository navigation
[android] - Refactor dependencies, introduce focused components - #7189
Conversation
a9bf943 to
667affe
Compare
|
@tobrun There are indeed a lot of inter-dependecies. And also some 2-way dependencies. It might be helpful for the clarity of the architecture to abstract some things a little bit more. For example,
There might be a couple of places where interfaces/choosing the highest applicable abstraction might help to clear up the dependencies a bit. |
Thinking about this again, the zoombutton controller is more like a widget shown on top of the map, I moved this back to MapView with the other widgets. These will be extracted as part of #6570.
I tried to limit the amount of arguments but not assigning mapbox to field in the MapGestureDetector. I have now changed this to take each dependency seperatly.
I'm now working to remove the NativeMapView in total, the second responsibility should be made a part of the transform class since they transform the map. Thanks for some initial 👀, will ping again for second round. |
0858b86 to
09dd4b8
Compare
|
The goal of this PR has diverged from it's initial intent, changes made cascaded in changes elsewhere. This PR is now more focused on a general refactor and taking apart the big dependencies into smaller single focused dependencies. This PR adds a lot of todo to the code but current state is acceptable to merge. (we are only missing the snapshot feature, the jni code needs to be refactored and can be picked up with #6238). Focus of Review would be MapboxMap, MapGestureDetector, MapKeyListener, Transform, TrackingSettings and UiSettings. To make the refactor possible I had to remove some unit tests. |
ivovandongen
left a comment
There was a problem hiding this comment.
Great work @tobrun! Cleans things up nicely. Just a few minor details.
If at all possible, it would be nice to re-implement the removed unit tests on top of the new abstractions.
There was a problem hiding this comment.
The initializations that have no dependencies might as well be done in the field declaration. That also enables us to make them final and maybe skip some null checks here and there.
There was a problem hiding this comment.
Initialize in field declaration
There was a problem hiding this comment.
Let's note these things on #6912 as well. I'm planning to pick that up soon.
There was a problem hiding this comment.
it seems not.. after that line it indicates: // this is not available before API 18, so it's there waiting for us to bump the minSDK requirments? IDK, this code is from before my time.
There was a problem hiding this comment.
Initialize in declaration
|
I have worked in the requested changes and working now on getting tests back up and running where possible. BTW biggest issue I had with this was not being able to mock final classes, looking into upgrading to mockito 2 for that. |
09dd4b8 to
a3c048f
Compare
|
I got the important tests back to run by using mockito 2 configuration for mocking final classes. Though I wasn't able to bring the MapboxMap test since they rely on NativeMapView (which relies on loading the native library). I'm thinking of porting those tests to an instrumentation test equivalent. I think we are covered for now. @ivovandongen can you do another review round? |
a3c048f to
477ebd3
Compare
Let's open a follow-up ticket for that then. |
| import static org.mockito.Mockito.when; | ||
|
|
||
| public class MapboxMapTest { | ||
|
|
There was a problem hiding this comment.
Why not just use @ignore on the class for now? Or does that make it crash. Makes it more visible that we need to do some work here.
|
@ivovandongen I have actually now have ported all the unit MapboxMapTest to an instrumentation equivalent. Can you review? update: need to revisit this implementation since they occasionally fail. The reason seems related to the issue we have had with add/remove source/layer test. |
f215d6f to
33b04c7
Compare
76fff1a to
bcfcd3f
Compare
|
I'm running the Android job multiple times on Bitrise to ensure we aren't introducing any flaky tests. update: seeing flaky tests, going to revisit the implementation. |
|
Not seeing any immediate fixes, going to ignore the MapboxMapTest and create a follow up ticket. |
WIP to refactor all gesture related code into a separate wrapper.
update: intent has changed from initial creation see below