gengxin
authorCCC <2393524978@qq.com>
Tue, 22 Aug 2023 07:30:52 +0000 (15:30 +0800)
committerCCC <2393524978@qq.com>
Tue, 22 Aug 2023 07:30:52 +0000 (15:30 +0800)
2.sdk/sdk/gui/lv_watch/lv_apps/mmi_video_call/mmi_video_call.c
2.sdk/sdk/gui/lv_watch/lv_apps/mmi_video_call/mmi_video_call_fzd.c
2.sdk/sdk/gui/lv_watch/lv_apps/mmi_wechat/wechat.h
2.sdk/sdk/gui/lv_watch/lv_apps/mmi_wechat/wechat_ui.c

index 199825e..6a805f6 100644 (file)
@@ -1887,7 +1887,7 @@ static lv_obj_t * mmi_vc_main_create(lv_obj_t * activity_obj)
                lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
                lv_obj_set_click(label, false);
                lv_label_set_text_id(label, WATCH_TEXT_ID_NO_SIM_OR_NETWORK); // WATCH_TEXT_ID_NO_CONTACTS_OR_NETWORK);
-               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, 0);
+               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, -10);
     } 
        else if(0 == s_vc_contact.total)
        {
@@ -1898,7 +1898,7 @@ static lv_obj_t * mmi_vc_main_create(lv_obj_t * activity_obj)
                lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
                lv_obj_set_click(label, false);
                lv_label_set_text_id(label, WATCH_TEXT_ID_NO_CONTACTS);
-               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, 0);
+               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, -10);
        }
        else
        {
index f848d89..7877cbc 100644 (file)
@@ -1912,7 +1912,7 @@ static lv_obj_t * mmi_vc_main_create(lv_obj_t * activity_obj)
                lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
                lv_obj_set_click(label, false);
                lv_label_set_text_id(label, WATCH_TEXT_ID_NO_SIM_OR_NETWORK); // WATCH_TEXT_ID_NO_CONTACTS_OR_NETWORK);
-               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, 0);
+               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, -10);
     } 
        else if(0 == s_vc_contact.total)
        {
@@ -1923,7 +1923,7 @@ static lv_obj_t * mmi_vc_main_create(lv_obj_t * activity_obj)
                lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
                lv_obj_set_click(label, false);
                lv_label_set_text_id(label, WATCH_TEXT_ID_NO_CONTACTS);
-               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, 0);
+               lv_obj_align(label, obj, LV_ALIGN_CENTER, 0, -10);
        }
        else
        {
index 9a35085..a995425 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
 
 #define WECHAT_MSG_SENDING_TIME_MAX            (1000 * 3) // ms
 
-#define WECHAT_MSG_TEXT_LEN_MAX                (64)
+#define WECHAT_MSG_TEXT_LEN_MAX                (32) // (64) // unicode
 
 
 typedef enum
@@ -76,11 +76,11 @@ typedef struct {
     lv_page_ext_t old_ext;
     lv_anim_t voice_playing_anim;
     bool pressing;
-    lv_style_t style_cont;
+    lv_style_t style_cont_self;
+    lv_style_t style_cont_other;
     lv_style_t style_label_time;
-    lv_style_t style_text;
     lv_style_t style_label_len_other;
-    lv_style_t style_label_len_ui;
+    lv_style_t style_label_len_self;
 } lv_wechat_msg_list_ext_t;
 
 typedef struct
index c3e4ead..1011195 100644 (file)
@@ -306,7 +306,7 @@ bool wechat_msg_receive_from_server(char * data_buff, int data_buff_len, nv_wech
        
        nv_watch_wechat_msg_item_info_t wechat_msg_item_info = {0};
        hal_rtc_t cur_time = {0};
-       char * t_file_ext[WECHAT_MSG_TYPE_MAX] = {"amr", "txt", "png", "png"};
+       char * t_file_ext[WECHAT_MSG_TYPE_MAX] = {"amr", "txt", "png", "png"}; // match nv_wechat_msg_type_e
        
        Hal_Rtc_Gettime(&cur_time);
        wechat_msg_item_info.msg_time.tm_year = cur_time.tm_year;
@@ -1200,11 +1200,12 @@ void wechat_chat_list_msg_item_style_reset(lv_wechat_ext_t * ext)
     if(NULL == list_page_ext) 
                return;
 
-       lv_style_reset(&(list_page_ext->style_cont));
+       lv_style_reset(&(list_page_ext->style_cont_self));
+       lv_style_reset(&(list_page_ext->style_cont_other));
        lv_style_reset(&(list_page_ext->style_label_time));
-       lv_style_reset(&(list_page_ext->style_text));
+       //lv_style_reset(&(list_page_ext->style_text));
+       lv_style_reset(&(list_page_ext->style_label_len_self));
        lv_style_reset(&(list_page_ext->style_label_len_other));
-       lv_style_reset(&(list_page_ext->style_label_len_ui));
 }
 
 void wechat_chat_list_msg_item_time(char * time_str, hal_rtc_t * cur_time, hal_rtc_t * msg_time, hal_rtc_t * last_msg_time)
@@ -1463,12 +1464,45 @@ void wechat_chat_list_voice_item_event_cb(lv_obj_t * img, lv_event_t e)
     }
 }
 
+void wechat_chat_list_text_item_event_cb(lv_obj_t * cont, lv_event_t e)
+{
+       lv_wechat_msg_list_item_ext_t * list_item_ext = (lv_wechat_msg_list_item_ext_t *)lv_obj_get_ext_attr(cont);
+       if(NULL == list_item_ext)
+               return;
+
+       s_wechat_selected_item_index = list_item_ext->item_index;
+       
+    lv_obj_t * scrl = lv_obj_get_parent(cont);
+    lv_obj_t * list_page = lv_obj_get_parent(scrl);
+       //lv_obj_t * scrl = lv_page_get_scrl(list_page);
+       
+    lv_wechat_msg_list_ext_t * list_page_ext = (lv_wechat_msg_list_ext_t *)lv_obj_get_ext_attr(list_page);
+       if(NULL == list_page_ext)
+               return;
+   
+       if(LV_EVENT_PRESSED == e)
+       {
+               list_page_ext->pressing = true;
+       }
+       else if((LV_EVENT_LONG_PRESSED == e) && (true == list_page_ext->pressing)) // delete msg item
+       {
+               list_page_ext->pressing = false;
+
+               wechat_chat_list_msg_item_delete_create();      
+       }
+       else if((LV_EVENT_CLICKED == e) && (true == list_page_ext->pressing)) // display text msg
+       {
+               list_page_ext->pressing = false;
+    }
+}
+
 //display time & content
 lv_obj_t * wechat_chat_list_msg_item_add(lv_obj_t * list_page, nv_watch_wechat_msg_item_info_t * msg_item, char * time_str, uint8_t i)
 {
        WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
        
        lv_obj_t * obj = NULL;
+       lv_wechat_msg_list_item_ext_t * list_item_ext = NULL;
        lv_wechat_msg_list_ext_t * list_page_ext = lv_obj_get_ext_attr(list_page);
        lv_obj_t * scrl = lv_page_get_scrl(list_page);
        lv_obj_t * last_obj = lv_obj_get_child(scrl, NULL);
@@ -1503,10 +1537,13 @@ lv_obj_t * wechat_chat_list_msg_item_add(lv_obj_t * list_page, nv_watch_wechat_m
        {
                case WECHAT_MSG_TYPE_VOICE:
                        lv_obj_t * unread_img = lv_img_create(list_page, NULL);
-                       obj = lv_img_create(list_page, NULL);
-                       lv_wechat_msg_list_item_ext_t * list_item_ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_wechat_msg_list_item_ext_t));
+                       //obj = lv_img_create(list_page, NULL);
+                       obj = lv_cont_create(list_page, NULL);
+                       list_item_ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_wechat_msg_list_item_ext_t));
                        list_item_ext->item_index = i;
                        list_item_ext->unread_img = NULL;
+                   lv_obj_set_size(obj, LV_HOR_RES * 2 / 3, 50);
+                       lv_cont_set_fit4(obj, LV_FIT_NONE, LV_FIT_NONE, LV_FIT_NONE, LV_FIT_TIGHT);
                        
                        lv_obj_t * play_img = lv_img_create(obj, NULL);
                        lv_obj_t * len_label = lv_label_create(obj, NULL);
@@ -1534,34 +1571,36 @@ lv_obj_t * wechat_chat_list_msg_item_add(lv_obj_t * list_page, nv_watch_wechat_m
                                if(WECHAT_MSG_DATA_RECORD_DURATION_MAX < duration)
                                        duration = WECHAT_MSG_DATA_RECORD_DURATION_MAX;
                                
-                               sprintf(len_str, "%d S", duration);
+                               sprintf(len_str, "%d\"", duration);
                                lv_label_set_text(len_label, len_str);
                        }
 
                        if(0 == msg_item->msg_from) // msg from slef
                        {
-                               lv_obj_add_style(len_label, LV_LABEL_PART_MAIN, &list_page_ext->style_label_len_ui);
-                               lv_img_set_src(obj, ICON_WECHAT_MY_VOICE_ITEM_BG);
+                               lv_obj_add_style(len_label, LV_LABEL_PART_MAIN, &list_page_ext->style_label_len_self);
+                               //lv_img_set_src(obj, ICON_WECHAT_MY_VOICE_ITEM_BG);
+                               lv_obj_add_style(obj, LV_CONT_PART_MAIN, &(list_page_ext->style_cont_self));
                                lv_obj_align(obj, scrl, LV_ALIGN_IN_TOP_RIGHT, -10, obj_y);
                                if(0 < duration) 
                                {
                                        lv_img_set_src(play_img, ICON_WECHAT_MY_VOICE_ITEM_PLAYING3);
                                }
                                lv_obj_align(play_img, obj, LV_ALIGN_IN_LEFT_MID, 15, 0);
-                               lv_obj_align(len_label, play_img, LV_ALIGN_OUT_RIGHT_MID, 25, 0);
+                               lv_obj_align(len_label, play_img, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
                                lv_obj_del(unread_img);
                        }
                        else // msg from other
                        {
                                lv_obj_add_style(len_label, LV_LABEL_PART_MAIN, &list_page_ext->style_label_len_other);
-                               lv_img_set_src(obj, ICON_WECHAT_OTHER_VOICE_ITEM_BG);
+                               //lv_img_set_src(obj, ICON_WECHAT_OTHER_VOICE_ITEM_BG);
+                               lv_obj_add_style(obj, LV_CONT_PART_MAIN, &(list_page_ext->style_cont_other));
                                lv_obj_align(obj, scrl, LV_ALIGN_IN_TOP_LEFT, 10, obj_y);
                                if(0 < duration) 
                                {
                                        lv_img_set_src(play_img, ICON_WECHAT_OTHER_VOICE_ITEM_PLAYING3);
                                }
                                lv_obj_align(play_img, obj, LV_ALIGN_IN_RIGHT_MID, -15, 0);
-                               lv_obj_align(len_label, play_img, LV_ALIGN_OUT_LEFT_MID, -25, 0);
+                               lv_obj_align(len_label, play_img, LV_ALIGN_OUT_LEFT_MID, -20, 0);
                                if(1 == msg_item->unread_flag) 
                                {
                                        lv_img_set_src(unread_img, ICON_WECHAT_UNREAD_FLAG);
@@ -1575,7 +1614,6 @@ lv_obj_t * wechat_chat_list_msg_item_add(lv_obj_t * list_page, nv_watch_wechat_m
                        }
                        
                        lv_obj_set_click(obj, true);
-                       //lv_page_glue_obj(obj, true);
                        lv_obj_set_event_cb(obj, wechat_chat_list_voice_item_event_cb);
                        lv_obj_set_adv_hittest(obj, false);
                        lv_page_focus(list_page, obj, 0);
@@ -1584,11 +1622,58 @@ lv_obj_t * wechat_chat_list_msg_item_add(lv_obj_t * list_page, nv_watch_wechat_m
                        break;
                        
                case WECHAT_MSG_TYPE_TEXT:
-                       #if 0
-                       obj = lv_cont_create(list, NULL);
-                       lv_obj_add_style(obj, LV_CONT_PART_MAIN, &ext->style_cont);
-                       lv_cont_set_fit(obj, true);
-                       #endif
+                       obj = lv_cont_create(list_page, NULL);
+                       list_item_ext = lv_obj_allocate_ext_attr(obj, sizeof(lv_wechat_msg_list_item_ext_t));
+                       list_item_ext->item_index = i;
+                       list_item_ext->unread_img = NULL;
+                   lv_obj_set_size(obj, LV_HOR_RES * 2 / 3, 50); //lv_obj_set_size(obj, 153, 53); // same with voice item
+                       lv_cont_set_fit4(obj, LV_FIT_NONE, LV_FIT_NONE, LV_FIT_NONE, LV_FIT_TIGHT);
+                       //lv_cont_set_layout(obj, LV_LAYOUT_COLUMN_LEFT);
+                       lv_obj_add_style(obj, LV_CONT_PART_MAIN, &(list_page_ext->style_cont_other));
+                       lv_obj_align(obj, scrl, LV_ALIGN_IN_TOP_LEFT, 10, obj_y);                       
+
+                       lv_fs_file_t file_p;
+                       lv_fs_res_t res;
+                       uint32_t file_size = 0, bytes_read = 0;
+                       char * file_buf = NULL;
+                       
+                       res = lv_fs_open(&file_p, msg_item->msg_data_full_file_name, LV_FS_MODE_RD);
+                       if(LV_FS_RES_OK != res) 
+                       {
+                               WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+                               lv_fs_close(&file_p);
+                               break;
+                       }
+                       
+                       lv_fs_size(&file_p, &file_size);
+                       file_buf = lv_mem_alloc(file_size + 1);
+                       _lv_memset_00(file_buf, file_size + 1);
+                       res = lv_fs_read(&file_p, file_buf, file_size, &bytes_read);
+                       lv_fs_close(&file_p);
+                       if(LV_FS_RES_OK != res)
+                       {
+                               WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+                               lv_mem_free(file_buf);
+                               break;
+                       }
+                       WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: %d,%d,%s\n", __FUNCTION__, __LINE__, file_size, bytes_read, file_buf);
+                       
+                       lv_obj_t * label_text = lv_label_create(obj, NULL);
+                       lv_obj_add_style(label_text, LV_LABEL_PART_MAIN, &(list_page_ext->style_label_len_other));
+                       lv_label_set_align(label_text, LV_LABEL_ALIGN_CENTER);
+                       lv_label_set_long_mode(label_text, LV_LABEL_LONG_BREAK);
+                       lv_obj_set_width(label_text, lv_obj_get_width(obj) - 20);
+                       lv_label_set_text(label_text, file_buf);
+                       lv_obj_align(label_text, obj, LV_ALIGN_IN_LEFT_MID, 10, 0);
+
+                       lv_obj_set_click(obj, true);
+                       lv_obj_set_event_cb(obj, wechat_chat_list_text_item_event_cb);
+                       lv_obj_set_adv_hittest(obj, false);
+                       lv_page_focus(list_page, obj, 0);
+                       lv_page_glue_obj(obj, true);
+                       lv_watch_obj_add_element(obj);
+                       
+                       lv_mem_free(file_buf);
                        break;
                        
                case WECHAT_MSG_TYPE_EXPRESSION:
@@ -1659,25 +1744,35 @@ void wechat_chat_list_create(lv_obj_t * obj, lv_wechat_ext_t * ext)
        lv_style_copy(&(list_page_ext->style_label_time), &lv_watch_font20);
        lv_style_set_text_color(&(list_page_ext->style_label_time), LV_STATE_DEFAULT, lv_color_make(20, 187, 242));
 
-       lv_style_init(&(list_page_ext->style_text));
-       lv_style_copy(&(list_page_ext->style_text), &lv_style_pretty);
-       lv_style_set_bg_color(&(list_page_ext->style_text), LV_STATE_DEFAULT, lv_color_make(0xFF, 0xE1, 0xE1));
-       lv_style_set_border_width(&(list_page_ext->style_text), LV_STATE_DEFAULT, 0);
-       lv_style_set_shadow_width(&(list_page_ext->style_text), LV_STATE_DEFAULT, 0);
+       //lv_style_init(&(list_page_ext->style_text));
+       //lv_style_copy(&(list_page_ext->style_text), &lv_style_pretty);
+       //lv_style_set_bg_color(&(list_page_ext->style_text), LV_STATE_DEFAULT, lv_color_make(0xFF, 0xE1, 0xE1));
+       //lv_style_set_border_width(&(list_page_ext->style_text), LV_STATE_DEFAULT, 0);
+       //lv_style_set_shadow_width(&(list_page_ext->style_text), LV_STATE_DEFAULT, 0);
 
        lv_style_init(&(list_page_ext->style_label_len_other));
-       lv_style_copy(&(list_page_ext->style_label_len_other), &lv_watch_font20);
+       lv_style_copy(&(list_page_ext->style_label_len_other), &lv_watch_font26);
        lv_style_set_text_color(&(list_page_ext->style_label_len_other), LV_STATE_DEFAULT, lv_color_make(202, 134, 255));
 
-       lv_style_init(&(list_page_ext->style_label_len_ui));
-       lv_style_copy(&(list_page_ext->style_label_len_ui), &lv_watch_font20);
-       lv_style_set_text_color(&(list_page_ext->style_label_len_ui), LV_STATE_DEFAULT, lv_color_make(108, 189, 5));
-
-       lv_style_init(&(list_page_ext->style_cont));
-       lv_style_set_pad_top(&(list_page_ext->style_cont), LV_STATE_DEFAULT, 8);
-       lv_style_set_pad_bottom(&(list_page_ext->style_cont), LV_STATE_DEFAULT, 8);
-       lv_style_set_pad_left(&(list_page_ext->style_cont), LV_STATE_DEFAULT, 8);
-       lv_style_set_pad_right(&(list_page_ext->style_cont), LV_STATE_DEFAULT, 8);
+       lv_style_init(&(list_page_ext->style_label_len_self));
+       lv_style_copy(&(list_page_ext->style_label_len_self), &lv_watch_font26);
+       lv_style_set_text_color(&(list_page_ext->style_label_len_self), LV_STATE_DEFAULT, lv_color_make(108, 189, 5));
+
+       lv_style_init(&(list_page_ext->style_cont_self));
+       lv_style_set_bg_color(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, LV_COLOR_MAKE(175, 242, 89));
+       lv_style_set_radius(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, 15); // 30
+       lv_style_set_pad_top(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, 10); // 8
+       lv_style_set_pad_bottom(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, 10); // 8
+       lv_style_set_pad_left(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, 5); // 8
+       lv_style_set_pad_right(&(list_page_ext->style_cont_self), LV_STATE_DEFAULT, 5); // 8
+
+       lv_style_init(&(list_page_ext->style_cont_other));
+       lv_style_set_bg_color(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, LV_COLOR_MAKE(0xE2, 0xBD, 0xFF));
+       lv_style_set_radius(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 15);
+       lv_style_set_pad_top(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 10);
+       lv_style_set_pad_bottom(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 10);
+       lv_style_set_pad_left(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 5);
+       lv_style_set_pad_right(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 5);
 
        lv_page_set_scrl_layout(list_page, LV_LAYOUT_OFF);
        lv_page_set_scrollable_fit2(list_page, LV_FIT_NONE, LV_FIT_TIGHT);