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 #include <system_info.h>
26 #define EDJE_PATH "/usr/apps/org.tizen.heremaps-uc/res/edje/heremaps-uc.edj"
29 TIZEN_PROFILE_UNKNOWN = 0,
30 TIZEN_PROFILE_MOBILE = 0x1,
31 TIZEN_PROFILE_WEARABLE = 0x2,
32 TIZEN_PROFILE_TV = 0x4,
33 TIZEN_PROFILE_IVI = 0x8,
34 TIZEN_PROFILE_COMMON = 0x10,
37 static tizen_profile_t _get_tizen_profile()
39 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
40 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
44 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
45 switch (*profileName) {
48 profile = TIZEN_PROFILE_MOBILE;
52 profile = TIZEN_PROFILE_WEARABLE;
56 profile = TIZEN_PROFILE_TV;
60 profile = TIZEN_PROFILE_IVI;
62 default: // common or unknown ==> ALL ARE COMMON.
63 profile = TIZEN_PROFILE_COMMON;
70 static Evas_Object *create_conformant(Evas_Object * parent)
73 Evas_Object *conformant = NULL;
75 conformant = elm_conformant_add(parent);
76 elm_win_conformant_set(parent, EINA_TRUE);
77 elm_win_resize_object_add(parent, conformant);
78 evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79 evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
80 evas_object_show(conformant);
86 static Evas_Object *create_layout(Evas_Object * parent)
89 Evas_Object *layout = NULL;
92 layout = elm_layout_add(parent);
93 elm_object_content_set(parent, layout);
94 evas_object_show(layout);
101 static void win_del(void *data, Evas_Object * obj, void *event)
107 static void save_vconf(int value)
112 ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
114 LS_LOGE("Fail to get vconf value");
115 else if (enabled != value) {
116 ret = vconf_set_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, value);
118 LS_LOGE("Fail to set vconf value");
122 static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
125 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
126 LS_RETURN_IF_FAILED(ad);
134 static void agree_btn_cb(void *data, Evas_Object * obj, void *event)
137 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
138 LS_RETURN_IF_FAILED(ad);
146 static void back_btn_cb(void *data, Evas_Object * obj, void *event)
149 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
150 LS_RETURN_IF_FAILED(ad);
157 static Evas_Object *create_win(const char *name)
162 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
164 elm_win_title_set(eo, name);
165 elm_win_borderless_set(eo, EINA_TRUE);
166 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
167 elm_win_alpha_set(eo, EINA_TRUE);
168 if (elm_win_wm_rotation_supported_get(eo)) {
169 int rots[4] = { 0, 90, 180, 270 };
170 elm_win_wm_rotation_available_rotations_set(eo, (const int *)(&rots), 4);
176 static void anchor_clicked_cb(void *data, Evas_Object *obj, void *event_info)
179 Elm_Entry_Anchor_Info *ai = event_info;
180 LS_RETURN_IF_FAILED(ai);
182 app_control_h ac = NULL;
183 app_control_create(&ac);
184 app_control_set_operation(ac, APP_CONTROL_OPERATION_VIEW);
185 app_control_set_uri(ac, ai->name);
186 app_control_send_launch_request(ac, NULL, NULL);
187 app_control_destroy(ac);
190 static Evas_Object *create_popup_tv(Evas_Object *layout, heremaps_uc_app_data *ad)
194 Evas_Object *disagree_btn, *agree_btn;
197 popup = elm_popup_add(layout);
198 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
199 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
200 elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
202 Evas_Object *box = elm_box_add(popup);
203 elm_box_align_set(box, 0.5, 0);
204 elm_object_part_content_set(popup, "elm.swallow.content", box);
205 evas_object_show(box);
207 char buf[4096] = {0};
208 char *str1 = P_("IDS_POSITIONING_CONSENT_BODY");
209 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>";
210 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>";
211 snprintf(buf, 4096, str1, str2, str3);
212 char *text = strdup(buf);
214 Evas_Object* entry = elm_entry_add(box);
215 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
216 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 elm_entry_editable_set(entry, EINA_FALSE);
218 elm_object_part_text_set(entry, "elm.text", text);
219 elm_entry_text_style_user_push(entry, "DEFAULT='align=center'");
220 elm_box_pack_end(box, entry);
221 evas_object_show(entry);
223 /* Disagree button */
224 disagree_btn = elm_button_add(popup);
225 elm_object_style_set(disagree_btn, "popup");
226 elm_object_text_set(disagree_btn, P_("IDS_ST_BUTTON_DISAGREE"));
227 elm_object_part_content_set(popup, "button1", disagree_btn);
228 evas_object_smart_callback_add(disagree_btn, "clicked", disagree_btn_cb, ad);
231 agree_btn = elm_button_add(popup);
232 elm_object_style_set(agree_btn, "popup");
233 elm_object_text_set(agree_btn, P_("IDS_ST_BUTTON_AGREE"));
234 elm_object_part_content_set(popup, "button2", agree_btn);
235 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
237 evas_object_show(popup);
242 static Evas_Object *create_popup_wearable(Evas_Object *layout, heremaps_uc_app_data *ad)
246 Evas_Object *agree_btn;
249 popup = elm_popup_add(layout);
250 elm_object_style_set(popup, "circle");
251 evas_object_size_hint_weight_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
252 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
254 Evas_Object *popupLayout = elm_layout_add(popup);
255 elm_layout_theme_set(popupLayout, "layout", "popup", "content/circle/buttons1");
256 evas_object_size_hint_align_set(popupLayout, EVAS_HINT_FILL, EVAS_HINT_FILL);
257 evas_object_size_hint_weight_set(popupLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
258 elm_object_part_text_set(popupLayout, "elm.text.title", P_("IDS_POSITIONING_CONSENT_TITLE"));
259 elm_object_content_set(popup, popupLayout);
261 Evas_Object *box = elm_box_add(popupLayout);
262 elm_box_align_set(box, 0.5, 0);
263 elm_object_part_content_set(popupLayout, "elm.swallow.content", box);
264 evas_object_show(box);
266 char buf[4096] = {0};
267 char *str1 = P_("IDS_POSITIONING_CONSENT_BODY");
268 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>";
269 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>";
270 snprintf(buf, 4096, str1, str2, str3);
271 char *text = strdup(buf);
273 Evas_Object* entry = elm_entry_add(box);
274 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
275 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
276 elm_entry_editable_set(entry, EINA_FALSE);
277 elm_object_part_text_set(entry, "elm.text", text);
278 elm_entry_text_style_user_push(entry, "DEFAULT='align=center'");
279 elm_box_pack_end(box, entry);
280 evas_object_show(entry);
283 agree_btn = elm_button_add(popup);
284 elm_object_style_set(agree_btn, "popup/circle");
285 evas_object_size_hint_weight_set(agree_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
286 elm_object_part_text_set(agree_btn, "elm.text", P_("IDS_ST_BUTTON_AGREE"));
288 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
289 elm_object_part_content_set(popup, "button1", agree_btn);
291 evas_object_show(popup);
296 static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
300 Evas_Object *disagree_btn, *agree_btn;
303 popup = elm_popup_add(layout);
304 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
305 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
306 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
307 elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
309 Evas_Object *box = elm_box_add(popup);
310 elm_box_align_set(box, 0.5, 0);
311 elm_object_part_content_set(popup, "elm.swallow.content", box);
312 evas_object_show(box);
314 char buf[4096] = {0};
315 char *str1 = P_("IDS_POSITIONING_CONSENT_BODY");
316 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>";
317 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>";
318 snprintf(buf, 4096, str1, str2, str3);
319 char *text = strdup(buf);
321 Evas_Object* entry = elm_entry_add(box);
322 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
323 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
324 elm_entry_editable_set(entry, EINA_FALSE);
325 elm_object_part_text_set(entry, "elm.text", text);
326 elm_entry_text_style_user_push(entry, "DEFAULT='align=center'");
327 evas_object_smart_callback_add(entry, "anchor,clicked", anchor_clicked_cb, NULL);
328 elm_box_pack_end(box, entry);
329 evas_object_show(entry);
331 /* Disagree button */
332 disagree_btn = elm_button_add(popup);
333 elm_object_style_set(disagree_btn, "popup");
334 elm_object_text_set(disagree_btn, P_("IDS_ST_BUTTON_DISAGREE"));
335 elm_object_part_content_set(popup, "button1", disagree_btn);
336 evas_object_smart_callback_add(disagree_btn, "clicked", disagree_btn_cb, ad);
339 agree_btn = elm_button_add(popup);
340 elm_object_style_set(agree_btn, "popup");
341 elm_object_text_set(agree_btn, P_("IDS_ST_BUTTON_AGREE"));
342 elm_object_part_content_set(popup, "button2", agree_btn);
343 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
345 evas_object_show(popup);
350 static bool _app_create_cb(void *user_data)
357 static void _app_terminate_cb(void *user_data)
362 static void _app_pause_cb(void *user_data)
365 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
366 LS_RETURN_IF_FAILED(ad);
368 if (ad->btn_clicked == 0)
374 static void _app_resume_cb(void *user_data)
379 static void _app_control_cb(app_control_h app_control, void *user_data)
383 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
384 LS_RETURN_IF_FAILED(ad);
387 evas_object_del(ad->win_main);
391 elm_app_base_scale_set(2.6);
392 elm_config_accel_preference_set("3d");
394 bindtextdomain(HEREMAPS_UC_PKG, LOCALE_DIR);
399 ad->win_main = create_win(HEREMAPS_UC_PKG);
400 ad->conformant = create_conformant(ad->win_main);
401 ad->layout_main = create_layout(ad->conformant);
403 if (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
404 ad->popup = create_popup_wearable(ad->layout_main, ad);
405 else if (_get_tizen_profile() == TIZEN_PROFILE_TV)
406 ad->popup = create_popup_tv(ad->layout_main, ad);
408 ad->popup = create_popup(ad->layout_main, ad);
410 evas_object_show(ad->win_main);
415 static void _app_low_memory_cb(void *user_data)
420 static void _app_low_battery_cb(void *user_data)
425 static void _app_device_orientation_cb(app_event_info_h event_info, void *user_data)
428 LS_RETURN_IF_FAILED(event_info);
429 LS_RETURN_IF_FAILED(user_data);
431 heremaps_uc_app_data *ad = (heremaps_uc_app_data *)user_data;
432 app_device_orientation_e orientation;
433 app_event_get_device_orientation(event_info, &orientation);
434 elm_win_rotation_with_resize_set(ad->win_main, orientation);
438 static void _app_language_changed_cb(app_event_info_h event_info, void *user_data)
442 char *locale = vconf_get_str(VCONFKEY_LANGSET);
444 elm_language_set(locale);
449 int main(int argc, char *argv[])
454 heremaps_uc_app_data ad = {0,};
456 ui_app_lifecycle_callback_s event_callback = {0,};
457 app_event_handler_h handlers[5] = {NULL, };
459 event_callback.create = _app_create_cb;
460 event_callback.terminate = _app_terminate_cb;
461 event_callback.app_control = _app_control_cb;
462 event_callback.pause = _app_pause_cb;
463 event_callback.resume = _app_resume_cb;
465 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed_cb, NULL);
467 ret = APP_ERROR_NONE;
468 ret = ui_app_main(argc, argv, &event_callback, &ad);
470 if (ret != APP_ERROR_NONE)
471 LS_LOGE("ui_app_main() is failed. err=%d", ret);