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

[Android Auto] Add support for Junction Views #6849

Merged
merged 8 commits into from
Jan 20, 2023

Conversation

tomaszrybakiewicz
Copy link
Contributor

Closes NAVAND-980

Description

Android Auto

  • introduced CarNavigationInfoServices.junctionApi(...) factory method
  • updated CarNavigationInfoProvider to detect and load Junction Bitmap on banner instructions change, and inject it into NavigationTemplate.NavigationInfo via CarNavigationInfoMapper
  • optimized CarLanesImageRenderer by caching the last generated image in the LruCache of size 1

Android Auto App

  • rewired MainActivity and introduced DrawerActivity for the debug menu - borrowed from the qa-test-app
  • added junction TestRoutes coordinates - borrowed from the examples//MapboxJunctionActivity
    • these routes must be fetched using a junction-enabled access token

Screenshots or Gifs

Screen recording of the android-auto-app running on Google Pixel 6 and Android Auto running on Desktop Head Unit
(playback speed up to 2x)

output.mp4

@tomaszrybakiewicz tomaszrybakiewicz added feature New feature request. Android Auto Bugs, improvements and feature requests on Android Auto. labels Jan 19, 2023
@github-actions
Copy link

github-actions bot commented Jan 19, 2023

Changelog

Features

  • Introduced ViewStyleCustomization.infoPanelGuidelineMaxPosPercent that allows customization of the NavigationView InfoPanel bottom guideline maximum position. Increased default value to 50%. #6792

Bug fixes and improvements

  • Each newly instantiated MapboxRouteArrowView class will initialize the layers with the provided options on the first render call. Previously this would only be done if the layers hadn't already been initialized. #6466

  • ⚠️ Updated the NavigationView default navigation puck asset. #6678

    Previous puck can be restored by injecting LocationPuck2D with the bearingImage set to com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon drawable:

    navigationView.customizeViewStyles {
        locationPuckOptions = LocationPuckOptions.Builder(context)
            .defaultPuck(
                LocationPuck2D(
                    bearingImage = ContextCompat.getDrawable(
                        context,
                        com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon,
                    )
                )
            )
            .idlePuck(regularPuck(context))
            .build()
    }
  • Improved MapboxNavigation#startReplayTripSession and ReplayRouteSession so that the previous trip session does not need to be stopped. ⚠️ ReplayRouteSession#onDetached removed the call to stopTripSession. #6817

  • Fixed an issue with NavigationView that caused info panel to shrink in landscape mode with a full screen theme. #6780

  • Fixed an issue where the first voice instruction might have been played twice. #6766

  • Introduced NavigationViewListener.onSpeedInfoClicked that would be triggered when MapboxSpeedInfoView is clicked upon. #6770

  • Fixed standalone MapboxManeuverView appearance when the app also integrates Drop-In UI. #6774

  • Fixed a rare java.lang.NullPointerException: Attempt to read from field 'SpeechAnnouncement PlayCallback.announcement' on a null object reference crash in PlayCallback.getAnnouncement. #6760

  • Added guarantees that route progress with RouteProgress#currentState == OFF_ROUTE arrives earlier than NavigationRerouteController#reroute is called. #6764

Known issues ⚠️

Other changes

Android Auto Changelog

Features

  • Added support for Junction Views. #6849

Bug fixes and improvements

@codecov
Copy link

codecov bot commented Jan 19, 2023

Codecov Report

Merging #6849 (ae83881) into main (ca03770) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #6849   +/-   ##
=========================================
  Coverage     72.63%   72.63%           
  Complexity     5568     5568           
=========================================
  Files           780      780           
  Lines         30104    30104           
  Branches       3556     3556           
=========================================
  Hits          21867    21867           
  Misses         6809     6809           
  Partials       1428     1428           

Comment on lines +7 to +13
<item>JCT</item>
<item>SAPA</item>
<item>CITYREAL</item>
<item>TOLLBRANCH</item>
<item>AFTERTOLL</item>
<item>EXPRESSWAY_ENTRANCE</item>
<item>EXPRESSWAY_EXIT</item>
Copy link
Contributor

Choose a reason for hiding this comment

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

i can see these are copied over from the MapboxJunctionActivity so could be considered out of scope for this change.

but i think we should have human readable descriptions for these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What human-readable description? These values are TestRoutes enum names.

Copy link
Contributor

@kmadsen kmadsen Jan 19, 2023

Choose a reason for hiding this comment

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

https://www.google.com/search?q=SAPA+mapbox+junction+view

I don't know what SAPA means, do you? If you do I'm only suggesting that we add words

/**
* Simple component for detecting and rendering Junction Views.
*/
private class Junctions(
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that junction views will eventually be part of drop-in-ui and this is an android-auto example. I think we should remove the app code so we don't have to maintain it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll remove it once Drop-In UI adds Junction View support.

@tomaszrybakiewicz
Copy link
Contributor Author

tomaszrybakiewicz commented Jan 19, 2023

@kmadsen Thanks for the review. I've applied your suggestions. Please let me know if there is anything else that needs to change.


assertNotNull(img1)
assertSame(img1, img2)
}
Copy link
Contributor

@kmadsen kmadsen Jan 19, 2023

Choose a reason for hiding this comment

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

This is not testing the actual equality since it's the same object.

It may be better to add build the data objects, also test the cache miss case

    @OptIn(ExperimentalMapboxNavigationAPI::class)
    @Test
    fun cache_hit_test() {
        val lane1 = LaneFactory.buildLane(
            allLanes = listOf(LaneIndicator.Builder()
                .drivingSide("right")
                .activeDirection("uturn")
                .isActive(true)
                .directions(listOf("uturn"))
                .build())
        )
        val lane2 = LaneFactory.buildLane(
            allLanes = listOf(LaneIndicator.Builder()
                .drivingSide("right")
                .activeDirection("uturn")
                .isActive(true)
                .directions(listOf("uturn"))
                .build())
        )

        val img1 = carLanesImageGenerator.renderLanesImage(lane1)
        val img2 = carLanesImageGenerator.renderLanesImage(lane2)

        assertNotNull(img1)
        assertSame(img1, img2)
    }

    @OptIn(ExperimentalMapboxNavigationAPI::class)
    @Test
    fun cache_miss_test() {
        val lane1 = LaneFactory.buildLane(
            allLanes = listOf(LaneIndicator.Builder()
                .drivingSide("right")
                .activeDirection("uturn")
                .isActive(true)
                .directions(listOf("uturn"))
                .build())
        )
        val lane2 = LaneFactory.buildLane(
            allLanes = listOf(LaneIndicator.Builder()
                .drivingSide("right")
                .activeDirection("uturn")
                .isActive(true)
                .directions(listOf("straight"))
                .build())
        )

        val img1 = carLanesImageGenerator.renderLanesImage(lane1)
        val img2 = carLanesImageGenerator.renderLanesImage(lane2)

        assertNotNull(img1)
        assertNotSame(img1, img2)
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

But the cache miss case is covered by the other tests, but this will fail even though the values are the same

    @Test
    fun cache_test() {
        val lane1 = mockk<Lane> {
            every { allLanes } returns listOf(
                mockk {
                    every { drivingSide } returns "right"
                    every { activeDirection } returns "uturn"
                    every { isActive } returns true
                    every { directions } returns listOf("uturn")
                }
            )
        }
        val lane2 = mockk<Lane> {
            every { allLanes } returns listOf(
                mockk {
                    every { drivingSide } returns "right"
                    every { activeDirection } returns "uturn"
                    every { isActive } returns true
                    every { directions } returns listOf("uturn")
                }
            )
        }
        val img1 = carLanesImageGenerator.renderLanesImage(lane1)
        val img2 = carLanesImageGenerator.renderLanesImage(lane2)

        assertNotNull(img1)
        assertSame(img1, img2)
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. I've updated CarLanesImageRendererTest to include both tests.

Copy link
Contributor

@kmadsen kmadsen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for addressing feedback!

@SevaZhukov it seems the changelog verification fails when android-auto changelogs are added

@tomaszrybakiewicz tomaszrybakiewicz added skip changelog Should not be added into version changelog. and removed skip changelog Should not be added into version changelog. labels Jan 20, 2023
@tomaszrybakiewicz tomaszrybakiewicz merged commit 5f67450 into main Jan 20, 2023
@tomaszrybakiewicz tomaszrybakiewicz deleted the NAVAND-980_tr-android-auto_junction_views branch January 20, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Auto Bugs, improvements and feature requests on Android Auto. feature New feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants