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;
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)
}
}
+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);
{
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);
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);
}
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);
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:
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);