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 static Evas_Object *create_conformant(Evas_Object * parent)
27 Evas_Object *conformant = NULL;
29 conformant = elm_conformant_add(parent);
30 elm_win_conformant_set(parent, EINA_TRUE);
31 elm_win_resize_object_add(parent, conformant);
32 evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
33 evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
34 evas_object_show(conformant);
40 static Evas_Object *create_layout(Evas_Object * parent)
43 Evas_Object *layout = NULL;
46 layout = elm_layout_add(parent);
47 elm_object_content_set(parent, layout);
48 evas_object_show(layout);
55 static void win_del(void *data, Evas_Object * obj, void *event)
61 static void save_vconf(int value, heremaps_uc_app_data *ad)
66 ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
68 LS_LOGE("Fail to get vconf value");
69 else if (enabled != value) {
70 ret = vconf_set_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, value);
72 LS_LOGE("Fail to set vconf value");
76 static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
79 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
86 static void agree_btn_cb(void *data, Evas_Object * obj, void *event)
89 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
96 static void back_btn_cb(void *data, Evas_Object * obj, void *event)
99 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
105 static Evas_Object *create_win(const char *name)
110 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
112 elm_win_title_set(eo, name);
113 elm_win_borderless_set(eo, EINA_TRUE);
114 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
115 elm_win_alpha_set(eo, EINA_TRUE);
116 if (elm_win_wm_rotation_supported_get(eo)) {
117 int rots[4] = { 0, 90, 180, 270 };
118 elm_win_wm_rotation_available_rotations_set(eo, (const int *)(&rots), 4);
124 static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
128 Evas_Object *disagree_btn, *agree_btn;
131 popup = elm_popup_add(layout);
132 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
133 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
134 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
135 elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
136 elm_object_text_set(popup, P_("IDS_POSITIONING_CONSENT_BODY"));
138 /* Disagree button */
139 disagree_btn = elm_button_add(popup);
140 elm_object_style_set(disagree_btn, "popup");
141 elm_object_text_set(disagree_btn, P_("IDS_ST_BUTTON_DISAGREE"));
142 elm_object_part_content_set(popup, "button1", disagree_btn);
143 evas_object_smart_callback_add(disagree_btn, "clicked", disagree_btn_cb, ad);
146 agree_btn = elm_button_add(popup);
147 elm_object_style_set(agree_btn, "popup");
148 elm_object_text_set(agree_btn, P_("IDS_ST_BUTTON_AGREE"));
149 elm_object_part_content_set(popup, "button2", agree_btn);
150 evas_object_smart_callback_add(agree_btn, "clicked", agree_btn_cb, ad);
152 evas_object_show(popup);
157 static bool _app_create_cb(void *user_data)
164 static void _app_terminate_cb(void *user_data)
169 static void _app_pause_cb(void *user_data)
174 static void _app_resume_cb(void *user_data)
179 static void _app_control_cb(app_control_h app_control, void *user_data)
183 heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
184 LS_RETURN_IF_FAILED(ad);
187 evas_object_del(ad->win_main);
191 elm_app_base_scale_set(2.6);
192 elm_config_accel_preference_set("3d");
194 bindtextdomain(HEREMAPS_UC_PKG, LOCALE_DIR);
198 ad->win_main = create_win(HEREMAPS_UC_PKG);
199 ad->conformant = create_conformant(ad->win_main);
200 ad->layout_main = create_layout(ad->conformant);
202 ad->popup = create_popup(ad->layout_main, ad);
204 evas_object_show(ad->win_main);
209 static void _app_low_memory_cb(void *user_data)
214 static void _app_low_battery_cb(void *user_data)
219 static void _app_device_orientation_cb(app_event_info_h event_info, void *user_data)
222 LS_RETURN_IF_FAILED(event_info);
223 LS_RETURN_IF_FAILED(user_data);
225 heremaps_uc_app_data *ad = (heremaps_uc_app_data *)user_data;
226 app_device_orientation_e orientation;
227 app_event_get_device_orientation(event_info, &orientation);
228 elm_win_rotation_with_resize_set(ad->win_main, orientation);
232 static void _app_language_changed_cb(app_event_info_h event_info, void *user_data)
236 char *locale = vconf_get_str(VCONFKEY_LANGSET);
237 if (locale) elm_language_set(locale);
240 int main(int argc, char *argv[])
245 heremaps_uc_app_data ad = {0,};
247 ui_app_lifecycle_callback_s event_callback = {0,};
248 app_event_handler_h handlers[5] = {NULL, };
250 event_callback.create = _app_create_cb;
251 event_callback.terminate = _app_terminate_cb;
252 event_callback.app_control = _app_control_cb;
253 event_callback.pause = _app_pause_cb;
254 event_callback.resume = _app_resume_cb;
256 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed_cb, NULL);
258 ret = APP_ERROR_NONE;
259 ret = ui_app_main(argc, argv, &event_callback, &ad);
261 if (ret != APP_ERROR_NONE)
262 LS_LOGE("ui_app_main() is failed. err=%d", ret);