/* * Copyright (c) 2010 Samsung Electronics, Inc. * All rights reserved. * * This software is a confidential and proprietary information * of Samsung Electronics, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Samsung Electronics. */ #include #include #include #include #include #include #include #include #include "setting-sound.h" #include "setting-volume.h" #include "setting-clock.h" #include "setting-info.h" #include "setting-display.h" #include "setting-language.h" #include "setting-device.h" #include "setting-connection.h" #include "setting-datausage.h" #include "util.h" #include "setting-common-sound.h" #include "setting.h" #include "setting_view_toast.h" static struct _main_menu_item setting_menu_its[] = { { SETTING_MAIN_MENU_WATCH_FACE_STYLES, "WDS_CLOCK_MBODY_WATCH_FACES_AND_STYLES", "b_settings_list_watchface_style.png", clock_cb}, { SETTING_MAIN_MENU_SOUND, "IDS_ST_OPT_SOUND_ABB2", "b_setting_list_sound.png", sound_cb}, { SETTING_MAIN_MENU_DEVICE, "IDS_ST_BODY_DEVICE", "b_settings_list_device.png", device_cb}, { SETTING_MAIN_MENU_DISPLAY, "IDS_ST_MBODY_DISPLAY_ABB", "b_setting_list_display.png", display_cb}, { SETTING_MAIN_MENU_CALL, "IDS_ST_BODY_CALL", "b_setting_list_call.png", call_cb}, { SETTING_MAIN_MENU_MESSAGES, "IDS_ST_BODY_MESSAGE", "b_setting_list_message.png", message_cb}, { SETTING_MAIN_MENU_CONNECTIONS, "IDS_ST_BODY_CONNECTIONS", "b_setting_list_connections.png", connection_cb}, { SETTING_MAIN_MENU_INPUT, "IDS_ST_HEADER_INPUT", "b_setting_list_input.png", keyboard_cb}, { SETTING_MAIN_MENU_AUTOFILL, "Autofill Service", "b_setting_list_input.png", autofill_cb}, { SETTING_MAIN_MENU_ACCESSIBILITY, "IDS_ST_BODY_ACCESSIBILITY", "b_setting_list_accessibility.png", accessiblity_cb}, { SETTING_MAIN_MENU_ACCOUNTS, "IDS_ST_BODY_ACCOUNTS", "b_setting_list_account.png", account_cb}, #if FEATURE_SETTING_EMUL { SETTING_MAIN_MENU_DEVELOPER_OPTIONS, "IDS_ST_BODY_DEVELOPER_OPTIONS", "b_settings_list_developer.png", developer_cb}, #endif { SETTING_MAIN_MENU_GEAR_INFO, "WDS_ST_MBODY_GEAR_INFO_ABB", "b_setting_list_gear_info.png", gear_info_cb}, { SETTING_MAIN_MENU_MAX, NULL, NULL, NULL } }; static Ecore_Timer *scrl_timer = NULL; static Evas_Object *_create_bg(Evas_Object *parent); static Evas_Object *_create_layout_main(Evas_Object *parent); static Evas_Object *_create_naviframe_layout(Evas_Object *parent); static void _create_view_layout(appdata *ad); static int init_watch_setting(appdata *ad); static Eina_Bool _scroller_timer_cb(void *data); static void _update_main_menu_title(void *data); static char * _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part) { char buf[__SETTING_BUF_SIZE__] = {0,}; snprintf(buf, sizeof(buf)-1, "%s", _("IDS_ST_OPT_SETTINGS")); return strdup(buf); } static Eina_Bool _scroller_timer_cb(void *data) { DBG("hide scroller bar"); Evas_Object *genlist = data; if (genlist) elm_layout_signal_emit(genlist, "do-hide-vbar", ""); return ECORE_CALLBACK_CANCEL; } void clock_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; genlist = _create_clock_list(data); if (genlist == NULL) { DBG("%s", "clock cb - layout is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_CLOCK; } void sound_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; _initialize(); genlist = _create_sound_list(data); if (genlist == NULL) { DBG("%s", "sound cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); evas_object_event_callback_add(nf_it, EVAS_CALLBACK_DEL, _clear_sound_cb, ad); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_SOUND; } void device_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; genlist = _create_device_action_list(data); if (genlist == NULL) { DBG("%s", "sound cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_SOUND; } void display_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; _init_display(); genlist = _create_display_list(data); if (genlist == NULL) { DBG("%s", "display cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, _clear_display_cb, ad); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_DISPLAY; } void keyboard_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.inputmethod-setting-list", .extra_data_name = "caller", .extra_value = "settings", .set_operation = NULL, .launch_group_mode = false }; launch_extra_app(extra_app); } void autofill_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.autofill-setting-wearable", .extra_data_name = "caller", .extra_value = "settings", .set_operation = NULL, .launch_group_mode = false }; launch_extra_app(extra_app); } void back_key_connection_cb(void *data, Evas_Object *obj, void *event_info) { appdata *ad = (appdata *)data; if (ad) { elm_naviframe_item_pop(ad->nf); _clear_connection_resource(); back_button_cb_pop(); } else { ERR("data ptr is NULL"); } } void connection_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *layout = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; layout = _create_connection_list(data); if (layout == NULL) { DBG("%s", "connection_cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, "empty"); back_button_cb_push(&back_key_connection_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_DOUBLE_PRESSING; } void language_cb(void *data, Evas_Object *obj, void *event_info) { elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; if (is_connected_GM()) { DBG("Setting - language can not change!!"); /* automatic freed!! */ struct _toast_data *toast = _create_toast(ad, _("IDS_ST_TPOP_CHANGE_LANGUAGE_ON_MOBILE_DEVICE")); if (toast) { _show_toast(ad, toast); } return; } _initialize_language(ad); _set_launguage_update_cb(_update_main_menu_title); genlist = _create_lang_list(data); if (genlist == NULL) { DBG("%s", "language cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_naviframe_item_pop_cb_set(nf_it, _clear_lang_navi_cb, ad); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); ad->MENU_TYPE = SETTING_LANGUAGE; } void gear_info_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; genlist = _create_info_list(data); if (genlist == NULL) { DBG("%s", "info cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_INFO; } void developer_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; appdata *ad = data; setting_ret_if(!data); if (false == check_to_run_submenu(event_info)) return; genlist = _create_developer_option_list(data); if (genlist == NULL) { DBG("%s", "info cb - genlist is null"); return; } nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, _clear_developer_option_cb, ad); back_button_cb_push(&back_key_generic_cb, data, NULL, ad->main_genlist, "main_genlist"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); ad->MENU_TYPE = SETTING_DEVELOPER_OPTIONS; } void account_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.my-account", .extra_data_name = "launch-type", .extra_value = "setting", .set_operation = NULL, .launch_group_mode = false }; launch_extra_app(extra_app); } void call_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.w-call-setting", .extra_data_name = NULL, .extra_value = NULL, .set_operation = NULL, .launch_group_mode = true }; launch_extra_app(extra_app); } void message_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.w-message", .extra_data_name = NULL, .extra_value = NULL, .set_operation = "http://tizen.org/appcontrol/operation/setting/messages", .launch_group_mode = true }; launch_extra_app(extra_app); } void accessiblity_cb(void *data, Evas_Object *obj, void *event_info) { DBG("enter"); elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); extra_app_data extra_app = { .app_id = "org.tizen.accessibility-setting-profile_wearable", .extra_data_name = NULL, .extra_value = NULL, .set_operation = NULL, .launch_group_mode = true }; launch_extra_app(extra_app); } static void _quit_cb(void *data, Evas_Object *obj, void *ei) { /* To make your application go to background, Call the elm_win_lower() instead Evas_Object *win = (Evas_Object *) data; elm_win_lower(win); */ elm_exit(); } static Eina_Bool _pop_cb_moment_bar(void *data, Elm_Object_Item *it) { /* Stop timer and task */ appdata *ad = data; setting_retv_if(!data, EINA_FALSE); if (ad && ad->win_main) { elm_win_lower(ad->win_main); } return EINA_TRUE; } static Eina_Bool _pop_cb(void *data, Elm_Object_Item *it) { /* Stop timer and task */ appdata *ad = data; setting_retv_if(!data, EINA_FALSE); clear_running_timer(); if (true == get_running()) set_running(false); if (scrl_timer) { ecore_timer_del(scrl_timer); scrl_timer = NULL; } if (ad && ad->win_main) { elm_win_lower(ad->win_main); } return EINA_FALSE; } static Evas_Object *_create_bg(Evas_Object *parent) { Evas_Object *bg; setting_retv_if(!parent, NULL); bg = elm_bg_add(parent); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(parent, bg); evas_object_show(bg); return bg; } static Evas_Object *_create_layout_main(Evas_Object *parent) { Evas_Object *layout; setting_retv_if(!parent, NULL); layout = elm_layout_add(parent); if (layout == NULL) { DBG("Failed elm_layout_add.\n"); return NULL; } elm_layout_theme_set(layout, "layout", "application", "default"); evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(parent, layout); evas_object_show(layout); return layout; } static void _lang_changed(app_event_info_h event_info, void *data) { appdata *ad = data; if (ad && ad->MENU_TYPE == SETTING_LANGUAGE) return; char *locale = vconf_get_str(VCONFKEY_LANGSET); if (locale) { DBG("Setting - language is changed : %s", locale); elm_language_set(locale); elm_config_all_flush(); } FREE(locale); } static int init_watch_setting(appdata *ad) { DBG("init_watch_setting() is called!"); setting_retv_if(!ad, EINA_FALSE); ad->bg = _create_bg(ad->win_main); /* Conformant *** disable comform : lauching time issue *** */ /* Base Layout */ ad->layout_main = _create_layout_main(ad->win_main); if (ad->layout_main == NULL) return -1; /* Indicator */ elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE); /* Naviframe */ ad->nf = _create_naviframe_layout(ad->layout_main); int vibration_level = 0; vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vibration_level); DBG("Setting - vibration level : %d", vibration_level); if (vibration_level == 2) { /* wrong value!! */ vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT); vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT); } return EINA_TRUE; } static Evas_Object *_create_naviframe_layout(Evas_Object *parent) { Evas_Object *nf = NULL; setting_retv_if(!parent, NULL); nf = elm_naviframe_add(parent); elm_object_part_content_set(parent, "elm.swallow.content", nf); evas_object_show(nf); return nf; } static char *_gl_text_get(void *data, Evas_Object *obj, const char *part) { char buf[512]; Item_Data *id = data; int index = id->index; setting_retv_if(!data, NULL); snprintf(buf, sizeof(buf) - 1, "%s", _(setting_menu_its[index].name)); return strdup(buf); } static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part) { char buf[__SETTING_BUF_SIZE__] = {0,}; Item_Data *id = data; int index = id->index; if (part && !strcmp(part, "elm.icon")) { Evas_Object *left_layout = elm_layout_add(obj); evas_object_size_hint_weight_set(left_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(left_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_layout_file_set(left_layout, EDJE_PATH, "left_icon_layout"); Evas_Object *img_bg = NULL; img_bg = elm_image_add(left_layout); snprintf(buf, sizeof(buf) - 1, "%s/b_settings_list_bg.png", IMG_DIR); elm_image_file_set(img_bg, buf, NULL); evas_object_size_hint_align_set(img_bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(img_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_part_content_set(left_layout, "elm.icon_circle", img_bg); snprintf(buf, sizeof(buf) - 1, "%s/%s", IMG_DIR, setting_menu_its[index].icon_name); Evas_Object *icon = elm_image_add(left_layout); elm_image_file_set(icon, buf, NULL); evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_color_set(icon, 0, 0, 0, 255); elm_object_part_content_set(left_layout, "elm.icon", icon); return left_layout ; } return NULL; } static void _gl_del(void *data, Evas_Object *obj) { Item_Data *id = data; FREE(id); } static Evas_Object *_create_main_menu(Evas_Object *parent, appdata *ad) { Evas_Object *genlist = NULL; struct _main_menu_item *menu_its = NULL; int idx = 0; /* Create item class */ elm_theme_extension_add(NULL, EDJE_PATH); Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); itc->item_style = "1text.1icon"; itc->func.text_get = _gl_text_get; itc->func.content_get = _gl_icon_get; itc->func.del = _gl_del; genlist = elm_genlist_add(ad->nf); if (genlist == NULL) { elm_genlist_item_class_free(itc); return NULL; } elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); int item_count = 0; menu_its = setting_menu_its; item_count = sizeof(setting_menu_its) / sizeof(struct _main_menu_item); Elm_Genlist_Item_Class *title_item = elm_genlist_item_class_new(); title_item->func.text_get = _gl_menu_title_text_get; title_item->item_style = "title"; title_item->func.del = _gl_del; elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_genlist_item_class_free(title_item); DBG("Setting - Main menu item count: %d", item_count); for (idx = 0; idx < item_count - 1; idx++) { Item_Data *id = calloc(sizeof(Item_Data), 1); if (id) { id->index = idx; id->item = elm_genlist_item_append( genlist, /* genlist object */ itc, /* item class */ id, /* data */ NULL, ELM_GENLIST_ITEM_NONE, menu_its[idx].func, ad); } } elm_genlist_item_class_free(itc); Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new(); padding->item_style = "padding"; padding->func.del = _gl_del; Elm_Object_Item *padding_item; padding_item = elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_atspi_accessible_role_set(padding_item, ELM_ATSPI_ROLE_REDUNDANT_OBJECT); elm_genlist_item_class_free(padding); ad->main_genlist = genlist; return genlist; } static void _update_main_menu_title(void *data) { DBG("_update_main_menu_title() is called"); appdata *ad = data; setting_ret_if(!ad); if (ad->main_genlist) { elm_genlist_realized_items_update(ad->main_genlist); } } static void _create_view_layout(appdata *ad) { Evas_Object *genlist = NULL; Elm_Object_Item *nf_it = NULL; setting_ret_if(!ad); setting_ret_if(!ad->nf); genlist = _create_main_menu(ad->win_main, ad); connect_to_wheel_with_genlist(genlist, ad); ad->main_navi = nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, ad); /* ad->win_main */ eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, _hw_back_key_cb, NULL); } static Evas_Object *create_win(const char *name) { Evas_Object *eo; eo = elm_win_add(NULL, name, ELM_WIN_BASIC); if (!eo) return NULL; elm_win_title_set(eo, name); elm_win_autodel_set(eo, EINA_TRUE); if (elm_win_wm_rotation_supported_get(eo)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(eo, (const int *)(&rots), 4); } evas_object_smart_callback_add(eo, "delete,request", _quit_cb, NULL); return eo; } static void _exit_app(void *data, Evas_Object *obj, void *event_info) { clear_back_button_list(); ui_app_exit(); } bool app_create(void *data) { DBG("Setting - app_create"); appdata *ad = (appdata *) data; setting_retv_if(!data, false); char *locale; feedback_initialize(); ad->win_main = create_win(PACKAGE); if (ad->win_main == NULL) return false; elm_win_screen_size_get(ad->win_main, NULL, NULL, &ad->root_w, &ad->root_h); evas_object_resize(ad->win_main, ad->root_w, ad->root_h); double scale = elm_config_scale_get(); if (scale < 1.0) { DBG("Setting - scale is more less than 1.0"); elm_config_scale_set(1.0); } ad->evas = evas_object_evas_get(ad->win_main); locale = vconf_get_str(VCONFKEY_LANGSET); if (locale) { elm_language_set(locale); FREE(locale); } ad->is_first_launch = 1; init_watch_setting(ad); ad->circle_surface = eext_circle_surface_naviframe_add(ad->nf); back_button_cb_push(&_exit_app, NULL, NULL, NULL, "EXIT!! NO genlist"); return true; } void app_terminate(void *data) { DBG("Setting - app_terminate"); appdata *ad = data; setting_ret_if(!data); feedback_deinitialize(); if (ad->datetime) { ad->datetime = NULL; } if (ad->dt_genlist_item_of_date) { ad->dt_genlist_item_of_date = NULL; } if (ad->dt_genlist_item_of_time) { ad->dt_genlist_item_of_time = NULL; } if (ad->pref_arm_rdg) { ad->pref_arm_rdg = NULL; } if (ad->main_genlist) { ad->main_genlist = NULL; } if (ad->main_brightness_ly) { ad->main_brightness_ly = NULL; } if (ad->main_volume_ly) { _clear_volume_resources(); ad->main_volume_ly = NULL; } if (ad->main_media_volume_ly) { _clear_volume_resources(); ad->main_media_volume_ly = NULL; } if (ad->main_watch_face_ly) { ad->main_watch_face_ly = NULL; } if (ad->main_connections_ly) { ad->main_connections_ly = NULL; } if (ad->main_data_usage_ly) { ad->main_data_usage_ly = NULL; } if (ad->double_rdg) { ad->double_rdg = NULL; } if (ad->font_size_rdg) { ad->font_size_rdg = NULL; } if (ad->language_item) { ad->language_item = NULL; } if (ad->language_rdg) { ad->language_rdg = NULL; } if (ad->double_press_item) { ad->double_press_item = NULL; } eext_circle_surface_del(ad->circle_surface); } void app_pause(void *data) { DBG("Setting - app_pause()"); appdata *ad = data; setting_ret_if(!data); if (ad) { if (ad->MENU_TYPE == SETTING_VOLUME_2_DEPTH) { _stop_all_volume_sound(); } else if (ad->MENU_TYPE == SETTING_SOUND_RINGTONE || ad->MENU_TYPE == SETTING_SOUND_NOTIFICATION) { _stop_all_sound_play(); } else if (ad->MENU_TYPE == SETTING_SOUND) { _stop_all_sound_play(); } } } void app_resume(void *data) { DBG("Setting - app_resume()"); setting_ret_if(!data); if (true == get_running()) set_running(false); } Elm_Object_Item *push_naviframe(appdata *ad, Evas_Object *layer) { Elm_Object_Item *nf_it = NULL; setting_retv_if(!ad, NULL); setting_retv_if(!ad->nf, NULL); nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layer, NULL); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_pop_cb_set(nf_it, _pop_cb_moment_bar, ad); /* ad->win_main */ return nf_it; } void clear_popup_naviframe(appdata *ad) { setting_retm_if(!ad, "NO App data!!"); Elm_Object_Item *bottom = elm_naviframe_bottom_item_get(ad->nf); if (ad->popup) { evas_object_del(ad->popup); ad->popup = NULL; } if (ad->main_navi) elm_naviframe_item_pop_to(bottom); return; } int process_extra_data(void *data, app_control_h service) { char *param = NULL; int ret; appdata *ad = data; setting_retvm_if(!data, 0, "NO App data!!"); if (app_control_get_extra_data(service, "launch-type", ¶m) == APP_CONTROL_ERROR_NONE) { if (!ad->is_first_launch) { clear_popup_naviframe(ad); clear_back_button_list(); back_button_cb_push(&_exit_app, NULL, NULL, NULL, "EXIT!! NO genlist"); } else { eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, _hw_back_key_cb, NULL); } if (param && !strcmp(param, "brightness")) { Evas_Object *brightness_ly = _show_brightness_popup(ad, NULL, NULL); ad->main_brightness_ly = push_naviframe(ad, brightness_ly); } else if (param && !strcmp(param, "volume")) { _initialize_volume(); Evas_Object *volume_ly = _create_volume_page(ad); ad->main_volume_ly = push_naviframe(ad, volume_ly); } else if (param && !strcmp(param, "media_volume")) { _initialize_volume(); Evas_Object *volume_ly = _media_create_volume_page(ad); ad->main_media_volume_ly = push_naviframe(ad, volume_ly); } else if (param && !strcmp(param, "watchface")) { initialize_clock(data); Evas_Object *watch_face_ly = _clock_type_cb(ad); ad->main_watch_face_ly = push_naviframe(ad, watch_face_ly); } else if (param && !strcmp(param, "connections")) { Evas_Object *connections_ly = _create_connection_list(ad); ad->main_connections_ly = push_naviframe(ad, connections_ly); } else if (param && !strcmp(param, "data_usage")) { Evas_Object *data_usage_ly = _create_data_usage_list(ad); ad->main_data_usage_ly = push_naviframe(ad, data_usage_ly); } if (ad->win_main) { evas_object_show(ad->win_main); elm_win_activate(ad->win_main); } DBG("Setting - enable direct brightness or volume setting"); ret = 1; } else { if (ad->is_first_launch) _create_view_layout(ad); DBG("Setting - disable direct brightness or volume setting - CanNOT read the launch-type param"); ret = 0; } FREE(param); return ret; } void app_ctrl(app_control_h service, void *data) { DBG("Setting - app_ctrl()"); appdata *ad = data; setting_ret_if(!data); if (process_extra_data(data, service)) return; if (!ad->is_first_launch) { clear_popup_naviframe(ad); /*reset back button callback stack*/ clear_back_button_list(); back_button_cb_push(&_exit_app, NULL, NULL, NULL, "EXIT!! NO genlist"); if (ad->main_genlist) { elm_genlist_item_show(elm_genlist_first_item_get(ad->main_genlist), ELM_GENLIST_ITEM_SCROLLTO_TOP); elm_layout_signal_emit(ad->main_genlist, "do-show-vbar", ""); if (scrl_timer) { ecore_timer_del(scrl_timer); scrl_timer = NULL; } scrl_timer = ecore_timer_add(1, (Ecore_Task_Cb)_scroller_timer_cb, ad->main_genlist); connect_to_wheel_with_genlist(ad->main_genlist, ad); } } else { ad->is_first_launch = 0; } if (ad->win_main) { evas_object_show(ad->win_main); elm_win_activate(ad->win_main); } ad->MENU_TYPE = SETTING_MAIN; } int main(int argc, char *argv[]) { DBG("%s,%d", __func__, __LINE__); appdata ad; ui_app_lifecycle_callback_s event_callback = {0,}; app_event_handler_h handlers[5] = {NULL, }; int ret = 0; event_callback.create = app_create; event_callback.terminate = app_terminate; event_callback.pause = app_pause; event_callback.resume = app_resume; event_callback.app_control = app_ctrl; ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL); ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _lang_changed, NULL); ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL); ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL); memset(&ad, 0x0, sizeof(appdata)); ret = ui_app_main(argc, argv, &event_callback, &ad); if (APP_ERROR_NONE != ret) { ERR("app_main() is failed. err = %d", ret); } return ret; }