From 58e0319b831eb27bbe283d895e2df9f2477a35ce Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 7 Oct 2016 15:39:53 +0900 Subject: [PATCH 01/16] Stop playing sound when starting STT Change-Id: I3426487ad9ac3b90430748ca09654e71c950583f Signed-off-by: sungwook79.park --- inc/SttManager.h | 1 + packaging/org.tizen.inputdelegator.spec | 1 + src/CMakeLists.txt | 6 +++++- src/SttManager.cpp | 36 ++++++++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/inc/SttManager.h b/inc/SttManager.h index 68a9a24..8b76f5e 100755 --- a/inc/SttManager.h +++ b/inc/SttManager.h @@ -221,6 +221,7 @@ class SttManager static void PrintErrorState(stt_error_e reason); static void PrintState(stt_state_e previous, stt_state_e current); static void PrintResultState(stt_result_event_e result_type); + static void ReleaseSoundFocus(); }; }} /** end of is::stt */ diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index 9a74048..efc6250 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -30,6 +30,7 @@ BuildRequires: pkgconfig(stt) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(sqlite3) +BuildRequires: pkgconfig(capi-media-audio-io) %if %{enable_log_manager} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01749a5..74963d3 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ PKG_CHECK_MODULES(STT REQUIRED stt) PKG_CHECK_MODULES(VCONF REQUIRED vconf) PKG_CHECK_MODULES(DB_UTIL_PKG REQUIRED db-util) PKG_CHECK_MODULES(SQLITE3_PKG REQUIRED sqlite3) +pkg_check_modules(CAPI_MEDIA_AUDIO_IO REQUIRED capi-media-audio-io) #PKG_CHECK_MODULES(GRAPHICS_EXTENSION REQUIRED graphics-extension) #PKG_CHECK_MODULES(WNOTI_SERVICE REQUIRED wnoti-service2) #PKG_CHECK_MODULES(SAP_CLIENT_STUB_API REQUIRED sap-client-stub-api) @@ -37,7 +38,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${SQLITE3_PKG_INCLUDE_DIRS} ${DATA_CONTROL_INCLUDE_DIRS} ${WNOTI_SERVICE_INCLUDE_DIRS} - ${SAP_CLIENT_STUB_API_INCLUDE_DIRS}) + ${SAP_CLIENT_STUB_API_INCLUDE_DIRS} + ${CAPI_MEDIA_AUDIO_IO_INCLUDE_DIRS}) LINK_DIRECTORIES(${DLOG_LIBRARY_DIRS} @@ -56,6 +58,7 @@ LINK_DIRECTORIES(${DLOG_LIBRARY_DIRS} ${VCONF_LIBRARY_DIRS} ${WNOTI_SERVICE_LIBRARY_DIRS} ${SAP_CLIENT_STUB_API_LIBRARY_DIRS} + ${CAPI_MEDIA_AUDIO_IO_LIBRARY_DIRS} ) ADD_EXECUTABLE(${W_INPUT_SELECTOR} @@ -75,6 +78,7 @@ TARGET_LINK_LIBRARIES(${W_INPUT_SELECTOR} ${DB_UTIL_PKG_LIBRARIES} ${SQLITE3_PKG_LIBRARIES} ${VCONF_LIBRARIES} + ${CAPI_MEDIA_AUDIO_IO_LIBRARIES} ) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE") diff --git a/src/SttManager.cpp b/src/SttManager.cpp index 1be05a3..c4a080e 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "Debug.h" #include "SttManager.h" @@ -30,6 +31,8 @@ enum { CREATE = 0x1000 }; +static sound_stream_info_h g_stream_info_h = NULL; + static inline const char *stt_state_str(stt_state_e cur) { if (cur == STT_STATE_CREATED) return (const char *) "STT_STATE_CREATED"; @@ -47,6 +50,10 @@ static inline const char *stt_state_str(stt_state_e cur) { return (const char *) "ABNORMAL CASE"; } +static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data) +{ +} + SttManager::SttManager(ISttFeedback& feedback) : ifeedback(feedback), iscancelled(false) @@ -61,6 +68,11 @@ SttManager::SttManager(ISttFeedback& feedback) if(ret != STT_ERROR_NONE) throw SttException(ret, ErrorString((stt_error_e)ret)); + ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_RECOGNITION, player_focus_state_cb, NULL, &g_stream_info_h); + if (SOUND_MANAGER_ERROR_NONE != ret) { + LOGW("Fail to create stream info. ret : %d", ret); + } + /** * Set default properties * @@ -84,6 +96,10 @@ SttManager::~SttManager() { PRINTFUNC(DLOG_ERROR, "reason : %s", e.what()); stt_destroy(handle); } + + ReleaseSoundFocus(); + + sound_manager_destroy_stream_information(g_stream_info_h); } void SttManager::Prepare() { @@ -123,7 +139,13 @@ void SttManager::Start() { */ asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL; int ret; - ret = stt_start(handle, language.c_str(), asrtype.c_str()); + + ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + if (SOUND_MANAGER_ERROR_NONE != ret) { + LOGW("Fail to acquire focus. ret : %d, stream handle : %p", ret, g_stream_info_h); + } + + ret = stt_start(handle, language.c_str(), asrtype.c_str()); if(ret != STT_ERROR_NONE) throw SttException(ret, ErrorString((stt_error_e)ret)); @@ -318,6 +340,11 @@ void SttManager::on_state_changed( SttManager& manager = *((SttManager *) user_data); if (current== STT_STATE_READY) { + if (previous == STT_STATE_RECORDING || + previous == STT_STATE_PROCESSING) { + ReleaseSoundFocus(); + } + if (previous == STT_STATE_CREATED) { manager.EnableSilenceDetection(); manager.ifeedback.AutoStart(); @@ -525,3 +552,10 @@ void SttManager::EnableSilenceDetection(bool enabled) { } } +void SttManager::ReleaseSoundFocus() +{ + int ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + if (SOUND_MANAGER_ERROR_NONE != ret) { + LOGW("Fail to release focus. ret : %d", ret); + } +} -- 2.7.4 From 5906bc8d71f6c4e322ac1777584dfc62827d1cf1 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Wed, 12 Oct 2016 11:35:34 +0900 Subject: [PATCH 02/16] Acquire recognition sound focus before starting STT Change-Id: I662783dc5bfc6c3d7bb7700e7f77c1e218233310 Signed-off-by: sungwook79.park --- src/SttManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SttManager.cpp b/src/SttManager.cpp index c4a080e..d8c53b5 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -140,9 +140,9 @@ void SttManager::Start() { asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL; int ret; - ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { - LOGW("Fail to acquire focus. ret : %d, stream handle : %p", ret, g_stream_info_h); + LOGW("Fail to acquire playback or recording focus. ret : %d, stream handle : %p", ret, g_stream_info_h); } ret = stt_start(handle, language.c_str(), asrtype.c_str()); @@ -554,8 +554,8 @@ void SttManager::EnableSilenceDetection(bool enabled) { void SttManager::ReleaseSoundFocus() { - int ret = sound_manager_release_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { - LOGW("Fail to release focus. ret : %d", ret); + LOGW("Fail to release playback or recording focus. ret : %d", ret); } } -- 2.7.4 From 76cd03d710da8dc07fc05d873c60b6512a8241bc Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 20 Oct 2016 15:08:54 +0900 Subject: [PATCH 03/16] Fixed defect detected by static analysis tool Change-Id: I5c3acc19e4478b2c3421b68b203b0a5e08f1bb16 --- src/MicEffector.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MicEffector.cpp b/src/MicEffector.cpp index f2602d1..9010026 100755 --- a/src/MicEffector.cpp +++ b/src/MicEffector.cpp @@ -408,7 +408,8 @@ void MicEffector::VolumeCheck(bool fake) volumes = ieffect.GetVolume(); } else { for(unsigned int i = 0; i < spectrum_count; i++) { - volumes.push_back(rand_r((unsigned int*)time(NULL)) % 2); + unsigned int seed = time(NULL); + volumes.push_back(rand_r(&seed) % 2); } } -- 2.7.4 From f3dca6f38fb2e27facf1aa7ce8745bad19477108 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 2 Nov 2016 19:08:00 +0900 Subject: [PATCH 04/16] Update package version to 0.1.161102 Change-Id: I8db8f6b7373f503a898ed7b75c3b4e121d2e1c5c --- org.tizen.inputdelegator.xml | 2 +- packaging/org.tizen.inputdelegator.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.inputdelegator.xml b/org.tizen.inputdelegator.xml index c27dfd7..e0dd87d 100755 --- a/org.tizen.inputdelegator.xml +++ b/org.tizen.inputdelegator.xml @@ -1,5 +1,5 @@ - + diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index efc6250..f8cbf92 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -1,6 +1,6 @@ Name: org.tizen.inputdelegator Summary: Input Delegator Application -Version: 0.1.160927 +Version: 0.1.161102 Release: 1 Group: Applications License: Apache-2.0 -- 2.7.4 From c5f086ad392fec078b6ca2fbe4f041b869ccac72 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 18 Nov 2016 16:03:49 +0900 Subject: [PATCH 05/16] Remove unused code Change-Id: I7e0c5c5432000b2cfde3592c1e3c678d49c2873a Signed-off-by: sungwook79.park --- res/edje/w-input-selector.edc | 301 ------------------------------------------ 1 file changed, 301 deletions(-) diff --git a/res/edje/w-input-selector.edc b/res/edje/w-input-selector.edc index a436e58..c00e082 100755 --- a/res/edje/w-input-selector.edc +++ b/res/edje/w-input-selector.edc @@ -368,308 +368,7 @@ collections { } \ ) - group { - name: "elm/genlist/item/3button/default"; - data.item: "treesize" 0; - data.item: "flips" "elm.flip.icon elm.flip.content"; - data.item: "contents" "base elm.icon.1.touch_area elm.icon.2.touch_area elm.icon.3.touch_area elm.icon.1 elm.icon.2 elm.icon.3 elm.swallow.center_check"; - data.item: "vi_effect" "off"; - - parts { - PART_LIST_BG - PART_LIST_PADDINGS( - LIST_BUTTON_PADDING_LEFT_SIZE_INC, LIST_BUTTON_PADDING_RIGHT_SIZE_INC, - LIST_BUTTON_PADDING_2BUTTON_TOP_SIZE_INC, LIST_BUTTON_PADDING_BOTTOM_SIZE_INC - ) - PART(SWALLOW, "base", - DESC_LRTB("elm.padding.left", "elm.padding.right", "elm.padding.top", "elm.padding.bottom", - min: 360 0; - fixed: 1 0; - visible: 1; - ) - ) - part { name: "elm.icon.1.touch_area"; // left icon -// type: RECT; - type: SWALLOW; - repeat_events, 0; - description { - state: "default" 0.0; - color: 255 0 0 100; - visible: 1; - align: 0.5 0.5; - fixed: 1 1; - rel1 { relative: 0.0 0.0; to: "elm.icon.1"; offset: -5 -5;} - rel2 { relative: 1.0 1.0; to: "elm.icon.1"; offset: +5 +5;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.1"; offset: -7 -7;} - rel2 { relative: 1.0 1.0; to: "elm.icon.1"; offset: +7 +7;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.1"; offset: -8 -8;} - rel2 { relative: 1.0 1.0; to: "elm.icon.1"; offset: +8 +8;} - } - } - part { name: "elm.icon.2.touch_area"; // center icon -// type: RECT; - type: SWALLOW; - repeat_events, 0; - description { - state: "default" 0.0; - color: 0 255 0 100; - visible: 1; - align: 0.5 0.5; - fixed: 1 1; - rel1 { relative: 0.0 0.0; to: "elm.icon.2"; offset: -5 -5;} - rel2 { relative: 1.0 1.0; to: "elm.icon.2"; offset: +5 +5;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.2"; offset: -7 -7;} - rel2 { relative: 1.0 1.0; to: "elm.icon.2"; offset: +7 +7;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.2"; offset: -8 -8;} - rel2 { relative: 1.0 1.0; to: "elm.icon.2"; offset: +8 +8;} - } - - } - part { name: "elm.icon.3.touch_area"; // right icon -// type: RECT; - type: SWALLOW; - repeat_events, 0; - description { - state: "default" 0.0; - color: 0 0 255 100; - visible: 1; - align: 0.5 0.5; - fixed: 1 1; - rel1 { relative: 0.0 0.0; to: "elm.icon.3"; offset: -6 -5;} - rel2 { relative: 1.0 1.0; to: "elm.icon.3"; offset: +6 +5;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.3"; offset: -7 -7;} - rel2 { relative: 1.0 1.0; to: "elm.icon.3"; offset: +7 +7;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "elm.icon.3"; offset: -9 -8;} - rel2 { relative: 1.0 1.0; to: "elm.icon.3"; offset: +9 +8;} - } - } - part { name: "elm.icon.1"; // left icon - type: SWALLOW; - repeat_events, 1; - description { - state: "default" 0.0; - //color: 255 0 0 255; - visible: 1; - align: 0.5 0; - fixed: 1 1; - min: 57 57; - max: 57 57; - rel1 { relative: 112/360 0; to: "base"; offset: 0 35;} - rel2 { relative: 112/360 0; to: "base"; offset: 0 35;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - min: 57+(99-57)/2 57+(99-57)/2; - max: 57+(99-57)/2 57+(99-57)/2; - rel1 { relative: ((64+112)/2)/360 0; to: "base"; offset: 0 (35+12)/2;} - rel2 { relative: ((64+112)/2)/360 0; to: "base"; offset: 0 (35+12)/2;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - min: 99 99; - max: 99 99; - rel1 { relative: 64/360 0; to: "base"; offset: 0 12;} - rel2 { relative: 64/360 0; to: "base"; offset: 0 12;} - } - } - part { name: "elm.icon.2"; // center icon - type: SWALLOW; - repeat_events, 1; - description { - state: "default" 0.0; - visible: 1; - align: 0.5 0; - fixed: 1 1; - min: 57 57; - max: 57 57; - rel1 { relative: 0.5 0; to: "bg"; offset: 0 20;} - rel2 { relative: 0.5 0; to: "bg"; offset: 0 20;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - min: 57+(99-57)/2 57+(99-57)/2; - max: 57+(99-57)/2 57+(99-57)/2; - rel1 { relative: 0.5 0; to: "bg"; offset: 0 (20+12)/2;} - rel2 { relative: 0.5 0; to: "bg"; offset: 0 (20+12)/2;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - min: 99 99; - max: 99 99; - rel1 { relative: 0.5 0; to: "base"; offset: 0 12;} - rel2 { relative: 0.5 0; to: "base"; offset: 0 12;} - } - } - part { name: "elm.icon.3"; // right icon - type: SWALLOW; - repeat_events, 1; - description { - state: "default" 0.0; - //color: 255 0 0 255; - visible: 1; - align: 0.5 0; - fixed: 1 1; - min: 57 57; - max: 57 57; - rel1 { relative: 249/360 0; to: "base"; offset: 0 35;} - rel2 { relative: 249/360 0; to: "base"; offset: 0 35;} - } - description { - state: "default" 0.1; - inherit: "default" 0.0; - min: 57+(99-57)/2 57+(99-57)/2; - max: 57+(99-57)/2 57+(99-57)/2; - rel1 { relative: ((249+297)/2)/360 0; to: "base"; offset: 0 (35+12)/2;} - rel2 { relative: ((249+297)/2)/360 0; to: "base"; offset: 0 (35+12)/2;} - } - description { - state: "default" 0.9; - inherit: "default" 0.0; - min: 99 99; - max: 99 99; - rel1 { relative: 297/360 0; to: "base"; offset: 0 12;} - rel2 { relative: 297/360 0; to: "base"; offset: 0 12;} - } - } - - PART(SPACER, "elm.padding.fake", - DESC_TB("elm.padding.top","elm.padding.bottom", - min: LIST_BUTTON_PADDING_CENTER_SIZE_INC 0; - max: LIST_BUTTON_PADDING_CENTER_SIZE_INC -1; - fixed: 1 0; - ) - ) - PART(SPACER, "elm.padding.center", - DESC_LTB("elm.padding.fake", "elm.padding.top", "elm.padding.bottom", - min: LIST_BUTTON_PADDING_CENTER_SIZE_INC 0; - max: LIST_BUTTON_PADDING_CENTER_SIZE_INC -1; - fixed: 1 0; - ) - ) - PART(SWALLOW, "elm.swallow.center_check", - description { state: "default" 0.0; - align: 0.5 0.5; - } - ) - } -//Gesture VI - program { name: "do_start_expand_0.0"; - action: STATE_SET "default" 0.0; - target: "elm.icon.1"; - target: "elm.icon.2"; - target: "elm.icon.3"; - target: "elm.icon.1.touch_area"; - target: "elm.icon.2.touch_area"; - target: "elm.icon.3.touch_area"; - transition: LINEAR 0.3; - } - program { name: "do_start_expand_0.1"; - action: STATE_SET "default" 0.1; - target: "elm.icon.1"; - target: "elm.icon.2"; - target: "elm.icon.3"; - target: "elm.icon.1.touch_area"; - target: "elm.icon.2.touch_area"; - target: "elm.icon.3.touch_area"; - transition: LINEAR 0.3; - } - program { name: "do_start_expand_0.9"; - action: STATE_SET "default" 0.9; - target: "elm.icon.1"; - target: "elm.icon.2"; - target: "elm.icon.3"; - target: "elm.icon.1.touch_area"; - target: "elm.icon.2.touch_area"; - target: "elm.icon.3.touch_area"; - transition: LINEAR 0.3; - } - program { name: "start_expand_0.0"; - source: "elm"; - signal: "elm,action,ime,0.0"; - script { - run_program(PROGRAM:"do_start_expand_0.0"); - } - } - program { name: "start_expand_0.1"; - source: "elm"; - signal: "elm,action,ime,0.1"; - script { - run_program(PROGRAM:"do_start_expand_0.1"); - } - } - program { name: "start_expand_0.9"; - source: "elm"; - signal: "elm,action,ime,0.9"; - script { - run_program(PROGRAM:"do_start_expand_0.9"); - } - } -//Rotary VI - program { name: "do_rotary_start_expand_0.9"; - action: STATE_SET "default" 0.9; - target: "elm.icon.1"; - target: "elm.icon.2"; - target: "elm.icon.3"; - target: "elm.icon.1.touch_area"; - target: "elm.icon.2.touch_area"; - target: "elm.icon.3.touch_area"; - transition: LINEAR 0.5; - } - program { name: "do_rotary_start_expand_0.0"; - action: STATE_SET "default" 0.0; - target: "elm.icon.1"; - target: "elm.icon.2"; - target: "elm.icon.3"; - target: "elm.icon.1.touch_area"; - target: "elm.icon.2.touch_area"; - target: "elm.icon.3.touch_area"; - transition: LINEAR 0.5; - } - program { name: "rotary_start_expand_0.9"; - source: "elm"; - signal: "elm,action,rotary,ime,0.9"; - script { - run_program(PROGRAM:"do_rotary_start_expand_0.9"); - } - } - program { name: "rotary_start_expand_0.0"; - source: "elm"; - signal: "elm,action,rotary,ime,0.0"; - script { - run_program(PROGRAM:"do_rotary_start_expand_0.0"); - } - } - - } // 3 button group { -- 2.7.4 From 74353db9442ec97b8f1d092c0462df42e1c9c950 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 18 Nov 2016 17:24:12 +0900 Subject: [PATCH 06/16] Change emoticon mode form rotary selector to list UI Change-Id: I6bc986252e1d9a3b1ceeb948483993fe72fb0b63 Signed-off-by: sungwook79.park --- inc/w-input-emoticon.h | 3 +- org.tizen.inputdelegator.xml | 2 +- po/en_US.po | 5 + res/edje/w-input-stt.edc | 220 ++++++++++- src/w-input-emoticon.cpp | 915 ++++++++++++++++++++++++++++++++++++++----- src/w-input-selector.cpp | 3 +- 6 files changed, 1039 insertions(+), 109 deletions(-) diff --git a/inc/w-input-emoticon.h b/inc/w-input-emoticon.h index 45ede7b..709fd76 100755 --- a/inc/w-input-emoticon.h +++ b/inc/w-input-emoticon.h @@ -16,6 +16,7 @@ #ifndef W_INPUT_EMOTICON_H_ #define W_INPUT_EMOTICON_H_ -void ise_show_emoticon_popup_rotary(void *data); +void ise_show_emoticon_list(void *data); + #endif /* W_INPUT_EMOTICON_H_ */ diff --git a/org.tizen.inputdelegator.xml b/org.tizen.inputdelegator.xml index e0dd87d..87d0348 100755 --- a/org.tizen.inputdelegator.xml +++ b/org.tizen.inputdelegator.xml @@ -2,7 +2,7 @@ - + w-input-selector.png diff --git a/po/en_US.po b/po/en_US.po index 27d5438..8f90a0a 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -256,3 +256,8 @@ msgstr "Gear Input" msgid "WDS_WMGR_POP_MAKE_SURE_THE_PS_APP_IS_ACTIVE_ON_YOUR_PHONE" msgstr "Make sure the %s app is active on your phone." +msgid "IDS_IME_HEADER_EMOJIS_ABB" +msgstr "Emojis" + +msgid "IDS_IME_HEADER_RECENT_M_RECETLY_SENT_EMOJIS_ABB" +msgstr "Recent" diff --git a/res/edje/w-input-stt.edc b/res/edje/w-input-stt.edc index 8eda165..b123590 100755 --- a/res/edje/w-input-stt.edc +++ b/res/edje/w-input-stt.edc @@ -1,6 +1,7 @@ #include "w-input-stt-button.edc" #define VOICE_CANDIDATE_AREA_HEIGHT 56 +#define BUTTON_TEXT_SIZE_INC 85 collections { @@ -436,22 +437,31 @@ collections styles { - style { name, "textblock_style"; - base, "font=Tizen:style=Regular font_size=36 align=center color=#FFFFFF text_class=text_class wrap=word ellipsis=1.0"; - tag, "br" "\n"; - tag, "ps" "ps"; - tag, "hilight" "+ font=Tizen:style=Bold"; - tag, "b" "+ font=Tizen:style=Bold"; - tag, "tab" "\t"; - } - style { name, "textblock_style_bottom"; - base, "font=Tizen:style=Regular font_size=36 align=center color=#FFFFFF text_class=text_class wrap=word ellipsis=1.0"; - tag, "br" "\n"; - tag, "ps" "ps"; - tag, "hilight" "+ font=Tizen:style=Bold"; - tag, "b" "+ font=Tizen:style=Bold"; - tag, "tab" "\t"; - } + style { name, "textblock_style"; + base, "font=Tizen:style=Regular font_size=36 align=center color=#FFFFFF text_class=text_class wrap=word ellipsis=1.0"; + tag, "br" "\n"; + tag, "ps" "ps"; + tag, "hilight" "+ font=Tizen:style=Bold"; + tag, "b" "+ font=Tizen:style=Bold"; + tag, "tab" "\t"; + } + style { name, "textblock_style_bottom"; + base, "font=Tizen:style=Regular font_size=36 align=center color=#FFFFFF text_class=text_class wrap=word ellipsis=1.0"; + tag, "br" "\n"; + tag, "ps" "ps"; + tag, "hilight" "+ font=Tizen:style=Bold"; + tag, "b" "+ font=Tizen:style=Bold"; + tag, "tab" "\t"; + } + style { name: "button_general_text_dim"; + base: "font=Tizen:style=Regular font_size="BUTTON_TEXT_SIZE_INC" align=center color=#FFFFFF ellipsis=0.0 wrap=mixed"; + } + style { name: "button_general_text_press"; + base: "font=Tizen:style=Regular font_size="BUTTON_TEXT_SIZE_INC" align=center color=#888888 ellipsis=0.0 wrap=mixed"; + } + style { name: "button_general_text_normal"; + base: "font=Tizen:style=Regular font_size="BUTTON_TEXT_SIZE_INC" align=center color=#FFFFFF ellipsis=0.0 wrap=mixed"; + } } group @@ -1947,6 +1957,184 @@ collections } } + group { name: "elm/button/base/emoticon"; + + script { + public mouse_down = 0; + public multi_down = 0; + } + parts { + part { name: "bg"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + min: 0 0; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + } + } + part { name: "padding_left_top"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + align: 0.0 0.0; + rel2.relative: 0.0 0.0; + min: 0 0; + fixed: 1 1; + //visible: 1; + //color: 255 0 0 100; + } + } + part { name: "padding_right_bottom"; + type: SPACER; + scale: 1; + description { state: "default" 0.0; + align: 1.0 1.0; + rel1.relative: 1.0 1.0; + min: 0 0; + fixed: 1 1; + //visible: 1; + //color: 0 255 0 100; + } + } + part { name: "elm.text"; + type: TEXTBLOCK; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + rel1 { + relative: 1.0 1.0; + to: "padding_left_top"; + } + rel2 { + relative: 0.0 0.0; + to: "padding_right_bottom"; + } + text { + max: 1 0; + style: "button_general_text_normal"; + } + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + text.style: "button_general_text_dim"; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + text.style: "button_general_text_press"; + } + } + part { name: "event"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + color: 0 0 0 0; + rel1.to: "bg"; + rel2.to: "bg"; + } + } + } + programs { + program { name: "pressed"; + signal: "mouse,down,1*"; + source: "event"; + script { + if ((get_int(multi_down) == 0) && (get_int(mouse_down) == 0)) + { + set_int(mouse_down, 1); + run_program(PROGRAM:"button_press1"); + } + } + } + program { name: "button_press1"; + script { + new st[31]; + new Float:vl; + get_state(PART:"bg", st, 30, vl); + if (strcmp(st, "disabled")) { + set_state(PART:"bg", "pressed", 0.0); + set_state(PART:"elm.text", "pressed", 0.0); + emit("elm,action,press", ""); + } + } + } + program { name: "unpressed"; + signal: "mouse,up,1"; + source: "event"; + script { + if (get_int(mouse_down) == 1) { + set_int(mouse_down, 0); + run_program(PROGRAM:"button_unpress1"); + } + } + } + program { name: "button_unpress1"; + script { + new st[31]; + new Float:vl; + get_state(PART:"bg", st, 30, vl); + if (strcmp(st, "disabled")) { + set_state(PART:"bg", "default", 0.0); + set_state(PART:"elm.text", "default", 0.0); + emit("elm,action,unpress", ""); + } + } + } + program { name: "touch_snd"; + signal: "mouse,clicked,1"; + source: "event"; + script { + new st[31]; + new Float:vl; + if (get_int(multi_down) == 0) { + get_state(PART:"bg", st, 30, vl); + if (strcmp(st, "disabled")) { + run_program(PROGRAM:"play_sample"); + emit("elm,action,click", ""); + } + } + } + } + program { + name: "play_sample"; + action: RUN_PLUGIN "touch_sound"; + } + program { name: "disable"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "bg"; + target: "elm.text"; + } + program { name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg"; + target: "elm.text"; + } + program { name: "multi_down"; + signal: "elm,action,multi,down"; + source: "elm"; + script { + set_int(multi_down, 1); + } + } + program { name: "multi_up"; + signal: "elm,action,multi,up"; + source: "elm"; + script { + set_int(multi_down, 0); + } + } + } + } + #define NAVIFRAME_VIEW_TRANS_TIME 0.4 //time for push and pop #define NAVIFRAME_TITLE_TRANS_TIME 0.5 //Title transition time #define NAVIFRAME_TITLE_EXPAND_TRANS_TIME 0.5 //Title Expansion transition time diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index aec6abf..e3b9b9d 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -14,155 +14,892 @@ * limitations under the License. */ -#include +#include #include #include +#include + +#include +#include #include "Debug.h" #include "w-input-selector.h" -#define EMOTICON_CNT 27 +#define RECENT_EMOJI_LIST "recent_emoji_list" + +#define EMOTICON_CNT 180 +#define RECENT_CNT 9 + +extern App_Data* app_data; + +static int is_content_reuse_on = 0; + using namespace std; +vector recent_emoji_list; + typedef struct { int code; - const char* name; + char* name; }Emoticon; +static Elm_Object_Item *it_emoticon_empty = NULL; +static Elm_Object_Item *it_emoticon_recent_group = NULL; +static Elm_Object_Item *it_emoticon_emoji_group = NULL; +static Elm_Object_Item *it_last = NULL; + +static Elm_Genlist_Item_Class *itc_emoticon = NULL; + +#define INITAL_ITEM_UNIT 24 +#define LOADING_ITEM_UNIT 27 +static int loading_done_for_item = 0; +Ecore_Timer *lazy_loading_timer_for_items = NULL; + +#define INITAL_CONTENT_UNIT 51 +#define LOADING_CONTENT_UNIT 9 +static int loading_done_for_contents = 0; +Ecore_Timer *lazy_loading_timer_for_contents = NULL; + + +typedef struct emoticon_content +{ + int index; + Evas_Object *content; + int used; +} emoticon_content_s; + +static emoticon_content_s emoticon_contents_pool[EMOTICON_CNT] = { 0, }; +static emoticon_content_s emoticon_recents_pool[RECENT_CNT] = { 0, }; + + Emoticon emoticon_info[EMOTICON_CNT] = { - {0x1f44c, "IDS_IME_BODY_OK_HAND_SIGN_M_EMOTICON_NAME_TTS"}, - {0x1f44d, "IDS_IME_BODY_THUMBS_UP_SIGN_M_EMOTICON_NAME"}, - {0x1f44e, "IDS_IME_BODY_THUMBS_DOWN_SIGN_M_EMOTICON_NAME"}, - {0x1f604, "IDS_IME_BODY_SMILING_FACE_WITH_OPEN_MOUTH_AND_SMILING_EYES_M_EMOTICON_NAME"}, - {0x1f606, "IDS_IME_BODY_SMILING_FACE_WITH_OPEN_MOUTH_AND_TIGHTLY_CLOSED_EYES_M_EMOTICON_NAME"}, - {0x1f60a, "IDS_IME_BODY_SMILING_FACE_WITH_SMILING_EYES_M_EMOTICON_NAME"}, - {0x1f60d, "IDS_IME_BODY_SMILING_FACE_WITH_HEART_SHAPED_EYES_M_EMOTICON_NAME"}, - {0x1f61a, "IDS_IME_BODY_KISSING_FACE_WITH_CLOSED_EYES_M_EMOTICON_NAME"}, - {0x1f61c, "IDS_IME_BODY_FACE_WITH_STUCK_OUT_TONGUE_AND_WINKING_EYE_M_EMOTICON_NAME"}, - {0x1f620, "IDS_IME_BODY_ANGRY_FACE_M_EMOTICON_NAME"}, - {0x1f621, "IDS_IME_BODY_POUTING_FACE_M_EMOTICON_NAME"}, - {0x1f622, "IDS_IME_BODY_CRYING_FACE_M_EMOTICON_NAME"}, - {0x1f624, "IDS_IME_BODY_FACE_WITH_LOOK_OF_TRIUMPH_M_EMOTICON_NAME"}, - {0x1f625, "IDS_IME_BODY_DISAPPOINTED_BUT_RELIEVED_FACE_M_EMOTICON_NAME"}, - {0x1f62a, "IDS_IME_BODY_SLEEPY_FACE_M_EMOTICON_NAME"}, - {0x1f62b, "IDS_IME_BODY_TIRED_FACE_M_EMOTICON_NAME"}, - {0x1f631, "IDS_IME_BODY_FACE_SCREAMING_IN_FEAR_M_EMOTICON_NAME"}, - {0x1f632, "IDS_IME_BODY_ASTONISHED_FACE_M_EMOTICON_NAME"}, - {0x1f637, "IDS_IME_BODY_FACE_WITH_MEDICAL_MASK_M_EMOTICON_NAME"}, - {0x1f495, "IDS_IME_BODY_TWO_HEARTS_M_EMOTICON_NAME"}, - {0x1f43d, "IDS_IME_BODY_PIG_NOSE_M_EMOTICON_NAME"}, - {0x1f415, "IDS_IME_BODY_DOG_M_EMOTICON_NAME"}, - {0x1f408, "IDS_IME_BODY_CAT_M_EMOTICON_NAME"}, - {0x1f414, "IDS_IME_BODY_CHICKEN_M_EMOTICON_NAME"}, - {0x1f433, "IDS_IME_BODY_SPOUTING_WHALE_M_EMOTICON_NAME"}, - {0x1f43c, "IDS_IME_BODY_PANDA_FACE_M_EMOTICON_NAME"}, - {0x1f42f, "IDS_IME_BODY_TIGER_FACE_M_EMOTICON_NAME"}, + {0x1f600, ""}, + {0x1f601, ""}, + {0x1f602, ""}, + {0x1f603, ""}, + {0x1f604, ""}, + {0x1f605, ""}, + {0x1f606, ""}, + {0x1f609, ""}, + {0x1f60a, ""}, + {0x1f60b, ""}, + {0x1f60e, ""}, + {0x1f60d, ""}, + {0x1f618, ""}, + {0x1f617, ""}, + {0x1f619, ""}, + {0x1f61a, ""}, + {0x263a, ""}, + {0x1f642, ""}, + {0x1f917, ""}, + {0x1f607, ""}, + {0x1f914, ""}, + {0x1f610, ""}, + {0x1f611, ""}, + {0x1f636, ""}, + {0x1f644, ""}, + {0x1f60f, ""}, + {0x1f623, ""}, + {0x1f625, ""}, + {0x1f62e, ""}, + {0x1f910, ""}, + {0x1f62f, ""}, + {0x1f634, ""}, + {0x1f62a, ""}, + {0x1f62b, ""}, + {0x1f60c, ""}, + {0x1f913, ""}, + {0x1f61b, ""}, + {0x1f61c, ""}, + {0x1f61d, ""}, + {0x1f641, ""}, + {0x1f612, ""}, + {0x1f613, ""}, + {0x1f614, ""}, + {0x1f615, ""}, + {0x1f616, ""}, + {0x1f643, ""}, + {0x1f637, ""}, + {0x1f912, ""}, + {0x1f915, ""}, + {0x1f911, ""}, + {0x1f632, ""}, + {0x1f61e, ""}, + {0x1f61f, ""}, + {0x1f624, ""}, + {0x1f622, ""}, + {0x1f62d, ""}, + {0x1f626, ""}, + {0x1f627, ""}, + {0x1f628, ""}, + {0x1f629, ""}, + {0x1f62c, ""}, + {0x1f630, ""}, + {0x1f631, ""}, + {0x1f633, ""}, + {0x1f635, ""}, + {0x1f621, ""}, + {0x1f620, ""}, + {0x1f608, ""}, + {0x1f648, ""}, + {0x1f649, ""}, + {0x1f64a, ""}, + {0x1f448, ""}, + {0x1f449, ""}, + {0x261d, ""}, + {0x1f446, ""}, + {0x1f595, ""}, + {0x1f447, ""}, + {0x270c, ""}, + {0x1f596, ""}, + {0x1f918, ""}, + {0x1f591, ""}, + {0x1f590, ""}, + {0x270a, ""}, + {0x270b, ""}, + {0x1f44a, ""}, + {0x1f44c, ""}, + {0x1f44d, ""}, + {0x1f44e, ""}, + {0x1f592, ""}, + {0x1f593, ""}, + {0x1f44b, ""}, + {0x1f44f, ""}, + {0x1f450, ""}, + {0x1f493, ""}, + {0x1f494, ""}, + {0x1f495, ""}, + {0x1f496, ""}, + {0x1f497, ""}, + {0x1f49d, ""}, + {0x1f49e, ""}, + {0x1f49f, ""}, + {0x2763, ""}, + {0x1f35e, ""}, + {0x1f9c0, ""}, + {0x1f356, ""}, + {0x1f357, ""}, + {0x1f354, ""}, + {0x1f35f, ""}, + {0x1f355, ""}, + {0x1f32d, ""}, + {0x1f32e, ""}, + {0x1f32f, ""}, + {0x1f37f, ""}, + {0x1f372, ""}, + {0x1f371, ""}, + {0x1f358, ""}, + {0x1f359, ""}, + {0x1f35a, ""}, + {0x1f35c, ""}, + {0x1f35b, ""}, + {0x1f35d, ""}, + {0x1f360, ""}, + {0x1f362, ""}, + {0x1f363, ""}, + {0x1f364, ""}, + {0x1f365, ""}, + {0x1f361, ""}, + {0x1f366, ""}, + {0x1f368, ""}, + {0x1f367, ""}, + {0x1f369, ""}, + {0x1f36a, ""}, + {0x1f382, ""}, + {0x1f370, ""}, + {0x1f36b, ""}, + {0x1f36c, ""}, + {0x1f36d, ""}, + {0x1f36e, ""}, + {0x1f36f, ""}, + {0x1f37c, ""}, + {0x2615, ""}, + {0x1f375, ""}, + {0x1f376, ""}, + {0x1f37e, ""}, + {0x1f377, ""}, + {0x1f378, ""}, + {0x1f379, ""}, + {0x1f37a, ""}, + {0x1f37b, ""}, + {0x1f383, ""}, + {0x1f384, ""}, + {0x1f388, ""}, + {0x1f389, ""}, + {0x1f38a, ""}, + {0x26bd, ""}, + {0x26be, ""}, + {0x1f3c0, ""}, + {0x1f3c8, ""}, + {0x1f3c9, ""}, + {0x1f3be, ""}, + {0x1f3b1, ""}, + {0x1f3b3, ""}, + {0x26f3, ""}, + {0x26f8, ""}, + {0x1f3a3, ""}, + {0x1f3bf, ""}, + {0x1f3cf, ""}, + {0x1f3d0, ""}, + {0x1f3d1, ""}, + {0x1f3d2, ""}, + {0x1f3d3, ""}, + {0x1f3f8, ""}, + {0x1f3af, ""}, + {0x1f3b2, ""}, + {0x1f3df, ""}, + {0x1f3db, ""}, + {0x1f3e0, ""}, + {0x1f3e2, ""}, + {0x1f3e5, ""}, + {0x1f3eb, ""}, }; -const char * get_emoticon_file_name(int index) -{ - static string path = get_resource_path() + string("images/u00000.png"); - int ipos = path.size()-9; - char str_emoticon_code[10] = {0}; - snprintf(str_emoticon_code, sizeof(str_emoticon_code), "%x", emoticon_info[index].code); - path.erase(ipos, 5); - path.insert(ipos, str_emoticon_code); - return path.c_str(); +static Eina_Bool _custom_back_cb(void *data, Elm_Object_Item *it) +{ + _back_to_genlist_for_selector(); + return EINA_TRUE; } -static Eina_Bool _custom_back_cb(void *data, Elm_Object_Item *it) + +//---------------------------------------------------------------------------------------// + +static Eina_Bool _custom_back_cb2(void *data, Elm_Object_Item *it) { + PRINTFUNC(DLOG_DEBUG, ""); + + if (is_content_reuse_on) { + int i; + + if (lazy_loading_timer_for_items != NULL) { + ecore_timer_del(lazy_loading_timer_for_items); + lazy_loading_timer_for_items = NULL; + } + + if (lazy_loading_timer_for_contents != NULL) { + ecore_timer_del(lazy_loading_timer_for_contents); + lazy_loading_timer_for_contents = NULL; + } + + //Recent EMOTICONS : the recent emoiton need to be updated whenever emoticon view is generated, so deleted here. + for (i=0;i< RECENT_CNT;i++) + { + if (emoticon_recents_pool[i].used == 0 && emoticon_recents_pool[i].content) { + evas_object_del(emoticon_recents_pool[i].content); + } + emoticon_recents_pool[i].content = NULL; + } + } + _back_to_genlist_for_selector(); return EINA_TRUE; } -static Eina_Bool -_rotary_selector_rotary_cb(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *info) + +void get_recent_emoticons(vector &emoticon_list) { - PRINTFUNC(DLOG_DEBUG, "%s", __func__); + int ret = PREFERENCE_ERROR_NONE; + char *str = NULL; + + ret = preference_get_string(RECENT_EMOJI_LIST, &str); + if (PREFERENCE_ERROR_NONE != ret) { + PRINTFUNC(DLOG_ERROR, "preference_get_string error!(%d)", ret); + } + + emoticon_list.clear(); + + PRINTFUNC(DLOG_DEBUG, "str = %s", str); + + if (str != NULL) { + char *tok; + tok = strtok(str, ","); + while (tok != NULL) { + PRINTFUNC(DLOG_DEBUG, "tok = %s", tok); + emoticon_list.push_back(strtol(tok, (char **)NULL, 10)); + tok = strtok(NULL, ","); + } + } - if (info->direction == EEXT_ROTARY_DIRECTION_CLOCKWISE){ - evas_object_smart_callback_call(obj, "item,selected", (void*)data); - eext_rotary_object_event_callback_del(obj, _rotary_selector_rotary_cb); - } + if (str) + free(str); - return ECORE_CALLBACK_PASS_ON; + return; } -static void _rotary_selector_item_clicked(void *data, Evas_Object *obj, void *event_info) +void set_recent_emoticons(vector &emoticon_list, int val) { - PRINTFUNC(DLOG_DEBUG, "%s", __func__); - App_Data* ad = (App_Data*) data; - if (!ad) - return; + int i; + int ret = PREFERENCE_ERROR_NONE; + + if (emoticon_list.size() > 0) { + for (i = 0; i < emoticon_list.size(); i++) { + PRINTFUNC(DLOG_DEBUG, "%d == %d", emoticon_list.at(i), val); - Eext_Object_Item *selected_item = (Eext_Object_Item *)event_info; - Eina_List *rotary_selector_list = (Eina_List *)eext_rotary_selector_items_get(obj); + if (emoticon_list.at(i) == val) { + emoticon_list.erase(emoticon_list.begin()+i); + break; + } + } - int i = 0; - Eina_List *l = rotary_selector_list; - Eext_Object_Item *item = (Eext_Object_Item *)eina_list_data_get(l); + if (emoticon_list.size() >= RECENT_CNT) { + emoticon_list.erase(emoticon_list.end()); + } + } + + emoticon_list.insert(emoticon_list.begin(), val); + + string stored; + char str[10] = {0, }; - for (i = 0; l != NULL; i++) { - if (selected_item == item) - break; + for (i = 0; i < emoticon_list.size(); i++) { + snprintf(str, sizeof(str), "%d", emoticon_list.at(i)); + stored += str; + if (i+1 != emoticon_list.size()) + stored += ","; + } + + PRINTFUNC(DLOG_DEBUG, "%s", stored.c_str()); - l = eina_list_next(l); - item = (Eext_Object_Item *)eina_list_data_get(l); + ret = preference_set_string(RECENT_EMOJI_LIST, stored.c_str()); + if (PREFERENCE_ERROR_NONE != ret) { + PRINTFUNC(DLOG_ERROR, "preference_set_string error!(%d)", ret); } +} + +static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event_info) +{ + int index = (int)data; + + PRINTFUNC(DLOG_DEBUG, "index = %d", index); + + // store in recents list + set_recent_emoticons(recent_emoji_list, index); int length; - const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[i].code, 0 }; + const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); reply_to_sender_by_callback((const char*)utf_8, "emoticon"); - PRINTFUNC(SECURE_DEBUG, "[%d]%s", i, utf_8); + PRINTFUNC(SECURE_DEBUG, "[%d]%s", index, utf_8); if (utf_8) free(utf_8); - if(ad->reply_type == REPLY_APP_NORMAL) - elm_exit(); + elm_exit(); +} + +Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ + if (parent == NULL) + return NULL; + + Evas_Object* btn = elm_button_add(parent); + elm_object_style_set(btn, "emoticon"); + evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + + int length; + const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; + char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); + elm_object_part_text_set(btn, "elm.text", utf_8); + + if (utf_8) + free(utf_8); + + evas_object_layer_set(btn, 32000); + + evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void *)index); + + return btn; } -static void _rotary_selector_item_selected(void *data, Evas_Object *obj, void *event_info) +Evas_Object* get_recent_emoticon_button(Evas_Object* parent, int index){ + if (parent == NULL) + return NULL; + + Evas_Object* btn = elm_button_add(parent); + elm_object_style_set(btn, "emoticon"); + evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + + int length; + const Eina_Unicode unicode_event[2] = { emoticon_info[recent_emoji_list.at(index)].code, 0 }; + char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); + elm_object_part_text_set(btn, "elm.text", utf_8); + + evas_object_data_set(btn, "index", (void*) recent_emoji_list.at(index)); + + if (utf_8) + free(utf_8); + + evas_object_layer_set(btn, 32000); + evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void*) recent_emoji_list.at(index)); + + return btn; +} + +static void _emoticon_gl_lang_changed(void *data, Evas_Object *obj, void *event_info) { - PRINTFUNC(DLOG_DEBUG, "%s", __func__); + elm_genlist_realized_items_update(obj); } -void ise_show_emoticon_popup_rotary(void *data) +static char * __emoticon_gl_text_get(void *data, Evas_Object *obj, const char *part) +{ + //PRINTFUNC(DLOG_DEBUG,"part = %s", part); + + const char* str = (const char*) data; + if (!str) + return NULL; + + if (!strcmp(part, "elm.text")) { + //PRINTFUNC(DLOG_DEBUG,"str = %s", str); + return strdup(gettext(str)); + } + return NULL; +} + +static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *it = (Elm_Object_Item *)event_info; + + const Elm_Genlist_Item_Class *itc = elm_genlist_item_item_class_get(it); + +// PRINTFUNC(DLOG_DEBUG,"%s - stype[%s]", __func__, itc->item_style); + if (!strcmp(itc->item_style, "3button_flat")) { + int index = (int)elm_object_item_data_get(it); + //PRINTFUNC(DLOG_DEBUG,"it = %p", it); + PRINTFUNC(DLOG_DEBUG, "index = %d %d %d", index, index+1, index+2); + + if (index < EMOTICON_CNT) { + emoticon_contents_pool[index].used = 0; + } + if (index + 1 < EMOTICON_CNT) { + emoticon_contents_pool[index+1].used = 0; + } + if (index + 2 < EMOTICON_CNT) { + emoticon_contents_pool[index+2].used = 0; + } + } else if (!strcmp(itc->item_style, "3button_flat_recent")) { + int index = (int)elm_object_item_data_get(it); + //PRINTFUNC(DLOG_DEBUG,"index = %d",index); + + if (index < recent_emoji_list.size()) { + emoticon_recents_pool[index].used = 0; + } + if (index + 1 < recent_emoji_list.size()) { + emoticon_recents_pool[index+1].used = 0; + } + if (index + 2 < recent_emoji_list.size()) { + emoticon_recents_pool[index+2].used = 0; + } + } +} + +static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *obj, const char *part) +{ + if (is_content_reuse_on) { + int index = (int)data; + int new_index = 0; + + //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); + if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { + if (!strcmp(part, "elm.icon.1")) { + if (index >= recent_emoji_list.size()) return NULL; + new_index = index; + } else if (!strcmp(part, "elm.icon.2")) { + if (index + 1 >= recent_emoji_list.size()) return NULL; + new_index = index + 1; + } else if (!strcmp(part, "elm.icon.3")) { + if (index + 2 >= recent_emoji_list.size()) return NULL; + new_index = index + 2; + } + + Evas_Object* btn = NULL; + btn = (Evas_Object*)emoticon_recents_pool[new_index].content; + emoticon_recents_pool[new_index].used = 1; + return btn; + } else if (!strcmp(part, "base")) { + Evas_Object* btn = elm_button_add(obj); + elm_object_style_set(btn, "ime/transparent"); + return btn; + } + } else { + int index = (int)data; + int new_index = 0; + + // PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); + if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { + if (!strcmp(part, "elm.icon.1")) { + if (index >= recent_emoji_list.size()) return NULL; + new_index = index; + } else if (!strcmp(part, "elm.icon.2")) { + if (index + 1 >= recent_emoji_list.size()) return NULL; + new_index = index + 1; + } else if (!strcmp(part, "elm.icon.3")) { + if (index + 2 >= recent_emoji_list.size()) return NULL; + new_index = index + 2; + } + return get_recent_emoticon_button(obj, new_index); + } else if (!strcmp(part, "base")) { + Evas_Object* btn = elm_button_add(obj); + elm_object_style_set(btn, "ime/transparent"); + return btn; + } + } + return NULL; +} + +static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object *obj, const char *part) +{ + //PRINTFUNC(DLOG_DEBUG,"%s", __func__); + + if (is_content_reuse_on) { + int index = (int)data; + int new_index = 0; + + if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { + if (!strcmp(part, "elm.icon.1")) { + if (index >= EMOTICON_CNT) return NULL; + new_index = index; + } else if (!strcmp(part, "elm.icon.2")) { + if (index + 1 >= EMOTICON_CNT) return NULL; + new_index = index + 1; + } else if (!strcmp(part, "elm.icon.3")) { + if (index + 2 >= EMOTICON_CNT) return NULL; + new_index = index + 2; + } + + Evas_Object* btn = NULL; + btn = (Evas_Object*)emoticon_contents_pool[new_index].content; + emoticon_contents_pool[new_index].used = 1; +#if 0 + char utf_8[10] = {0, }; + snprintf(utf_8, sizeof(utf_8), "%d", new_index); + elm_object_part_text_set(btn, "elm.text", strdup(utf_8)); +#else + int length; + const Eina_Unicode unicode_event[2] = { emoticon_info[new_index].code, 0 }; + char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); + elm_object_part_text_set(btn, "elm.text", utf_8); + evas_object_data_set(btn, "index", (void*)new_index); + + if (utf_8) + free(utf_8); +#endif + return btn; + + } else if (!strcmp(part, "base")) { + Evas_Object* btn = elm_button_add(obj); + elm_object_style_set(btn, "ime/transparent"); + return btn; + } + } else { + int index = (int)data; + int new_index = 0; + + if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) { + if (!strcmp(part, "elm.icon.1")) { + if (index >= EMOTICON_CNT) return NULL; + new_index = index; + } else if (!strcmp(part, "elm.icon.2")) { + if (index + 1 >= EMOTICON_CNT) return NULL; + new_index = index + 1; + } else if (!strcmp(part, "elm.icon.3")) { + if (index + 2 >= EMOTICON_CNT) return NULL; + new_index = index + 2; + } + return get_emoticon_button(obj, new_index); + } else if (!strcmp(part, "base")) { + Evas_Object* btn = elm_button_add(obj); + elm_object_style_set(btn, "ime/transparent"); + return btn; + } + } + return NULL; +} + + +void _create_reusable_recents(Evas_Object *parent) +{ + if (!parent) { + PRINTFUNC(DLOG_ERROR, "parent is null"); + return; + } + + int i; + for (i = 0; i < recent_emoji_list.size(); i++ ) { + emoticon_recents_pool[i].index = i; + emoticon_recents_pool[i].content = get_recent_emoticon_button(parent, i); + emoticon_recents_pool[i].used = 0; + } +} + +static Eina_Bool _lazy_loader_cb_for_contents(void *data) +{ + Evas_Object *gl = (Evas_Object *)data; + if (!gl) { + PRINTFUNC(DLOG_ERROR, "gl is null"); + lazy_loading_timer_for_contents = NULL; + return ECORE_CALLBACK_CANCEL; + } + + if (loading_done_for_contents == EMOTICON_CNT) { + PRINTFUNC(DLOG_DEBUG, "lazy loading contents done"); + lazy_loading_timer_for_contents = NULL; + return ECORE_CALLBACK_CANCEL; + } + + int loading_top = 0; + if (loading_done_for_contents + LOADING_CONTENT_UNIT > EMOTICON_CNT) { + loading_top = EMOTICON_CNT; + } else { + loading_top = loading_done_for_contents + LOADING_CONTENT_UNIT; + } + + PRINTFUNC(DLOG_DEBUG, "_lazy_loader_cb_for_contents loading_done = %d", loading_done_for_contents); + + int i; + for (i = loading_done_for_contents; i < loading_top; i++) { + emoticon_contents_pool[i].index = i; + emoticon_contents_pool[i].used = 0; + + if (emoticon_contents_pool[i].content == NULL) { // reusable + emoticon_contents_pool[i].content = get_emoticon_button(gl, i); + } + } + + loading_done_for_contents = loading_top; + + return ECORE_CALLBACK_RENEW; +} + +void create_reusable_button(Evas_Object *parent) +{ + if (!parent) { + PRINTFUNC(DLOG_ERROR, "parent is null"); + return; + } + loading_done_for_contents = INITAL_CONTENT_UNIT; + + int i; + for (i = 0; i < INITAL_CONTENT_UNIT; i++ ) { + emoticon_contents_pool[i].index = i; + emoticon_contents_pool[i].used = 0; + + if (emoticon_contents_pool[i].content == NULL) { // reusable + emoticon_contents_pool[i].content = get_emoticon_button(parent, i); + } + } + + lazy_loading_timer_for_contents = ecore_timer_add(0.25, _lazy_loader_cb_for_contents, (void *)parent); +} + +static Eina_Bool _lazy_loader_cb_for_items(void *data) +{ + Evas_Object *gl = (Evas_Object *)data; + if (!gl) { + PRINTFUNC(DLOG_ERROR, "gl is null"); + lazy_loading_timer_for_items = NULL; + return ECORE_CALLBACK_CANCEL; + } + + if (loading_done_for_item == EMOTICON_CNT) { + PRINTFUNC(DLOG_DEBUG, "lazy loading item done"); + //elm_genlist_realized_items_update(gl); + elm_genlist_item_class_free(itc_emoticon); + lazy_loading_timer_for_items = NULL; + + return ECORE_CALLBACK_CANCEL; + } + + int loading_top = 0; + if (loading_done_for_item + LOADING_ITEM_UNIT > EMOTICON_CNT) { + loading_top = EMOTICON_CNT; + } else { + loading_top = loading_done_for_item + LOADING_ITEM_UNIT; + } + + if (loading_top > loading_done_for_contents) { + PRINTFUNC(DLOG_DEBUG, "Wait for content loading"); + return ECORE_CALLBACK_RENEW; + } + PRINTFUNC(DLOG_DEBUG, "_lazy_loader_cb_for_items loading_done_for_item = %d", loading_done_for_item); + + int i; + for (i = loading_done_for_item; i < loading_top; i++ ) { + if (i%3 == 0) + elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + } + + loading_done_for_item = loading_top; + return ECORE_CALLBACK_RENEW; +} + +void _create_reusable_contents(Evas_Object *gl){ + if (!gl) { + PRINTFUNC(DLOG_ERROR, "gl is null"); + return; + } + int i; + loading_done_for_item = INITAL_ITEM_UNIT; + + for (i = 0; i < INITAL_ITEM_UNIT; i++ ) { + if (i%3 == 0) + elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + } + + lazy_loading_timer_for_items = ecore_timer_add(0.1, _lazy_loader_cb_for_items, (void *)gl); +} + +Evas_Object* _create_emoticon_genlist(void* data) { PRINTFUNC(DLOG_DEBUG, "%s", __func__); App_Data* ad = (App_Data*) data; if (!ad) + return NULL; + + Evas_Object* genlist = elm_genlist_add(ad->naviframe); + if (NULL == genlist) + return NULL; + + Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface); + eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + evas_object_data_set(genlist, "circle", (void *) circle_object_genlist); + eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE); + + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(genlist); + + Elm_Object_Item *nf_emoticon_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, genlist, "empty"); + + elm_naviframe_item_pop_cb_set(nf_emoticon_item, _custom_back_cb2, ad); + + evas_object_smart_callback_add(genlist, "language,changed", _emoticon_gl_lang_changed, genlist); + + if (is_content_reuse_on) { + evas_object_smart_callback_add(genlist, "content,unswallowed", _emoticon_gl_content_unswallowed_cb, NULL); + } + + return genlist; +} + +void _update_emoticon_items(void *data) +{ + PRINTFUNC(DLOG_DEBUG, "%s", __func__); + Evas_Object* gl = (Evas_Object*) data; + if (!gl) return; + int i; + Elm_Object_Item *it = NULL; + Elm_Object_Item *first_it = NULL; + + Elm_Genlist_Item_Class * itc_dummy = elm_genlist_item_class_new(); + itc_dummy->item_style = "title"; + itc_dummy->func.text_get = NULL; + itc_dummy->func.content_get = NULL; + itc_dummy->func.state_get = NULL; + itc_dummy->func.del = NULL; - Evas_Object *rotary_selector = eext_rotary_selector_add(ad->naviframe); -// uxt_theme_object_replace_color(rotary_selector, "B01153", "AO0117"); - PRINTFUNC(DLOG_DEBUG, "replace color"); - for (int i = 0; i < EMOTICON_CNT; ++i) - { - Evas_Object *img = NULL; - Eext_Object_Item *item = eext_rotary_selector_item_append(rotary_selector); + Elm_Genlist_Item_Class *itc_group = elm_genlist_item_class_new(); - img = elm_image_add(rotary_selector); - elm_image_file_set(img, get_emoticon_file_name(i), NULL); - eext_rotary_selector_item_part_content_set(item, "item,bg_image", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img); + itc_group->item_style = "groupindex"; + itc_group->func.text_get = __emoticon_gl_text_get; + itc_group->func.content_get = NULL; + itc_group->func.state_get = NULL; + itc_group->func.del = NULL; - img = elm_image_add(rotary_selector); - elm_image_file_set(img, get_emoticon_file_name(i), NULL); - eext_rotary_selector_item_part_content_set(item, "selector,icon", EEXT_ROTARY_SELECTOR_ITEM_STATE_NORMAL, img); + Elm_Genlist_Item_Class *itc_recent = elm_genlist_item_class_new(); + if (is_content_reuse_on) { +// itc_recent->content_reusable = EINA_TRUE; } + itc_recent->item_style = "3button_flat_recent"; + itc_recent->func.text_get = NULL; + itc_recent->func.content_get = __emoticon_gl_recent_content_get; + itc_recent->func.state_get = NULL; + itc_recent->func.del = NULL; - evas_object_smart_callback_add(rotary_selector, "item,selected", _rotary_selector_item_selected, rotary_selector); - evas_object_smart_callback_add(rotary_selector, "item,clicked", _rotary_selector_item_clicked, (void*)ad); + itc_emoticon = elm_genlist_item_class_new(); + if (is_content_reuse_on) { +// itc_emoticon->content_reusable = EINA_TRUE; + } + itc_emoticon->item_style = "3button_flat"; + itc_emoticon->func.text_get = NULL; + itc_emoticon->func.content_get = __emoticon_gl_emoticon_content_get; + itc_emoticon->func.state_get = NULL; + itc_emoticon->func.del = NULL; - Elm_Object_Item *nf_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, rotary_selector, "empty"); - elm_naviframe_item_pop_cb_set(nf_item, _custom_back_cb, NULL); - eext_rotary_object_event_activated_set(rotary_selector, EINA_TRUE); + // dummy title for empty space + it_emoticon_empty = elm_genlist_item_append(gl, itc_dummy, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); - PRINTFUNC(DLOG_DEBUG, "%s", __func__); + if (recent_emoji_list.size() > 0) { + if (is_content_reuse_on) { + _create_reusable_recents(gl); + } + + // Group Recents + it_emoticon_recent_group = elm_genlist_item_append(gl, itc_group, (void*)"IDS_IME_HEADER_RECENT_M_RECETLY_SENT_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + if (first_it == NULL) + first_it = it_emoticon_recent_group; + + PRINTFUNC(DLOG_DEBUG, "size = %d", recent_emoji_list.size()); + + for (i=0;i < recent_emoji_list.size();i=i+3) + { + it = elm_genlist_item_append(gl, itc_recent, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + } + } + + // Group Emoticons + it_emoticon_emoji_group = elm_genlist_item_append(gl, itc_group, (void*)"IDS_IME_HEADER_EMOJIS_ABB", NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)2); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + if (first_it == NULL) + first_it = it_emoticon_emoji_group; + + if (is_content_reuse_on) { + _create_reusable_contents(gl); + } else { + // Emoticons + for (i=0;i< EMOTICON_CNT;i=i+3) { + it = elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i); + it_last = it; + } + elm_genlist_item_class_free(itc_emoticon); + } + it = elm_genlist_item_next_get(first_it); + const Elm_Genlist_Item_Class *itc_temp = elm_genlist_item_item_class_get(it); + if (itc_temp == itc_group) { + it = elm_genlist_item_next_get(it); + } + elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + + elm_genlist_item_class_free(itc_recent); + elm_genlist_item_class_free(itc_group); + elm_genlist_item_class_free(itc_dummy); +} + +void ise_show_emoticon_list(void *data) +{ + App_Data* ad = (App_Data*) data; + if (!ad) + return; + + it_emoticon_empty = NULL; + it_emoticon_recent_group = NULL; + it_emoticon_emoji_group = NULL; + it_last = NULL; + + get_recent_emoticons(recent_emoji_list); + + Evas_Object* emoticon_list = NULL; + + emoticon_list = _create_emoticon_genlist(ad); + + if (is_content_reuse_on) { + create_reusable_button(ad->naviframe); // button object need to survive even if genlist is deleted. + } + _update_emoticon_items(emoticon_list); } diff --git a/src/w-input-selector.cpp b/src/w-input-selector.cpp index 8eb09bd..828c9a5 100755 --- a/src/w-input-selector.cpp +++ b/src/w-input-selector.cpp @@ -147,8 +147,7 @@ static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info if(!ad) return; -// ise_show_emoticon_popup(ad); - ise_show_emoticon_popup_rotary(ad); + ise_show_emoticon_list(ad); } static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info) -- 2.7.4 From 9496d3676727d41903b8e5f15f3c9efe183b5c74 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Mon, 21 Nov 2016 12:00:06 +0900 Subject: [PATCH 07/16] Fix issue about strtok detected by static analysis tool Change-Id: I3aa91b54122d8f06028f9f0d310dc451babb0f8d Signed-off-by: sungwook79.park --- src/w-input-emoticon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index e3b9b9d..d6e17bf 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -313,12 +313,12 @@ void get_recent_emoticons(vector &emoticon_list) PRINTFUNC(DLOG_DEBUG, "str = %s", str); if (str != NULL) { - char *tok; - tok = strtok(str, ","); + char *tok, *ptr; + tok = strtok_r(str, ",", &ptr); while (tok != NULL) { PRINTFUNC(DLOG_DEBUG, "tok = %s", tok); emoticon_list.push_back(strtol(tok, (char **)NULL, 10)); - tok = strtok(NULL, ","); + tok = strtok_r(NULL, ",", &ptr); } } -- 2.7.4 From ebdbe373c84b61a013b73f5376e81a9d1363c6bb Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Tue, 22 Nov 2016 14:32:44 +0900 Subject: [PATCH 08/16] Update package version to 0.1.161122 Change-Id: I1f4bd19c9f14d8cd1a26be24280c3d7aba352fc9 Signed-off-by: sungwook79.park --- org.tizen.inputdelegator.xml | 2 +- packaging/org.tizen.inputdelegator.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.inputdelegator.xml b/org.tizen.inputdelegator.xml index 87d0348..bafb22e 100755 --- a/org.tizen.inputdelegator.xml +++ b/org.tizen.inputdelegator.xml @@ -1,5 +1,5 @@ - + diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index f8cbf92..0416a7d 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -1,6 +1,6 @@ Name: org.tizen.inputdelegator Summary: Input Delegator Application -Version: 0.1.161102 +Version: 0.1.161122 Release: 1 Group: Applications License: Apache-2.0 -- 2.7.4 From 2c2a1320539c24b872772c15c5a9337bba134ee7 Mon Sep 17 00:00:00 2001 From: "aravind.gara" Date: Tue, 22 Nov 2016 20:55:59 +0900 Subject: [PATCH 09/16] sound-manager API changed Change-Id: Ib748132786489d056d15088faa0a749b417115e1 Signed-off-by: aravind.gara --- src/SttManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SttManager.cpp b/src/SttManager.cpp index d8c53b5..517b250 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -50,7 +50,8 @@ static inline const char *stt_state_str(stt_state_e cur) { return (const char *) "ABNORMAL CASE"; } -static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data) +static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason_for_change, int sound_behaviors, const char *extra_info, void *user_data) { } @@ -140,7 +141,7 @@ void SttManager::Start() { asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL; int ret; - ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); + ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to acquire playback or recording focus. ret : %d, stream handle : %p", ret, g_stream_info_h); } @@ -554,7 +555,7 @@ void SttManager::EnableSilenceDetection(bool enabled) { void SttManager::ReleaseSoundFocus() { - int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); + int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to release playback or recording focus. ret : %d", ret); } -- 2.7.4 From 72b9709f0cb45ae74042cba2e7b8659eb083bd9a Mon Sep 17 00:00:00 2001 From: sungwook park Date: Thu, 24 Nov 2016 02:27:12 -0800 Subject: [PATCH 10/16] Revert "sound-manager API changed" This reverts commit 2c2a1320539c24b872772c15c5a9337bba134ee7. Change-Id: I93bb56fb617397c705c3bd46f46880b165b7651e --- src/SttManager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SttManager.cpp b/src/SttManager.cpp index 517b250..d8c53b5 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -50,8 +50,7 @@ static inline const char *stt_state_str(stt_state_e cur) { return (const char *) "ABNORMAL CASE"; } -static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, - sound_stream_focus_change_reason_e reason_for_change, int sound_behaviors, const char *extra_info, void *user_data) +static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data) { } @@ -141,7 +140,7 @@ void SttManager::Start() { asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL; int ret; - ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); + ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to acquire playback or recording focus. ret : %d, stream handle : %p", ret, g_stream_info_h); } @@ -555,7 +554,7 @@ void SttManager::EnableSilenceDetection(bool enabled) { void SttManager::ReleaseSoundFocus() { - int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); + int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to release playback or recording focus. ret : %d", ret); } -- 2.7.4 From 5cf54f8cc513587ffdaed5141273ff2dd1f6978f Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 25 Nov 2016 17:21:38 +0900 Subject: [PATCH 11/16] Fix build error when Werror option is on Change-Id: I2dc58f397cf225aa83caf0e05f9807c6c15e1efc Signed-off-by: sungwook79.park --- packaging/org.tizen.inputdelegator.spec | 2 -- src/w-input-emoticon.cpp | 29 +++++++++++------------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index 0416a7d..5d24c27 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -67,11 +67,9 @@ Input Delegator Application for Wearable environment %setup -q %build -%if 0%{?sec_build_binary_debug_enable} export CFLAGS+=" -DTIZEN_DEBUG_ENABLE -Werror" export CXXFLAGS+=" -DTIZEN_DEBUG_ENABLE -Werror" export FFLAGS+=" -DTIZEN_DEBUG_ENABLE -Werror" -%endif export CXXFLAGS="$CXXFLAGS -std=gnu++0x" diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index d6e17bf..8ad6c45 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -41,7 +41,7 @@ vector recent_emoji_list; typedef struct { int code; - char* name; + const char* name; }Emoticon; static Elm_Object_Item *it_emoticon_empty = NULL; @@ -257,13 +257,6 @@ Emoticon emoticon_info[EMOTICON_CNT] = { }; -static Eina_Bool _custom_back_cb(void *data, Elm_Object_Item *it) -{ - _back_to_genlist_for_selector(); - return EINA_TRUE; -} - - //---------------------------------------------------------------------------------------// static Eina_Bool _custom_back_cb2(void *data, Elm_Object_Item *it) @@ -330,7 +323,7 @@ void get_recent_emoticons(vector &emoticon_list) void set_recent_emoticons(vector &emoticon_list, int val) { - int i; + unsigned int i; int ret = PREFERENCE_ERROR_NONE; if (emoticon_list.size() > 0) { @@ -378,7 +371,7 @@ static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event set_recent_emoticons(recent_emoji_list, index); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); reply_to_sender_by_callback((const char*)utf_8, "emoticon"); @@ -400,7 +393,7 @@ Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); @@ -424,7 +417,7 @@ Evas_Object* get_recent_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[recent_emoji_list.at(index)].code, 0 }; + const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[recent_emoji_list.at(index)].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); @@ -481,7 +474,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo emoticon_contents_pool[index+2].used = 0; } } else if (!strcmp(itc->item_style, "3button_flat_recent")) { - int index = (int)elm_object_item_data_get(it); + unsigned int index = (int)elm_object_item_data_get(it); //PRINTFUNC(DLOG_DEBUG,"index = %d",index); if (index < recent_emoji_list.size()) { @@ -499,7 +492,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *obj, const char *part) { if (is_content_reuse_on) { - int index = (int)data; + unsigned int index = (unsigned int)data; int new_index = 0; //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); @@ -525,7 +518,7 @@ static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *o return btn; } } else { - int index = (int)data; + unsigned int index = (unsigned int)data; int new_index = 0; // PRINTFUNC(DLOG_DEBUG,"%s %d", part, index); @@ -579,7 +572,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object elm_object_part_text_set(btn, "elm.text", strdup(utf_8)); #else int length; - const Eina_Unicode unicode_event[2] = { emoticon_info[new_index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[new_index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); evas_object_data_set(btn, "index", (void*)new_index); @@ -627,7 +620,7 @@ void _create_reusable_recents(Evas_Object *parent) return; } - int i; + unsigned int i; for (i = 0; i < recent_emoji_list.size(); i++ ) { emoticon_recents_pool[i].index = i; emoticon_recents_pool[i].content = get_recent_emoticon_button(parent, i); @@ -792,7 +785,7 @@ void _update_emoticon_items(void *data) if (!gl) return; - int i; + unsigned int i; Elm_Object_Item *it = NULL; Elm_Object_Item *first_it = NULL; -- 2.7.4 From a204ab0e832a2e7d46a63d96e396e708dfe35403 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 25 Nov 2016 17:24:51 +0900 Subject: [PATCH 12/16] Update package version to 0.1.161125 Change-Id: I6c2bb4ca55413444532f56af7812ba13dfcd54c9 Signed-off-by: sungwook79.park --- org.tizen.inputdelegator.xml | 2 +- packaging/org.tizen.inputdelegator.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.inputdelegator.xml b/org.tizen.inputdelegator.xml index bafb22e..950f7e0 100755 --- a/org.tizen.inputdelegator.xml +++ b/org.tizen.inputdelegator.xml @@ -1,5 +1,5 @@ - + diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index 5d24c27..8194598 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -1,6 +1,6 @@ Name: org.tizen.inputdelegator Summary: Input Delegator Application -Version: 0.1.161122 +Version: 0.1.161125 Release: 1 Group: Applications License: Apache-2.0 -- 2.7.4 From 0d9a51f1dcae57c94dd5cd6859a7268857aaeb01 Mon Sep 17 00:00:00 2001 From: "aravind.gara" Date: Tue, 29 Nov 2016 17:38:18 +0900 Subject: [PATCH 13/16] sound-manager API changed. Change-Id: I074b9459d75036e7aa3841c90c1e26d0c920875c Signed-off-by: aravind.gara --- src/SttManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SttManager.cpp b/src/SttManager.cpp index d8c53b5..3632923 100755 --- a/src/SttManager.cpp +++ b/src/SttManager.cpp @@ -50,7 +50,8 @@ static inline const char *stt_state_str(stt_state_e cur) { return (const char *) "ABNORMAL CASE"; } -static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *extra_info, void *user_data) +static void player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *extra_info, void *user_data) { } @@ -140,7 +141,7 @@ void SttManager::Start() { asrtype = STT_RECOGNITION_TYPE_FREE_PARTIAL; int ret; - ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); + ret = sound_manager_acquire_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to acquire playback or recording focus. ret : %d, stream handle : %p", ret, g_stream_info_h); } @@ -554,7 +555,7 @@ void SttManager::EnableSilenceDetection(bool enabled) { void SttManager::ReleaseSoundFocus() { - int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), NULL); + int ret = sound_manager_release_focus(g_stream_info_h, (sound_stream_focus_mask_e)(SOUND_STREAM_FOCUS_FOR_PLAYBACK | SOUND_STREAM_FOCUS_FOR_RECORDING), SOUND_BEHAVIOR_NONE, NULL); if (SOUND_MANAGER_ERROR_NONE != ret) { LOGW("Fail to release playback or recording focus. ret : %d", ret); } -- 2.7.4 From ab216464b5c37788f60eca3ff8d40b036b613038 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 2 Dec 2016 15:01:22 +0900 Subject: [PATCH 14/16] Update package version to 0.1.161202 Change-Id: Ief3cf9dfc50f86d95d90c8d35ea7abf70ab451a7 Signed-off-by: sungwook79.park --- org.tizen.inputdelegator.xml | 2 +- packaging/org.tizen.inputdelegator.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.inputdelegator.xml b/org.tizen.inputdelegator.xml index 950f7e0..a00448c 100755 --- a/org.tizen.inputdelegator.xml +++ b/org.tizen.inputdelegator.xml @@ -1,5 +1,5 @@ - + diff --git a/packaging/org.tizen.inputdelegator.spec b/packaging/org.tizen.inputdelegator.spec index 8194598..841f06a 100755 --- a/packaging/org.tizen.inputdelegator.spec +++ b/packaging/org.tizen.inputdelegator.spec @@ -1,6 +1,6 @@ Name: org.tizen.inputdelegator Summary: Input Delegator Application -Version: 0.1.161125 +Version: 0.1.161202 Release: 1 Group: Applications License: Apache-2.0 -- 2.7.4 From 381634f971c2f2b330ce39772b9edddcbe5673a3 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 2 Dec 2016 16:17:54 +0900 Subject: [PATCH 15/16] Fix build error Change-Id: Ideda05974beecc2b1f746c1a14f4814966c1b177 Signed-off-by: Jihoon Kim --- src/w-input-emoticon.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/w-input-emoticon.cpp b/src/w-input-emoticon.cpp index 8ad6c45..f0c64f2 100755 --- a/src/w-input-emoticon.cpp +++ b/src/w-input-emoticon.cpp @@ -371,7 +371,7 @@ static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event set_recent_emoticons(recent_emoji_list, index); int length; - const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); reply_to_sender_by_callback((const char*)utf_8, "emoticon"); @@ -393,7 +393,7 @@ Evas_Object* get_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); @@ -417,7 +417,7 @@ Evas_Object* get_recent_emoticon_button(Evas_Object* parent, int index){ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); int length; - const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[recent_emoji_list.at(index)].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[recent_emoji_list.at(index)].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); @@ -572,7 +572,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object elm_object_part_text_set(btn, "elm.text", strdup(utf_8)); #else int length; - const Eina_Unicode unicode_event[2] = { (unsigned int)emoticon_info[new_index].code, 0 }; + const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[new_index].code, 0 }; char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length); elm_object_part_text_set(btn, "elm.text", utf_8); evas_object_data_set(btn, "index", (void*)new_index); -- 2.7.4 From 372d6fee3ef4443b31d249ce6f6b2da41d3b4589 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Thu, 8 Dec 2016 13:50:30 +0900 Subject: [PATCH 16/16] Adopt wave VI for voice mode Change-Id: I944da15dc5ce5a28308a6575dde14e2a33100b63 Signed-off-by: sungwook79.park --- inc/MicEffector.h | 14 +- res/edje/w-input-stt.edc | 31 ++- src/MicEffector.cpp | 553 ++++++++++++++++++++++----------------------- src/WInputSttMicEffect.cpp | 168 +++++++------- src/w-input-stt-voice.cpp | 116 +++++----- 5 files changed, 446 insertions(+), 436 deletions(-) mode change 100755 => 100644 src/MicEffector.cpp mode change 100755 => 100644 src/WInputSttMicEffect.cpp diff --git a/inc/MicEffector.h b/inc/MicEffector.h index 8284f1c..aa3b821 100755 --- a/inc/MicEffector.h +++ b/inc/MicEffector.h @@ -18,7 +18,7 @@ #include #include -#include "Debug.h" + #define SAMPLE_COUNT 59 @@ -140,14 +140,6 @@ class MicEffector void DrawDummyFrame(); /** - * Efl vector canvas handle - * - */ -// ea_vector_canvas_h *canvas; -// ea_vector_path_h *path; -// ea_vector_paint_h *paint; - - /** * Volume values. * */ @@ -161,6 +153,10 @@ class MicEffector bool started; bool fake; + Evas_Object *vg; + Efl_VG *root; + Efl_VG *shape; + /** * timer handle * diff --git a/res/edje/w-input-stt.edc b/res/edje/w-input-stt.edc index b123590..62d648d 100755 --- a/res/edje/w-input-stt.edc +++ b/res/edje/w-input-stt.edc @@ -603,23 +603,46 @@ collections description { state, "default" 0.0; - min, 0 74; - max, 9999 74; + min, 0 64; + max, 360 64; align, 0.5 1; rel1 { relative, 0 1; to, "bg"; - offset, 0 -14; + offset, 0 -1; } rel2 { relative, 1 1; to, "bg"; - offset, 0 -14; + offset, 0 -1; + } + } + + description + { + state, "hide" 0.0; + min, 0 64; + max, 360 64; + align, 0.5 1; + rel1 + { + relative, 0 (360+64)/360; + to, "bg"; + offset, 0 +13; } + rel2 + { + relative, 1 (360+64)/360; + to, "bg"; + offset, 0 +13; + } + } + } + part { name, "EFFECT_BG"; diff --git a/src/MicEffector.cpp b/src/MicEffector.cpp old mode 100755 new mode 100644 index 9010026..b318e57 --- a/src/MicEffector.cpp +++ b/src/MicEffector.cpp @@ -14,9 +14,21 @@ * limitations under the License. */ +#define EFL_BETA_API_SUPPORT 1 +#define EFL_EO_API_SUPPORT 1 + +#include + #include #include "MicEffector.h" +#include +#include +#include +#undef LOG_TAG +#define LOG_TAG "INPUT_DELEGATOR" + + using namespace is::ui; /** @@ -33,28 +45,27 @@ static float timeout_s = 1.0f / 60.0f; double cubic_easy_in_out(double index, double start, double end, double duration) { - index /= duration/2; - if (index < 1) - return end/2*index*index*index + start; + index /= duration/2; + if (index < 1) + return end/2*index*index*index + start; - index -= 2; - return end/2*(index*index*index + 2) + start; + index -= 2; + return end/2*(index*index*index + 2) + start; } double cubic_easy_in(double index, double start, double end, double duration) { - index /= duration; - return end*index*index*index*index*index + start; + index /= duration; + return end*index*index*index*index*index + start; } double cubic_easy_out(double index, double start, double end, double duration) { - index /= duration; - index--; - return end*(index*index*index + 1) + start; + index /= duration; + index--; + return end*(index*index*index + 1) + start; } - /** * Constructor * @@ -63,30 +74,32 @@ double cubic_easy_out(double index, double start, double end, double duration) * #2. Drawing empty frame to avoid broken screen. * */ - MicEffector::MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector& effect) - : drawcount(0) - , forcestop(false) - , started(false) - , fake(false) - , timer(NULL) - , layout(layout) - , ieffect(effect) + : drawcount(0) + , forcestop(false) + , started(false) + , fake(false) + , timer(NULL) + , layout(layout) + , ieffect(effect) { -// path = ea_vector_path_create(); -// paint = ea_vector_paint_create(); -// ea_vector_paint_set_style(paint, EA_VECTOR_PAINT_STYLE_STROKE); -// ea_vector_paint_set_line_cap(paint, EA_VECTOR_PAINT_LINE_CAP_ROUND); -// ea_vector_paint_set_line_join(paint, EA_VECTOR_PAINT_LINE_JOIN_ROUND); -// ea_vector_paint_set_line_width(paint, 3.0); -// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, 1.0f); + vg = evas_object_vg_add(evas_object_evas_get(canvas)); + evas_object_show(vg); -// this->canvas = ea_vector_canvas_create(canvas); + root = evas_object_vg_root_node_get(vg); + shape = evas_vg_shape_add(root); + evas_vg_node_color_set(shape, 80, 80, 80, 80); - DrawDummyFrame(); -}; + elm_object_part_content_set(layout, "EFFECT_BG", vg); + evas_vg_shape_stroke_cap_set(shape, EFL_GFX_CAP_BUTT); + evas_vg_shape_stroke_join_set(shape, EFL_GFX_JOIN_MITER); + evas_vg_shape_stroke_width_set(shape, 3.0); + evas_vg_shape_stroke_color_set(shape, 255, 255, 255, 255); + + DrawDummyFrame(); +}; /** * Destructor @@ -96,32 +109,32 @@ MicEffector::MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector& */ MicEffector::~MicEffector() { - if(timer) - { - ecore_timer_del(timer); - timer = NULL; - } - -// ea_vector_path_destroy(path); -// ea_vector_paint_destroy(paint); -// ea_vector_canvas_destroy(canvas); + if (timer) { + ecore_timer_del(timer); + timer = NULL; + } + if (vg) + evas_object_del(vg); + + if (root) + evas_object_del(root); + + if (shape) + evas_object_del(shape); } - - /** * Draw empty frame to remove or initiate screen * */ void MicEffector::DrawDummyFrame() { -// ea_vector_path_reset(path); -// ea_vector_path_move_to(path, 0, 0); -// ea_vector_path_line_to(path, 0, 0); -// ea_vector_canvas_draw(canvas, path, paint); -} - + evas_vg_shape_reset(shape); + evas_vg_shape_append_move_to(shape, 0, 0); + evas_vg_shape_append_line_to(shape, 0, 0); + evas_object_show(vg); +} /** * Draw Que animation @@ -134,83 +147,80 @@ void MicEffector::DrawDummyFrame() */ void MicEffector::DrawQue(int idx, bool is_start) { -// float margin = spectrum_posx; -// float posx = 0.0; - - double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23); + float margin = spectrum_posx; + float posx = 0.0; - unsigned int start = start_stop_anim_count - (int) speed; - unsigned int end = start_stop_anim_count + (int) speed; + double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23); -// double opacity; + unsigned int start = start_stop_anim_count - (int) speed; + unsigned int end = start_stop_anim_count + (int) speed; - if (is_start) { -// opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0); - } else { -// opacity = cubic_easy_out(idx, 0, 1.0, 26.0); - } + double opacity = 0.0;; -// ea_vector_path_reset(path); + if (is_start) { + opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0); + } else { + opacity = cubic_easy_out(idx, 0, 1.0, 26.0); + } - for(unsigned int i = start; i < end; i++) - { -// posx = margin + (i * 5); + evas_vg_shape_reset(shape); -// ea_vector_path_move_to(path, posx, 37.0f); -// ea_vector_path_line_to(path, posx, 38.0f); + for (unsigned int i = start; i < end; i++) + { + posx = margin + (i * 5); -// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity); - } + evas_vg_shape_append_move_to(shape, posx, 37); + evas_vg_shape_append_line_to(shape, posx, 38); + evas_vg_shape_stroke_color_set(shape, 255, 255, 255, opacity); + } -// ea_vector_canvas_draw(canvas, path, paint); + evas_object_show(vg); } - - float MicEffector::GetAmplifyValue(unsigned int idx) { - float amplify = 0.0; + float amplify = 0.0; - int max[SAMPLE_COUNT] = { - /** - * dot "A" (9) - * - */ - 1, 1, 1, 1, + int max[SAMPLE_COUNT] = { + /** + * dot "A" (9) + * + */ + 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, - /** - * dot "B" (9) - * - */ - 10, 8, 2, 3, 10, 11, 6, 12, 4, + /** + * dot "B" (9) + * + */ + 10, 8, 2, 3, 10, 11, 6, 12, 4, - /** - * dot "C" (15) - * - */ - 3, 5, 9, 12, 11, 8, 14, 15, 13, 11, 12, 6, 8, 3, 2, + /** + * dot "C" (15) + * + */ + 3, 5, 9, 12, 11, 8, 14, 15, 13, 11, 12, 6, 8, 3, 2, - /** - * reverse dot "B" (9) - * - */ - 4, 12, 6, 11, 10, 3, 2, 8, 10, + /** + * reverse dot "B" (9) + * + */ + 4, 12, 6, 11, 10, 3, 2, 8, 10, - /** - * dot "A" (9) - * - */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, + /** + * dot "A" (9) + * + */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1 - }; + 1, 1, 1, 1 + }; - amplify = (float) max[idx] / 10.0f * 1.9f; + amplify = (float) max[idx] / 10.0f * 1.9f; - return amplify; + return amplify; } /** @@ -222,84 +232,77 @@ float MicEffector::GetAmplifyValue(unsigned int idx) */ void MicEffector::DrawWave(unsigned int idx, int amount, int prev_amount, double opacity, bool is_lastcmd) { -// float ratio = GetAmplifyValue(idx); + float ratio = GetAmplifyValue(idx); -// float am = ((float) amount) * ratio; -// float pam = ((float) prev_amount) * ratio; -// float cnt = (float) drawcount; + float am = ((float) amount) * ratio; + float pam = ((float) prev_amount) * ratio; + float cnt = (float) drawcount; - float posx = spectrum_posx; + float posx = spectrum_posx; -// float height = pam > am? -// pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7): -// cubic_easy_in_out(cnt + 1.0, pam, am, 7); + float height = pam > am? + pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7): + cubic_easy_in_out(cnt + 1.0, pam, am, 7); - posx += idx * 5; + posx += idx * 8; -// ea_vector_path_move_to(path, posx, (37.0f - (height / 2.0))); -// ea_vector_path_line_to(path, posx, (38.0f + (height / 2.0))); - - if (is_lastcmd) { -// ea_vector_paint_set_color(paint, 0.1451f, 0.204f, 0.255f, opacity);//RGB = 37:52:65 - } else { -// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);//RGB: 255 255 255 - } + evas_vg_shape_append_move_to(shape, posx, (37.0f - (height / 2.0))); + evas_vg_shape_append_line_to(shape, posx, (38.0f + (height / 2.0))); + evas_vg_shape_stroke_color_set(shape, 255, 255, 255, opacity); } - - /** * Effect Start * */ void MicEffector::Start() { - if(timer) { - ecore_timer_del(timer); - timer = NULL; - } - - drawcount = 0; - - prev.clear(); - current.clear(); - - for(size_t i = 0; i < spectrum_count; i++) - { - prev.push_back(0); - current.push_back(0); - } - - Listening(); - - /** - * Que animation - * - */ - timer = ecore_timer_add(timeout_s, - [](void *data)->Eina_Bool - { - MicEffector *effector = static_cast(data); - - effector->DrawQue(effector->drawcount); - - if(effector->drawcount < (int) start_stop_anim_count) { - effector->drawcount += 2; - return ECORE_CALLBACK_RENEW; - } else { - for(unsigned int i = 0; i < spectrum_count; i++) - effector->DrawWave(i, 0, 0); - -// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint); - - effector->drawcount = 0; - effector->timer = NULL; - effector->VolumeCheck(); - effector->Effect(); - return ECORE_CALLBACK_CANCEL; - } - }, - this); + if (timer) { + ecore_timer_del(timer); + timer = NULL; + } + + drawcount = 0; + + prev.clear(); + current.clear(); + + for (size_t i = 0; i < spectrum_count; i++) + { + prev.push_back(0); + current.push_back(0); + } + + Listening(); + + /** + * Que animation + * + */ + timer = ecore_timer_add(timeout_s, + [](void *data)->Eina_Bool + { + MicEffector *effector = static_cast(data); + + effector->DrawQue(effector->drawcount); + + if (effector->drawcount < (int) start_stop_anim_count) { + effector->drawcount += 2; + return ECORE_CALLBACK_RENEW; + } else { + for (unsigned int i = 0; i < spectrum_count; i++) + effector->DrawWave(i, 0, 0); + + evas_object_show(effector->vg); + + effector->drawcount = 0; + effector->timer = NULL; + effector->VolumeCheck(true); + effector->Effect(); + return ECORE_CALLBACK_CANCEL; + } + }, + this); } /** @@ -308,90 +311,83 @@ void MicEffector::Start() */ void MicEffector::Effect(bool fake) { - /** - * Volume effect animation - * - */ - if ( timer ) { - ecore_timer_del(timer); - timer = NULL; - } - - timer = ecore_timer_add(timeout_s, - [](void *data)->Eina_Bool - { - MicEffector *effector = static_cast(data); - - bool is_empty_prev = effector->prev.empty(); - - -// ea_vector_path_reset(effector->path); - - for(unsigned int i = 0; i < effector->current.size(); i++) - { - if (is_empty_prev) - effector->DrawWave(i, effector->current.at(i), 0); - else - effector->DrawWave(i, effector->current.at(i), effector->prev.at(i)); - } -// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint); - - if (effector->drawcount < 7) { - effector->drawcount++; - } else { - effector->drawcount = 0; - effector->VolumeCheck(effector->fake); - } - - return ECORE_CALLBACK_RENEW; - }, this); + /** + * Volume effect animation + * + */ + if ( timer ) { + ecore_timer_del(timer); + timer = NULL; + } + + timer = ecore_timer_add(timeout_s, + [](void *data)->Eina_Bool + { + MicEffector *effector = static_cast(data); + + bool is_empty_prev = effector->prev.empty(); + + evas_vg_shape_reset(effector->shape); + + for (unsigned int i = 0; i < effector->current.size(); i++) + { + if (is_empty_prev) { + effector->DrawWave(i, effector->current.at(i), 0); + } else { + effector->DrawWave(i, effector->current.at(i), effector->prev.at(i)); + } + } + evas_object_show(effector->vg); + + if (effector->drawcount < 7) { + effector->drawcount++; + effector->VolumeCheck(true); + } else { + effector->drawcount = 0; + effector->VolumeCheck(true); + } + + return ECORE_CALLBACK_RENEW; + }, this); } - - /** * Stop volume animation effect * */ void MicEffector::Stop(bool forced) { - if(timer) - { - ecore_timer_del(timer); - timer = NULL; - } - - if(!started) - { - Idle(); - return; - } - - forcestop = forced; - - timer = ecore_timer_add(timeout_s, - [](void *data)->Eina_Bool - { - MicEffector *effector = static_cast(data); - - effector->DrawQue(start_stop_anim_count - effector->drawcount, false); - - if(effector->drawcount < (int) start_stop_anim_count) { - effector->drawcount += 2; - return ECORE_CALLBACK_RENEW; - } else { - if(!effector->forcestop) { - effector->Processing(); - } else { - effector->Idle(); - } - - effector->forcestop = false; - effector->drawcount = 0; - effector->timer = NULL; - return ECORE_CALLBACK_CANCEL; - } - }, this); + if (timer) + { + ecore_timer_del(timer); + timer = NULL; + } + + if (!started) + { + Idle(); + return; + } + + forcestop = forced; + + timer = ecore_timer_add(timeout_s, + [](void *data)->Eina_Bool + { + MicEffector *effector = static_cast(data); + + effector->DrawQue(start_stop_anim_count - effector->drawcount, false); + + if (effector->drawcount < (int) start_stop_anim_count) { + effector->drawcount += 2; + return ECORE_CALLBACK_RENEW; + } else { + effector->forcestop = false; + effector->drawcount = 0; + effector->timer = NULL; + return ECORE_CALLBACK_CANCEL; + } + }, this); } /** @@ -400,80 +396,73 @@ void MicEffector::Stop(bool forced) */ void MicEffector::VolumeCheck(bool fake) { - std::vector volumes; + std::vector volumes; - this->fake = fake; + this->fake = fake; - if(!fake) { - volumes = ieffect.GetVolume(); - } else { - for(unsigned int i = 0; i < spectrum_count; i++) { - unsigned int seed = time(NULL); - volumes.push_back(rand_r(&seed) % 2); - } - } + if (!fake) { + volumes = ieffect.GetVolume(); + } else { + for (unsigned int i = 0; i < spectrum_count; i++) { + unsigned int seed = time(NULL); + volumes.push_back(rand_r(&seed) % 6); + } + } - prev.clear(); - prev.assign(current.begin(), current.end()); + prev.clear(); + prev.assign(current.begin(), current.end()); - current.clear(); - current.assign(volumes.begin(), volumes.end()); + current.clear(); + current.assign(volumes.begin(), volumes.end()); } - - /** * Signal. Listening effect * */ void MicEffector::Listening() { - started = true; + started = true; - elm_object_signal_emit(layout, "elm,state,eq,show", "eq"); - elm_object_signal_emit(layout, "elm,state,listening", "elm"); + elm_object_signal_emit(layout, "elm,state,listening", "elm"); + elm_object_signal_emit(layout, "elm,state,eq,show", "eq"); } - - /** * Signal. Processing effect * */ void MicEffector::Processing() { - started = false; + started = false; - elm_object_signal_emit(layout, "elm,state,eq,hide", "eq"); - elm_object_signal_emit(layout, "elm,state,processing", "elm"); + elm_object_signal_emit(layout, "elm,state,eq,hide", "eq"); + elm_object_signal_emit(layout, "elm,state,processing", "elm"); - ieffect.ProcessingAnimationStart(); + ieffect.ProcessingAnimationStart(); } - - /** * Signal. Idle effect * */ void MicEffector::Idle() { - const char *text; - const char *state; - double val; + const char *text; + const char *state; + double val; - started = false; + started = false; - elm_object_signal_emit(layout, "elm,state,eq,hide", "eq"); + elm_object_signal_emit(layout, "elm,state,eq,hide", "eq"); - text = elm_object_part_text_get(layout, "elm.text"); - state = edje_object_part_state_get(elm_layout_edje_get(layout), "guide_text_block", &val); + text = elm_object_part_text_get(layout, "elm.text"); + state = edje_object_part_state_get(elm_layout_edje_get(layout), "guide_text_block", &val); - if ((text && strlen(text) > 0) && (state && !strcmp(state, "bottom"))) - elm_object_signal_emit(layout, "elm,state,init_message", "elm"); - else - elm_object_signal_emit(layout, "elm,state,init", "elm"); + if ((text && strlen(text) > 0) && (state && !strcmp(state, "bottom"))) + elm_object_signal_emit(layout, "elm,state,init_message", "elm"); + else + elm_object_signal_emit(layout, "elm,state,init", "elm"); - ieffect.ProcessingAnimationStop(); + ieffect.ProcessingAnimationStop(); } - diff --git a/src/WInputSttMicEffect.cpp b/src/WInputSttMicEffect.cpp old mode 100755 new mode 100644 index 5454f27..b999be7 --- a/src/WInputSttMicEffect.cpp +++ b/src/WInputSttMicEffect.cpp @@ -17,14 +17,17 @@ #include #include #include - +#include #include #include "WInputSttMicEffect.h" +#include +#undef LOG_TAG +#define LOG_TAG "INPUT_DELEGATOR" namespace { template -static unsigned long long SumSquare(unsigned long long const& a, T const& b) { - return a + b*b; +static float SumSquare(float const& a, T const& b) { + return a + b*b; } const double MAX_AMPLITUDE_MEAN_16 = 23170.115738161934; @@ -38,118 +41,113 @@ using namespace is::ui; WInputSttMicEffect::WInputSttMicEffect() - : square_sum(0) - , count(5) - , handle(NULL) - , processing_effect_timer(NULL) - , progressbar(NULL) { + : square_sum(0) + , count(5) + , handle(NULL) + , processing_effect_timer(NULL) + , progressbar(NULL) { } WInputSttMicEffect::~WInputSttMicEffect() { - ProcessingAnimationStop(); + ProcessingAnimationStop(); } std::vector WInputSttMicEffect::GetVolume() { - std::vector result; - - short pcm[512] = {0}; - int size = 0; - int ret = 0; - -// ret = stt_get_spectrum(handle, (void *) pcm, &size); - count = 5; - - if (STT_ERROR_NONE != ret) { - PRINTFUNC(DLOG_ERROR, "stt_audio_snapshot invalid (%d)", ret); - } else { - unsigned int level = 0; - unsigned int step = (unsigned int) (size/2/sample_count); - - for (unsigned int k = 0; k < sample_count; k++ ){ - square_sum = std::accumulate(pcm + k*step, pcm + k*step + 5, 0ull, SumSquare); - level = ConvertLevel(); - result.push_back(level); - } - } - return result; + std::vector result; + + float pcm[512] = {0}; + int size = 50; + int ret = 0; + + ret = stt_get_recording_volume(handle, pcm); + count = 5; + + if (STT_ERROR_NONE != ret) { + } else { + unsigned int level = 0; + unsigned int step = (unsigned int) (size/2/sample_count); + + for (unsigned int k = 0; k < sample_count; k++ ){ + square_sum = (unsigned long long)std::accumulate(pcm + k*step, pcm + k*step + 5, 0ull, SumSquare); + level = ConvertLevel(); + result.push_back(level); + } + } + return result; } float WInputSttMicEffect::GetDecibel() const { - float rms = std::sqrt(square_sum/count); - return 20.0*log10(rms); + float rms = std::sqrt(square_sum/count); + return 20.0*log10(rms); } int WInputSttMicEffect::ConvertLevel() { - float db = GetDecibel(); - - if ( db <= 30.0 ){ - return 0; - } else if ( db <= 33.3 ){ - return 1; - } else if ( db <= 36.6 ){ - return 2; - } else if ( db <= 40 ){ - return 3; - } else if ( db <= 43.3 ){ - return 4; - } else if ( db <= 46.6 ){ - return 5; - } else if ( db <= 50 ){ - return 6; - } else if ( db <= 53.3 ){ - return 7; - } else if ( db <= 56.6 ){ - return 8; - } else if ( db <= 60 ){ - return 9; - } else { - return 10; - } + float db = GetDecibel(); + + if ( db <= 30.0 ){ + return 0; + } else if ( db <= 33.3 ){ + return 1; + } else if ( db <= 36.6 ){ + return 2; + } else if ( db <= 40 ){ + return 3; + } else if ( db <= 43.3 ){ + return 4; + } else if ( db <= 46.6 ){ + return 5; + } else if ( db <= 50 ){ + return 6; + } else if ( db <= 53.3 ){ + return 7; + } else if ( db <= 56.6 ){ + return 8; + } else if ( db <= 60 ){ + return 9; + } else { + return 10; + } } void WInputSttMicEffect::ProcessingAnimationStart() { - elm_progressbar_pulse(progressbar, EINA_TRUE); + elm_progressbar_pulse(progressbar, EINA_TRUE); - processing_effect_timer = ecore_timer_add(0.1, - [](void *data)->Eina_Bool - { - if(!data) return ECORE_CALLBACK_CANCEL; + processing_effect_timer = ecore_timer_add(0.1, + [](void *data)->Eina_Bool + { + if (!data) return ECORE_CALLBACK_CANCEL; /* - WInputSttMicEffect *effect = (WInputSttMicEffect *) data; - Evas_Object *progressbar = effect->progressbar; + WInputSttMicEffect *effect = (WInputSttMicEffect *) data; + Evas_Object *progressbar = effect->progressbar; - double progress = eext_circle_value_get(progressbar); + double progress = eext_circle_value_get(progressbar); - if (progress < 100) - progress += 5.0; - else - progress = 0.0; + if (progress < 100) + progress += 5.0; + else + progress = 0.0; - eext_circle_value_set(progressbar, progress); + eext_circle_value_set(progressbar, progress); */ - return ECORE_CALLBACK_RENEW; - }, this); + return ECORE_CALLBACK_RENEW; + }, this); } void WInputSttMicEffect::ProcessingAnimationStop() { - if(processing_effect_timer) - { - ecore_timer_del(processing_effect_timer); - processing_effect_timer = NULL; - } - elm_progressbar_pulse(progressbar, EINA_FALSE); + if (processing_effect_timer) + { + ecore_timer_del(processing_effect_timer); + processing_effect_timer = NULL; + } + elm_progressbar_pulse(progressbar, EINA_FALSE); } - - void WInputSttMicEffect::SetSttHandle(stt_h handle) { - this->handle = handle; + this->handle = handle; } - - void WInputSttMicEffect::SetProgressBar(Evas_Object *progress) { - this->progressbar = progress; + this->progressbar = progress; } diff --git a/src/w-input-stt-voice.cpp b/src/w-input-stt-voice.cpp index c135e4c..56514f7 100755 --- a/src/w-input-stt-voice.cpp +++ b/src/w-input-stt-voice.cpp @@ -64,7 +64,7 @@ static Elm_Genlist_Item_Class itc_title; static Elm_Genlist_Item_Class itc_1text; static Elm_Genlist_Item_Class itc_2text; - +static Eina_Bool change_guide_text(void *data); static void set_guide_text(VoiceData *vd, const char* text, bool translatable = false); const char *supported_language[] = { @@ -313,7 +313,6 @@ static Eina_Bool _update_textblock_timer_cb(void *data) if(voicedata->state == STT_STATE_VAL_LISTENING){ if(voicedata->guide_text_timer != NULL){ - PRINTFUNC(DLOG_DEBUG, "Skip hide_guide_text"); ecore_timer_del(voicedata->guide_text_timer); voicedata->guide_text_timer = NULL; } @@ -393,21 +392,48 @@ static Eina_Bool _recognition_failure_cb(void *data) void start_by_press(VoiceData *voicedata) { - PRINTFUNC(DLOG_DEBUG, ""); - + LOGD("start_by_press "); edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); - - return; } static void on_mic_button_press_cb(void *data, Evas_Object *obj, void *event_info) { - PRINTFUNC(NO_PRINT, ""); - + LOGD("on_mic_button_press_cb"); VoiceData *voicedata = (VoiceData *)data; - edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); + if (!voicedata) return; - return; + if (voicedata->sttmanager != NULL && + (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING + || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING)) { + try { + voicedata->state = STT_STATE_VAL_INIT; + voicedata->sttmanager->Stop(); + } + catch (is::stt::SttException &e) { + } + + if (voicedata->effector) + voicedata->effector->Stop(true); + + if (NULL != voicedata->start_timer) { + ecore_timer_del(voicedata->start_timer); + voicedata->start_timer = NULL; + } + if (NULL != voicedata->guide_text_timer) { + ecore_timer_del(voicedata->guide_text_timer); + voicedata->guide_text_timer = NULL; + } + if (NULL != voicedata->refresh_timer) { + ecore_timer_del(voicedata->refresh_timer); + voicedata->refresh_timer = NULL; + } + } else { + if (NULL != voicedata->guide_text_timer) { + ecore_timer_del(voicedata->guide_text_timer); + voicedata->guide_text_timer = NULL; + } + edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); + } } @@ -525,32 +551,33 @@ static Eina_Bool _idler_cb(void *data) if(true == _app_stt_initialize(voicedata)) { - PRINTFUNC(NO_PRINT, "_app_stt_initialize None Error"); + LOGD("_app_stt_initialize None Error"); voicedata->voicefw_state = 1; voicedata->state = STT_STATE_VAL_INIT; } else { voicedata->voicefw_state = 0; - PRINTFUNC(DLOG_ERROR, "Initialization Fail!
Check STT-daemon is running"); + LOGD("Initialization Fail!
Check STT-daemon is running"); } Evas_Object *canvas = elm_object_part_content_get(voicedata->layout_main, "EFFECT_BG"); - is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect(); - ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + if (ieffect) + ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); is::ui::MicEffector *effector = new is::ui::MicEffector(canvas, voicedata->layout_main, *ieffect); voicedata->ieffect = ieffect; voicedata->effector = effector; - ieffect->SetProgressBar(voicedata->progressbar); - ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + if (ieffect) { + ieffect->SetProgressBar(voicedata->progressbar); + ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + } voicedata->mo->Update(); elm_access_highlight_set(voicedata->mic_button); - return ECORE_CALLBACK_CANCEL; } @@ -606,23 +633,21 @@ void powerLock(void *data, bool enable) } } +static Eina_Bool change_guide_text(void *data){ + VoiceData *voicedata = (VoiceData *) data; + if (!voicedata) return ECORE_CALLBACK_CANCEL; -static Eina_Bool hide_guide_text(void *data){ - if(data) { - VoiceData *voicedata = (VoiceData *) data; - - voicedata->guide_text_timer = NULL; - + stt_state_e state = voicedata->sttmanager->GetCurrent(); + if (state == STT_STATE_RECORDING || state == STT_STATE_PROCESSING) + elm_object_domain_translatable_part_text_set(voicedata->layout_main, "elm.text", PACKAGE, SK_TAP_TO_PAUSE); - PRINTFUNC(DLOG_ERROR, ""); - elm_object_part_text_set(voicedata->layout_main, "elm.text", ""); - } return ECORE_CALLBACK_CANCEL; } + static void set_guide_text(VoiceData *vd, const char* text, bool translatable) { - //elm_object_signal_emit(vd->layout_main, "idle,state,text,visible", "elm"); + elm_object_signal_emit(vd->layout_main, "idle,state,guide_text,bottom", "elm"); if(translatable) elm_object_domain_translatable_part_text_set(vd->layout_main, "elm.text", PACKAGE, text); @@ -631,7 +656,7 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable) if(!strcmp(text, SK_SPEAK_NOW)){ if(vd->guide_text_timer == NULL) - vd->guide_text_timer = ecore_timer_add(2.0, hide_guide_text, vd); + vd->guide_text_timer = ecore_timer_add(2.0, change_guide_text, vd); } } @@ -642,22 +667,6 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable) */ void set_animation_state(VoiceData *voicedata) { - PRINTFUNC(DLOG_DEBUG, ""); - - PRINTFUNC(DLOG_ERROR, "voicedata->state == %s", - voicedata->state == STT_STATE_VAL_INIT ? - "STT_STATE_VAL_INIT" : - voicedata->state == STT_STATE_VAL_LISTENING ? - "STT_STATE_VAL_LISTENING" : - voicedata->state == STT_STATE_VAL_PREPARE_LISTENING ? - "STT_STATE_VAL_PREPARE_LISTENING" : - voicedata->state == STT_STATE_VAL_PROCESSING ? - "STT_STATE_VAL_PROCESSING" : - voicedata->state == STT_STATE_VAL_PREPARE_PROCESSING ? - "STT_STATE_VAL_PREPARE_PROCESSING" : - voicedata->state == STT_STATE_VAL_TERMINATING ? - "STT_STATE_VAL_TERMINATING" : "STT_STATE_VAL_NOT_RECOGNISED"); - if (voicedata->state == STT_STATE_VAL_INIT) { #if 0 if (voicedata->sttmanager->GetCurrent() == STT_STATE_READY) { @@ -673,9 +682,8 @@ void set_animation_state(VoiceData *voicedata) if(voicedata->effector) voicedata->effector->Stop(true); - set_guide_text(voicedata, ""); + set_guide_text(voicedata, "Tap mic to speak"); - PRINTFUNC(DLOG_DEBUG, "%d", voicedata->stt_results.size()); powerLock((void*)voicedata, false); } else if (voicedata->state == STT_STATE_VAL_LISTENING) { set_guide_text(voicedata, SK_SPEAK_NOW, true); @@ -691,7 +699,6 @@ void set_animation_state(VoiceData *voicedata) stt_feedback(VIBRATION_STOP); } else { - PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR"); set_guide_text(voicedata, _(SK_RECOGNITION_FAILED)); //_elm_access_say(voicedata->layout_main, _(SK_RECOGNITION_FAILED)); @@ -705,8 +712,6 @@ void set_animation_state(VoiceData *voicedata) voicedata->effector->Stop(true); voicedata->refresh_timer = ecore_timer_add(2.0, _recognition_failure_cb, voicedata); - - //powerLock((void*)voicedata, false); } } @@ -759,20 +764,15 @@ static Eina_Bool _start_timer_cb(void* data) voicedata->sttmanager->Start(); } catch (is::stt::SttException &e) { - PRINTFUNC(DLOG_ERROR, "%s", e.what()); - if (e.GetEcode() == STT_ERROR_OUT_OF_NETWORK) { - PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR"); set_guide_text(voicedata, _(SK_NETWORK_ERROR)); voicedata->state = STT_STATE_VAL_INIT; } else if (e.GetEcode() == STT_ERROR_RECORDER_BUSY) { - PRINTFUNC(DLOG_WARN, "STT is used by another application"); - show_popup_toast(_(SK_STT_BUSY), false); + set_guide_text(voicedata, _(SK_STT_BUSY)); voicedata->state = STT_STATE_VAL_INIT; } else { - PRINTFUNC(DLOG_WARN, "Check error code"); - show_popup_toast(_(SK_STT_BUSY), false); + set_guide_text(voicedata, _(SK_STT_BUSY)); voicedata->state = STT_STATE_VAL_INIT; } } @@ -791,6 +791,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission PRINTFUNC(NO_PRINT, ""); VoiceData *vd = (VoiceData *)data; + if (vd == NULL) + return; int tempVal = vd->sttmanager->GetCurrent(); if(tempVal == STT_STATE_CREATED) { @@ -856,6 +858,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission catch (is::stt::SttException &e) { PRINTFUNC(DLOG_ERROR, "%s", e.what()); } + if (vd->effector) + vd->effector->Stop(true); break; -- 2.7.4