4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jongmun Woo <jongmun.woo@samsung.com>, Seechan Kim <cbible.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "heremaps-uc-common.h"
24 #define EDJE_PATH "/usr/apps/org.tizen.heremaps-uc/res/edje/heremaps-uc.edj"
26 static Evas_Object *create_conformant(Evas_Object * parent)
29 Evas_Object *conformant = NULL;
31 conformant = elm_conformant_add(parent);
32 elm_win_conformant_set(parent, EINA_TRUE);
33 elm_win_resize_object_add(parent, conformant);
34 evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35 evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
36 evas_object_show(conformant);
42 static Evas_Object *create_layout(Evas_Object * parent)
45 Evas_Object *layout = NULL;
48 layout = elm_layout_add(parent);
49 elm_object_content_set(parent, layout);
50 evas_object_show(layout);
57 static void win_del(void *data, Evas_Object * obj, void *event)
63 static void save_vconf(int value, heremaps_uc_app_data *ad)
68 ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
70 LS_LOGE("Fail to get vconf value");
71 else if (enabled != value) {
72 ret = vconf_set_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, value);
74 LS_LOGE("Fail to set vconf value");
78 static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
81 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
88 static void agree_btn_cb(void *data, Evas_Object * obj, void *event)
91 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
98 static void back_btn_cb(void *data, Evas_Object * obj, void *event)
101 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
107 static Evas_Object *create_win(const char *name)
112 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
114 elm_win_title_set(eo, name);
115 elm_win_borderless_set(eo, EINA_TRUE);
116 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
117 elm_win_alpha_set(eo, EINA_TRUE);
118 if (elm_win_wm_rotation_supported_get(eo)) {
119 int rots[4] = { 0, 90, 180, 270 };
120 elm_win_wm_rotation_available_rotations_set(eo, (const int *)(&rots), 4);
126 #ifdef TIZEN_WEARABLE
127 static Evas_Object *create_popup_wearable(Evas_Object *layout, heremaps_uc_app_data *ad)
131 Evas_Object *disagree_btn, *agree_btn;
134 popup = elm_popup_add(layout);
135 elm_object_style_set(popup, "circle");
136 evas_object_size_hint_weight_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
137 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
139 Evas_Object *popupLayout = elm_layout_add(popup);
140 elm_layout_theme_set(popupLayout, "layout", "popup", "content/circle/buttons2");
141 evas_object_size_hint_align_set(popupLayout, EVAS_HINT_FILL, EVAS_HINT_FILL);
142 evas_object_size_hint_weight_set(popupLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 elm_object_part_text_set(popupLayout, "elm.text.title", P_("IDS_POSITIONING_CONSENT_TITLE"));
144 elm_object_content_set(popup, popupLayout);
146 Evas_Object *box = elm_box_add(popupLayout);
147 elm_box_align_set(box, 0.5, 0);
148 elm_object_part_content_set(popupLayout, "elm.swallow.content", box);
149 evas_object_show(box);
151 char buf[4096] = {0};
152 char *str1 = P_("IDS_POSITIONING_CONSENT_BODY");
153 char *str2 = "<color=#006fd1ff underline=on underline_color=#006fd1ff><a href=http://here.com/terms/service-terms>http://here.com/terms/service-terms</a></color>";
154 char *str3 = "<color=#006fd1ff underline=on underline_color=#006fd1ff><a href=http://here.com/privacy/privacy-policy>http://here.com/privacy/privacy-policy</a></color>";
155 snprintf(buf, 4096, str1, str2, str3);
156 char *text = strdup(buf);
158 Evas_Object *entry1 = elm_entry_add(box);
159 evas_object_size_hint_weight_set(entry1, EVAS_HINT_EXPAND, 0.0);
160 evas_object_size_hint_align_set(entry1, EVAS_HINT_FILL, EVAS_HINT_FILL);
161 elm_entry_editable_set(entry1, EINA_FALSE);
162 elm_entry_line_wrap_set(entry1, ELM_WRAP_CHAR);
163 elm_object_part_text_set(entry1, "elm.text", text);
164 elm_box_pack_end(box, entry1);
165 evas_object_show(entry1);
167 /* Disagree button */
168 disagree_btn = elm_button_add(popup);
169 elm_object_style_set(disagree_btn, "popup/circle/left");
170 evas_object_size_hint_weight_set(disagree_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
171 evas_object_smart_callback_add(disagree_btn, "clicked", disagree_btn_cb, ad);
172 elm_object_part_content_set(popup, "button1", disagree_btn);
174 Evas_Object *icon = elm_image_add(disagree_btn);
175 elm_image_file_set(icon, EDJE_PATH, "tw_ic_popup_btn_delete.png");
176 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
177 elm_object_part_content_set(disagree_btn, "elm.swallow.content", icon);
178 evas_object_show(icon);
181 agree_btn = elm_button_add(popup);
182 elm_object_style_set(agree_btn, "popup/circle/right");
183 evas_object_size_hint_weight_set(agree_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
185 icon = elm_image_add(agree_btn);
186 elm_image_file_set(icon, EDJE_PATH, "tw_ic_popup_btn_check.png");
187 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
188 elm_object_part_content_set(agree_btn, "elm.swallow.content", icon);
189 evas_object_show(icon);
191 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
192 elm_object_part_content_set(popup, "button2", agree_btn);
194 evas_object_show(popup);
200 static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
204 Evas_Object *disagree_btn, *agree_btn;
207 popup = elm_popup_add(layout);
208 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
209 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
210 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
213 char buf[4096] = {0};
214 char *str1 = P_("IDS_POSITIONING_CONSENT_BODY");
215 char *str2 = "<color=#006fd1ff underline=on underline_color=#006fd1ff><a href=http://here.com/terms/service- terms>http://here.com/terms/service-terms</a></color>";
216 char *str3 = "<color=#006fd1ff underline=on underline_color=#006fd1ff><a href=http://here.com/privacy/privac y-policy>http://here.com/privacy/privacy-policy</a></color>";
217 snprintf(buf, 4096, str1, str2, str3);
218 char *text = strdup(buf);
219 elm_object_text_set(popup, text);
221 /* Disagree button */
222 disagree_btn = elm_button_add(popup);
223 elm_object_style_set(disagree_btn, "popup");
224 elm_object_text_set(disagree_btn, P_("IDS_ST_BUTTON_DISAGREE"));
225 elm_object_part_content_set(popup, "button1", disagree_btn);
226 evas_object_smart_callback_add(disagree_btn, "clicked", disagree_btn_cb, ad);
229 agree_btn = elm_button_add(popup);
230 elm_object_style_set(agree_btn, "popup");
231 elm_object_text_set(agree_btn, P_("IDS_ST_BUTTON_AGREE"));
232 elm_object_part_content_set(popup, "button2", agree_btn);
233 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
235 evas_object_show(popup);
241 static bool _app_create_cb(void *user_data)
248 static void _app_terminate_cb(void *user_data)
253 static void _app_pause_cb(void *user_data)
258 static void _app_resume_cb(void *user_data)
263 static void _app_control_cb(app_control_h app_control, void *user_data)
267 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
268 LS_RETURN_IF_FAILED(ad);
271 evas_object_del(ad->win_main);
275 elm_app_base_scale_set(2.6);
276 elm_config_accel_preference_set("3d");
278 bindtextdomain(HEREMAPS_UC_PKG, LOCALE_DIR);
282 ad->win_main = create_win(HEREMAPS_UC_PKG);
283 ad->conformant = create_conformant(ad->win_main);
284 ad->layout_main = create_layout(ad->conformant);
286 #ifdef TIZEN_WEARABLE
287 ad->popup = create_popup_wearable(ad->layout_main, ad);
289 ad->popup = create_popup(ad->layout_main, ad);
292 evas_object_show(ad->win_main);
297 static void _app_low_memory_cb(void *user_data)
302 static void _app_low_battery_cb(void *user_data)
307 static void _app_device_orientation_cb(app_event_info_h event_info, void *user_data)
310 LS_RETURN_IF_FAILED(event_info);
311 LS_RETURN_IF_FAILED(user_data);
313 heremaps_uc_app_data *ad = (heremaps_uc_app_data *)user_data;
314 app_device_orientation_e orientation;
315 app_event_get_device_orientation(event_info, &orientation);
316 elm_win_rotation_with_resize_set(ad->win_main, orientation);
320 static void _app_language_changed_cb(app_event_info_h event_info, void *user_data)
324 char *locale = vconf_get_str(VCONFKEY_LANGSET);
325 if (locale) elm_language_set(locale);
328 int main(int argc, char *argv[])
333 heremaps_uc_app_data ad = {0,};
335 ui_app_lifecycle_callback_s event_callback = {0,};
336 app_event_handler_h handlers[5] = {NULL, };
338 event_callback.create = _app_create_cb;
339 event_callback.terminate = _app_terminate_cb;
340 event_callback.app_control = _app_control_cb;
341 event_callback.pause = _app_pause_cb;
342 event_callback.resume = _app_resume_cb;
344 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed_cb, NULL);
346 ret = APP_ERROR_NONE;
347 ret = ui_app_main(argc, argv, &event_callback, &ad);
349 if (ret != APP_ERROR_NONE)
350 LS_LOGE("ui_app_main() is failed. err=%d", ret);