-
Notifications
You must be signed in to change notification settings - Fork 319
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
Create separate options for Launcher and View #782
Conversation
9a059d9
to
6934d07
Compare
65cc2ef
to
fabfe57
Compare
Hey guys i'm still stuck here ! please what can i do to resolve this problem ? |
fabfe57
to
59c4ade
Compare
android:defaultValue="1" | ||
android:entries="@array/route_profile_array" | ||
android:entryValues="@array/route_profile_values_array" | ||
android:key="route_profile" |
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.
you could add this to strings.xml as route_profile_key
like the other list preferences do
.shouldSimulateRoute(getShouldSimulateRoute()) | ||
.navigationOptions(navigationOptions); |
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.
Are you sure it's safe to remove this logic? This was for when the user changes language, so you fetch a new route.
Locale locale) { | ||
Integer unitType = options.unitType(); | ||
if (unitType == null) { | ||
unitType = LocaleUtils.getUnitTypeForLocale(locale); |
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.
I think this is redundant but I'm going to dig deeper to find out
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.
@danesfeder as of fix in #811 this is definitely redundant
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.
After addressing these minor issues and clarifying the questions asked, this should be ready to go 🚀
@@ -231,7 +229,7 @@ public void onResponse(Call<DirectionsResponse> call, Response<DirectionsRespons | |||
mapRoute.addRoutes(response.body().routes()); | |||
boundCameraToRoute(); | |||
} else { | |||
Snackbar.make(mapView, "Please select a longer route", BaseTransientBottomBar.LENGTH_SHORT).show(); | |||
Snackbar.make(mapView, "Please select a longer route", Snackbar.LENGTH_SHORT).show(); |
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.
In order to increase readability, what about replacing magic numbers (literals in general including String
s) with constants with a particular meaning?
Further information: Replace Magic Number with Symbolic Constant.
@@ -310,27 +308,26 @@ private boolean getShouldSimulateRoute() { | |||
return sharedPreferences.getBoolean(getString(R.string.simulate_route_key), false); | |||
} | |||
|
|||
private String getRouteProfile() { | |||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); | |||
return sharedPreferences.getString("route_profile", ""); |
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.
Magic numbers 👇
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
options.awsPoolId(preferences | ||
.getString(NavigationConstants.NAVIGATION_VIEW_AWS_POOL_ID, null)); | ||
options.shouldSimulateRoute(preferences | ||
.getBoolean(NavigationConstants.NAVIGATION_VIEW_SIMULATE_ROUTE, false)); | ||
options.directionsProfile(preferences | ||
.getString(NavigationConstants.NAVIGATION_VIEW_ROUTE_PROFILE_KEY, "")); |
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.
Magic number ""
@@ -23,7 +24,7 @@ | |||
* You can launch the UI with either a route you have already retrieved from | |||
* {@link com.mapbox.services.android.navigation.v5.navigation.NavigationRoute} or you can pass a | |||
* {@link Point} origin and {@link Point} destination and the UI will request the {@link DirectionsRoute} | |||
* while initializing. | |||
* while initializing.` |
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.
Typo `
@@ -90,7 +90,7 @@ private void extractStepResources(RouteProgress progress) { | |||
|
|||
private void formatStepDistance(Context context, RouteProgress progress, | |||
Locale locale, @NavigationUnitType.UnitType int unitType) { | |||
if (distanceUtils == null || this.locale != locale || this.unitType != unitType) { | |||
if (distanceUtils == null || this.locale.equals(locale) || this.unitType != unitType) { |
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.
To match previous behavior (this.locale != locale
), shouldn't be !this.locale.equals(locale)
instead? Maybe it's a bug fix that I'm missing. Could you clarify?
@@ -72,7 +72,7 @@ public void onViewDetachedFromWindow(InstructionViewHolder holder) { | |||
|
|||
public void updateSteps(Context context, RouteProgress routeProgress, | |||
Locale locale, @NavigationUnitType.UnitType int unitType) { | |||
if (distanceUtils == null || this.locale != locale || this.unitType != unitType) { | |||
if (distanceUtils == null || this.locale.equals(locale) || this.unitType != unitType) { |
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.
To match previous behavior (this.locale != locale
), shouldn't be !this.locale.equals(locale)
instead? Maybe it's a bug fix that I'm missing. Could you clarify?
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.
Ahh good catch 🍍
59c4ade
to
3360da8
Compare
Closes #779, Closes #754, Closes #794
This PR introduces
NavigationLauncherOptions
to be used withNavigationLauncher
. BothNavigationLauncherOptions
andNavigationViewOptions
subclassNavigationOptions
as there a few shared variables between both options objects.Previously
NavigationViewOptions
were used withNavigationLauncher
as well asNavigationView#startNavigation
. This didn't make sense becauseNavigationLauncher
wasn't considering all of the variables passed fromNavigationViewOptions
, such as the listeners.