2 * Copyright (c) 2010 Samsung Electronics, Inc.
5 * This software is a confidential and proprietary information
6 * of Samsung Electronics, Inc. ("Confidential Information"). You
7 * shall not disclose such Confidential Information and shall use
8 * it only in accordance with the terms of the license agreement
9 * you entered into with Samsung Electronics.
13 #include <Ecore_X.h> /* ecore_x_window_size_get */
14 #include <utilX.h> /* KEY_END */
16 #include <vconf-keys.h>
18 #include <appcore-efl.h>
19 #include <efl_assist.h>
21 #include "setting-sound.h"
22 #include "setting-volume.h"
23 #include "setting-clock.h"
24 #include "setting-homescreen.h"
25 #include "setting-info.h"
26 #include "setting-bluetooth.h"
27 #include "setting-motion.h"
28 #include "setting-display.h"
29 #include "setting-language.h"
30 #include "setting-reset.h"
31 #include "setting-battery.h"
32 #include "setting-privacy.h"
33 #include "setting-double.h"
34 #include "setting-safety.h"
35 #include "setting-notification.h"
36 #include "setting-profile.h"
38 #include "setting-common-sound.h"
40 #include "setting_control_bt.h"
41 #include "setting_view_toast.h"
42 #include "setting_indicator_util.h"
44 #define FEATURE_SETTING_CHANGEABLE
46 #ifdef FEATURE_SETTING_CHANGEABLE
47 #include "setting-theme.h"
51 #ifndef FEATURE_SETTING_SDK
52 #define LANGUAGE_MENU_INDEX 10
54 #define LANGUAGE_MENU_INDEX 5
58 #define LANGUAGE_ICON_DISABLED "b_settings_language_disabled.png"
59 #define LANGUAGE_ICON_ENABLED "b_settings_language.png"
61 static struct _menu_item setting_emergency_menu_its[] = {
62 #ifdef FEATURE_SETTING_EMUL
63 { "IDS_ST_BUTTON_CLOCK", "b_settings_change_clock.png", clock_cb },
65 //#if !defined(FEATURE_SETTING_SDK) && !defined(FEATURE_SETTING_EMUL)
66 { "IDS_ST_OPT_SOUND_ABB2", "b_settings_volume.png", sound_cb },
67 // { "IDS_ST_OPT_VOLUME", "b_settings_volume.png", volume_cb },
69 { "IDS_ST_MBODY_DISPLAY_ABB", "b_setting_display.png", display_cb },
70 #ifndef FEATURE_SETTING_EMUL
71 // { "IDS_ST_BODY_BATTERY_ABB", "b_settings_battery.png", battery_cb },
72 { "IDS_QP_BUTTON_BLUETOOTH", "b_settings_bluetooth.png", bluetooth_cb },
74 #if !defined(FEATURE_SETTING_SDK) && !defined(FEATURE_SETTING_EMUL)
75 { "IDS_ST_MBODY_SAFETY_ABB", "b_settings_safety.png", safety_cb },
80 static struct _menu_item setting_menu_its[] = {
81 { "IDS_ST_BUTTON_CLOCK", "b_settings_change_clock.png", clock_cb },
82 #if !defined(FEATURE_SETTING_SDK) && !defined(FEATURE_SETTING_EMUL)
83 { "IDS_ST_BODY_WALLPAPERS", "b_setting_wallpaper.png", homescreen_cb },
84 { "IDS_ST_BUTTON_NOTIFICATIONS", "b_settings_notifications.png", notification_cb },
86 //#ifndef FEATURE_SETTING_EMUL
87 { "IDS_ST_OPT_SOUND_ABB2", "b_settings_volume.png", sound_cb },
88 // { "IDS_ST_OPT_VOLUME", "b_settings_volume.png", volume_cb },
90 { "IDS_ST_MBODY_DISPLAY_ABB", "b_setting_display.png", display_cb },
91 { "IDS_ST_MBODY_TEXT_INPUT_ABB", "text_input_icon.png", keyboard_cb },
92 #ifndef FEATURE_SETTING_EMUL
93 // { "IDS_ST_BODY_BATTERY_ABB", "b_settings_battery.png", battery_cb },
94 { "IDS_QP_BUTTON_BLUETOOTH", "b_settings_bluetooth.png", bluetooth_cb },
95 // { "IDS_WMGR_HEADER_MOTIONS", "b_settings_motion.png", motion_cb },
97 #if !defined(FEATURE_SETTING_SDK) && !defined(FEATURE_SETTING_EMUL)
98 { "IDS_ST_MBODY_DOUBLE_PRESS_ABB", "b_setting_double-press.png", double_pressing_cb },
99 { "IDS_LCKSCN_BODY_PRIVACY_LOCK_ABB", "b_settings_lockscreen.png", lockscreen_cb },
100 { "IDS_HEALTH_MBODY_PROFILE", "b_settings_profile.png", profile_cb },
102 // { "IDS_ST_BUTTON_LANGUAGE", "b_settings_language.png", language_cb },
103 #if !defined(FEATURE_SETTING_SDK) && !defined(FEATURE_SETTING_EMUL)
104 //{ "Safety", "b_settings_safety.png", safety_cb },
107 // factory reset is not supported in tizen_2.3
109 { "IDS_ST_BODY_RESET_GEAR_ABB", "b_settings_reset.png", reset_gear_cb },
112 #ifndef FEATURE_SETTING_EMUL
113 { "IDS_ST_BUTTON_GEAR_INFO", "b_settings_info.png", gear_info_cb },
118 static int is_emergency;
119 static Elm_Object_Item * lang_item = NULL;
120 static bool running = false;
121 static Ecore_Timer *running_timer = NULL;
122 static Ecore_Timer *scrl_timer = NULL;
124 static Evas_Object* _create_bg(Evas_Object *parent);
125 static Evas_Object* _create_conform(Evas_Object *parent);
126 static Evas_Object* _create_layout_main(Evas_Object* parent);
127 static Evas_Object* _create_naviframe_layout(Evas_Object* parent);
128 static void _create_view_layout(appdata *ad);
129 static int init_clocksetting(appdata *ad);
130 static Eina_Bool _app_ctrl_timer_cb(void *data);
131 static Eina_Bool _scroller_timer_cb(void *data);
133 #ifdef FEATURE_SETTING_CHANGEABLE
135 static Ea_Theme_Color_Table* _changeable_colors_set(void)
137 Ea_Theme_Color_Table *table;
139 /* Enable changeable UI */
140 ea_theme_changeable_ui_enabled_set(EINA_TRUE);
142 table = ea_theme_color_table_new(COLOR_INFO_TABLE);
143 ea_theme_colors_set(table, EA_THEME_STYLE_DEFAULT);
148 static void _changeable_colors_free(Ea_Theme_Color_Table *table)
150 // when the process is killed, you don’t need to call this
151 //ea_theme_colors_unset(table, EA_THEME_STYLE_DEFAULT); // This API will be removed.
152 ea_theme_color_table_free(table);
156 void clock_cb(void *data, Evas_Object *obj, void *event_info)
158 Evas_Object* layout = NULL;
159 Elm_Object_Item *nf_it = NULL;
164 DBG("Setting - ad is null");
169 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
173 if (is_running_clock) {
174 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
178 initialize_clock(data);
180 //genlist = _create_clock_list(data);
181 layout = _clock_type_cb(data);
184 DBG("%s", "clock cb - layout is null");
187 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
188 evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _clear_clock_cb, ad);
189 //elm_naviframe_item_pop_cb_set(nf_it, _clear_clock_cb, ad);
190 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
192 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
193 is_running_clock = 1;
195 ad->MENU_TYPE = SETTING_CLOCK;
198 void notification_cb(void *data, Evas_Object *obj, void *event_info)
200 Evas_Object* genlist = NULL;
201 Elm_Object_Item *nf_it = NULL;
206 DBG("Setting - ad is null");
211 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
217 genlist = _create_noti_list(data);
220 DBG("%s", "notification_cb - genlist is null");
223 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
224 elm_naviframe_item_pop_cb_set(nf_it, _clear_noti_cb, ad);
225 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
227 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
229 ad->MENU_TYPE = SETTING_NOTIFICATION;
232 void homescreen_cb(void *data, Evas_Object *obj, void *event_info)
234 Evas_Object* layout = NULL;
235 Elm_Object_Item *nf_it = NULL;
240 DBG("Setting - ad is null");
245 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
249 //layout = _create_homescreen_list(data);
250 layout = create_wallpaper_list(data);
253 DBG("%s", "homescreen cb - layout is null");
256 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
257 //elm_naviframe_item_pop_cb_set(nf_it, _clear_homescreen_cb, ad);
258 evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _clear_homescreen_cb, ad);
259 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
261 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
263 ad->MENU_TYPE = SETTING_HOMESCREEN;
267 void sound_cb(void *data, Evas_Object *obj, void *event_info)
269 Evas_Object* genlist = NULL;
270 Elm_Object_Item *nf_it = NULL;
275 DBG("Setting - ad is null");
280 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
286 genlist = _create_sound_list(data);
289 DBG("%s", "sound cb - genlist is null");
292 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
293 elm_naviframe_item_pop_cb_set(nf_it, _clear_sound_cb, ad);
294 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
296 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
298 ad->MENU_TYPE = SETTING_SOUND;
301 void volume_cb(void *data, Evas_Object *obj, void *event_info)
303 Evas_Object* genlist = NULL;
304 Elm_Object_Item *nf_it = NULL;
309 DBG("Setting - ad is null");
314 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
318 _initialize_volume();
320 genlist = _create_volume_list(data);
323 DBG("%s", "volume cb - genlist is null");
326 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
327 //elm_naviframe_item_pop_cb_set(nf_it, _clear_volume_cb, ad);
328 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
330 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
332 ad->MENU_TYPE = SETTING_VOLUME;
335 void display_cb(void *data, Evas_Object *obj, void *event_info)
337 Evas_Object* genlist = NULL;
338 Elm_Object_Item *nf_it = NULL;
343 DBG("Setting - ad is null");
348 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
354 genlist = _create_display_list(data);
357 DBG("%s", "display cb - genlist is null");
360 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
361 //elm_naviframe_item_pop_cb_set(nf_it, _clear_display_cb, ad);
362 evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, _clear_display_cb, ad);
363 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
365 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
367 ad->MENU_TYPE = SETTING_DISPLAY;
370 void keyboard_cb(void *data, Evas_Object *obj, void *event_info)
372 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
378 DBG("Setting - ad is null");
387 app_control_h service;
388 app_control_create(&service);
389 app_control_set_package(service, "org.tizen.w-text-input-setting");
390 app_control_send_launch_request(service, NULL, NULL);
391 app_control_destroy(service);
396 ecore_timer_del(running_timer);
397 running_timer = NULL;
399 running_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_app_ctrl_timer_cb, NULL);
403 void battery_cb(void *data, Evas_Object *obj, void *event_info)
405 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
407 Evas_Object* layout = NULL;
408 Elm_Object_Item *nf_it = NULL;
413 DBG("Setting - ad is null");
418 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
422 _initialize_battery();
423 layout = _battery_status_cb(data);
426 DBG("%s", "battery cb - layout is null");
429 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
430 //elm_naviframe_item_pop_cb_set(nf_it, _clear_battery_list_cb, ad);
431 evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _clear_battery_cb, ad);
432 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
434 ad->MENU_TYPE = SETTING_BATTERY;
437 void bluetooth_cb(void *data, Evas_Object *obj, void *event_info)
439 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
441 Evas_Object* genlist = NULL;
442 Elm_Object_Item *nf_it = NULL;
447 DBG("Setting - ad is null");
457 genlist = _create_bt_list(data);
460 DBG("%s", "bluetooth cb - genlist is null");
463 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
464 //elm_naviframe_item_pop_cb_set(nf_it, _clear_bluetooth_cb, ad);
465 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
467 ad->MENU_TYPE = SETTING_BLUETOOTH;
470 void motion_cb(void *data, Evas_Object *obj, void *event_info)
472 Evas_Object* genlist = NULL;
473 Elm_Object_Item *nf_it = NULL;
478 DBG("Setting - ad is null");
483 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
487 _initialize_motion();
488 genlist = _create_motion_list(data);
491 DBG("%s", "motion cb - genlist is null");
494 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
495 elm_naviframe_item_pop_cb_set(nf_it, _clear_motion_cb, ad);
496 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
498 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
501 void lockscreen_cb(void *data, Evas_Object *obj, void *event_info)
503 Evas_Object* layout = NULL;
504 Elm_Object_Item *nf_it = NULL;
510 DBG("Setting - ad is null");
515 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
519 layout = create_privacy_list(data);
522 DBG("%s", "lockscreen cb - genlist is null");
526 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
527 elm_naviframe_item_pop_cb_set(nf_it, clear_privacy_cb, ad);
528 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
530 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
532 ad->MENU_TYPE = SETTING_SCREEN_LOCK;
535 void double_pressing_cb(void *data, Evas_Object *obj, void *event_info)
537 Evas_Object* layout = NULL;
538 Elm_Object_Item *nf_it = NULL;
544 DBG("Setting - ad is null");
549 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
553 init_double_pressing(ad);
555 layout = create_double_app_list(data);
558 DBG("%s", "double cb - genlist is null");
562 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
563 evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, clear_double_app_cb, ad);
564 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
566 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
568 ad->MENU_TYPE = SETTING_DOUBLE_PRESSING;
571 void language_cb(void *data, Evas_Object *obj, void *event_info)
573 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
575 Evas_Object* genlist = NULL;
576 Elm_Object_Item *nf_it = NULL;
581 DBG("Setting - ad is null");
586 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
590 if( is_connected_GM() )
592 DBG("Setting - language can not change!!");
595 struct _toast_data * toast = _create_toast(ad, _("IDS_ST_TPOP_CHANGE_LANGUAGE_ON_MOBILE_DEVICE"));
597 _show_toast(ad, toast);
602 _initialize_language(ad);
603 _set_launguage_update_cb(_update_main_menu_title);
605 genlist = _create_lang_list(data);
608 DBG("%s", "language cb - genlist is null");
611 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
612 elm_naviframe_item_pop_cb_set(nf_it, _clear_lang_cb, ad);
613 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
615 ad->MENU_TYPE = SETTING_LANGUAGE;
618 void safety_cb(void *data, Evas_Object *obj, void *event_info)
620 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
625 DBG("Setting - ad is null");
630 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
634 Evas_Object* layout = NULL;
635 Elm_Object_Item *nf_it = NULL;
637 layout = create_safety_list(ad);
640 DBG("%s", "safety cb - genlist is null");
644 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
645 elm_naviframe_item_pop_cb_set(nf_it, clear_safety_cb, ad);
646 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
648 ad->MENU_TYPE = SETTING_SAFETY;
651 void reset_gear_cb(void *data, Evas_Object *obj, void *event_info)
656 DBG("Setting - ad is null");
661 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
665 _reset_popup_cb(data, obj, event_info);
667 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
669 ad->MENU_TYPE = SETTING_RESET;
672 void gear_info_cb(void *data, Evas_Object *obj, void *event_info)
674 Evas_Object* genlist = NULL;
675 Elm_Object_Item *nf_it = NULL;
680 DBG("Setting - ad is null");
685 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
689 genlist = _create_info_list(data);
692 DBG("%s", "info cb - genlist is null");
695 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
696 elm_naviframe_item_pop_cb_set(nf_it, _clear_info_cb, ad);
697 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
699 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
701 ad->MENU_TYPE = SETTING_INFO;
704 static Eina_Bool _app_ctrl_timer_cb(void *data) {
707 running_timer = NULL;
708 return ECORE_CALLBACK_CANCEL;
711 static Eina_Bool _scroller_timer_cb(void *data) {
712 DBG("hide scroller bar");
714 Evas_Object *genlist = data;
717 elm_layout_signal_emit(genlist, "do-hide-vbar", "");
719 return ECORE_CALLBACK_CANCEL;
722 void profile_cb(void *data, Evas_Object *obj, void *event_info)
728 DBG("Setting - ad is null");
733 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
738 _create_profile(data, obj, event_info);
742 ecore_timer_del(running_timer);
743 running_timer = NULL;
745 running_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_app_ctrl_timer_cb, NULL);
747 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
750 static void _quit_cb(void *data, Evas_Object *obj, void *ei)
753 //To make your application go to background,
754 //Call the elm_win_lower() instead
755 Evas_Object *win = (Evas_Object *) data;
761 static Eina_Bool _pop_cb(void *data, Elm_Object_Item *it)
763 // Stop timer and task
766 ecore_timer_del(running_timer);
767 running_timer = NULL;
773 ecore_timer_del(scrl_timer);
777 if (ad && ad->win_main)
779 elm_win_lower(ad->win_main);
785 static Evas_Object* _create_bg(Evas_Object *parent)
789 if (parent == NULL) return NULL;
791 bg = elm_bg_add(parent);
792 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
793 elm_win_resize_object_add(parent, bg);
794 evas_object_show(bg);
799 static Evas_Object* _create_conform(Evas_Object *parent)
801 Evas_Object *conform;
803 if (parent == NULL) return NULL;
805 conform = elm_conformant_add(parent);
806 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
807 elm_win_resize_object_add(parent, conform);
808 evas_object_show(conform);
813 static Evas_Object* _create_layout_main(Evas_Object* parent)
817 if (parent == NULL) return NULL;
819 layout = elm_layout_add(parent);
823 DBG("Failed elm_layout_add.\n");
827 elm_layout_theme_set(layout, "layout", "application", "default");
828 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
829 elm_win_resize_object_add(parent, layout);
831 evas_object_show(layout);
836 static void _lang_changed(void *data)
839 if( ad && ad->MENU_TYPE == SETTING_LANGUAGE )
842 char *locale = vconf_get_str(VCONFKEY_LANGSET);
845 DBG("Setting - language is changed : %s", locale);
846 elm_language_set(locale);
847 elm_config_all_flush();
851 static void _window_resize_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
853 appdata *ad = (appdata *)data;
854 evas_object_geometry_get(ad->win_main, NULL, NULL, &ad->root_w, &ad->root_h);
857 static void init_values(appdata *ad)
864 ad->is_motion_smart_relay_on = 1;
865 ad->is_motion_wake_up_on = 1;
868 static int init_clocksetting(appdata *ad)
870 DBG("init_clocksetting() is called!");
875 ad->bg = _create_bg(ad->win_main);
877 // Conformant *** disable comform : lauching time issue ***
879 ad->conform = _create_conform(ad->win_main);
880 if (ad->conform == NULL)
884 ad->layout_main = _create_layout_main(ad->win_main);
885 if (ad->layout_main == NULL)
889 elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
892 ad->nf = _create_naviframe_layout(ad->layout_main);
895 _create_view_layout(ad);
899 int vibration_level = 0;
900 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vibration_level);
902 DBG("Setting - vibration level : %d", vibration_level);
904 if( vibration_level == 2 ) // wrong value!!
906 vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
907 vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
912 static Evas_Object* _create_naviframe_layout(Evas_Object* parent)
914 Evas_Object *nf = NULL;
916 if (parent == NULL) return NULL;
918 nf = elm_naviframe_add(parent);
919 elm_object_part_content_set(parent, "elm.swallow.content", nf);
921 evas_object_show(nf);
926 static char* _gl_text_get(void *data, Evas_Object *obj, const char *part)
929 Item_Data *id = data;
930 int index = id->index;
934 if( index == LANGUAGE_MENU_INDEX ) {
935 if( is_connected_GM() ) {
936 strcpy(expression, "<font color=#515151>%s</font>");
938 strcpy(expression, "%s");
941 strcpy(expression, "%s");
945 snprintf(buf, sizeof(buf)-1, "%s", _(setting_emergency_menu_its[index].name));
947 snprintf(buf, sizeof(buf)-1, "%s", _(setting_menu_its[index].name));
952 static Evas_Object * _gl_icon_get(void *data, Evas_Object *obj, const char *part)
955 Item_Data *id = data;
956 int index = id->index;
958 if( index == LANGUAGE_MENU_INDEX ) {
959 if( is_connected_GM() ) {
960 snprintf(buf, sizeof(buf)-1, "%s", LANGUAGE_ICON_DISABLED);
962 snprintf(buf, sizeof(buf)-1, "%s", LANGUAGE_ICON_ENABLED);
966 snprintf(buf, sizeof(buf)-1, "%s", setting_emergency_menu_its[index].icon_name);
968 snprintf(buf, sizeof(buf)-1, "%s", setting_menu_its[index].icon_name);
971 Evas_Object *icon = elm_image_add(obj);
972 elm_image_file_set(icon, EDJE_PATH, buf);
973 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
974 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
975 evas_object_size_hint_min_set(icon, 52, 52);
980 static void _gl_del(void *data, Evas_Object *obj)
982 Item_Data *id = data;
987 static Evas_Object * _gl_indicator_get(void *data, Evas_Object *obj, const char *part)
989 Evas_Object *layout = NULL;
991 layout = elm_layout_add(obj);
992 elm_layout_file_set(layout, EDJE_PATH, "setting/indicator");
994 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
995 indicator_view_update(layout);
996 evas_object_show(layout);
997 DBG("indicator get!!!!!!!!");
1002 static Evas_Object* _create_mainlist_winset(Evas_Object* parent, appdata* ad)
1004 Evas_Object *genlist = NULL;
1005 struct _menu_item *menu_its = NULL;
1008 // Create item class
1009 elm_theme_extension_add(NULL, EDJE_PATH);
1010 Elm_Genlist_Item_Class *itc_tmp = elm_genlist_item_class_new();
1011 itc_tmp->item_style = "setting_indicator";
1012 itc_tmp->func.content_get = _gl_indicator_get;
1013 itc_tmp->func.del = _gl_del;
1015 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
1016 itc->item_style = "1text.1icon";
1017 itc->func.text_get = _gl_text_get;
1018 itc->func.content_get = _gl_icon_get;
1019 itc->func.del = _gl_del;
1021 genlist = elm_genlist_add(ad->nf);
1024 elm_genlist_item_class_free(itc);
1027 elm_genlist_realization_mode_set(genlist, EINA_TRUE);
1028 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1030 Item_Data *id_indi = calloc(sizeof(Item_Data), 1);
1031 id_indi->index = idx;
1032 id_indi->item = elm_genlist_item_append(
1037 ELM_GENLIST_ITEM_NONE,
1039 elm_genlist_item_select_mode_set(id_indi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1042 vconf_get_bool(VCONFKEY_SETAPPL_EMERGENCY_STATUS_BOOL, &is_emergency);
1049 menu_its = setting_emergency_menu_its;
1050 item_count = sizeof(setting_emergency_menu_its) / sizeof(struct _menu_item);
1054 menu_its = setting_menu_its;
1055 item_count = sizeof(setting_menu_its) / sizeof(struct _menu_item);
1058 DBG("Setting - Main menu item count: %d", item_count);
1060 //while (menu_its[ idx ].name != NULL) {
1061 for( idx = 0; idx < item_count-1; idx++ )
1063 Item_Data *id = calloc(sizeof(Item_Data), 1);
1065 id->item = elm_genlist_item_append(
1066 genlist, // genlist object
1070 ELM_GENLIST_ITEM_NONE,
1071 menu_its[ idx ].func,
1075 if( !is_emergency && ( idx == LANGUAGE_MENU_INDEX ) )
1077 lang_item = id->item;
1083 elm_genlist_item_class_free(itc);
1084 elm_genlist_item_class_free(itc_tmp);
1086 ad->main_genlist = genlist;
1088 indicator_set_vconf_changed_cb(ad);
1093 static void _update_main_menu_title( void * data )
1095 DBG("_update_main_menu_title() is called");
1097 appdata * ad = data;
1100 DBG("appdata is NULL");
1104 if( ad->main_genlist )
1106 elm_genlist_realized_items_update(ad->main_genlist);
1110 static void _naviframe_back_cb(void * data, Evas_Object * obj, void * event_info)
1112 appdata * ad = data;
1116 if(ad->MENU_TYPE == SETTING_BLUETOOTH)
1118 clear_bt_resource();
1119 ad->MENU_TYPE = SETTING_MAIN;
1121 else if(ad->MENU_TYPE == SETTING_VOLUME_2_DEPTH)
1123 _clear_volume_resources();
1125 ad->MENU_TYPE = SETTING_VOLUME;
1127 else if(ad->MENU_TYPE == SETTING_SOUND_RINGTONE)
1131 ad->MENU_TYPE = SETTING_SOUND;
1133 else if(ad->MENU_TYPE == SETTING_SOUND_NOTIFICATION)
1137 ad->MENU_TYPE = SETTING_SOUND;
1140 ea_naviframe_back_cb(data, obj, event_info);
1143 static void _create_view_layout(appdata *ad)
1145 Evas_Object *genlist = NULL;
1146 Evas_Object *btn = NULL;
1147 Elm_Object_Item *nf_it = NULL;
1149 if (ad == NULL) return;
1150 if (ad->nf == NULL) return;
1152 genlist = _create_mainlist_winset(ad->win_main, ad);
1153 ea_object_event_callback_add(ad->nf, EA_CALLBACK_BACK, _naviframe_back_cb, ad);
1154 ea_object_event_callback_add(ad->nf, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
1156 nf_it = elm_naviframe_item_push(ad->nf, NULL, btn, NULL, genlist, NULL);
1157 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
1159 elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, ad); // ad->win_main
1161 //register_vconf_changing(VCONFKEY_WMS_WMANAGER_CONNECTED, change_language_enabling, NULL);
1164 static Evas_Object* create_win(const char *name)
1168 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
1172 elm_win_title_set(eo, name);
1173 elm_win_autodel_set(eo, EINA_TRUE);
1175 if (elm_win_wm_rotation_supported_get(eo)) {
1176 int rots[4] = { 0, 90, 180, 270 };
1177 elm_win_wm_rotation_available_rotations_set(eo, (const int*)(&rots), 4);
1180 evas_object_smart_callback_add(eo, "delete,request", _quit_cb, NULL);
1185 bool app_create(void *data)
1187 //DBG("[TIME] 3. it taked %d msec from main to setting_main_app_create ", appcore_measure_time());
1188 //appcore_measure_start();
1190 DBG("Setting - app_create");
1192 appdata *ad = (appdata *) data;
1195 DBG("app_create start.");
1197 ecore_x_window_size_get(ecore_x_window_root_first_get(), &ad->root_w, &ad->root_h);
1199 ad->win_main = create_win(PACKAGE);
1200 if (ad->win_main == NULL)
1203 evas_object_resize(ad->win_main, ad->root_w, ad->root_h);
1204 //evas_object_event_callback_add(ad->win_main, EVAS_CALLBACK_RESIZE, _window_resize_cb, ad);
1206 double scale = elm_config_scale_get();
1209 DBG("Setting - scale is more less than 1.0");
1210 elm_config_scale_set(1.0);
1213 ad->evas = evas_object_evas_get(ad->win_main);
1215 //appcore_set_i18n(PACKAGE, LOCALEDIR);
1216 //appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, _lang_changed, ad);
1218 locale = vconf_get_str(VCONFKEY_LANGSET);
1221 elm_language_set(locale);
1224 #ifdef FEATURE_SETTING_CHANGEABLE
1225 // set color table for changeable color
1226 ad->color_table = _changeable_colors_set();
1229 ad->is_first_launch = 1;
1231 init_clocksetting(ad);
1233 DBG("app_create finish.");
1235 DBG("[TIME] 4. setting_main_app_create taked %d msec ", appcore_measure_time());
1236 //appcore_measure_start();
1238 evas_object_show(ad->win_main);
1243 void app_terminate(void *data)
1245 DBG("Setting - app_terminate");
1249 indicator_unset_vconf_changed_cb();
1253 ad->alert_rdg = NULL;
1257 ad->datetime = NULL;
1259 if( ad->dt_genlist_item_of_date )
1261 ad->dt_genlist_item_of_date = NULL;
1263 if( ad->dt_genlist_item_of_time )
1265 ad->dt_genlist_item_of_time = NULL;
1267 if( ad->pref_arm_rdg )
1269 ad->pref_arm_rdg = NULL;
1271 if( ad->main_genlist )
1273 ad->main_genlist = NULL;
1275 if( ad->double_rdg )
1277 ad->double_rdg = NULL;
1279 if( ad->font_size_rdg )
1281 ad->font_size_rdg = NULL;
1283 if( ad->language_item )
1285 ad->language_item = NULL;
1287 if( ad->language_rdg )
1289 ad->language_rdg = NULL;
1292 /* unregister motion vconf changed callback */
1293 //unregister_vconf_changing(VCONFKEY_WMS_WMANAGER_CONNECTED, change_language_enabling);
1295 #ifdef FEATURE_SETTING_CHANGEABLE
1296 if (ad->color_table) {
1297 _changeable_colors_free(ad->color_table);
1298 ad->color_table = NULL;
1303 void app_pause(void *data)
1305 DBG("Setting - app_pause()");
1310 if( ad->MENU_TYPE == SETTING_VOLUME_2_DEPTH )
1312 _stop_all_volume_sound();
1314 else if( ad->MENU_TYPE == SETTING_SOUND_RINGTONE ||
1315 ad->MENU_TYPE == SETTING_SOUND_NOTIFICATION )
1317 _stop_all_sound_play();
1319 else if(ad->MENU_TYPE == SETTING_BATTERY)
1321 _clear_battery_cb(NULL, NULL, NULL, NULL);
1323 else if( ad->MENU_TYPE == SETTING_SOUND )
1325 _stop_all_sound_play();
1330 void app_resume(void *data)
1332 DBG("Setting - app_resume()");
1340 void app_reset(app_control_h service, void *data)
1342 DBG("Setting - app_reset()");
1346 char *operation = NULL;
1347 app_control_get_operation(service, &operation);
1348 DBG("operation : %s", operation);
1349 if (!ad->is_first_launch) {
1350 if (operation && !strcmp(operation, "http://tizen.org/appcontrol/operation/main")) {
1351 Elm_Object_Item *bottom = elm_naviframe_bottom_item_get(ad->nf);
1352 Elm_Object_Item *top = elm_naviframe_top_item_get(ad->nf);
1355 evas_object_del(ad->popup);
1359 while (bottom != top) {
1360 elm_object_item_del(top);
1361 top = elm_naviframe_top_item_get(ad->nf);
1364 if (ad->main_genlist) {
1365 elm_genlist_item_show(elm_genlist_first_item_get(ad->main_genlist),
1366 ELM_GENLIST_ITEM_SCROLLTO_TOP);
1367 elm_layout_signal_emit(ad->main_genlist, "do-show-vbar", "");
1370 ecore_timer_del(scrl_timer);
1373 scrl_timer = ecore_timer_add(1, (Ecore_Task_Cb)_scroller_timer_cb, ad->main_genlist);
1377 ad->is_first_launch = 0;
1382 elm_win_activate(ad->win_main);
1385 ad->MENU_TYPE = SETTING_MAIN;
1387 /* Register language change vconf */
1388 //register_vconf_changing(VCONFKEY_WMS_WMANAGER_CONNECTED, change_language_enabling, NULL);
1392 int main(int argc, char *argv[])
1394 DBG("%s,%d", __func__, __LINE__);
1398 app_event_callback_s event_callback;
1400 event_callback.create = app_create;
1401 event_callback.terminate = app_terminate;
1402 event_callback.pause = app_pause;
1403 event_callback.resume = app_resume;
1404 event_callback.app_control = app_reset;
1405 event_callback.low_memory = NULL;
1406 event_callback.low_battery = NULL;
1407 event_callback.device_orientation = NULL;
1408 event_callback.language_changed = _lang_changed;
1409 event_callback.region_format_changed = NULL;
1411 memset(&ad, 0x0, sizeof(appdata));
1413 return app_efl_main(&argc, &argv, &event_callback, &ad);
1417 int main(int argc, char *argv[])
1421 DBG("[TIME] 1. aul_launch -> main :: Setting main : %d msec ", appcore_measure_time_from("APP_START_TIME"));
1422 appcore_measure_start();
1424 struct appcore_ops ops = {
1425 .create = app_create,
1426 .terminate = app_terminate,
1428 .resume = app_resume,
1432 memset(&ad, 0x0, sizeof(appdata));
1435 ad.MENU_TYPE = SETTING_MAIN;
1437 DBG("[TIME] 2. main : %d msec ", appcore_measure_time());
1438 appcore_measure_start();
1440 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);