This is a solution to the mobile code challenge by a mobility company that operates in Berlin. It provides a mobile app that allows users to book pooled rides and track their progress.
-
The solution was forked after 3-4 days of starting the challenge in a branch named:
main
in case it was needed by the examiners. -
Regarding
extras
andextras-2
, the latter is the most recent. The biggest difference between those two is the layout changes and saving the map markers to be removed when the booking is closed. -
Regarding
extras-after-deadline
, I am experimenting for a bit.
The application is basically a simulation (visualization) on google map view for data sent from mobilityCompany's WebSocket.
mobilityCompany's team implemented the basic architecture for this code and based on this framework I implemented a solution that satisfies the requirements:
- shows the user the live location of their assigned vehicle on a map
- shows the ride's current status (waiting, in the vehicle, dropped off) in a UI component
- shows the ride's pickup and drop-off addresses in a UI component
- In the presentation layer, MVP model is used.
- Dagger 2.0 is used for Dependency Injection through out the code.
- The architecture model is very clean.
Network
is in a separate module and communicates with theInteractor
. It also instantiates data classes likeEvent
- The
Interactor
communicated withpresenters
in each of the main and the two features - Each one of the two features is in MVP model so the view and the model communicate through the presenters
- Each feature's
mapper
inheritsdata
interface and overrides itsmapDataModelToViewModel
in different classes 4.OkHttp is used to handle communication with the WebSocket.
- moshi is used to easily map the JSON objects with data.
- RxKotlin and RxJava were used. Reactive programming is implemented for a more efficient use of resources setting the
Event
as the observables so that the observers (subscribers) only work when notified.
-
Once the application opens it connects to the WebSocket and grabs the data which will:
- Initialize the vehicle location.
- Shows the pickup, drop-off, and intermediate stops markers.
- Shows the status on the screen.
- Shows the pickup and drop-off addresses on the screen.
-
With every "vehicleLocationUpdated" event: The vehicle marker will be animated
-
With every "intermediateStopLocationsChanged" event:
- The stops markers will be drawn.
- The screen shows the next stop address (assuming, the event will always be sent when a car reaches a stop)
-
With every "statusUpdated" and "bookingClosed" event: The status and the booking status will be updated on the screen. The program checks if status of booking is closed to clear all markers on screen.
- When the internet connection is out for a bit while the application is running, it does not notify the user.
- When the user zooms in with elevation, the vehicle marker rotation is not right.
- There is no need for a release Google API key.
- I thought about making the markers clickable to display addresses but I ended up not doing it as I thought it's redundant data that is not necessary since the next stop location is displayed on the screen.
- I designed the drawables on illustrator for a vectorized code. However, I discovered that google map needs the markers to be an image/bitmap, so I had to convert the vector images .SVG to .PNG.
- The webSocket will always send an event when the vehicle reaches an intermediate stop to update the "Heading to" text view.
Event.data
from the webSocket may be null butEvent.data[0].Address
will never be null but could be empty.
- Unit testing.
- Handling webSocket's failure for a better UX.
- Import the project using Android studio.
- Go to
google_maps_api.xml
- Google's API_key is set (open) to be used. However, if it was expired, kindly follow the instructions commented in the file to create a Google Maps API key and paste it in the aforementioned xml file.