diff --git a/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift b/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift index fa4d4d7742..2cfa7feaf7 100644 --- a/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift +++ b/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift @@ -152,9 +152,9 @@ final class MopubBanner: NSObject, Banner { let fbConfig = FacebookNativeAdRenderer.rendererConfiguration(with: settings) request = MPNativeAdRequest(adUnitIdentifier: placementID, rendererConfigurations: [config, fbConfig]) let targeting = MPNativeAdRequestTargeting() - targeting?.keywords = "user_lang:\(AppInfo.shared().twoLetterLanguageId ?? "")" + targeting?.keywords = "user_lang:\(AppInfo.shared().twoLetterLanguageId)" targeting?.desiredAssets = [kAdTitleKey, kAdTextKey, kAdIconImageKey, kAdCTATextKey] - if let location = MWMLocationManager.lastLocation() { + if let location = LocationManager.lastLocation() { targeting?.location = location } request.targeting = targeting diff --git a/iphone/Maps/Core/Location/MWMLocationManager+SpeedAndAltitude.swift b/iphone/Maps/Core/Location/MWMLocationManager+SpeedAndAltitude.swift index d2ff7a940b..72c30b7c8e 100644 --- a/iphone/Maps/Core/Location/MWMLocationManager+SpeedAndAltitude.swift +++ b/iphone/Maps/Core/Location/MWMLocationManager+SpeedAndAltitude.swift @@ -1,4 +1,4 @@ -extension MWMLocationManager { +extension LocationManager { @objc static func speedSymbolFor(_ speed: Double) -> String { switch max(speed, 0) { case 0 ..< 1: return "🐢" diff --git a/iphone/Maps/Core/Location/MWMLocationManager.h b/iphone/Maps/Core/Location/MWMLocationManager.h index 81dbceffbd..f5e3f7c366 100644 --- a/iphone/Maps/Core/Location/MWMLocationManager.h +++ b/iphone/Maps/Core/Location/MWMLocationManager.h @@ -1,6 +1,9 @@ #import "MWMMyPositionMode.h" #import "MWMLocationObserver.h" +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(LocationManager) @interface MWMLocationManager : NSObject + (void)start; @@ -12,9 +15,9 @@ + (void)setMyPositionMode:(MWMMyPositionMode)mode; -+ (CLLocation *)lastLocation; ++ (nullable CLLocation *)lastLocation; + (BOOL)isLocationProhibited; -+ (CLHeading *)lastHeading; ++ (nullable CLHeading *)lastHeading; + (void)applicationDidBecomeActive; + (void)applicationWillResignActive; @@ -29,3 +32,5 @@ + (instancetype) new __attribute__((unavailable("call +manager instead"))); @end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Theme/Core/ThemeManager.swift b/iphone/Maps/Core/Theme/Core/ThemeManager.swift index a5b66f4485..ddb213b309 100644 --- a/iphone/Maps/Core/Theme/Core/ThemeManager.swift +++ b/iphone/Maps/Core/Theme/Core/ThemeManager.swift @@ -30,7 +30,7 @@ final class ThemeManager: NSObject { return isDarkModeEnabled ? .vehicleNight : .vehicleDay } else { guard isVehicleRouting else { return .day } - switch FrameworkHelper.daytime(at: MWMLocationManager.lastLocation()) { + switch FrameworkHelper.daytime(at: LocationManager.lastLocation()) { case .day: return .vehicleDay case .night: return .vehicleNight @unknown default: diff --git a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift index 3e1131bcc9..e58a12e491 100644 --- a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift +++ b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift @@ -61,7 +61,7 @@ extension BottomMenuInteractor: BottomMenuInteractorProtocol { func shareLocation(cell: BottomMenuItemCell) { Statistics.logEvent(kStatToolbarClick, withParameters: [kStatItem : kStatShareMyLocation]) - let lastLocation = MWMLocationManager.lastLocation() + let lastLocation = LocationManager.lastLocation() guard let coordinates = lastLocation?.coordinate else { UIAlertView(title: L("unknown_current_position"), message: nil, diff --git a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift index fd36106a70..bd23983e0e 100644 --- a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift +++ b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift @@ -61,7 +61,7 @@ class DownloadMapsViewController: MWMViewController { case .downloaded: dataSource = DownloadedMapsDataSource() case .available: - dataSource = AvailableMapsDataSource(location: MWMLocationManager.lastLocation()?.coordinate) + dataSource = AvailableMapsDataSource(location: LocationManager.lastLocation()?.coordinate) @unknown default: fatalError() } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift index f9b98cba51..9d6363d6fc 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift @@ -231,16 +231,16 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout { self?.onLoadUgc() } - MWMLocationManager.add(observer: self) - if let lastLocation = MWMLocationManager.lastLocation() { + LocationManager.add(observer: self) + if let lastLocation = LocationManager.lastLocation() { onLocationUpdate(lastLocation) self.lastLocation = lastLocation } - if let lastHeading = MWMLocationManager.lastHeading() { + if let lastHeading = LocationManager.lastHeading() { onHeadingUpdate(lastHeading) } - if !MWMLocationManager.isLocationProhibited() && FrameworkHelper.isNetworkConnected() { + if !LocationManager.isLocationProhibited() && FrameworkHelper.isNetworkConnected() { taxiViewController.view.isHidden = false } @@ -429,7 +429,7 @@ extension PlacePageCommonLayout: MWMLocationObserver { if location.speed > 0 && location.timestamp.timeIntervalSinceNow >= -2 { let speed = imperial ? location.speed * 2.237 : location.speed * 3.6 let speedMeasurement = Measurement(value: speed.rounded(), unit: imperial ? UnitSpeed.milesPerHour: UnitSpeed.kilometersPerHour) - let speedString = "\(MWMLocationManager.speedSymbolFor(location.speed))\(unitsFormatter.string(from: speedMeasurement))" + let speedString = "\(LocationManager.speedSymbolFor(location.speed))\(unitsFormatter.string(from: speedMeasurement))" previewViewController.updateSpeedAndAltitude("\(altString) \(speedString)") } else { previewViewController.updateSpeedAndAltitude(altString) diff --git a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift index fd413fb9b2..d529e64237 100644 --- a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift +++ b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift @@ -39,7 +39,7 @@ extension FirstLaunchPresenter: IFirstLaunchPresenter { func onAppear() { switch config.requestPermission { case .location: - MWMLocationManager.start() + LocationManager.start() case .notifications: MWMPushNotifications.setup() case .nothing: diff --git a/iphone/Maps/UI/Welcome/WelcomePageController.swift b/iphone/Maps/UI/Welcome/WelcomePageController.swift index 64484c59d6..a027f1f03f 100644 --- a/iphone/Maps/UI/Welcome/WelcomePageController.swift +++ b/iphone/Maps/UI/Welcome/WelcomePageController.swift @@ -93,7 +93,7 @@ final class WelcomePageController: UIPageViewController { view.removeFromSuperview() removeFromParent() parentController.closePageController(self) - FrameworkHelper.processFirstLaunch(MWMLocationManager.lastLocation() != nil) + FrameworkHelper.processFirstLaunch(LocationManager.lastLocation() != nil) } @objc func show() {