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
path: root/iphone
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2015-09-02 15:58:49 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:03:31 +0300
commit35fa22a8a4029e6a0bb7f898ddc3098ce80bfbc1 (patch)
tree0dba45d8ab73a578141f43d6d7b3f0e20b96bfaa /iphone
parentf9691859212b71d93a39842fc50384cf20d18d23 (diff)
Corrections after colleagues comments.
Diffstat (limited to 'iphone')
-rw-r--r--iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.h3
-rw-r--r--iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm46
-rw-r--r--iphone/Maps/Classes/SearchView.mm8
3 files changed, 20 insertions, 37 deletions
diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.h
index 493fbdaafe..d7efee3d06 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.h
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.h
@@ -11,9 +11,6 @@
#include "std/string.hpp"
#include "std/vector.hpp"
-FOUNDATION_EXPORT NSString * const MWMTEXTTOSPEECH_ENABLE;
-FOUNDATION_EXPORT NSString * const MWMTEXTTOSPEECH_DISABLE;
-
@interface MWMTextToSpeech : NSObject
- (instancetype)init;
diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm
index f4cab101ba..f4c8be1662 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm
@@ -12,8 +12,8 @@
#include "Framework.h"
-NSString * const MWMTEXTTOSPEECH_ENABLE = @"MWMTEXTTOSPEECH_ENABLE";
-NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
+extern NSString * const kMwmTextToSpeechEnable = @"MWMTEXTTOSPEECH_ENABLE";
+extern NSString * const kMwmTextToSpeechDisable = @"MWMTEXTTOSPEECH_DISABLE";
@interface MWMTextToSpeech()
@property (nonatomic) AVSpeechSynthesizer * speechSynthesizer;
@@ -33,12 +33,12 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(enable)
- name:MWMTEXTTOSPEECH_ENABLE
+ name:kMwmTextToSpeechEnable
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(disable)
- name:MWMTEXTTOSPEECH_DISABLE
+ name:kMwmTextToSpeechDisable
object:nil];
}
return self;
@@ -65,16 +65,13 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
return [bcp47LangName substringToIndex:2];
}
-- (bool)isValid
+- (BOOL)isValid
{
return _speechSynthesizer != nil && _speechVoice != nil;
}
- (void)enable
{
- if (YES == [self isEnable])
- return;
-
if (![self isValid])
[self createSynthesizer];
@@ -83,9 +80,6 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
- (void)disable
{
- if (NO == [self isEnable])
- return;
-
GetFramework().EnableTurnNotifications(false);
}
@@ -109,26 +103,26 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
if (!locale)
{
+ LOG(LERROR, ("locale is nil. Trying default locale."));
locale = DEFAULT_LANG;
- NSAssert(locale, @"locale is nil. Trying default locale.");
}
- NSArray * availTtsLangs = [AVSpeechSynthesisVoice speechVoices];
+ NSArray * availTTSLangs = [AVSpeechSynthesisVoice speechVoices];
- if (!availTtsLangs)
+ if (!availTTSLangs)
{
- NSAssert(availTtsLangs, @"availTtsLangs is nil. MWMTextToSpeech is not valid.");
+ LOG(LERROR, ("No languages for TTS. MWMTextFoSpeech is invalid."));
return; // self is not valid.
}
AVSpeechSynthesisVoice * voice = [AVSpeechSynthesisVoice voiceWithLanguage:locale];
- if (!voice || ![availTtsLangs containsObject:voice])
+ if (!voice || ![availTTSLangs containsObject:voice])
{
locale = DEFAULT_LANG;
AVSpeechSynthesisVoice * voice = [AVSpeechSynthesisVoice voiceWithLanguage:locale];
- if (!voice || ![availTtsLangs containsObject:voice])
+ if (!voice || ![availTTSLangs containsObject:voice])
{
- NSAssert(availTtsLangs, @"Available language for TTS not found. MWMTextToSpeech is not valid.");
+ LOG(LERROR, ("The UI language and English are not available for TTS. MWMTestToSpeech is invalid."));
return; // self is not valid.
}
}
@@ -139,7 +133,7 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
- (void)speakOneString:(NSString *)textToSpeak
{
- if (!textToSpeak || [textToSpeak length] == 0)
+ if (!textToSpeak || ![textToSpeak length])
return;
NSLog(@"Speak text: %@", textToSpeak);
@@ -149,15 +143,6 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
[self.speechSynthesizer speakUtterance:utterance];
}
-- (void)speak:(vector<string> const &)strings
-{
- if (strings.empty())
- return;
-
- for (auto const & text : strings)
- [self speakOneString:@(text.c_str())];
-}
-
- (void)playTurnNotifications
{
if (![self isValid])
@@ -169,10 +154,9 @@ NSString * const MWMTEXTTOSPEECH_DISABLE = @"MWMTEXTTOSPEECH_DISABLE";
vector<string> notifications;
frm.GenerateTurnSound(notifications);
- if (notifications.empty())
- return;
- [self speak:notifications];
+ for (auto const & text : notifications)
+ [self speakOneString:@(text.c_str())];
}
@end
diff --git a/iphone/Maps/Classes/SearchView.mm b/iphone/Maps/Classes/SearchView.mm
index f22e779761..09e0a3a8b1 100644
--- a/iphone/Maps/Classes/SearchView.mm
+++ b/iphone/Maps/Classes/SearchView.mm
@@ -6,7 +6,6 @@
#import "MapViewController.h"
#import "MWMMapViewControlsManager.h"
#import "MWMSearchDownloadMapRequest.h"
-#import "MWMTextToSpeech.h"
#import "SearchCategoryCell.h"
#import "SearchResultCell.h"
#import "SearchShowOnMapCell.h"
@@ -30,6 +29,9 @@
#include "search/params.hpp"
#include "search/result.hpp"
+extern NSString * const kMwmTextToSpeechEnable;
+extern NSString * const kMwmTextToSpeechDisable;
+
@interface SearchResultsWrapper : NSObject
- (id)initWithResults:(search::Results const &)res;
@@ -402,9 +404,9 @@ static BOOL keyboardLoaded = NO;
// turn notification
if (sound)
- [[NSNotificationCenter defaultCenter] postNotificationName:MWMTEXTTOSPEECH_ENABLE object:nil];
+ [[NSNotificationCenter defaultCenter] postNotificationName:kMwmTextToSpeechEnable object:nil];
if (nosound)
- [[NSNotificationCenter defaultCenter] postNotificationName:MWMTEXTTOSPEECH_DISABLE object:nil];
+ [[NSNotificationCenter defaultCenter] postNotificationName:kMwmTextToSpeechDisable object:nil];
// close Search panel
[self searchBarDidPressCancelButton:nil];