diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index becf92cbe8..06a1ec1808 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -139,8 +139,8 @@ using Observers = NSHashTable; self.routePreview = nil; self.navigationInfoView.state = MWMNavigationInfoViewStateHidden; self.navigationInfoView = nil; - self.navigationControlView.isVisible = NO; - self.navigationControlView = nil; + _navigationControlView.isVisible = NO; + _navigationControlView = nil; [self.statusBox stateHidden]; self.statusBox = nil; } diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 95a02d976e..bd97298690 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -1,6 +1,7 @@ #import "MapsAppDelegate.h" #import #import +#import "3party/Alohalytics/src/alohalytics_objc.h" #import "EAGLView.h" #import "LocalNotificationManager.h" #import "MWMAuthorizationCommon.h" @@ -13,10 +14,10 @@ #import "MWMRoutePoint+CPP.h" #import "MWMRouter.h" #import "MWMSearch+CoreSpotlight.h" +#import "MWMTextToSpeech.h" #import "MapViewController.h" #import "Statistics.h" #import "SwiftBridge.h" -#import "3party/Alohalytics/src/alohalytics_objc.h" #include "Framework.h" @@ -606,6 +607,7 @@ using namespace osm_auth_ios; [MWMLocationManager applicationDidBecomeActive]; [MWMSearch addCategoriesToSpotlight]; [MWMKeyboard applicationDidBecomeActive]; + [MWMTextToSpeech applicationDidBecomeActive]; LOG(LINFO, ("applicationDidBecomeActive - end")); } diff --git a/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.h b/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.h index ac9398773c..a00655c08d 100644 --- a/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.h +++ b/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.h @@ -10,6 +10,8 @@ + (void)addObserver:(id)observer; + (void)removeObserver:(id)observer; ++ (void)applicationDidBecomeActive; + @property(nonatomic) BOOL active; - (void)setNotificationsLocale:(NSString *)locale; - (void)playTurnNotifications; diff --git a/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.mm b/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.mm index 72e08acaef..9771e1e75e 100644 --- a/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.mm +++ b/iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.mm @@ -72,6 +72,12 @@ using Observers = NSHashTable; return tts; } ++ (void)applicationDidBecomeActive +{ + [MWMTextToSpeech tts].speechSynthesizer = nil; + [MWMTextToSpeech tts].speechVoice = nil; +} + - (instancetype)initTTS { self = [super init]; @@ -154,7 +160,7 @@ using Observers = NSHashTable; if (![[self class] isTTSEnabled] || self.active == active) return; if (active && ![self isValid]) - [self createSynthesizer]; + [self createVoice:[MWMTextToSpeech savedLanguage]]; [self setAudioSessionActive:active]; [MWMRouter enableTurnNotifications:active]; dispatch_async(dispatch_get_main_queue(), ^{ @@ -168,21 +174,14 @@ using Observers = NSHashTable; return [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsTTSLanguageBcp47]; } -- (void)createSynthesizer -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; - self.speechSynthesizer.delegate = self; - [self createVoice:[[self class] savedLanguage]]; - }); - // TODO(vbykoianko) Use [NSLocale preferredLanguages] instead of [AVSpeechSynthesisVoice - // currentLanguageCode]. - // [AVSpeechSynthesisVoice currentLanguageCode] is used now because of we need a language code in - // BCP-47. -} - - (void)createVoice:(NSString *)locale { + if (!self.speechSynthesizer) + { + self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; + self.speechSynthesizer.delegate = self; + } + NSMutableArray * candidateLocales = [@[ kDefaultLanguage, @"en-GB" ] mutableCopy]; if (locale) @@ -238,7 +237,13 @@ using Observers = NSHashTable; - (void)playTurnNotifications { - if (![MWMRouter isOnRoute] || ![self isValid]) + if (![MWMRouter isOnRoute]) + return; + + if (self.active && ![self isValid]) + [self createVoice:[MWMTextToSpeech savedLanguage]]; + + if (!self.active || ![self isValid]) return; NSArray * turnNotifications = [MWMRouter turnNotifications];