From 44004e4fa5dac79762a54ee8475d998146e9a6c3 Mon Sep 17 00:00:00 2001 From: Bumseung Cho Date: Thu, 22 Aug 2013 12:08:23 +0900 Subject: [PATCH] TDIS-6894 Screen reader will support to read long string more than 2000byte. Change-Id: I6421f2483d76a0dd4be88907076f8dfe74c07785 Signed-off-by: Bumseung Cho --- src/ui/FUi_AccessibilityTtsPlayer.cpp | 105 +++++++++++++++++++++++++++++--- src/ui/FUi_ResourceManager.cpp | 1 - src/ui/inc/FUi_AccessibilityTtsPlayer.h | 4 +- 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/src/ui/FUi_AccessibilityTtsPlayer.cpp b/src/ui/FUi_AccessibilityTtsPlayer.cpp index dd6c9d9..f22b9e4 100644 --- a/src/ui/FUi_AccessibilityTtsPlayer.cpp +++ b/src/ui/FUi_AccessibilityTtsPlayer.cpp @@ -30,14 +30,18 @@ using namespace Tizen::Locales; namespace Tizen { namespace Ui { +const int MAX_TTS_CHARACTER_COUNT = 400; + _AccessibilityTtsPlayer::_AccessibilityTtsPlayer(_AccessibilityManager& manager) : __initialized(false) , __activated(false) + , __extra(false) , __ttsHandle(0) , __localeIdx(-1) , __speed(TTS_SPEED_AUTO) , __status(ACCESSIBILITY_SCREEN_READER_STATUS_ERROR) , __grammar(L"") + , __readingContents(L"") , __pCurrentLocale(null) , __pSupportedLocaleList(null) , __pManager(&manager) @@ -192,7 +196,7 @@ _AccessibilityTtsPlayer::TtsStateChangedReceiver(tts_h ttsHandle, tts_state_e pr ttsError = tts_foreach_supported_voices(ttsHandle, TtsSupportedLocaleListGetter, (void*)(static_cast<_AccessibilityTtsPlayer*>(pTtsInstance)->__pSupportedLocaleList)); SysTryLog(NID_UI, ttsError == TTS_ERROR_NONE, "[%s] Failed to get supported voices", GetEngineErrorMessage(ttsError)); - static_cast<_AccessibilityTtsPlayer*>(pTtsInstance)->__initialized = true; + static_cast<_AccessibilityTtsPlayer*>(pTtsInstance)->__initialized = true; static_cast<_AccessibilityTtsPlayer*>(pTtsInstance)->OnStatusChanged(ACCESSIBILITY_SCREEN_READER_STATUS_READY); } else if ((previousState == TTS_STATE_READY || previousState == TTS_STATE_PAUSED) && (currentState == TTS_STATE_PLAYING)) @@ -221,12 +225,19 @@ _AccessibilityTtsPlayer::TtsStartedReceiver(tts_h ttsHandle, int utteranceId, vo void _AccessibilityTtsPlayer::TtsCompletedReceiver(tts_h ttsHandle, int utteranceId, void* pTtsInstance) { - int ttsError = tts_stop(ttsHandle); - SysTryReturnVoidResult(NID_UI, ttsError == TTS_ERROR_NONE, E_SYSTEM, - "[CB] Failed to stop, error[%s]", GetEngineErrorMessage(ttsError)); _AccessibilityTtsPlayer* pPlayer = static_cast<_AccessibilityTtsPlayer*>(pTtsInstance); - pPlayer->SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_READY); - pPlayer->__pManager->OnFinishReading(pPlayer->__grammar); + if(static_cast<_AccessibilityTtsPlayer*>(pTtsInstance)->__extra) + { + pPlayer->Speak(pPlayer->__readingContents); + } + else + { + int ttsError = tts_stop(ttsHandle); + SysTryReturnVoidResult(NID_UI, ttsError == TTS_ERROR_NONE, E_SYSTEM, + "[CB] Failed to stop, error[%s]", GetEngineErrorMessage(ttsError)); + pPlayer->SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_READY); + pPlayer->__pManager->OnFinishReading(pPlayer->__grammar); + } } void _AccessibilityTtsPlayer::TtsErrorReceiver(tts_h ttsHandle, int ttsUtteranceId, tts_error_e error, void* pTtsInstance) @@ -320,13 +331,89 @@ _AccessibilityTtsPlayer::Speak(const String& text) "Not yet initialized! This method should be called after initialized."); result r = E_SUCCESS; + String _text = text; tts_state_e ttsState = TTS_STATE_READY; int ttsError = tts_get_state(__ttsHandle, &ttsState); SysTryReturnResult(NID_UI, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state."); Stop(); - const char* pTextN = _StringConverter::CopyToCharArrayN(text); + if(_text.GetLength() > MAX_TTS_CHARACTER_COUNT) + { + bool find = false; + int index = -1; + r = _text.IndexOf(L' ', MAX_TTS_CHARACTER_COUNT, index); + if (r == E_SUCCESS) + { + if(index < MAX_TTS_CHARACTER_COUNT + MAX_TTS_CHARACTER_COUNT * 0.2) + { + find = true; + } + } + if(find == false) + { + r = _text.IndexOf(L'\n', MAX_TTS_CHARACTER_COUNT, index); + if (r == E_SUCCESS) + { + if(index < MAX_TTS_CHARACTER_COUNT + MAX_TTS_CHARACTER_COUNT * 0.2) + { + find = true; + } + } + } + if(find == false) + { + r = _text.IndexOf(L'\t', MAX_TTS_CHARACTER_COUNT, index); + if (r == E_SUCCESS) + { + if(index < MAX_TTS_CHARACTER_COUNT + MAX_TTS_CHARACTER_COUNT * 0.2) + { + find = true; + } + } + } + if(find == false) + { + r = _text.IndexOf(L'.', MAX_TTS_CHARACTER_COUNT, index); + if (r == E_SUCCESS) + { + if(index < MAX_TTS_CHARACTER_COUNT + MAX_TTS_CHARACTER_COUNT * 0.2) + { + find = true; + } + } + } + if(find == false) + { + r = _text.IndexOf(L',', MAX_TTS_CHARACTER_COUNT, index); + if (r == E_SUCCESS) + { + if(index < MAX_TTS_CHARACTER_COUNT + MAX_TTS_CHARACTER_COUNT * 0.2) + { + find = true; + } + } + } + if (find == false) + { + index = MAX_TTS_CHARACTER_COUNT; + } + if(_text.GetLength() > index + 1) + { + _text.SubString(index+1, _text.GetLength() - index-1, __readingContents); + _text.SubString(0,index, const_cast(_text)); + __extra = true; + } + else + { + __extra = false; + } + } + else + { + __extra = false; + } + const char* pTextN = _StringConverter::CopyToCharArrayN(_text); int ttsUtteranceId = 0; ttsError = tts_add_text(__ttsHandle, pTextN, null, TTS_VOICE_TYPE_AUTO, __speed, &ttsUtteranceId); @@ -502,6 +589,10 @@ _AccessibilityTtsPlayer::OnErrorOccurred(Tizen::Base::String& errorString) void _AccessibilityTtsPlayer::OnStatusChanged(AccessibilityScreenReaderStatus status) { + if(__extra) + { + return; + } switch(status) { case ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING: diff --git a/src/ui/FUi_ResourceManager.cpp b/src/ui/FUi_ResourceManager.cpp index 061eeaf..ba42383 100755 --- a/src/ui/FUi_ResourceManager.cpp +++ b/src/ui/FUi_ResourceManager.cpp @@ -347,7 +347,6 @@ _ResourceManager::_ResourceManager(void) int appBaseWidth = DEFAULT_SCREEN_WIDTH; int appBaseHeight = DEFAULT_SCREEN_HEIGHT; - result r = E_SUCCESS; int appLogicalResolution = _CoordinateSystem::GetInstance()->GetLogicalResolutionInt(); diff --git a/src/ui/inc/FUi_AccessibilityTtsPlayer.h b/src/ui/inc/FUi_AccessibilityTtsPlayer.h index d8e38a4..27823d1 100644 --- a/src/ui/inc/FUi_AccessibilityTtsPlayer.h +++ b/src/ui/inc/FUi_AccessibilityTtsPlayer.h @@ -85,12 +85,14 @@ private: private: bool __initialized; - bool __activated; + bool __activated; + bool __extra; tts_h __ttsHandle; int __localeIdx; tts_speed_e __speed; AccessibilityScreenReaderStatus __status; Tizen::Base::String __grammar; + Tizen::Base::String __readingContents; Tizen::Locales::Locale* __pCurrentLocale; Tizen::Base::Collection::IList* __pSupportedLocaleList; _AccessibilityManager* __pManager; -- 2.7.4