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.
24 #include <app_common.h>
26 #include "MoreOption.h"
27 #include "w-input-selector.h"
28 #include "w-input-stt-ise.h"
29 #include "w-input-stt-voice.h"
31 extern Evas_Object *g_setting_window;
33 MoreOption::MoreOption(Evas_Object *naviframe, void* voicedata)
35 , more_option_layout(NULL)
39 , option_opened(EINA_FALSE)
40 , voicedata(voicedata) {
41 /** todo. implement constructor */
44 MoreOption::~MoreOption() {
45 /** todo. implement destructor */
47 // if(more_option_layout)
48 // evas_object_del(more_option_layout);
51 void MoreOption::Create() {
56 catch(std::exception &e) {
57 PRINTFUNC(DLOG_ERROR, "%s", e.what());
62 void MoreOption::AddLayout() {
65 PRINTFUNC(DLOG_ERROR, "Invalid naviframe.");
68 more_option_layout = eext_more_option_add(nf);
70 if(!more_option_layout)
71 PRINTFUNC(DLOG_ERROR, "It's failed to create layout");
73 evas_object_smart_callback_add(more_option_layout, "more,option,opened",
74 [](void *data, Evas_Object *obj, void *event_info){
75 PRINTFUNC(DLOG_DEBUG, "more option is opened!!! \n");
80 * if more option is completed, stt have to be stopped.
83 MoreOption *opt = (MoreOption *)data;
84 VoiceData *vd = (VoiceData *) opt->voicedata;
86 if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING ||
87 vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
88 vd->sttmanager->Cancel();
91 catch(is::stt::SttException &e) {
92 PRINTFUNC(DLOG_ERROR, "%s", e.what());
95 opt->option_opened = EINA_TRUE;
98 evas_object_smart_callback_add(more_option_layout, "more,option,closed",
99 [](void *data, Evas_Object *obj, void *event_info){
100 PRINTFUNC(DLOG_DEBUG, "more option is closed!!! \n");
102 MoreOption *opt = (MoreOption *)data;
103 VoiceData *vd = (VoiceData *) opt->voicedata;
105 activate_circle_scroller_for_stt_textbox(vd, EINA_TRUE);
107 opt->option_opened = EINA_FALSE;
110 evas_object_show(more_option_layout);
113 void MoreOption::SetContentLayout(Evas_Object *content) {
118 elm_object_part_content_set(more_option_layout, "elm.swallow.content", content);
120 Elm_Object_Item *nit = NULL;
121 nit = elm_naviframe_item_push(nf, NULL, NULL, NULL, more_option_layout, "empty");
122 elm_naviframe_item_title_enabled_set(nit, EINA_FALSE, EINA_FALSE);
124 elm_naviframe_item_pop_cb_set(nit,
125 [](void *data, Elm_Object_Item *it)->Eina_Bool
127 MoreOption *opt = (MoreOption *)data;
128 VoiceData *vd = (VoiceData *) opt->voicedata;
130 if(vd->disclaimer == 1){
131 PRINTFUNC(DLOG_ERROR, "pop to top"); //inb case of (selector view -> disclaimer view-> stt view)
133 if(opt->option_opened == EINA_FALSE){
134 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
137 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
138 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
139 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
141 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
142 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
143 vd->effector->Stop();
145 vd->sttmanager->Stop();
146 }catch(is::stt::SttException &e){
147 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
150 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
151 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
153 vd->sttmanager->Cancel();
154 }catch(is::stt::SttException &e){
155 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
162 elm_naviframe_item_pop_to(elm_naviframe_bottom_item_get(vd->naviframe));
166 _back_to_genlist_for_selector();
171 if(opt->option_opened == EINA_FALSE){
172 PRINTFUNC(DLOG_DEBUG, "pop_cb called in STT view\n");
175 if (vd->sttmanager->GetCurrent() == STT_STATE_CREATED ||
176 vd->sttmanager->GetCurrent() == STT_STATE_READY) {
177 PRINTFUNC(DLOG_DEBUG, "STT_STATE_CREATED || STT_STATE_READY\n");
179 } else if (vd->sttmanager->GetCurrent() == STT_STATE_RECORDING) {
180 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
181 vd->effector->Stop();
183 vd->sttmanager->Stop();
184 }catch(is::stt::SttException &e){
185 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
188 } else if (vd->sttmanager->GetCurrent() == STT_STATE_PROCESSING) {
189 PRINTFUNC(DLOG_DEBUG, "STT_STATE_RECORDING\n");
191 vd->sttmanager->Cancel();
192 }catch(is::stt::SttException &e){
193 PRINTFUNC(DLOG_ERROR, "reason : %s", e.what());
197 _back_to_genlist_for_selector();
203 PRINTFUNC(DLOG_DEBUG, "naviframe transition, not finished\n");
211 void MoreOption::Update()
213 char lang[6] = {0, };
214 strncpy(lang, ((VoiceData *)voicedata)->kbd_lang , 5);
216 const char* display_lang = get_lang_label(lang);
217 eext_more_option_item_part_text_set(item, "selector,sub_text", display_lang);
220 Evas_Object* MoreOption::AddLanguageIcon(Evas_Object *parent) {
221 Evas_Object *icon = elm_image_add(parent);
223 PRINTFUNC(DLOG_ERROR, "It's failed to add image.");
226 std::string res_path;
227 char *tmp_path = app_get_resource_path();
233 std::string image_path = res_path + "images/prompt_ic_languages.png";
235 elm_image_file_set(icon, image_path.c_str(), NULL);
236 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
237 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
238 evas_object_show(icon);
243 void MoreOption::AddMorePage() {
246 item = eext_more_option_item_append(more_option_layout);
249 eext_more_option_item_part_text_set(item, "selector,main_text", _("WDS_IME_HEADER_INPUT_LANGUAGES_ABB"));
251 img = AddLanguageIcon(more_option_layout);
253 eext_more_option_item_part_content_set(item, "item,icon", img);
255 evas_object_smart_callback_add(more_option_layout, "item,clicked",
256 [](void *data, Evas_Object *obj, void *event_info)
258 PRINTFUNC(DLOG_DEBUG, "item,clicked");
259 if(g_setting_window == NULL)
260 create_setting_window(obj);
263 evas_object_smart_callback_add(more_option_layout, "item,selected",
264 [](void *data, Evas_Object *obj, void *event_info)
266 PRINTFUNC(DLOG_DEBUG, "item,selected");