Modify the drawing strategy of 'Setting->about phone' and to fix the blank issue..
authorJing Yigang <yigang.jing@samsung.com>
Tue, 28 Aug 2012 04:25:58 +0000 (12:25 +0800)
committerJing Yigang <yigang.jing@samsung.com>
Tue, 28 Aug 2012 04:25:58 +0000 (12:25 +0800)
Change-Id: If99a363cb0658abc80fd23b284491f121bef25cc

setting-about/include/setting-about.h
setting-about/src/setting-about-main.c
setting-about/src/setting-about.c

index 222d320..c3006c7 100755 (executable)
@@ -58,7 +58,7 @@ struct _SettingAboutUG {
        ui_gadget_h ug;
        TapiHandle *handle;
        bool tapi_responsed;
-       
+
        setting_view *view_to_load;
 
        Elm_Genlist_Item_Class itc_1text;
@@ -98,7 +98,7 @@ struct _SettingAboutUG {
 
 extern setting_view setting_view_about_main;
 extern int setting_about_generate_genlist(void *data);
-void setting_about_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
-                                 void *priv);
+void setting_about_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
+void setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info);
 
 #endif                         /* __SETTING_ABOUT_H__ */
index 536d60f..352c3e5 100755 (executable)
@@ -81,7 +81,6 @@ static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
 static void __setting_about_main_certificates_clicked(void *data);
 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj);
 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj);
-static void __setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info);
 /* ***************************************************
  *
  *basic func
@@ -622,7 +621,8 @@ int setting_about_generate_genlist(void *data)
        /* error check */
        retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
 
-       SettingAboutUG *ad = (SettingAboutUG *) data; 
+       SettingAboutUG *ad = (SettingAboutUG *) data;
+       bool is_emul_bin = isEmulBin();
 
        Evas_Object *scroller = ad->genlsit;
        Elm_Object_Item *item = NULL;
@@ -705,7 +705,7 @@ int setting_about_generate_genlist(void *data)
                }
        } else if (ad->my_numbers.count > 1){
                setting_enable_expandable_genlist(scroller, ad,
-                                         __setting_about_main_exp_cb, NULL);
+                                         setting_about_main_exp_cb, NULL);
                item_data = setting_create_Gendial_exp_parent_field(scroller,
                                                    &(ad->itc_2text_3_parent),
                                                    NULL, NULL,
@@ -749,7 +749,7 @@ int setting_about_generate_genlist(void *data)
        }
 
        // [UI] Bluetooth address
-       if ( ! isEmulBin()) { // requested by DI Kim due to BT BS on 11/26
+       if ( ! is_emul_bin) { // requested by DI Kim due to BT BS on 11/26
                memset(str, 0x00, sizeof(str));
                setting_about_main_get_bluetooth_address_string(str, sizeof(str));
                ad->item_data_bt =
@@ -822,7 +822,7 @@ int setting_about_generate_genlist(void *data)
 
 #ifdef SUPPORT_DIAG_USAGE
        // [UI] Diagnostics and Usage
-       if (!isEmulBin()) {
+       if (!is_emul_bin) {
                setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
                                         setting_about_main_mouse_up_Gendial_list_cb,
                                         ad, SWALLOW_Type_INVALID, NULL, NULL,
@@ -833,7 +833,7 @@ int setting_about_generate_genlist(void *data)
 
 #ifdef SUPPORT_FOTA
        // [UI] Software update
-       if (!isEmulBin()) {
+       if (!is_emul_bin) {
                setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
                                         setting_about_main_mouse_up_Gendial_list_cb,
                                         ad, SWALLOW_Type_INVALID, NULL, NULL,
@@ -897,19 +897,7 @@ static int setting_about_main_create(void *cb)
 
        ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
 
-       int err = 0;
-       int value;
-       setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
-       if (VCONFKEY_TELEPHONY_SIM_INSERTED != value)
-       {
-               setting_about_generate_genlist((void *)ad);
-       } else {
-               if (ad->handle && !ad->tapi_responsed) {//not responsed yet
-                       //SETTING_TRACE(">>> IF THERE'S SIM CARD, THIS LINE SHOULD NOT WORK");
-               } else {//already responsed
-                       // do nothing
-               }
-       }
+       setting_about_generate_genlist((void *)ad);
 
        setting_view_about_main.is_create = 1;
        SETTING_TRACE_END;
@@ -1270,97 +1258,4 @@ static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
        }
 }
 
-void __setting_about_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       SETTING_TRACE_BEGIN;
-       /* error check */
-       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
-       Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
-       Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
-       elm_genlist_item_selected_set(subitem, 0);
-       Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
-       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
-       ret_if(NULL == data_subItem || NULL == data_parentItem);
-
-
-       int err;
-       setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
-       setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
-
-       data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
-       elm_object_item_data_set(data_parentItem->item, data_parentItem);
-       elm_genlist_item_update(data_parentItem->item);
-       elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
-}
-
-static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
-
-{
-       SETTING_TRACE_BEGIN;
-       retm_if(data == NULL, "Data parameter is NULL");
-       Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
-
-       Elm_Object_Item *subItem = list_item->item;
-       Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
-
-       Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
-       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
-       ret_if(NULL == data_subItem || NULL == data_parentItem);
-
-       int err;
-       setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
-
-       ret_if(0 != err);
-       data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
-       elm_object_item_data_set(data_parentItem->item, data_parentItem);
-       elm_genlist_item_update(data_parentItem->item);
-       elm_radio_value_set(obj, data_subItem->chk_status);
-}
-
-static void __setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       SETTING_TRACE_BEGIN;
-       setting_retm_if(data == NULL, "Data parameter is NULL");
-       setting_retm_if(event_info == NULL, "event_info parameter is NULL");
-
-       SettingAboutUG *ad = (SettingAboutUG *) data;
-       Elm_Object_Item *parentItem = event_info;       /* parent item */
-       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);
-       Evas_Object *scroller = elm_object_item_widget_get(parentItem);
-
-       Evas_Object *rgd = elm_radio_add(scroller);
-       elm_radio_value_set(rgd, -1);
-
-       int err;
-       char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
-       setting_get_string_slp_key(data_parentItem->int_slp_setting_binded, sel_num, &err);
-       SETTING_TRACE("binded: %d, checked: %s, err: %d", data_parentItem->int_slp_setting_binded, sel_num, err);
-
-       int i = 0;
-       int sel_idx = -1;
-       Setting_GenGroupItem_Data *item_data = NULL;
-       for(; i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
-               if (ad->my_numbers.list[i].num == NULL) {
-                       break;
-               }
-
-               if (sel_idx == -1 && 0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
-                       sel_idx = i;
-               }
-               item_data = setting_create_Gendial_exp_sub_field(scroller,
-                                       &(ad->itc_1icon_1text_sub),
-                                       __setting_about_sub_list_sel_cb, ad, parentItem,
-                                       SWALLOW_Type_1RADIO, rgd,
-                                       i,
-                                       ad->my_numbers.list[i].num, __setting_about_sub_list_rd_change);
-               if (item_data) {
-                       item_data->userdata = ad;
-                       //elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-               } else {
-                       SETTING_TRACE_ERROR("item_data is NULL");
-               }
-       }
-
-       elm_radio_value_set(rgd, sel_idx);
-}
 
index a796bf8..d9fd17b 100755 (executable)
@@ -240,6 +240,66 @@ static void setting_about_ug_on_key_event(ui_gadget_h ug,
        }
 }
 
+static void __about_gl_sel_expand(void *data, Evas_Object *obj,
+                                  void *event_info)
+{
+       /* SETTING_TRACE_BEGIN; */
+       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+       Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+       elm_genlist_item_selected_set(item, 0);
+       bool status = !elm_genlist_item_expanded_get(item);
+       elm_genlist_item_expanded_set(item, status);
+}
+
+Eina_Bool __insert_item_idler(void *data)
+{
+       SETTING_TRACE_BEGIN;
+       retv_if(!data, FALSE);
+       SettingAboutUG *ad = data;
+       if (ad->item_dev_name) //the genlist exists already.
+       {
+               SETTING_TRACE("Beging to insert items...");
+               // [UI] My number
+               int err;
+               char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
+               setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
+
+               Setting_GenGroupItem_Data *item_data = NULL;
+               if (ad->my_numbers.count == 1) {
+                       item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
+                       setting_retm_if(!item_data, "calloc item_data failed");
+                       item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
+                       item_data->sub_desc = (char *)g_strdup(sel_num);
+                       item_data->swallow_type = SWALLOW_Type_INVALID;
+
+                       item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_2),
+                                                             item_data, NULL,
+                                                             ad->item_dev_name->item,
+                                                             ELM_GENLIST_ITEM_NONE,
+                                                             NULL, NULL);
+                       elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+               } else if (ad->my_numbers.count > 1) {
+                       setting_enable_expandable_genlist(ad->genlsit, ad,
+                                                 setting_about_main_exp_cb, NULL);
+                       item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
+                       setting_retm_if(!item_data, "calloc item_data failed");
+                       item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
+                       item_data->sub_desc = (char *)g_strdup(sel_num);
+                       item_data->swallow_type = SWALLOW_Type_INVALID;
+
+                       item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
+                       item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_3_parent),
+                                                             item_data, NULL,
+                                                             ad->item_dev_name->item,
+                                                             ELM_GENLIST_ITEM_TREE,
+                                                             __about_gl_sel_expand, NULL);
+               }
+       }
+
+       return FALSE;
+}
+
 static void __on_sim_get_msisdn(TapiHandle *handle, int result, void *data, void *user_data)
 {
        SETTING_TRACE_BEGIN;
@@ -272,7 +332,7 @@ static void __on_sim_get_msisdn(TapiHandle *handle, int result, void *data, void
        setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
 
        bool isFound = FALSE;
-       SETTING_TRACE("ad->my_numbers.count[%d]", ad->my_numbers.count);
+       //SETTING_TRACE("ad->my_numbers.count[%d]", ad->my_numbers.count);
 
        for (i = 0; i < ad->my_numbers.count && i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
                SETTING_TRACE("index[%d] - name[%s], num[%s]", i, ad->my_numbers.list[i].name, ad->my_numbers.list[i].num);
@@ -290,7 +350,8 @@ static void __on_sim_get_msisdn(TapiHandle *handle, int result, void *data, void
                evas_object_del(ad->popup);
                ad->popup = NULL;
        }
-       setting_about_generate_genlist((void *)ad);
+       //setting_about_generate_genlist((void *)ad);
+       ecore_idler_add(__insert_item_idler, ad);
 }
 
 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
@@ -316,6 +377,7 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
        if (VCONFKEY_TELEPHONY_SIM_INSERTED == value)//There is a sim card, so do display to user
        {
                aboutUG->handle = tel_init(NULL);
+               SETTING_TRACE("aboutUG->handle:%p", aboutUG->handle);
                if (aboutUG->handle) {
                        SETTING_TRACE("tel_init sucessed, and there is at least one sim card, now trying to get misidns");
                        if (tel_get_sim_msisdn(aboutUG->handle, __on_sim_get_msisdn, aboutUG) == TAPI_API_SUCCESS) {
@@ -380,6 +442,100 @@ void setting_about_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
        SETTING_TRACE_END;
 }
 
+static void __setting_about_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       SETTING_TRACE_BEGIN;
+       /* error check */
+       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+       Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
+       Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
+       elm_genlist_item_selected_set(subitem, 0);
+       Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
+       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
+       ret_if(NULL == data_subItem || NULL == data_parentItem);
+
+
+       int err;
+       setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
+       setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
+
+       data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
+       elm_object_item_data_set(data_parentItem->item, data_parentItem);
+       elm_genlist_item_update(data_parentItem->item);
+       elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
+}
+
+static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
+
+{
+       SETTING_TRACE_BEGIN;
+       retm_if(data == NULL, "Data parameter is NULL");
+       Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
+
+       Elm_Object_Item *subItem = list_item->item;
+       Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
+
+       Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
+       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
+       ret_if(NULL == data_subItem || NULL == data_parentItem);
+
+       int err;
+       setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
+
+       ret_if(0 != err);
+       data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
+       elm_object_item_data_set(data_parentItem->item, data_parentItem);
+       elm_genlist_item_update(data_parentItem->item);
+       elm_radio_value_set(obj, data_subItem->chk_status);
+}
+
+void setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       SETTING_TRACE_BEGIN;
+       setting_retm_if(data == NULL, "Data parameter is NULL");
+       setting_retm_if(event_info == NULL, "event_info parameter is NULL");
+
+       SettingAboutUG *ad = (SettingAboutUG *) data;
+       Elm_Object_Item *parentItem = event_info;       /* parent item */
+       Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);
+       Evas_Object *scroller = elm_object_item_widget_get(parentItem);
+
+       Evas_Object *rgd = elm_radio_add(scroller);
+       elm_radio_value_set(rgd, -1);
+
+       int err;
+       char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
+       setting_get_string_slp_key(data_parentItem->int_slp_setting_binded, sel_num, &err);
+       SETTING_TRACE("binded: %d, checked: %s, err: %d", data_parentItem->int_slp_setting_binded, sel_num, err);
+
+       int i = 0;
+       int sel_idx = -1;
+       Setting_GenGroupItem_Data *item_data = NULL;
+       for(; i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
+               if (ad->my_numbers.list[i].num == NULL) {
+                       break;
+               }
+
+               if (sel_idx == -1 && 0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
+                       sel_idx = i;
+               }
+               item_data = setting_create_Gendial_exp_sub_field(scroller,
+                                       &(ad->itc_1icon_1text_sub),
+                                       __setting_about_sub_list_sel_cb, ad, parentItem,
+                                       SWALLOW_Type_1RADIO, rgd,
+                                       i,
+                                       ad->my_numbers.list[i].num, __setting_about_sub_list_rd_change);
+               if (item_data) {
+                       item_data->userdata = ad;
+               } else {
+                       SETTING_TRACE_ERROR("item_data is NULL");
+               }
+       }
+
+       elm_radio_value_set(rgd, sel_idx);
+}
+
+
 /**
 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
 *