Skip to content
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

Add Imperial / Metric support for UI & Notification #501

Merged
merged 7 commits into from
Nov 21, 2017

Conversation

danesfeder
Copy link
Contributor

@danesfeder danesfeder commented Nov 14, 2017

  • Adds NavigationViewOptions to consolidate variables passed into the drop-in UI
  • ViewModels now look for unit type in preferences
  • Custom views can now be updated with a RouteProgress + NavigationUnitType (if you want to use the views individually)
  • Adds int unitType to MapboxNavigationOptions to set the correct distance in the notification

TODO:

  • Use NavigationViewOptions for transferring DirectionsRoute or Point data

cc @ericrwolfe

@danesfeder danesfeder added the feature New feature request. label Nov 14, 2017
@danesfeder danesfeder self-assigned this Nov 14, 2017
@danesfeder danesfeder added ⚠️ DO NOT MERGE PR should not be merged! ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Nov 14, 2017
*/
public static void startNavigation(Activity activity, DirectionsRoute route,
String awsPoolId, boolean simulateRoute) {
public static void startNavigation(Activity activity, DirectionsRoute route, NavigationViewOptions options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

*/
public static void startNavigation(Activity activity, Point origin, Point destination,
String awsPoolId, boolean simulateRoute) {
NavigationViewOptions options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

*/
public void startNavigation(Activity activity) {
routeViewModel.extractLaunchData(activity);
public void startNavigation(NavigationViewOptions options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

private boolean shouldShowThenStep;

public InstructionModel(RouteProgress progress, DecimalFormat decimalFormat) {
public InstructionModel(RouteProgress progress, DecimalFormat decimalFormat,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

* @since 0.6.2
*/
@SuppressWarnings("UnusedDeclaration")
public void update(RouteProgress routeProgress) {
public void update(RouteProgress routeProgress, @NavigationUnitType.UnitType int unitType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

*/
public void extractLaunchData(Activity activity) {
public void extractLaunchData(NavigationViewOptions options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

*/
@SuppressWarnings("UnusedDeclaration")
public void update(RouteProgress routeProgress) {
public void update(RouteProgress routeProgress, @NavigationUnitType.UnitType int unitType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

public SummaryModel(RouteProgress progress, DecimalFormat decimalFormat) {
distanceRemaining = distanceFormatterBold(progress.distanceRemaining(), decimalFormat, false);
public SummaryModel(RouteProgress progress, DecimalFormat decimalFormat,
@NavigationUnitType.UnitType int unitType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok here breaking SemVer?

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are fine breaking SemVer :shipit:
The rest of the comments are minor details.

int unitType) {

boolean isImperialUnitType = unitType == NavigationUnitType.TYPE_IMPERIAL;
String largeUnitFormat = isImperialUnitType ? " mi" : " km";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers.


boolean isImperialUnitType = unitType == NavigationUnitType.TYPE_IMPERIAL;
String largeUnitFormat = isImperialUnitType ? " mi" : " km";
String smallUnitFormat = isImperialUnitType ? " ft" : " m";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here ☝️

return TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, TurfConstants.UNIT_MILES) < 10
&& TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, TurfConstants.UNIT_FEET) > 401;
private static boolean mediumDistance(double distance, String largeFinalUnit, String smallFinalUnit) {
return TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, largeFinalUnit) < 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers.

private static boolean longDistance(double distance) {
return TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, TurfConstants.UNIT_MILES) > 10;
private static boolean longDistance(double distance, String largeFinalUnit) {
return TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, largeFinalUnit) > 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here ☝️

@@ -37,6 +37,7 @@ public void setUp() throws Exception {
route = response.routes().get(0);
}

@Ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove sanity test if it's not worth it anymore?

@danesfeder danesfeder merged commit 3755824 into master Nov 21, 2017
@danesfeder danesfeder deleted the dan-metric-support branch November 21, 2017 20:38
@danesfeder danesfeder restored the dan-metric-support branch November 21, 2017 20:38
@danesfeder danesfeder deleted the dan-metric-support branch November 21, 2017 20:39
@danesfeder danesfeder mentioned this pull request Dec 6, 2017
10 tasks
@Guardiola31337 Guardiola31337 added the backwards incompatible Requires a SEMVER major version change. label Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible Requires a SEMVER major version change. feature New feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants