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

Allow the use of multiple status banners #2747

Merged
merged 40 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
008c70e
created struct to represent showStatus, refactored relevant files, st…
Nov 20, 2020
2c91aa9
statuses append correctly and don't duplicate, continued work on show…
Nov 20, 2020
ff37fac
added show and hide to manageStatuses() method
Nov 23, 2020
f2ff5df
refactored rerouting status and broke array appending
Nov 24, 2020
8cb1376
refactor to have all logic for status banner management within Status…
Nov 24, 2020
3aac0ee
update integration test fixture
Nov 25, 2020
3e7f2dd
expose hideStatus(status:) to NavigationViewController and TopBannerV…
Nov 30, 2020
eb9600c
hiding enable precise location status is triggered automatically but …
Dec 1, 2020
a8a2020
issue with showing other statuses after one is hiddin is that there a…
Dec 3, 2020
28d0b16
shows and hides multiple status banners properly; enable precise loca…
Dec 8, 2020
d46a345
need to add another way to hide to handle the case where things don't…
Dec 8, 2020
60b02d7
reflect added test file
Dec 11, 2020
7be66f1
change how status is hidden in manageStatuses()
Dec 14, 2020
67ebac9
add delay to hideStatus() call within manageStatuses(), change enable…
Dec 14, 2020
beeee42
changed name of authorizationChange boolean for clarity
Dec 14, 2020
739d32e
deleted all calls/mentions of showStatus()
Dec 14, 2020
98b9730
clean up code, add more test cases
Dec 14, 2020
d9af246
test cases pass as expected
Dec 14, 2020
c77e74a
made test cases more resiliant; need to investigate using hideStatus(…
Dec 17, 2020
c77e3f6
trying to use dispatch queue in hide
Dec 22, 2020
eee4c9f
contained all delays within hide(), doesn't work
Dec 22, 2020
d989ead
works with only one dispatch queue, need to rerun tests
Dec 22, 2020
6cad500
deprecated old showStatus method, tests are better written and all bu…
Jan 5, 2021
81f30c2
updated test cases, wait for expectation fails but it's supposed to s…
Jan 5, 2021
1b73921
fixed failing test, removed debugging statements, clean up code
Jan 6, 2021
1b0d4e0
incorporating feedback
Jan 19, 2021
069922c
made priority public, added inline doc for addNewStatus()
Jan 20, 2021
53cd613
update changelog, clean up code, add reducedAccuracyActivatedMode == …
Feb 15, 2021
d6c4bcf
MapboxNavigationNative v31.0.1
1ec5 Feb 13, 2021
8790a4c
Add Changelog entry.
avi-c Feb 17, 2021
a673fe2
Fix CHANGELOG entry to mention CarPlay
avi-c Feb 17, 2021
5e41168
Typo
1ec5 Feb 23, 2021
b519916
update changelog, clean up code, add reducedAccuracyActivatedMode == …
Feb 15, 2021
057974e
incorporated feedback, update changelog
Mar 1, 2021
d948241
remove unnecessary doc comments from previous commit
Mar 1, 2021
7847b34
fix changelog issue
Mar 1, 2021
515dab5
fix status initialization in StatusViewTests
Mar 1, 2021
8c5719d
switch to typealias being priority instead of rawrepresentable
Mar 11, 2021
572b1b1
add doc comments, fix naming for priority value
Mar 11, 2021
fdd9ca6
clean up doc comments, remove Priority struct entirely
Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
## v1.3.0

* MapboxCoreNavigation can now be installed using Swift Package Manager. ([#2771](https://github.com/mapbox/mapbox-navigation-ios/pull/2771))
* The CarPlay guidance panel now shows lane guidance. ([#2798](https://github.com/mapbox/mapbox-navigation-ios/pull/2798))
* The CarPlay guidance panel now shows lane guidance. ([#1885](https://github.com/mapbox/mapbox-navigation-ios/pull/1885))
Copy link
Contributor

Choose a reason for hiding this comment

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

This change looks like a bad merge; can you revert it? Thanks!

* Old versions of routing tiles are automatically deleted from the cache to save storage space. ([#2807](https://github.com/mapbox/mapbox-navigation-ios/pull/2807))
* Fixed an issue where lane guidance icons would indicate the wrong arrow for certain maneuvers. ([#2796](https://github.com/mapbox/mapbox-navigation-ios/pull/2796), [#2809](https://github.com/mapbox/mapbox-navigation-ios/pull/2809))
* Fixed a crash showing a junction view. ([#2805](https://github.com/mapbox/mapbox-navigation-ios/pull/2805))
* Fixed an issue with CarPlay visual instructions where U-Turn maneuver icons were not being flipped properly based on regional driving side ([#2803](https://github.com/mapbox/mapbox-navigation-ios/pull/2803))
* Fixed swiping for right-to-left languages for the Guidance Card UI to be more intuitive. ([#2724](https://github.com/mapbox/mapbox-navigation-ios/pull/2724))
* `NavigationViewController` can now manage multiple status banners one after another. Renamed the `NavigationViewController.showStatus(title:spinner:duration:animated:interactive:)` method to `NavigationViewController.show(_:)` and added a corresponding `NavigationViewController.hide(_:)` method. Renamed the `NavigationStatusPresenter.showStatus(title:spinner:duration:animated:interactive:)` method to `NavigationStatusPresenter.show(_:)` and added a `NavigationStatusPresenter.hide(_:)` method. ([#2747](https://github.com/mapbox/mapbox-navigation-ios/pull/2747))

## v1.2.1

Expand Down
6 changes: 5 additions & 1 deletion MapboxNavigation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
B430D2FA25534FDC0088CC23 /* UserHaloCourseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */; };
B48CEFC125796FD300696BB3 /* route-for-vanishing-route-line.json in Resources */ = {isa = PBXBuildFile; fileRef = B48CEFAB25796F5A00696BB3 /* route-for-vanishing-route-line.json */; };
B4F7631C2578751300177B33 /* VanishingRouteLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F7631B2578751300177B33 /* VanishingRouteLine.swift */; };
C3D225512587F411007DBCDF /* StatusViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D225502587F411007DBCDF /* StatusViewTests.swift */; };
C51511D120EAC89D00372A91 /* CPMapTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51511D020EAC89D00372A91 /* CPMapTemplate.swift */; };
C51DF8661F38C31C006C6A15 /* Locale.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51DF8651F38C31C006C6A15 /* Locale.swift */; };
C51FC31720F689F800400CE7 /* CustomStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51FC31620F689F800400CE7 /* CustomStyles.swift */; };
Expand Down Expand Up @@ -884,9 +885,10 @@
AED2156E208F7FEA009AA673 /* NavigationViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewControllerTests.swift; sourceTree = "<group>"; };
AED6285522CBE4CE00058A51 /* ViewController+GuidanceCards.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "ViewController+GuidanceCards.swift"; path = "Example/ViewController+GuidanceCards.swift"; sourceTree = "<group>"; };
AEF2C8F12072B603007B061F /* routeWithTunnels_9thStreetDC.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = routeWithTunnels_9thStreetDC.json; sourceTree = "<group>"; };
B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHaloCourseView.swift; sourceTree = "<group>"; };
B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHaloCourseView.swift; sourceTree = "<group>"; };
B48CEFAB25796F5A00696BB3 /* route-for-vanishing-route-line.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "route-for-vanishing-route-line.json"; sourceTree = "<group>"; };
B4F7631B2578751300177B33 /* VanishingRouteLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VanishingRouteLine.swift; sourceTree = "<group>"; };
C3D225502587F411007DBCDF /* StatusViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusViewTests.swift; sourceTree = "<group>"; };
C51511D020EAC89D00372A91 /* CPMapTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPMapTemplate.swift; sourceTree = "<group>"; };
C51DF8651F38C31C006C6A15 /* Locale.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Locale.swift; sourceTree = "<group>"; };
C51FC31620F689F800400CE7 /* CustomStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CustomStyles.swift; path = Example/CustomStyles.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1369,6 +1371,7 @@
35B711D01E5E7AD2001EDA8D /* MapboxNavigationTests */ = {
isa = PBXGroup;
children = (
C3D225502587F411007DBCDF /* StatusViewTests.swift */,
16E11B53212B3D4700027CD3 /* Extensions and Categories */,
355DB5731EFA73410091BFB7 /* Fixtures */,
3527D2B61EC45FBD00C07FC9 /* Fixtures.xcassets */,
Expand Down Expand Up @@ -2677,6 +2680,7 @@
8D9CD7FF20880581004DC4B3 /* XCTestCase.swift in Sources */,
35DC585D1FABC61100B5A956 /* InstructionsBannerViewIntegrationTests.swift in Sources */,
3502231A205BC94E00E1449A /* Constants.swift in Sources */,
C3D225512587F411007DBCDF /* StatusViewTests.swift in Sources */,
DA0557252155040700A1F2AA /* RouteTests.swift in Sources */,
C55C299920D2E2F600B0406C /* NavigationMapViewTests.swift in Sources */,
4341758423061666004264A9 /* SnapshotTest+Mapbox.swift in Sources */,
Expand Down
14 changes: 13 additions & 1 deletion Sources/MapboxNavigation/NavigationComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,20 @@ public protocol CarPlayConnectionObserver: class {
This protocol defines a UI Component that is capable of presenting a status message.
*/
public protocol NavigationStatusPresenter: class {
/**
Shows a Status for a specified amount of time.
*/
func show(_: StatusView.Status)

/**
Hides a given Status without hiding the status view.
*/
func hide(_: StatusView.Status)

/**
Shows the status view for a specified amount of time.
`showStatus()` uses a default value for priority and the title input as identifier. To use these variables, use `show(_:)`
*/
func showStatus(title: String, spinner: Bool, duration: TimeInterval, animated: Bool, interactive: Bool)
@available(*, deprecated, message: "Add a status using show(_:) instead")
func showStatus(title: String, spinner spin: Bool, duration: TimeInterval, animated: Bool, interactive: Bool)
}
45 changes: 39 additions & 6 deletions Sources/MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum MapOrnamentPosition {
`CarPlayNavigationViewController` manages the corresponding user interface on a CarPlay screen.
*/
open class NavigationViewController: UIViewController, NavigationStatusPresenter {

/**
A `Route` object constructed by [MapboxDirections](https://docs.mapbox.com/ios/api/directions/) along with its index in a `RouteResponse`.

Expand All @@ -51,6 +52,8 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
}
}

var didChangeAuthorizationIsFirstCalled = true

/**
A `Route` object constructed by [MapboxDirections](https://docs.mapbox.com/ios/api/directions/).
*/
Expand Down Expand Up @@ -401,7 +404,10 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
guard AVAudioSession.sharedInstance().outputVolume <= NavigationViewMinimumVolumeForWarning else { return }

let title = NSLocalizedString("INAUDIBLE_INSTRUCTIONS_CTA", bundle: .mapboxNavigation, value: "Adjust Volume to Hear Instructions", comment: "Label indicating the device volume is too low to hear spoken instructions and needs to be manually increased")
showStatus(title: title, spinner: false, duration: 3, animated: true, interactive: false)

// create low volume notification status and append to array of statuses
let lowVolumeStatus = StatusView.Status(identifier: "INAUDIBLE_INSTRUCTIONS_CTA", title: title, duration: 3, animated: true, priority: StatusView.Priority(value: 3))
show(lowVolumeStatus)
}


Expand Down Expand Up @@ -462,9 +468,28 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
UNUserNotificationCenter.current().add(notificationRequest, withCompletionHandler: nil)
}

public func showStatus(title: String, spinner: Bool, duration: TimeInterval, animated: Bool, interactive: Bool) {
/**
Shows a Status for a specified amount of time.
*/
public func show(_ status: StatusView.Status) {
navigationComponents.compactMap({ $0 as? NavigationStatusPresenter }).forEach {
$0.show(status)
}
}

/**
Hides a given Status without hiding the status view.
*/
public func hide(_ status: StatusView.Status) {
navigationComponents.compactMap({ $0 as? NavigationStatusPresenter }).forEach {
$0.showStatus(title: title, spinner: spinner, duration: duration, animated: animated, interactive: interactive)
$0.hide(status)
}
}

@available(*, deprecated, message: "Add a status using show(_:) instead")
public func showStatus(title: String, spinner spin: Bool, duration: TimeInterval, animated: Bool, interactive: Bool) {
navigationComponents.compactMap({ $0 as? NavigationStatusPresenter }).forEach {
$0.showStatus(title: title, spinner: spin, duration: duration, animated: animated, interactive: interactive)
}
}
}
Expand Down Expand Up @@ -724,21 +749,29 @@ extension NavigationViewController: NavigationServiceDelegate {
public func navigationServiceShouldDisableBatteryMonitoring(_ service: NavigationService) -> Bool {
return navigationComponents.allSatisfy { $0.navigationServiceShouldDisableBatteryMonitoring(service) }
}

public func navigationServiceDidChangeAuthorization(_ service: NavigationService, didChangeAuthorizationFor locationManager: CLLocationManager) {
// CLLocationManager.accuracyAuthorization was introduced in the iOS 14 SDK in Xcode 12, so Xcode 11 doesn’t recognize it.
guard let accuracyAuthorizationValue = locationManager.value(forKey: "accuracyAuthorization") as? Int else { return }
let accuracyAuthorization = MBNavigationAccuracyAuthorization(rawValue: accuracyAuthorizationValue)
let previousAuthorizationValue = 1 - accuracyAuthorizationValue

// create authorization status
let title = NSLocalizedString("ENABLE_PRECISE_LOCATION", bundle: .mapboxNavigation, value: "Enable precise location to navigate", comment: "Label indicating precise location is off and needs to be turned on to navigate")
let authorizationStatus = StatusView.Status(identifier: "ENABLE_PRECISE_LOCATION", title: title, duration: .infinity, priority: StatusView.Priority(value: 1))

if #available(iOS 14.0, *), accuracyAuthorization == .reducedAccuracy {
let title = NSLocalizedString("ENABLE_PRECISE_LOCATION", bundle: .mapboxNavigation, value: "Enable precise location to navigate", comment: "Label indicating precise location is off and needs to be turned on to navigate")
showStatus(title: title, spinner: false, duration: 20, animated: true, interactive: false)
show(authorizationStatus)
mapView?.reducedAccuracyActivatedMode = true
} else if #available(iOS 14.0, *), previousAuthorizationValue == 1, didChangeAuthorizationIsFirstCalled == false {
hide(authorizationStatus)
mapView?.reducedAccuracyActivatedMode = false
} else {
//Fallback on earlier versions
mapView?.reducedAccuracyActivatedMode = false
return
}
didChangeAuthorizationIsFirstCalled = false
}

// MARK: - Building Extrusion Highlighting
Expand Down
Loading