[Telegram] Add the profile view and fixed set image popup 24/53524/2
authormoon87.park <moon87.park@samsung.com>
Mon, 7 Dec 2015 12:06:35 +0000 (21:06 +0900)
committerSung-jae Park <nicesj@nicesj.com>
Wed, 9 Dec 2015 00:04:18 +0000 (16:04 -0800)
Change-Id: Id0db7f31726701951ea4bbc1e062883e61d05122

TelegramTizen/res/edje/telegram_init_screen.edc
TelegramTizen/src/tg_messaging_view.c
TelegramTizen/src/tg_settings_view.c
TelegramTizen/src/tg_user_info_view.c

index 0b75fc2..d1d788c 100644 (file)
@@ -2731,8 +2731,9 @@ group
             type: SWALLOW; 
             description { 
                state: default 0.0;
-               rel1.relative: 0.1 0.4;
-               rel2.relative: 0.9 0.6;
+               rel1.relative: 0.5 0.5;
+               rel2.relative: 0.5 0.5;
+               min: 100 100;
             }
          }
       }
@@ -3492,12 +3493,23 @@ group
                                        color: 255 255 255 255;
                                }
                        }
+                       part {
+                               name: "left,pad";
+                               type: SPACER;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 0.0 1.0; }
+                                       min: 32 0;
+                                       align: 0.0 0.5;
+                               }
+                       }
                        part{
                        name: "swallow.phone_type";
                        type: SWALLOW;
                        description{
                                state: "default" 0.0;
-                               rel1 { relative: 0.0 0.0; }
+                               rel1 { relative: 1.0 0.1; to: "left,pad"; }
                                rel2 { relative: 0.65 0.5; }            
                                color: 0 0 0 0;
                        }
@@ -3508,13 +3520,13 @@ group
                        type: SWALLOW;
                        description{
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.5; }
-                                       rel2 { relative: 0.65 1.0; }            
+                                       rel1 { relative: 1.0 0.5; to: "left,pad"; }
+                                       rel2 { relative: 0.65 0.9; }            
                                        color: 0 0 0 0;
                         }
                }
                part{
-                       name: "swallow.phone_msg";
+                       name: "swallow.phone_call";
                        type: SWALLOW;
                        description{
                                        state: "default" 0.0;
@@ -3524,7 +3536,7 @@ group
                         }
                }
                part{
-                       name: "swallow.phone_call";
+                       name: "swallow.phone_msg";
                        type: SWALLOW;
                        description{
                                        state: "default" 0.0;
@@ -3575,8 +3587,9 @@ group
                        description{
                                state: "default" 0.0;
                                rel1 { relative: 0.0 0.0; }
-                               rel2 { relative: 1.0 0.4; }     
-                               color: 255 0 0 255;                     
+                               rel2 { relative: 1.0 0.0; }
+                               align: 0.5 0.0;
+                               min: 0 440;
                        }
                }       
                part{
@@ -3584,9 +3597,10 @@ group
                        type: SWALLOW;
                        description{
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.4; }
-                                       rel2 { relative: 1.0 0.5; }     
-                                       color: 0 255 0 255;                     
+                                       rel1 { relative: 0.0 1.0; to_y: "swallow.profile_pic"; }
+                                       rel2 { relative: 1.0 1.0; to_y: "swallow.profile_pic"; }
+                                       align: 0.5 0.0;
+                                       min: 0 150;
                         }
                }
        }
index d2eeaed..46eb476 100644 (file)
@@ -218,7 +218,7 @@ void on_messaging_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
        }
 
 
-       if (id == 0) {
+       if (id == 1) { // Clear history
                if (user_data->peer_type == TGL_PEER_USER || user_data->peer_type == TGL_PEER_CHAT) {
 
 #if 0
@@ -319,7 +319,7 @@ void on_messaging_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
 
                }
 
-       } else if (id == 1) {
+       } else if (id == 2) { //Delete
                if (user_data->peer_type == TGL_PEER_USER) {
                        char* tablename = get_table_name_from_number(user_data->peer_id);
                        delete_all_records(tablename);
@@ -371,8 +371,9 @@ void on_messaging_menu_option_selected_cb(void *data, Evas_Object *obj, void *ev
                } else {
 
                }
+       } else if (id == 0) { // View profile
+               launch_user_info_screen(ad, user_data->peer_id);
        } else {
-
        }
        if (ad->msg_popup) {
                evas_object_del(ad->msg_popup);
@@ -385,9 +386,9 @@ char* on_messaging_menu_group_text_get_cb(void *data, Evas_Object *obj, const ch
 {
        int id = (int) data;
        if (id == 0) {
-               return strdup("Clear history");
+               return strdup(i18n_get_text("IDS_TGRAM_OPT_CLEAR_HISTORY_ABB3"));
        } else {
-               return strdup("Delete and exit");
+               return strdup(i18n_get_text("IDS_TGRAM_OPT_DELETE"));
        }
 }
 
@@ -399,17 +400,20 @@ char* on_messaging_menu_text_get_cb(void *data, Evas_Object *obj, const char *pa
        tg_peer_info_s *user_data = sel_item->use_data;
        if ((user_data->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(user_data->peer_id)) {
            if (id == 0) {
-               return strdup("Add to contacts");
+               return strdup(i18n_get_text("IDS_TGRAM_OPT_ADD_TO_CONTACTS_ABB2"));
            } else if (id == 1) {
-                       return strdup("Clear history");
+               return strdup(i18n_get_text("IDS_TGRAM_OPT_CLEAR_HISTORY_ABB3"));
                } else {
-                       return strdup("Delete");
+                       return strdup(i18n_get_text("IDS_TGRAM_OPT_DELETE"));
                }
        } else {
                if (id == 0) {
-                       return strdup("Clear history");
+                       return strdup(i18n_get_text("IDS_TGRAM_OPT_VIEW_PROFILE_ABB"));
+               }
+               else if (id == 1) {
+                       return strdup(i18n_get_text("IDS_TGRAM_OPT_CLEAR_HISTORY_ABB3"));
                } else {
-                       return strdup("Delete");
+                       return strdup(i18n_get_text("IDS_TGRAM_OPT_DELETE"));
                }
        }
 }
@@ -463,13 +467,12 @@ void on_messaging_menu_button_clicked(void *data, Evas_Object *obj, void *event_
        itc.func.state_get = NULL;
        itc.func.del = NULL;
 
-       tg_peer_info_s *user_data = sel_item->use_data;
-       if ((user_data->peer_type == TGL_PEER_USER) && get_buddy_unknown_status(user_data->peer_id)) {
-               for (i = 0; i < 3; i++) {
+       if (sel_item->use_data->peer_type == TGL_PEER_CHAT) {
+               for (i = 0; i < 2; i++) {
                        elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_messaging_menu_option_selected_cb, ad);
                }
        } else {
-               for (i = 0; i < 2; i++) {
+               for (i = 0; i < 3; i++) {
                        elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_messaging_menu_option_selected_cb, ad);
                }
        }
@@ -1471,7 +1474,6 @@ Evas_Object *on_message_item_content_get_cb(void *data, Evas_Object *obj, const
                        if (msg->media_type == tgl_message_media_none) {
                                char *temp_msg = replace(msg->message, '\n', "<br>");
                                eina_strbuf_append(buf, temp_msg);
-                               LOGD("!!!!!! message: %s", eina_strbuf_string_get(buf));
                                elm_entry_entry_set(entry, eina_strbuf_string_get(buf));
                                eina_strbuf_free(buf);
 
@@ -1604,7 +1606,6 @@ Evas_Object *on_message_item_content_get_cb(void *data, Evas_Object *obj, const
                        elm_object_part_content_set(entry, "status_icon", status_obj);
                        evas_object_show(status_obj);
 
-                       LOGD("!!!!!! entry: %p", entry);
                        evas_object_event_callback_add(entry, EVAS_CALLBACK_RESIZE, __resize_cb, "entry");
                        evas_object_event_callback_add(entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, __hint_cb, "HINT : entry");
 
index e76a614..7a41624 100644 (file)
@@ -339,12 +339,9 @@ void on_camera_button_clicked(void *data, Evas_Object *obj, void *event_info)
 
        //evas_object_data_set(popup, "cam_icon", cam_icon);
        evas_object_data_set(popup, "app_data", ad);
-       /* box */
-       box = elm_box_add(popup);
-       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
        /* genlist */
-       genlist = elm_genlist_add(box);
+       genlist = elm_genlist_add(popup);
        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);
 
@@ -358,8 +355,7 @@ void on_camera_button_clicked(void *data, Evas_Object *obj, void *event_info)
                elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, on_image_request_option_selected_cb, popup);
        }
        evas_object_show(genlist);
-       elm_box_pack_end(box, genlist);
-       elm_object_content_set(popup, box);
+       elm_object_content_set(popup, genlist);
 
        evas_object_show(popup);
 }
index d129339..9bdca0f 100644 (file)
@@ -624,6 +624,58 @@ static void on_user_info_call_clicked(void *data, Evas_Object *obj, void *event_
        app_control_destroy(app_control);
 }
 
+static void compare_with_current_date(int rtime, Elm_Object_Item *nf_it)
+{
+       char time_str[256]={0,};
+       time_t local_t = time(NULL);
+       int diff_sec = 0;
+       int diff_min = 0;
+       int diff_hour = 0;
+       int diff_day = 0;
+
+       diff_sec = local_t - rtime;
+       diff_min = diff_sec / 60;
+       diff_hour = diff_min / 60;
+       diff_day = diff_hour / 24;
+       LOGD("different : day : %d, hour = %d, min = %d, sec = %d", diff_day, diff_hour, diff_min, diff_sec);
+
+
+       if (diff_day > 30) {
+               snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_LONG_TIME_AGO_ABB"));
+               goto OUT;
+       }
+
+       if (diff_day > 7) {
+               snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_WITHIN_A_MONTH_ABB"));
+               goto OUT;
+       }
+       if (diff_day > 1) {
+               snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_WITHIN_A_WEEK_ABB"));
+               goto OUT;
+       }
+
+       if (diff_hour > 1) {
+               snprintf(time_str, sizeof(time_str) - 1, i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_PD_HOURS_AGO_ABB"), diff_hour);
+               goto OUT;
+       }
+
+       if (diff_hour == 1) {
+               snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_1_HOUR_AGO_ABB"));
+               goto OUT;
+       }
+       if (diff_min > 1) {
+               snprintf(time_str, sizeof(time_str) - 1, i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_PD_MINUTES_AGO_ABB"), diff_min);
+               goto OUT;
+       }
+       if (diff_min == 1) {
+               snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_1_MINUTE_AGO_ABB"));
+               goto OUT;
+       }
+       snprintf(time_str, sizeof(time_str) - 1, "%s", i18n_get_text("IDS_TGRAM_HEADER_LAST_SEEN_RECENTLY_ABB"));
+
+OUT:
+       elm_object_item_part_text_set(nf_it, "subtitle", time_str);
+}
 
 void launch_user_info_screen(appdata_s* ad, int peer_id)
 {
@@ -775,25 +827,7 @@ void launch_user_info_screen(appdata_s* ad, int peer_id)
                        if (is_online > 0) {
                                elm_object_item_part_text_set(navi_item, "subtitle", i18n_get_text("IDS_TGRAM_SBODY_ONLINE"));
                        } else {
-                               time_t t = last_seen;
-
-                               if (is_today) {
-                                       format = "Last seen %I:%M %p";
-                               } else {
-                                       format = "Last seen %b %d, %I:%M %P";
-                               }
-
-                               struct tm lt;
-                               char res[256];
-                               (void) localtime_r(&t, &lt);
-
-                               if (strftime(res, sizeof(res), format, &lt) == 0) {
-                                       (void) fprintf(stderr,  "strftime(3): cannot format supplied "
-                                                       "date/time into buffer of size %u "
-                                                       "using: '%s'\n",
-                                                       sizeof(res), format);
-                               }
-                               elm_object_item_part_text_set(navi_item, "subtitle", res);
+                               compare_with_current_date(last_seen, navi_item);
                        }
 
                        for (int i = 0 ; i < eina_list_count(buddy_details_array); i++) {
@@ -813,15 +847,39 @@ void launch_user_info_screen(appdata_s* ad, int peer_id)
 
 
        Evas_Object *profile_pic = NULL;
+       Evas_Object *image_layout = NULL;
 
        if (ad->peer_in_cahtting_data->use_data->photo_path && strlen(ad->peer_in_cahtting_data->use_data->photo_path) > 0 && strstr(ad->peer_in_cahtting_data->use_data->photo_path, "_null_") == NULL) {
+
+               evas_object_color_set(profile_pic, 45, 165, 224, 255);
+
+               image_layout = elm_layout_add(ad->nf);
+               elm_layout_file_set(image_layout, edj_path, "contact_image_masking");
+               evas_object_size_hint_weight_set(image_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(image_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(image_layout);
+
                profile_pic = get_image_from_path(ad->peer_in_cahtting_data->use_data->photo_path, ad->nf);
+               evas_object_color_set(profile_pic, 45, 165, 224, 225);
+
+               elm_object_part_content_set(image_layout, "image", profile_pic);
        } else  {
-               profile_pic = get_image_from_path(ui_utils_get_resource(TG_CALLER_ID_IMAGE), ad->nf);
+
                evas_object_color_set(profile_pic, 45, 165, 224, 255);
+
+               image_layout = elm_layout_add(ad->nf);
+               elm_layout_file_set(image_layout, edj_path, "contact_image_masking");
+               evas_object_size_hint_weight_set(image_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(image_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_show(image_layout);
+
+               profile_pic = get_image_from_path(ui_utils_get_resource(TG_CALLER_ID_IMAGE), ad->nf);
+               evas_object_color_set(profile_pic, 45, 165, 224, 225);
+
+               elm_object_part_content_set(image_layout, "image", profile_pic);
        }
 
-       elm_object_part_content_set(layout, "swallow.profile_pic", profile_pic);
+       elm_object_part_content_set(layout, "swallow.profile_pic", image_layout);
 
        /************************* profile pic *******************************************/
 
@@ -836,7 +894,7 @@ void launch_user_info_screen(appdata_s* ad, int peer_id)
        Evas_Object *phone_type = elm_label_add(ad->nf);
        elm_object_style_set(phone_type, "transparent");
        char phone_type_str[256];
-       sprintf(phone_type_str, "<font=Tizen:style=Normal color=#A9A9A9 align=left><font_size=35>&nbsp;&nbsp;%s</font_size></font>","Mobile");
+       sprintf(phone_type_str, "<font=Tizen:style=Normal color=#A9A9A9 align=left><font_size=35>&nbsp;&nbsp;%s</font_size></font>",i18n_get_text("IDS_TGRAM_BODY_MOBILE_ABB"));
        elm_object_text_set(phone_type, phone_type_str);
        evas_object_size_hint_weight_set(phone_type, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(phone_type, EVAS_HINT_FILL, EVAS_HINT_FILL);