From acdcc0df92ff48133968820d4bc105f1178b1dfb Mon Sep 17 00:00:00 2001 From: "jin0.kim" Date: Sun, 18 Oct 2015 19:17:50 +0830 Subject: [PATCH] update setting screen Change-Id: Idf3e4e7db6d4d6320944bd49b1ee817a7a1304b5 --- TelegramTizen/src/tg_settings_view.c | 38 ++++++++++++++++++++---------------- TelegramTizen/tg_utils/tg_common.c | 38 ++++++++++++++++++++++++++++-------- TelegramTizen/tg_utils/tg_common.h | 3 +++ 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/TelegramTizen/src/tg_settings_view.c b/TelegramTizen/src/tg_settings_view.c index 11b5514..c0d050f 100644 --- a/TelegramTizen/src/tg_settings_view.c +++ b/TelegramTizen/src/tg_settings_view.c @@ -290,7 +290,7 @@ void on_image_request_option_selected_cb(void *data, Evas_Object *obj, void *eve return; } - if (id == 0) { + if (id == 1) { app_control_set_operation(app_control, APP_CONTROL_OPERATION_CREATE_CONTENT); app_control_set_mime(app_control, "image/jpg"); app_control_send_launch_request(app_control, &on_image_select_result_cb, ad); @@ -308,30 +308,35 @@ char* on_camera_load_text_get_cb(void *data, Evas_Object *obj, const char *part) { int id = (int) data; if (id == 0) { - return strdup("Camera"); + return strdup(_("IDS_TGRAM_OPT_FROM_GALLERY_ABB2")); } else { - return strdup("Gallery"); + return strdup(_("IDS_TGRAM_OPT_TAKE_PICTURE_ABB")); } } void on_camera_button_clicked(void *data, Evas_Object *obj, void *event_info) { Evas_Object* cam_icon = data; - appdata_s* ad = evas_object_data_get(data, "app_data"); + static Elm_Genlist_Item_Class itc; Evas_Object *popup; Evas_Object *box; Evas_Object *genlist; int i; + + appdata_s* ad = evas_object_data_get(obj, "app_data"); Evas_Object *win = ad->win; + Elm_Object_Item *it = event_info; + elm_genlist_item_selected_set(it, EINA_FALSE); + popup = elm_popup_add(win); elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL); elm_object_part_text_set(popup, "title,text", "Load image from"); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_data_set(popup, "cam_icon", cam_icon); + //evas_object_data_set(popup, "cam_icon", cam_icon); evas_object_data_set(popup, "app_data", ad); /* box */ box = elm_box_add(popup); @@ -426,7 +431,7 @@ void on_chat_bg_change_option_selected_cb(void *data, Evas_Object *obj, void *ev show_toast(ad, "Error: Can not load image picker"); return; } - if (id == 0) { + /*if (id == 0) { if (ad->chat_background) { free(ad->chat_background); ad->chat_background = NULL; @@ -437,7 +442,7 @@ void on_chat_bg_change_option_selected_cb(void *data, Evas_Object *obj, void *ev if (chat_bg) { elm_image_file_set(chat_bg, ad->chat_background, NULL); } - }else if (id == 1) { + }else */if (id == 1) { app_control_set_operation(app_control, APP_CONTROL_OPERATION_CREATE_CONTENT); app_control_set_mime(app_control, "image/jpg"); app_control_send_launch_request(app_control, &on_chat_bg_select_result_cb, ad); @@ -457,15 +462,12 @@ char* on_chat_bg_load_text_get_cb(void *data, Evas_Object *obj, const char *part { int id = (int) data; if (id == 0) { - return strdup("Set default"); - } else if (id == 1) { - return strdup("Camera"); + return strdup(_("IDS_TGRAM_OPT_FROM_GALLERY_ABB2")); } else { - return strdup("Gallery"); + return strdup(_("IDS_TGRAM_OPT_TAKE_PICTURE_ABB")); } } - void on_settings_info_item_clicked(void *data, Evas_Object *obj, void *event_info) { Elm_Object_Item *it = event_info; @@ -486,16 +488,19 @@ void on_settings_info_item_clicked(void *data, Evas_Object *obj, void *event_inf elm_object_part_text_set(popup, "title,text", "Load image from"); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_data_set(popup, "app_data", ad); /* box */ box = elm_box_add(popup); + elm_box_horizontal_set(box, EINA_FALSE); evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); /* genlist */ genlist = elm_genlist_add(box); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_scroller_content_min_limit(genlist, EINA_TRUE, EINA_TRUE); itc.item_style = "default"; itc.func.text_get = on_chat_bg_load_text_get_cb; @@ -503,14 +508,12 @@ void on_settings_info_item_clicked(void *data, Evas_Object *obj, void *event_inf itc.func.state_get = NULL; itc.func.del = NULL; - for (i = 0; i < 3; i++) { + for (i = 0; i < 2; i++) { elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_chat_bg_change_option_selected_cb, popup); } evas_object_show(genlist); elm_box_pack_end(box, genlist); - evas_object_size_hint_min_set(box, -1, 350); elm_object_content_set(popup, box); - evas_object_show(popup); } @@ -729,6 +732,7 @@ Evas_Object* _content_requested_cb(void *data, Evas_Object *obj, const char *par evas_object_size_hint_align_set(user_pic_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(user_pic_layout); elm_object_part_content_set(user_pic_layout, "content", profile_pic); + evas_object_data_set(ad->nf, "user_profile_pic", profile_pic); eo = elm_layout_add(obj); elm_layout_theme_set(eo, "layout", "list/B/type.1", "default"); @@ -767,7 +771,7 @@ void launch_settings_screen(appdata_s* ad) itc.func.state_get = NULL; itc.func.del = NULL; - elm_genlist_item_append(list, &itc, (void*) 0, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void*) 0); + elm_genlist_item_append(list, &itc, (void*) 0, NULL, ELM_GENLIST_ITEM_NONE, on_camera_button_clicked, (void*) 0); elm_genlist_item_append(list, &itc, (void*) 1, NULL, ELM_GENLIST_ITEM_NONE, on_settings_info_item_clicked, (void*)1); Elm_Object_Item* navi_item = elm_naviframe_item_push(ad->nf, "Settings", NULL, NULL, list, NULL); diff --git a/TelegramTizen/tg_utils/tg_common.c b/TelegramTizen/tg_utils/tg_common.c index b892a85..2d7d493 100644 --- a/TelegramTizen/tg_utils/tg_common.c +++ b/TelegramTizen/tg_utils/tg_common.c @@ -429,6 +429,7 @@ void on_floating_icon_clicked(void *data, Evas_Object *obj, void *event_info) case TG_PEER_SEARCH_VIEW_STATE: elm_image_file_set(image, ui_utils_get_resource(TG_ICON_FLOATING_PENCIL), NULL); launch_settings_screen(ad); + delete_floating_button(ad); break; case TG_USER_MAIN_VIEW_STATE: elm_image_file_set(image, ui_utils_get_resource(TG_ICON_FLOATING_ADD), NULL); @@ -454,6 +455,7 @@ void create_floating_button(appdata_s* ad) { if (!ad) return; + if (ad->floating_btn) return; @@ -479,20 +481,40 @@ void delete_floating_button(appdata_s* ad) return; if (ad->floating_btn){ - evas_object_hide(ad->floating_btn); + elm_layout_signal_emit(ad->floating_btn, "elm,state,floatingbutton,hidden", "elm"); + } +} + +void show_floating_button(appdata_s* ad) +{ + if (!ad) + return; + + if (ad->floating_btn){ + elm_layout_signal_emit(ad->floating_btn, "elm,state,floatingbutton,visible", "elm"); } } void update_floating_button(appdata_s* ad, int mode) { - Evas_Object *plus_icon = elm_image_add(ad->nf); - elm_image_file_set(plus_icon, ui_utils_get_resource(TG_ICON_FLOATING_ADD), NULL); - evas_object_show(plus_icon); + // To do thi function + if (!ad->floating_btn) + return; - Evas_Object *new_msg_btn = elm_button_add(ad->floating_btn); - evas_object_smart_callback_add(new_msg_btn, "clicked", on_add_contact_clicked, ad); - elm_object_part_content_set(new_msg_btn, "icon", plus_icon); + Evas_Object* image = (Evas_Object*)evas_object_data_get(ad->floating_btn, "image"); + + switch(mode) { + case TG_PEER_SEARCH_VIEW_STATE: + elm_image_file_set(image, ui_utils_get_resource(TG_ICON_FLOATING_ADD), NULL); + break; + case TG_USER_MAIN_VIEW_STATE: + elm_image_file_set(image, ui_utils_get_resource(TG_ICON_FLOATING_ADD), NULL); + break; + default : + elm_image_file_set(image, ui_utils_get_resource(TG_ICON_FLOATING_PENCIL), NULL); + break; + } - elm_object_part_content_set(ad->floating_btn, "button1", new_msg_btn); + elm_layout_signal_emit(ad->floating_btn, "elm,state,floatingbutton,visible", "elm"); } diff --git a/TelegramTizen/tg_utils/tg_common.h b/TelegramTizen/tg_utils/tg_common.h index 72c7496..6f0f965 100644 --- a/TelegramTizen/tg_utils/tg_common.h +++ b/TelegramTizen/tg_utils/tg_common.h @@ -145,6 +145,7 @@ } \ } while (0) +#define _(str) gettext(str) #define SAFE_STRCMP(str1, str2) ((str1 && str2) ? strcmp(str1, str2) : -1) #define SAFE_STRDUP(text) (text == NULL ? NULL : strdup(text)) //what to use for strcpy? #define SAFE_STRLEN(src) \ @@ -1091,6 +1092,8 @@ extern void create_floating_button(appdata_s* ad); extern void delete_floating_button(appdata_s* ad); +extern void show_floating_button(appdata_s* ad); + extern void update_floating_button(appdata_s* ad, int mode); extern void on_new_message_clicked(void *data, Evas_Object *obj, void *event_info); -- 2.7.4