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)
40 , option_opened(EINA_FALSE)
41 , voicedata(voicedata) {
42 /** todo. implement constructor */
45 MoreOption::~MoreOption() {
46 /** todo. implement destructor */
48 // if(more_option_layout)
49 // evas_object_del(more_option_layout);
52 void MoreOption::Create() {
57 catch(std::exception &e) {
58 PRINTFUNC(DLOG_ERROR, "%s", e.what());
63 void MoreOption::AddLayout() {
66 PRINTFUNC(DLOG_ERROR, "Invalid naviframe.");
69 more_option_layout = eext_more_option_add(nf);
71 if(!more_option_layout)
72 PRINTFUNC(DLOG_ERROR, "It's failed to create layout");
74 evas_object_smart_callback_add(more_option_layout, "more,option,opened",
75 [](void *data, Evas_Object *obj, void *event_info){
76 PRINTFUNC(DLOG_DEBUG, "more option is opened!!! \n");
81 * if more option is completed, stt have to be stopped.
84 MoreOption *opt = (MoreOption *)data;
85 VoiceData *vd = (VoiceData *) opt->voicedata;
87 if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
88 vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
89 vd->sttmanager->Cancel();
92 catch(is::stt::SttException &e) {
93 PRINTFUNC(DLOG_ERROR, "%s", e.what());
96 opt->option_opened = EINA_TRUE;
99 evas_object_smart_callback_add(more_option_layout, "more,option,closed",
100 [](void *data, Evas_Object *obj, void *event_info){
101 PRINTFUNC(DLOG_DEBUG, "more option is closed!!! \n");
103 MoreOption *opt = (MoreOption *)data;
104 VoiceData *vd = (VoiceData *) opt->voicedata;
106 activate_circle_scroller_for_stt_textbox(vd, EINA_TRUE);
108 opt->option_opened = EINA_FALSE;
111 evas_object_show(more_option_layout);
114 void MoreOption::SetContentLayout(Evas_Object *content) {
119 elm_object_part_content_set(more_option_layout, "elm.swallow.content", content);
121 Elm_Object_Item *nit = NULL;
122 nit = elm_naviframe_item_push(nf, NULL, NULL, NULL, more_option_layout, "empty");
123 elm_naviframe_item_title_enabled_set(nit, EINA_FALSE, EINA_FALSE);
125 elm_naviframe_item_pop_cb_set(nit,
126 [](void *data, Elm_Object_Item *it)->Eina_Bool
128 MoreOption *opt = (MoreOption *)data;
129 VoiceData *vd = (VoiceData *) opt->voicedata;
131 if(vd->disclaimer == 1){
132 PRINTFUNC(DLOG_ERROR, "pop to top"); //inb case of (selector view -> disclaimer view-> stt view)
134 if(opt->option_opened == EINA_FALSE){
135 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
138 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
139 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
140 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
142 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
143 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
144 vd->effector->Stop();
146 vd->sttmanager->Stop();
147 }catch(is::stt::SttException &e){
148 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
151 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
152 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
154 vd->sttmanager->Cancel();
155 }catch(is::stt::SttException &e){
156 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
163 elm_naviframe_item_pop_to(elm_naviframe_bottom_item_get(vd->naviframe));
167 _back_to_genlist_for_selector();
172 if(opt->option_opened == EINA_FALSE){
173 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
176 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
177 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
178 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
180 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
181 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
182 vd->effector->Stop();
184 vd->sttmanager->Stop();
185 }catch(is::stt::SttException &e){
186 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
189 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
190 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
192 vd->sttmanager->Cancel();
193 }catch(is::stt::SttException &e){
194 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
198 _back_to_genlist_for_selector();
204 PRINTFUNC(DLOG_DEBUG, "naviframe transition, not finished\n");
212 void MoreOption::Update()
214 char lang[6] = {0, };
215 strncpy(lang, ((VoiceData *)voicedata)->kbd_lang , 5);
217 const char* display_lang = get_lang_label(lang);
218 eext_more_option_item_part_text_set(item, "selector,sub_text", display_lang);
221 Evas_Object* MoreOption::AddLanguageIcon(Evas_Object *parent) {
222 Evas_Object *icon = elm_image_add(parent);
224 PRINTFUNC(DLOG_ERROR, "It's failed to add image.");
227 string res_path = get_resource_path();
229 res_path = res_path + "wearable/";
231 res_path = res_path + "tv/";
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");