-
Notifications
You must be signed in to change notification settings - Fork 318
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
Refactor route logic #30
Conversation
Refactoring's mostly complete, just need to fix up checkstyle issues and document the classes/methods. @zugaldia ready for the review so we can do the |
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.
It overall looks so much cleaner than before, I really like where this is going. Let's go ahead with fixing checkstyle, adding docs and making sure that every new class has a corresponding new test class.
navigation/app/build.gradle
Outdated
@@ -35,7 +35,7 @@ dependencies { | |||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | |||
|
|||
// Mapbox Maps SDK | |||
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') { | |||
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0-beta.1@aar') { |
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.
@cammace beta.2 as of 3 minutes ago :)
private CopyOnWriteArrayList<NavigationEventListener> navigationEventListeners; | ||
private CopyOnWriteArrayList<ProgressChangeListener> progressChangeListeners; | ||
private CopyOnWriteArrayList<OffRouteListener> offRouteListeners; | ||
private List<AlertLevelChangeListener> alertLevelChangeListeners; |
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.
@cammace Why the change? Any drawbacks from keeping the previous type?
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.
It seems unnecessary at least for now since we aren't passing these list to a different thread.
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.
@cammace We aren't but the developer might work with different threads?
@@ -36,6 +33,7 @@ | |||
* @since 0.1.0 | |||
*/ | |||
@Experimental | |||
@SuppressWarnings( {"MissingPermission"}) |
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.
Instead of attaching this to the whole class, let's put on the line(s) where it's actually need to avoid masking other instances.
@@ -79,8 +77,7 @@ public void setupNotification(Activity activity) { | |||
// Sets up the top bar notification | |||
notifyBuilder = new NotificationCompat.Builder(this) | |||
.setContentTitle("Mapbox Navigation") | |||
.setContentText("Distance: " + routeProgress.getCurrentLegProgress().getCurrentStepProgress() | |||
.getDistanceRemaining()) | |||
.setContentText("navigating") |
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.
Can we provide a more descriptive text by default? Is there an API for the dev to update this text? (can be ticketed separately)
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.
Planned on overhauling the notification stuff in a separate PR, The notification isn't even working right now during a navigation session...
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.
@cammace Sounds good, let's ticket it separately.
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.
ticketed in #25
return location; | ||
} | ||
|
||
// TODO split this method |
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.
Let's ticket or remove if done.
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.
ticketed in #39
double secondsToEndOfStep = userSnapToStepDistanceFromManeuver / location.getSpeed(); | ||
boolean courseMatchesManeuverFinalHeading = false; | ||
|
||
// TODO set to eventually adjust for different direction profiles. |
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.
Let's ticket or remove if done.
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.
support for different direction profiles is already ticked in #24
} | ||
|
||
// TODO use this to update notification |
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.
Let's ticket or remove if done.
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.
noted on #25
} else { | ||
// TODO throw exception 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.
Let's ticket or remove if done.
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.
NavigationException
has been added and is now being thrown here.
} else { | ||
locationUpdatedThread.quit(); | ||
} | ||
|
||
// Lower accuracy to minimize battery usage while not in navigation mode. | ||
// TODO restore accuracy state to what user had before nav session |
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.
Let's ticket or remove if done.
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.
ticketed in #38 and removed.
Assert.assertEquals(NavigationConstants.MEDIUM_ALERT_LEVEL, alertLevel); | ||
} | ||
|
||
// TODO improve increaseIndex for testing |
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.
Let's ticket or remove if done.
@zugaldia ready for a second pass |
This PR is intended to fix a number of issues, mainly around the internal method monitorStepProgress which was difficult to write unit test for. It has now been broken up into separate methods that have one specific job, this is allowing me to write more unit test.
cc: @mapbox/navigation