2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <app_common.h>
27 #include "MoreOption.h"
28 #include "w-input-selector.h"
29 #include "w-input-stt-ise.h"
30 #include "w-input-stt-voice.h"
34 extern Evas_Object *g_setting_window;
36 MoreOption::MoreOption(Evas_Object *naviframe, void* voicedata)
38 , more_option_layout(NULL)
42 , option_opened(EINA_FALSE)
43 , voicedata(voicedata) {
44 /** todo. implement constructor */
47 MoreOption::~MoreOption() {
48 /** todo. implement destructor */
50 // if(more_option_layout)
51 // evas_object_del(more_option_layout);
54 void MoreOption::Create() {
59 catch(std::exception &e) {
60 PRINTFUNC(DLOG_ERROR, "%s", e.what());
65 void MoreOption::AddLayout() {
68 PRINTFUNC(DLOG_ERROR, "Invalid naviframe.");
71 more_option_layout = eext_more_option_add(nf);
73 if(!more_option_layout)
74 PRINTFUNC(DLOG_ERROR, "It's failed to create layout");
76 evas_object_smart_callback_add(more_option_layout, "more,option,opened",
77 [](void *data, Evas_Object *obj, void *event_info){
78 PRINTFUNC(DLOG_DEBUG, "more option is opened!!! \n");
83 * if more option is completed, stt have to be stopped.
86 MoreOption *opt = (MoreOption *)data;
87 VoiceData *vd = (VoiceData *) opt->voicedata;
89 if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
90 vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
91 vd->sttmanager->Cancel();
94 catch(is::stt::SttException &e) {
95 PRINTFUNC(DLOG_ERROR, "%s", e.what());
98 opt->option_opened = EINA_TRUE;
101 evas_object_smart_callback_add(more_option_layout, "more,option,closed",
102 [](void *data, Evas_Object *obj, void *event_info){
103 PRINTFUNC(DLOG_DEBUG, "more option is closed!!! \n");
105 MoreOption *opt = (MoreOption *)data;
106 VoiceData *vd = (VoiceData *) opt->voicedata;
108 activate_circle_scroller_for_stt_textbox(vd, EINA_TRUE);
110 opt->option_opened = EINA_FALSE;
113 evas_object_show(more_option_layout);
116 void MoreOption::SetContentLayout(Evas_Object *content) {
121 elm_object_part_content_set(more_option_layout, "elm.swallow.content", content);
123 Elm_Object_Item *nit = NULL;
124 nit = elm_naviframe_item_push(nf, NULL, NULL, NULL, more_option_layout, "empty");
125 elm_naviframe_item_title_enabled_set(nit, EINA_FALSE, EINA_FALSE);
127 elm_naviframe_item_pop_cb_set(nit,
128 [](void *data, Elm_Object_Item *it)->Eina_Bool
130 MoreOption *opt = (MoreOption *)data;
131 VoiceData *vd = (VoiceData *) opt->voicedata;
133 if(vd->disclaimer == 1){
134 PRINTFUNC(DLOG_ERROR, "pop to top"); //inb case of (selector view -> disclaimer view-> stt view)
136 if(opt->option_opened == EINA_FALSE){
137 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
140 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
141 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
142 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
144 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
145 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
146 vd->effector->Stop();
148 vd->sttmanager->Stop();
149 }catch(is::stt::SttException &e){
150 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
153 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
154 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
156 vd->sttmanager->Cancel();
157 }catch(is::stt::SttException &e){
158 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
165 elm_naviframe_item_pop_to(elm_naviframe_bottom_item_get(vd->naviframe));
169 _back_to_genlist_for_selector();
174 if(opt->option_opened == EINA_FALSE){
175 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
178 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
179 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
180 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
182 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
183 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
184 vd->effector->Stop();
186 vd->sttmanager->Stop();
187 }catch(is::stt::SttException &e){
188 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
191 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
192 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
194 vd->sttmanager->Cancel();
195 }catch(is::stt::SttException &e){
196 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
200 _back_to_genlist_for_selector();
206 PRINTFUNC(DLOG_DEBUG, "naviframe transition, not finished\n");
214 void MoreOption::Update()
216 char lang[6] = {0, };
217 strncpy(lang, ((VoiceData *)voicedata)->kbd_lang , 5);
219 const char* display_lang = get_lang_label(lang);
220 eext_more_option_item_part_text_set(item, "selector,sub_text", display_lang);
223 Evas_Object* MoreOption::AddLanguageIcon(Evas_Object *parent) {
224 Evas_Object *icon = elm_image_add(parent);
226 PRINTFUNC(DLOG_ERROR, "It's failed to add image.");
229 string res_path = get_resource_path();
231 res_path = res_path + "wearable/";
233 res_path = res_path + "mobile/";
235 std::string image_path = res_path + "images/prompt_ic_languages.png";
237 elm_image_file_set(icon, image_path.c_str(), NULL);
238 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
239 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
240 evas_object_show(icon);
245 void MoreOption::AddMorePage() {
248 item = eext_more_option_item_append(more_option_layout);
251 eext_more_option_item_part_text_set(item, "selector,main_text", _("WDS_IME_HEADER_INPUT_LANGUAGES_ABB"));
253 img = AddLanguageIcon(more_option_layout);
255 eext_more_option_item_part_content_set(item, "item,icon", img);
257 evas_object_smart_callback_add(more_option_layout, "item,clicked",
258 [](void *data, Evas_Object *obj, void *event_info)
260 PRINTFUNC(DLOG_DEBUG, "item,clicked");
261 if(g_setting_window == NULL)
262 create_setting_window(obj);
265 evas_object_smart_callback_add(more_option_layout, "item,selected",
266 [](void *data, Evas_Object *obj, void *event_info)
268 PRINTFUNC(DLOG_DEBUG, "item,selected");