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

Create separate options for Launcher and View #782

Merged
merged 5 commits into from
Mar 31, 2018
Merged

Conversation

danesfeder
Copy link
Contributor

@danesfeder danesfeder commented Mar 19, 2018

Closes #779, Closes #754, Closes #794

This PR introduces NavigationLauncherOptions to be used with NavigationLauncher. Both NavigationLauncherOptions and NavigationViewOptions subclass NavigationOptions as there a few shared variables between both options objects.

Previously NavigationViewOptions were used with NavigationLauncher as well as NavigationView#startNavigation. This didn't make sense because NavigationLauncher wasn't considering all of the variables passed from NavigationViewOptions, such as the listeners.

@Imadargyrets
Copy link

Hey guys i'm still stuck here ! please what can i do to resolve this problem ?

android:defaultValue="1"
android:entries="@array/route_profile_array"
android:entryValues="@array/route_profile_values_array"
android:key="route_profile"
Copy link
Contributor

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);
Copy link
Contributor

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);
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 this is redundant but I'm going to dig deeper to find out

Copy link
Contributor

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

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.

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();
Copy link
Contributor

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 Strings) 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", "");
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 👇

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, ""));
Copy link
Contributor

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.`
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh good catch 🍍

@danesfeder danesfeder merged commit 064d8ee into master Mar 31, 2018
@danesfeder danesfeder deleted the dan-broken-profile branch March 31, 2018 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants