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 12/24 hour format Navigation View Option #805

Merged
merged 1 commit into from
Mar 28, 2018

Conversation

Guardiola31337
Copy link
Contributor

  • Adds 12/24 hour format NavigationViewOption

If the dev doesn't provide a NavigationTimeFormat.Type explicitly NavigationTimeFormat.NONE_SPECIFIED is set (default) and the device's 24-hour format setting (DateFormat.is24HourFormat(Context)) is used.

Fixes #740

cc @danesfeder @devotaaabel

Copy link
Contributor

@danesfeder danesfeder left a comment

Choose a reason for hiding this comment

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

Just some cleanup questions / comments.

One thing that's we also have to look at here is MapboxNavigationNotification which also uses TimeUtils#formatArrivalTime. We might have to move the timeFormatType to MapboxNavigationOptions so it can be used for both the core + UI libraries. The notification is currently created in the core library for the NavigationService

@@ -371,12 +374,15 @@ public void startNavigation(NavigationViewOptions options) {

private void setLocale(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.

I think it would be good to refactor this method, as it's called setLocale but it's setting Locale, unitType, and timeFormatType. For readability, it may be good to extract these each into their own private method.

boolean isDeviceTwentyFourHourFormat = DateFormat.is24HourFormat(getApplication());
String arrivalTime = formatTime(time, (int) routeProgress.durationRemaining(), timeFormatType,
isDeviceTwentyFourHourFormat);
summaryModel.setValue(new SummaryModel(getApplication(), routeProgress, locale, unitType, arrivalTime));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move the arrival time formatting into the SummaryModel itself? Application and routeProgress are already being passed. I think it would clean up onProgressChange

It would also remove the duplicate code found in SummaryBottomSheet

@@ -40,7 +45,10 @@
private ProgressBar rerouteProgressBar;
private boolean isRerouting;
private Locale locale;
private @NavigationUnitType.UnitType int unitType = NavigationUnitType.NONE_SPECIFIED;
@NavigationUnitType.UnitType
private int unitType = NavigationUnitType.NONE_SPECIFIED;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to align how both the unitType and timeFormatType are both set to NONE_SPECIFIED initially. Currently the time format is set in the NavigationViewOptions#builder(), while unitType is set here in SummaryBottomSheet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I went ahead and removed the unitType initialization here. It's not necessary because we're already initializing it in MapboxNavigationOptions#builder() 👀

@Guardiola31337 Guardiola31337 force-pushed the pg-740-navigation-view-option-12-24-time branch 2 times, most recently from 988ed70 to d4cd5da Compare March 28, 2018 09:05
@Guardiola31337
Copy link
Contributor Author

One thing that's we also have to look at here is MapboxNavigationNotification which also uses TimeUtils#formatArrivalTime. We might have to move the timeFormatType to MapboxNavigationOptions so it can be used for both the core + UI libraries. The notification is currently created in the core library for the NavigationService

Yeah, I noticed as well. BTW I think we should do that (consolidate TimeUtils#formatArrivalTime and TimeUtils#formatTime methods and use only one of them across the SDK) when we tackle #713 i.e. in a different PR. What do you think?

Addressed the rest of the comments. This is ready for a second round of 👀

@Guardiola31337 Guardiola31337 force-pushed the pg-740-navigation-view-option-12-24-time branch from d4cd5da to 34f21e6 Compare March 28, 2018 13:50
Copy link
Contributor

@danesfeder danesfeder left a comment

Choose a reason for hiding this comment

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

@Guardiola31337 this looks great, thanks for the updates :shipit:

@Guardiola31337 Guardiola31337 merged commit ec7f0af into master Mar 28, 2018
@Guardiola31337 Guardiola31337 deleted the pg-740-navigation-view-option-12-24-time branch March 28, 2018 15:00
@danesfeder danesfeder mentioned this pull request Apr 3, 2018
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants