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 const char *item_style = NULL;
124 item_style = "empty";
125 nit = elm_naviframe_item_push(nf, NULL, NULL, NULL, more_option_layout, item_style);
126 elm_naviframe_item_title_enabled_set(nit, EINA_FALSE, EINA_FALSE);
128 elm_naviframe_item_pop_cb_set(nit,
129 [](void *data, Elm_Object_Item *it)->Eina_Bool
131 MoreOption *opt = (MoreOption *)data;
132 VoiceData *vd = (VoiceData *) opt->voicedata;
134 if(vd->disclaimer == 1){
135 PRINTFUNC(DLOG_ERROR, "pop to top"); //inb case of (selector view -> disclaimer view-> stt view)
137 if(opt->option_opened == EINA_FALSE){
138 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
141 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
142 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
143 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
145 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
146 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
147 vd->effector->Stop();
149 vd->sttmanager->Stop();
150 }catch(is::stt::SttException &e){
151 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
154 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
155 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
157 vd->sttmanager->Cancel();
158 }catch(is::stt::SttException &e){
159 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
166 elm_naviframe_item_pop_to(elm_naviframe_bottom_item_get(vd->naviframe));
170 _back_to_genlist_for_selector();
175 if(opt->option_opened == EINA_FALSE){
176 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
179 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
180 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
181 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
183 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
184 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
185 vd->effector->Stop();
187 vd->sttmanager->Stop();
188 }catch(is::stt::SttException &e){
189 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
192 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
193 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
195 vd->sttmanager->Cancel();
196 }catch(is::stt::SttException &e){
197 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
201 _back_to_genlist_for_selector();
207 PRINTFUNC(DLOG_DEBUG, "naviframe transition, not finished\n");
215 void MoreOption::Update()
217 char lang[6] = {0, };
218 strncpy(lang, ((VoiceData *)voicedata)->kbd_lang , 5);
220 const char* display_lang = get_lang_label(lang);
221 eext_more_option_item_part_text_set(item, "selector,sub_text", display_lang);
224 Evas_Object* MoreOption::AddLanguageIcon(Evas_Object *parent) {
225 Evas_Object *icon = elm_image_add(parent);
227 PRINTFUNC(DLOG_ERROR, "It's failed to add image.");
230 string res_path = get_resource_path();
232 res_path = res_path + "wearable/";
234 res_path = res_path + "tv/";
236 res_path = res_path + "mobile/";
238 std::string image_path = res_path + "images/prompt_ic_languages.png";
240 elm_image_file_set(icon, image_path.c_str(), NULL);
241 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 evas_object_show(icon);
248 void MoreOption::AddMorePage() {
251 item = eext_more_option_item_append(more_option_layout);
254 eext_more_option_item_part_text_set(item, "selector,main_text", _("WDS_IME_HEADER_INPUT_LANGUAGES_ABB"));
256 img = AddLanguageIcon(more_option_layout);
258 eext_more_option_item_part_content_set(item, "item,icon", img);
260 evas_object_smart_callback_add(more_option_layout, "item,clicked",
261 [](void *data, Evas_Object *obj, void *event_info)
263 PRINTFUNC(DLOG_DEBUG, "item,clicked");
264 if(g_setting_window == NULL)
265 create_setting_window(obj);
268 evas_object_smart_callback_add(more_option_layout, "item,selected",
269 [](void *data, Evas_Object *obj, void *event_info)
271 PRINTFUNC(DLOG_DEBUG, "item,selected");