Skip to content

Convert NavigationView to View - #346

Merged
danesfeder merged 23 commits into
masterfrom
dan-nav-view
Oct 12, 2017
Merged

danesfeder merged 23 commits into
masterfrom
dan-nav-view

Conversation

@danesfeder

@danesfeder danesfeder commented Oct 10, 2017 •

Copy link
Copy Markdown
Contributor

Converting NavigationView to a plain View will allow us to inflate from either an Activity or Fragment / in set portions of the layouts being inflated.

Todo:

  • Callback for finishing navigation (clicking "X" or "End Navigation" in the notification)
  • Handle if inflated with Context that isn't a LifecycleOwner
  • Use NavigationLauncher to launch new Activity that inflates NavigationView
  • Fix bottomsheet directions list (re-update) when rerouting
  • Better system for nav puck placement
  • Code cleanup and javadoc

cc @ericrwolfe

@danesfeder danesfeder added feature New feature request. navigation-ui ⚠️ DO NOT MERGE PR should not be merged! labels Oct 10, 2017
@ericrwolfe ericrwolfe added this to the v0.7.0-1 milestone Oct 11, 2017
@ericrwolfe ericrwolfe modified the milestones: v0.7.0-1, v0.7.0 Oct 11, 2017
@danesfeder

danesfeder commented Oct 11, 2017 •

Copy link
Copy Markdown
Contributor Author

@tobrun @Guardiola31337 @zugaldia Working on a better way to aim the camera to always account for / be above the bottomsheet. If you have any immediate ideas, please let me know. Thank you!

Issue visible in scenarios like:
ezgif com-video-to-gif

cc @ericrwolfe

@zugaldia

Copy link
Copy Markdown
Member

@tobrun @Guardiola31337 @zugaldia Working on a better way to aim the camera to always account for / be above the bottomsheet. If you have any immediate ideas, please let me know. Thank you!

Could we address that as a follow up ticket/PR? That behavior was already present in the previous NavigationView (Activity), right? We should keep this PR focused on the View conversion.

@danesfeder

Copy link
Copy Markdown
Contributor Author

That behavior was already present in the previous NavigationView (Activity), right?

@zugaldia Yeah there was a bug with the puck being covered at the start of the UI. The View implementation just really exposes this bug because devs can set whatever height for the View they'd like. I'm cool with holding on this for now though

locationViewModel = ViewModelProviders.of(this).get(LocationViewModel.class);
routeViewModel = ViewModelProviders.of(this).get(RouteViewModel.class);
navigationViewModel = ViewModelProviders.of(this).get(NavigationViewModel.class);
if (getContext() instanceof FragmentActivity) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we throw the ClassCastException here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getLifecycle().addObserver(locationLayer);
getLifecycle().addObserver(locationViewModel);
getLifecycle().addObserver(navigationViewModel);
((LifecycleOwner) getContext()).getLifecycle().addObserver(locationLayer);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same here - we are assuming the context is a LifecycleOwner

Copy link
Copy Markdown
Member

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 throw an exception because it's gonna crash anyway if this isn't a LifecycleOwner and also gives us the opportunity to provide a better error message ("make sure that the provided context is a valid LifecycleOwner").

Guardiola31337 and others added 3 commits October 12, 2017 11:51
* send an empty array when either locations before or after are empty arrays

* send empty array even when locations before and after are null
@danesfeder

Copy link
Copy Markdown
Contributor Author

Combined with MapboxMap#setPadding() (thanks @tobrun), this PR will address issues we've been seeing with the puck underneath the bottom sheet. This new solution should scale to all devices and also address if someone sets NavigationView to 50% of the screen:

screen_comparison

@danesfeder

Copy link
Copy Markdown
Contributor Author

Running on half of the Moto G Play:

device-2017-10-12-142605

@danesfeder danesfeder self-assigned this Oct 12, 2017
}

/**
/**a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this a is accidental.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, good catch

public void onSlide(@NonNull View bottomSheet, float slideOffset) {
navigationPresenter.onBottomSheetSlide(slideOffset,
sheetShadow.getVisibility() != View.VISIBLE);
sheetShadow.getVisibility() == View.VISIBLE);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was this change of behavior intentional?


private void addLegSteps(RouteProgress routeProgress) {
if (newLeg(routeProgress) && legHasSteps(routeProgress)) {
if ((newLeg(routeProgress) || legSteps.size() == 0) && legHasSteps(routeProgress)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

intentional? were you trying to correct another issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we weren't repopulating the directions list during re-route scenarios (with the new legs) - the size will be zero because clear the list when we get an off-route

getLifecycle().addObserver(locationLayer);
getLifecycle().addObserver(locationViewModel);
getLifecycle().addObserver(navigationViewModel);
((LifecycleOwner) getContext()).getLifecycle().addObserver(locationLayer);

Copy link
Copy Markdown
Member

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 throw an exception because it's gonna crash anyway if this isn't a LifecycleOwner and also gives us the opportunity to provide a better error message ("make sure that the provided context is a valid LifecycleOwner").

locationViewModel = ViewModelProviders.of(this).get(LocationViewModel.class);
routeViewModel = ViewModelProviders.of(this).get(RouteViewModel.class);
navigationViewModel = ViewModelProviders.of(this).get(NavigationViewModel.class);
if (getContext() instanceof FragmentActivity) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@danesfeder danesfeder added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Oct 12, 2017
@danesfeder
danesfeder merged commit d8615f7 into master Oct 12, 2017
@danesfeder
danesfeder deleted the dan-nav-view branch October 12, 2017 22:04
Grsmto pushed a commit to Grsmto/mapbox-navigation-android that referenced this pull request Oct 23, 2017
* master: (36 commits)
  Add bearing for each waypoint (mapbox#408)
  Adjust (port / land) Top Banners and add secondary text view (mapbox#404)
  Release 0.6.3 (mapbox#386)
  Add feedback method (mapbox#392)
  Project clean up (mapbox#397)
  limit routeline GeoJSON to maxzoom 16 to avoid creating more clipping mask for high zoom levels (mapbox#391)
  API Voice instructions (mapbox#394)
  MAS 3.0 (mapbox#373)
  Convert NavigationView to View  (mapbox#346)
  only raw location in metrics (mapbox#349)
  only reroute once users traveled past 50 meters (mapbox#347)
  Account for different landscape view when adjusting drawable colors API 19 and below (mapbox#343)
  Send empty arrays properly (mapbox#354)
  send feedback identifier when the event happens (mapbox#359)
  Add Null check on the notification manager (mapbox#332)
  fix hardcoded feedback id generating a new one on each navigation session (mapbox#352)
  fixed broken link to test app in documentation (mapbox#357)
  adjusted readme to 0.6.2 (mapbox#333)
  Release v0.6.2 (mapbox#324)
  reroute metric (mapbox#296)
  ...

# Conflicts:
#	app/src/main/java/com/mapbox/services/android/navigation/testapp/activity/MockNavigationActivity.java
#	navigation/libandroid-navigation/build.gradle
#	navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/DefaultMilestones.java
#	navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/offroute/OffRouteDetector.java
#	scripts/release.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants