Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@gmail.com>2017-08-17 17:10:27 +0300
committerburivuh <burivuh@maps.me>2017-08-17 17:28:48 +0300
commitd0d51150fb3733b0414571e30a14b2abf9373f8a (patch)
tree5b00d461d433601d6bb9643fe40c4b0956e27318
parentc7bd87f3b9442e7ee184c607dbb8210bebe4c9cc (diff)
[MAPSME-5305] [ios] Fixed voice change support.beta-967
-rw-r--r--iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm4
-rw-r--r--iphone/Maps/Classes/MapsAppDelegate.mm4
-rw-r--r--iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.h2
-rw-r--r--iphone/Maps/Core/TextToSpeech/MWMTextToSpeech.mm31
4 files changed, 25 insertions, 16 deletions
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<Observer>;
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 <CoreSpotlight/CoreSpotlight.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
+#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<MWMTextToSpeechObserver>)observer;
+ (void)removeObserver:(id<MWMTextToSpeechObserver>)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<Observer>;
return tts;
}
++ (void)applicationDidBecomeActive
+{
+ [MWMTextToSpeech tts].speechSynthesizer = nil;
+ [MWMTextToSpeech tts].speechVoice = nil;
+}
+
- (instancetype)initTTS
{
self = [super init];
@@ -154,7 +160,7 @@ using Observers = NSHashTable<Observer>;
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<Observer>;
return [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsTTSLanguageBcp47];
}
-- (void)createSynthesizer
+- (void)createVoice:(NSString *)locale
{
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ if (!self.speechSynthesizer)
+ {
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
-{
NSMutableArray<NSString *> * candidateLocales = [@[ kDefaultLanguage, @"en-GB" ] mutableCopy];
if (locale)
@@ -238,7 +237,13 @@ using Observers = NSHashTable<Observer>;
- (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<NSString *> * turnNotifications = [MWMRouter turnNotifications];