static nv_watch_wechat_msg_info_t * s_wechat_msg_info = NULL;
static nv_watch_wechat_msg_item_info_t s_wechat_msg_item_info = {0};
static uint8_t s_wechat_play_anim_count = 0;
-char s_wechat_selected_item_index = -1;
+static char s_wechat_selected_item_index = -1;
+static bool s_item_receive_playing = false;
void wechat_msg_info_nv_write(void)
}
}
s_wechat_msg_info->msg_count--;
-
- wechat_msg_info_nv_write();
}
void wechat_msg_info_all_item_delete(void)
_lv_memset_00(&(s_wechat_msg_info->msg_item[i]), msg_item_info_size);
}
s_wechat_msg_info->msg_count = 0;
-
- wechat_msg_info_nv_write();
}
void wechat_msg_info_new_item_add(nv_watch_wechat_msg_item_info_t * msg_item)
s_wechat_msg_info->msg_count++;
_lv_memcpy(&(s_wechat_msg_info->msg_item[s_wechat_msg_info->msg_count - 1]), msg_item, msg_item_info_size);
-
- wechat_msg_info_nv_write();
}
void * wechat_actId_ext_get(lv_watch_Activity_Id_t actId)
ext->delete_timer_id = NULL;
}
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-
wechat_msg_voice_item_playing_stop(ext);
-
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-
wechat_chat_list_msg_item_style_reset(ext);
+ //
+ Hal_NFFS_File_Play_End();
+ Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+ Hal_Vibrator_Play_End();
+ s_item_receive_playing = false;
+
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
}
Hal_NFFS_File_Play_End();
Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
Hal_Vibrator_Play_End();
+ s_item_receive_playing = false;
}
}
Hal_NFFS_File_Play_End();
Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
Hal_Vibrator_Play_End();
+ s_item_receive_playing = false;
+}
+
+static bool wechat_msg_item_info_write_to_file(char * file_path, char * file_buf, uint32_t file_size)
+{
+ lv_fs_file_t file_p;
+ lv_fs_res_t res;
+ uint32_t bytes_write = 0;
+
+ res = lv_fs_open(&file_p, file_path, LV_FS_MODE_WR);
+ if(LV_FS_RES_OK != res)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+ lv_fs_close(&file_p);
+ return false;
+ }
+ res = lv_fs_write(&file_p, file_buf, file_size, &bytes_write);
+ lv_fs_close(&file_p);
+ if(LV_FS_RES_OK != res)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
+ return false;
+ }
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: file_size=%d,write_size=%d\n", __FUNCTION__, __LINE__, file_size, bytes_write);
+
+ return true;
}
-#if 1
void wechat_msg_receive_update_ui(void)
{
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_receive_audio_play_audio_ctrl_callback))
{
- Hal_NFFS_File_Play_Onetime(AUDIO_WECHAT_RECEIVE, (HAL_SPEAKER_GAIN)query_current_volume(), wechat_receive_audio_play_over_cb, NULL);
-
- Hal_Vibrator_Play_Onetime(NULL, 1000);
+ if(false == s_item_receive_playing)
+ {
+ s_item_receive_playing = true;
+
+ Hal_NFFS_File_Play_Onetime(AUDIO_WECHAT_RECEIVE, (HAL_SPEAKER_GAIN)query_current_volume(), wechat_receive_audio_play_over_cb, NULL);
+ Hal_Vibrator_Play_Onetime(NULL, 1000);
+ }
if(lv_watch_get_activity_obj(ACT_ID_WECHAT_MAIN))
{
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;
- wechat_msg_item_info.msg_time.tm_mon = cur_time.tm_mon;
- wechat_msg_item_info.msg_time.tm_mday = cur_time.tm_mday;
- wechat_msg_item_info.msg_time.tm_hour = cur_time.tm_hour;
- wechat_msg_item_info.msg_time.tm_min = cur_time.tm_min;
- wechat_msg_item_info.msg_time.tm_sec = cur_time.tm_sec;
+ _lv_memcpy(&(wechat_msg_item_info.msg_time), &cur_time, sizeof(hal_rtc_t));
wechat_msg_item_info.msg_from = 1;
wechat_msg_item_info.unread_flag = 1;
wechat_msg_item_info.msg_type = type; // WECHAT_MSG_TYPE_VOICE;
+ wechat_msg_item_info.msg_data_size = data_buff_len;
sprintf(wechat_msg_item_info.msg_data_full_file_name, "C:/wechat_r%04d%02d%02d_%02d%02d%02d.%s", /*WECHAT_MSG_DATA_FILE_PATH, */
- wechat_msg_item_info.msg_time.tm_year, wechat_msg_item_info.msg_time.tm_mon, wechat_msg_item_info.msg_time.tm_mday,
- wechat_msg_item_info.msg_time.tm_hour, wechat_msg_item_info.msg_time.tm_min, wechat_msg_item_info.msg_time.tm_sec,
+ wechat_msg_item_info.msg_time.tm_year,
+ wechat_msg_item_info.msg_time.tm_mon,
+ wechat_msg_item_info.msg_time.tm_mday,
+ wechat_msg_item_info.msg_time.tm_hour,
+ wechat_msg_item_info.msg_time.tm_min,
+ wechat_msg_item_info.msg_time.tm_sec,
t_file_ext[type]);
- lv_fs_file_t file_p = {0};
- lv_fs_res_t res = 0;
- uint32_t bytes_write = 0;
-
- res = lv_fs_open(&file_p, wechat_msg_item_info.msg_data_full_file_name, LV_FS_MODE_WR);
- if(LV_FS_RES_OK != res)
+ if(false == wechat_msg_item_info_write_to_file(wechat_msg_item_info.msg_data_full_file_name, data_buff, data_buff_len))
{
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
- lv_fs_close(&file_p);
-
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
return false;
}
-
- lv_fs_seek(&file_p, 0);
- res = lv_fs_write(&file_p, data_buff, data_buff_len, &bytes_write);
- if(LV_FS_RES_OK != res)
+
+ lv_wechat_ext_t * ext = wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
+ if(NULL != ext)
{
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
- lv_fs_close(&file_p);
-
- return false;
+ wechat_msg_voice_item_playing_stop(ext);
}
- lv_fs_close(&file_p);
wechat_msg_info_new_item_add(&wechat_msg_item_info);
// ui
if(false == mmi_active_screen_is_prohibit_interrupted()
&& false == mmi_health_measure_state_is_ui_measure()
- && false == wechat_msg_voice_is_playing()
+// && false == wechat_msg_voice_is_playing()
&& false == wechat_msg_voice_is_recording()
&& false == wechat_msg_item_is_sending()
#ifdef __MMI_ZHSX_SUPPORT_DO_NOT_DISTURB__
return true;
}
-#else
-
-bool wechat_msg_receive_from_server(char * data_buff, int data_buff_len, nv_wechat_msg_type_e type)
-{
- if(NULL == data_buff || 0 == data_buff_len)
- {
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- return false;
- }
- if(WECHAT_MSG_TYPE_MAX <= type)
- {
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- return false;
- }
-
- 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"};
-
- Hal_Rtc_Gettime(&cur_time);
- wechat_msg_item_info.msg_time.tm_year = cur_time.tm_year;
- wechat_msg_item_info.msg_time.tm_mon = cur_time.tm_mon;
- wechat_msg_item_info.msg_time.tm_mday = cur_time.tm_mday;
- wechat_msg_item_info.msg_time.tm_hour = cur_time.tm_hour;
- wechat_msg_item_info.msg_time.tm_min = cur_time.tm_min;
- wechat_msg_item_info.msg_time.tm_sec = cur_time.tm_sec;
-
- wechat_msg_item_info.msg_from = 1;
- wechat_msg_item_info.unread_flag = 1;
- wechat_msg_item_info.msg_type = type; // WECHAT_MSG_TYPE_VOICE;
- sprintf(wechat_msg_item_info.msg_data_full_file_name, "C:/wechat_r%04d%02d%02d_%02d%02d%02d.%s", /*WECHAT_MSG_DATA_FILE_PATH, */
- wechat_msg_item_info.msg_time.tm_year, wechat_msg_item_info.msg_time.tm_mon, wechat_msg_item_info.msg_time.tm_mday,
- wechat_msg_item_info.msg_time.tm_hour, wechat_msg_item_info.msg_time.tm_min, wechat_msg_item_info.msg_time.tm_sec,
- t_file_ext[type]);
-
- lv_fs_file_t file_p = {0};
- lv_fs_res_t res = 0;
- uint32_t bytes_write = 0;
-
- res = lv_fs_open(&file_p, wechat_msg_item_info.msg_data_full_file_name, LV_FS_MODE_WR);
- if(LV_FS_RES_OK != res)
- {
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
- lv_fs_close(&file_p);
-
- return false;
- }
-
- lv_fs_seek(&file_p, 0);
- res = lv_fs_write(&file_p, data_buff, data_buff_len, &bytes_write);
- if(LV_FS_RES_OK != res)
- {
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
- lv_fs_close(&file_p);
-
- return false;
- }
- lv_fs_close(&file_p);
-
- wechat_msg_info_new_item_add(&wechat_msg_item_info);
-
- if(false == mmi_active_screen_is_prohibit_interrupted()
- && false == mmi_health_measure_state_is_ui_measure()
- && false == wechat_msg_voice_is_playing()
- && false == wechat_msg_voice_is_recording()
- && false == wechat_msg_item_is_sending()
- )
- {
- mmi_watch_wake_up();
-
- if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_receive_audio_play_audio_ctrl_callback))
- {
- Hal_NFFS_File_Play_Onetime(AUDIO_WECHAT_RECEIVE, (HAL_SPEAKER_GAIN)query_current_volume(), wechat_receive_audio_play_over_cb, NULL);
- }
-
- Hal_Vibrator_Play_Onetime(NULL, 1000);
-
- if(lv_watch_get_activity_obj(ACT_ID_WECHAT_MAIN))
- {
- wechat_main_screen_refresh();
- }
- else
- {
- wechat_create_event_cb(NULL, LV_EVENT_CLICKED);
- }
- }
-
- return true;
-}
-#endif
-
bool wechat_msg_send_to_server(void)
{
bool result = false; // true-success; false-fail
- 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, s_wechat_msg_item_info.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);
-
+ lv_wechat_ext_t * ext = (lv_wechat_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
+ if(NULL == ext)
return false;
- }
-
- 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)
+
+ uint32_t file_size = ext->record_size;
+ char * file_buf = lv_mem_alloc(file_size + 1);
+ if(NULL == file_buf)
{
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d\n", __FUNCTION__, __LINE__, res);
-
- result = false;
- }
- else
+ lv_mem_free(ext->record_buffer);
+ ext->record_buffer = NULL;
+ return false;
+ }
+ _lv_memset_00(file_buf, file_size + 1);
+ _lv_memcpy(file_buf, ext->record_buffer, file_size);
+ lv_mem_free(ext->record_buffer);
+ ext->record_buffer = NULL;
+
+ if(true == wechat_msg_item_info_write_to_file(s_wechat_msg_item_info.msg_data_full_file_name, file_buf, file_size))
{
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: errno=%d,file_size=%d\n", __FUNCTION__, __LINE__, res, file_size);
-
if(true == mmi_protocol_action_send_talk(file_buf, file_size))
{
+ s_wechat_msg_item_info.msg_data_size = file_size;
wechat_msg_info_new_item_add(&s_wechat_msg_item_info);
result = true;
}
else
{
lv_fs_remove(s_wechat_msg_item_info.msg_data_full_file_name);
- result = false;
}
}
+
lv_mem_free(file_buf);
_lv_memset_00(&s_wechat_msg_item_info, sizeof(nv_watch_wechat_msg_item_info_t));
{
//lv_wechat_ext_t * ext = (lv_wechat_ext_t *)para;
- //if(NULL != ext->delete_timer_id)
- //{
- // Hal_Timer_Stop(ext->delete_timer_id);
- // ext->delete_timer_id = NULL;
- //}
-
- //lv_obj_del(ext->delete_bg);
wechat_main_screen_refresh();
}
Hal_Timer_Stop(sending_ext->result_timer_id);
sending_ext->result_timer_id = NULL;
}
-
- //WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- //if(NULL != sending_ext->sending_anim.var)
- //{
- // lv_anim_del(sending_ext->sending_anim.var, NULL);
- // sending_ext->sending_anim.var = NULL;
- //}
}
}
return NULL;
wechat_chat_list_set_slide_enable(&sending_ext->old_ext, false); /*prevent to slide out while recording*/
- sending_ext->result_timer_id = NULL;
+ _lv_memset_00(&(sending_ext->sending_anim), sizeof(lv_anim_t));
sending_ext->send_result = wechat_msg_send_to_server();
sending_ext->sending_timer_id = Hal_Timer_Start(1000 * 3, wechat_msg_sending_screen_timeout, sending_ext, FALSE);
+ sending_ext->result_timer_id = NULL;
lv_obj_t * img_bkg = lv_img_create(obj, NULL);
lv_img_set_src(img_bkg, ICON_WECHAT_SENDING_BG);
int8_t count_down = WECHAT_MSG_DATA_RECORD_DURATION_MAX - s_wechat_play_anim_count / 4;
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: count down=%d\n", __FUNCTION__, __LINE__, count_down);
- if(0 == count_down)
- {
- Hal_File_Record_Stop_Req(&(recording_ext->file_size));
- recording_ext->file_size = 0;
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
-
- //lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
- lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
- if(NULL != activity_obj)
- {
- lv_obj_del(activity_obj);
- }
- wechat_msg_sending_screen_create(NULL);
- }
- else
+ if(0 < count_down)
{
const char * content = lv_lang_get_text(WATCH_TEXT_ID_RELEASE_SENDING);
uint8_t len = strlen(content) + 8;
}
}
+bool wechat_msg_recording_stop(bool is_cancel)
+{
+ uint32_t duration_ms = 0;
+ uint32_t size = 0;
+
+ Hal_Record_Buffer_Stop_Req(&size, &duration_ms);
+ Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+
+ lv_wechat_ext_t * ext = (lv_wechat_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
+ if(NULL == ext)
+ return false;
+
+ if(true == is_cancel)
+ {
+ lv_mem_free(ext->record_buffer);
+ ext->record_buffer = NULL;
+ return false;
+ }
+
+ if(WECHAT_MSG_DATA_AMR_HEAD_SIZE >= size)
+ {
+ lv_mem_free(ext->record_buffer);
+ ext->record_buffer = NULL;
+ return false;
+ }
+ ext->record_size = size;
+
+ return true;
+}
+
void wechat_msg_recording_audio_ctrl_callback(AUDIO_CTRL_PRIORITY priority)
{
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: priority=%d\n", __FUNCTION__, __LINE__, priority);
}
else if(AUDIO_CTRL_PRIORITY_5 > priority)
{
- lv_wechat_msg_recording_ext_t * recording_ext = (lv_wechat_msg_recording_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_RECORDING);
- if(NULL != recording_ext)
- {
- Hal_File_Record_Stop_Req(&(recording_ext->file_size));
- recording_ext->file_size = 0;
- }
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+ wechat_msg_recording_stop(true);
//lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
}
}
-void wechat_msg_recording_cb(MCI_EVNET_T event , MCI_INFO_T info_type, int32_t value)
+void wechat_msg_recording_task_cb(lv_task_t * task)
{
- WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: event=%d\n", __FUNCTION__, __LINE__, event);
-
lv_wechat_ext_t * ext = (lv_wechat_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
if(NULL == ext)
return ;
/*sliding to the right, not click button*/
return;
}
-
- lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
- switch(ext->event)
+ lv_obj_t * activity_obj;
+ MCI_EVNET_T event = (MCI_EVNET_T) (task->user_data);
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: event=%d\n", __FUNCTION__, __LINE__, event);
+
+ switch(event)
{
case MCI_EVENT_EOS:
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- //lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
+
+ wechat_msg_recording_stop(false);
+ activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
if(NULL != activity_obj)
{
lv_obj_del(activity_obj);
case MCI_EVENT_ERROR:
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- lv_wechat_msg_recording_ext_t * recording_ext = (lv_wechat_msg_recording_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_RECORDING);
- if(NULL != recording_ext)
- {
- Hal_File_Record_Stop_Req(&(recording_ext->file_size));
- recording_ext->file_size = 0;
- }
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
- lv_fs_remove(s_wechat_msg_item_info.msg_data_full_file_name);
- //lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
+
+ wechat_msg_recording_stop(true);
+ activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
if(NULL != activity_obj)
{
lv_obj_del(activity_obj);
}
break;
- case MCI_EVENT_INFO:
- break;
+ //case MCI_EVENT_INFO:
+ // break;
default:
break;
}
}
+void wechat_msg_recording_cb(MCI_EVNET_T event, MCI_INFO_T info_type, int32_t value)
+{
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: event=%d,type=%d,value=%d\n", __FUNCTION__, __LINE__, event, info_type, value);
+
+ if(MCI_EVENT_INFO != event)
+ {
+ //recording_ext->event = event;
+ lv_task_t * record_task = lv_task_create(wechat_msg_recording_task_cb, 10, LV_TASK_PRIO_HIGH, event);
+ lv_task_once(record_task);
+ }
+}
+
+
void wechat_msg_recording_screen_prepare_destory(lv_obj_t * activity_obj)
{
- printf("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
-#if 0
lv_watch_png_cache_all_free();
- lv_obj_t * obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
- if(NULL != obj)
- {
- lv_obj_del(obj);
- }
-#endif
+ wechat_msg_recording_stop(true);
}
-void wechat_msg_recording_screen_create(void)
+lv_obj_t * wechat_msg_recording_screen_create(lv_obj_t * activity_obj)
{
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- lv_watch_activity_ext_t activity_ext = {0};
+ if(NULL == activity_obj)
+ {
+ lv_watch_activity_ext_t activity_ext = {0};
- activity_ext.actId = ACT_ID_WECHAT_RECORDING;
- activity_ext.create = NULL;
- activity_ext.prepare_destory = wechat_common_screen_prepare_destory;
- lv_obj_t * activity_obj = lv_watch_creat_activity_obj(&activity_ext);
- LV_ASSERT_MEM(activity_obj);
+ activity_ext.actId = ACT_ID_WECHAT_RECORDING;
+ activity_ext.create = wechat_msg_recording_screen_create;
+ activity_ext.prepare_destory = wechat_msg_recording_screen_prepare_destory; // wechat_common_screen_prepare_destory;
+ activity_obj = lv_watch_creat_activity_obj(&activity_ext);
+ if(NULL == activity_obj)
+ return NULL;
+ }
lv_obj_t * obj = lv_watch_obj_create(activity_obj);
LV_ASSERT_MEM(obj);
s_wechat_msg_item_info.msg_from, s_wechat_msg_item_info.msg_data_full_file_name);
//recording
+#if 0
if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_msg_recording_audio_ctrl_callback))
{
Hal_File_Record_Start_Req(s_wechat_msg_item_info.msg_data_full_file_name, wechat_msg_recording_cb);
}
+
+#else
+
+ lv_wechat_ext_t * ext = (lv_wechat_ext_t *)wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
+ if(NULL == ext)
+ return NULL;
- return;
+ if(NULL != ext->record_buffer)
+ {
+ lv_mem_free(ext->record_buffer);
+ ext->record_buffer = NULL;
+ }
+ ext->record_buffer = (uint8_t *)lv_mem_alloc(WECHAT_MSG_DATA_RECORD_SIZE_MAX);
+ if(NULL != ext->record_buffer)
+ {
+ _lv_memset_00(ext->record_buffer, WECHAT_MSG_DATA_RECORD_SIZE_MAX);
+
+ if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_msg_recording_audio_ctrl_callback))
+ {
+ Hal_Record_Buffer_Start_Req(ext->record_buffer,
+ WECHAT_MSG_DATA_RECORD_SIZE_MAX,
+ WECHAT_MSG_DATA_RECORD_DURATION_MAX * 1000,
+ wechat_msg_recording_cb);
+ }
+ }
+#endif
+
+ return obj;
}
static void wechat_out_of_memory_btn_event_cb(lv_obj_t * btn, lv_event_t e)
{
wechat_chat_list_set_slide_enable(&ext->old_ext, false); /*prevent to slide out while recording*/
- wechat_msg_recording_screen_create();
+ wechat_msg_recording_screen_create(NULL);
}
}
else if(LV_EVENT_CLICKED == e || LV_EVENT_PRESS_LOST == e)
{
- if(lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING))
+ lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
+ if(NULL != activity_obj)
{
lv_wechat_ext_t * ext = wechat_actId_ext_get(ACT_ID_WECHAT_MAIN);
if(NULL == ext)
lv_coord_t img_record_top = obj->coords.y1;
if(30 < img_record_top - point_y) // (point_y < (img_record_top - 20))
{
- /*last point is above img, consider as sliding up and cancel recording*/
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: indev_y=%d, img_y=%d\n", __FUNCTION__, __LINE__, point_y, img_record_top);
-
- Hal_File_Record_Stop_Req(&(recording_ext->file_size));
- recording_ext->file_size = 0;
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
- lv_fs_remove(s_wechat_msg_item_info.msg_data_full_file_name);
- //lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
- lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
- if(NULL != activity_obj)
- {
- lv_obj_del(activity_obj);
- }
+ wechat_msg_recording_stop(true);
+ lv_obj_del(activity_obj);
//return main list screen
wechat_main_screen_refresh();
}
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- Hal_File_Record_Stop_Req(&(recording_ext->file_size));
- recording_ext->file_size = 0;
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
- //lv_watch_del_interface(ACT_ID_WECHAT_RECORDING);
- lv_obj_t * activity_obj = lv_watch_get_activity_obj(ACT_ID_WECHAT_RECORDING);
- if(NULL != activity_obj)
- {
- lv_obj_del(activity_obj);
- }
+ wechat_msg_recording_stop(false);
+ lv_obj_del(activity_obj);
wechat_msg_sending_screen_create(NULL);
}
}
if(NULL == ext)
return ;
+ //
+ Hal_NFFS_File_Play_End();
+ Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+ Hal_Vibrator_Play_End();
+
wechat_msg_voice_item_playing_stop(ext);
}
}
+void wechat_msg_voice_item_reset_play_state(lv_wechat_msg_list_ext_t * list_page_ext)
+{
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
+ if(NULL == list_page_ext || NULL == list_page_ext->voice_playing_anim.var)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ return;
+ }
+
+ uint8_t msg_from = list_page_ext->voice_playing_msg_from;
+
+ lv_anim_del(list_page_ext->voice_playing_anim.var, NULL);
+ lv_img_set_src(list_page_ext->voice_playing_anim.var, ((0 == msg_from) ? ICON_WECHAT_MY_VOICE_ITEM_PLAYING3 : ICON_WECHAT_OTHER_VOICE_ITEM_PLAYING3));
+ list_page_ext->voice_playing_anim.var = NULL;
+}
+
void wechat_msg_voice_item_playing_stop(lv_wechat_ext_t * ext)
{
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
if(NULL == ext || NULL == ext->list)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
return;
+ }
- lv_wechat_msg_list_ext_t * list_page_ext = lv_obj_get_ext_attr(ext->list);
- if(NULL == list_page_ext)
+ lv_wechat_msg_list_ext_t * list_page_ext = (lv_wechat_msg_list_ext_t *)lv_obj_get_ext_attr(ext->list);
+ if(NULL == list_page_ext || NULL == list_page_ext->voice_playing_anim.var)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
return;
+ }
- if(NULL != list_page_ext->voice_playing_anim.var)
- {
- Hal_File_Play_End();
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
-
- uint8_t msg_from = wechat_msg_info_index_item_msg_from_get(s_wechat_selected_item_index);
-
- lv_anim_del(list_page_ext->voice_playing_anim.var, NULL);
- lv_img_set_src(list_page_ext->voice_playing_anim.var, (0 == msg_from) ? ICON_WECHAT_MY_VOICE_ITEM_PLAYING3 : ICON_WECHAT_OTHER_VOICE_ITEM_PLAYING3);
- list_page_ext->voice_playing_anim.var = NULL;
- }
+ Hal_File_Play_End();
+ Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+ wechat_msg_voice_item_reset_play_state(list_page_ext);
}
void wechat_chat_list_msg_item_style_reset(lv_wechat_ext_t * ext)
Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
lv_wechat_msg_list_ext_t * list_page_ext = (lv_wechat_msg_list_ext_t *)para;
-
if(NULL == list_page_ext || NULL == list_page_ext->voice_playing_anim.var)
{
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
return;
}
-
- uint8_t msg_from = wechat_msg_info_index_item_msg_from_get(s_wechat_selected_item_index);
-
- lv_anim_del(list_page_ext->voice_playing_anim.var, NULL);
- lv_img_set_src(list_page_ext->voice_playing_anim.var, ((0 == msg_from) ? ICON_WECHAT_MY_VOICE_ITEM_PLAYING3 : ICON_WECHAT_OTHER_VOICE_ITEM_PLAYING3));
- list_page_ext->voice_playing_anim.var = NULL;
+ wechat_msg_voice_item_reset_play_state(list_page_ext);
}
void wechat_chat_list_voice_item_play_action(lv_wechat_msg_list_ext_t * list_page_ext, lv_obj_t * play_img, lv_obj_t * unread_img)
{
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+
//display ui
lv_anim_t * a = &(list_page_ext->voice_playing_anim);
if(NULL != unread_img)
{
lv_obj_del(unread_img);
+ unread_img = NULL;
}
+ list_page_ext->voice_playing_msg_from = msg_item->msg_from;
//play voice
if(AUDIO_CTRL_PRIORITY_5 == Hal_Audio_Manage_Start_Req(AUDIO_CTRL_PRIORITY_5, wechat_chat_list_voice_item_playing_audio_ctrl_callback))
{
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
Hal_File_Play_Onetime(msg_item->msg_data_full_file_name, query_current_volume(), wechat_chat_list_voice_item_play_over_cb, list_page_ext, 0);
}
}
{
list_page_ext->pressing = false;
- lv_obj_t * play_img = lv_obj_get_child_back(cont, NULL);
nv_watch_wechat_msg_item_info_t * msg_item = NULL;
wechat_msg_info_index_item_get(s_wechat_selected_item_index, &msg_item);
- if(NULL != list_page_ext->voice_playing_anim.var) // exist voice playing
+ if(0 != msg_item->msg_data_size)
{
- lv_obj_t * old_img = list_page_ext->voice_playing_anim.var;
-
- //stop old item voice
- Hal_File_Play_End();
- Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
-
- lv_anim_del(list_page_ext->voice_playing_anim.var, NULL);
- lv_img_set_src(list_page_ext->voice_playing_anim.var, ((0 == msg_item->msg_from) ? ICON_WECHAT_MY_VOICE_ITEM_PLAYING3 : ICON_WECHAT_OTHER_VOICE_ITEM_PLAYING3));
- list_page_ext->voice_playing_anim.var = NULL;
-
- //play new item voice
- if((play_img != old_img) && (NULL != msg_item->msg_data_full_file_name))
+ if(NULL != list_page_ext->voice_playing_anim.var) // exist voice playing
{
- wechat_chat_list_voice_item_play_action(list_page_ext, play_img, list_item_ext->unread_img);
- }
- }
- else if(NULL != msg_item->msg_data_full_file_name)
- {
- wechat_chat_list_voice_item_play_action(list_page_ext, play_img, list_item_ext->unread_img);
- }
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: index=%d\n", __FUNCTION__, __LINE__, list_item_ext->item_index);
+
+ //stop item voice
+ Hal_File_Play_End();
+ Hal_Audio_Manage_End_Ind(AUDIO_CTRL_PRIORITY_5);
+ wechat_msg_voice_item_reset_play_state(list_page_ext);
+ }
+ else if(NULL != msg_item->msg_data_full_file_name)
+ {
+ WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: index=%d\n", __FUNCTION__, __LINE__, list_item_ext->item_index);
+
+ lv_obj_t * play_img = lv_obj_get_child_back(cont, NULL);
+ wechat_chat_list_voice_item_play_action(list_page_ext, play_img, ((1 == msg_item->unread_flag) ? list_item_ext->unread_img : NULL));
+ }
+ }
}
}
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, 20, 0);
+ lv_obj_align(len_label, play_img, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
lv_obj_del(unread_img);
}
else // msg from other
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, -20, 0);
+ lv_obj_align(len_label, play_img, LV_ALIGN_OUT_LEFT_MID, -10, 0);
if(1 == msg_item->unread_flag)
{
lv_img_set_src(unread_img, ICON_WECHAT_UNREAD_FLAG);
}
lv_fs_size(&file_p, &file_size);
- file_buf = lv_mem_alloc(file_size + 1);
+ file_buf = (char *)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);
lv_style_set_pad_right(&(list_page_ext->style_cont_other), LV_STATE_DEFAULT, 5);
_lv_memset_00(&(list_page_ext->voice_playing_anim), sizeof(lv_anim_t));
+ list_page_ext->voice_playing_msg_from = 0;
list_page_ext->pressing = false;
ext->list = list_page;
}
}
-//void wechat_no_network_create(lv_obj_t * obj)
-//{
-// lv_obj_t * img = lv_img_create(obj, NULL);
-// //lv_obj_set_size(img, lv_obj_get_width(obj), lv_obj_get_height(obj));
-// lv_img_set_src(img, ICON_WECHAT_NO_NETWORK);
-// lv_obj_align(img, obj, LV_ALIGN_CENTER, 0, 0);
-// lv_obj_set_click(img, false);
-//}
-
void wechat_main_screen_refresh(void)
{
WECHAT_DEBUG_PRINTF("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
ext->from = from;
ext->delete_timer_id = NULL;
ext->delete_bg = NULL;
+ ext->record_buffer = NULL;
+ ext->record_size = 0;
lv_obj_t * cont = lv_cont_create(obj, NULL);
lv_obj_set_size(cont, lv_obj_get_width(obj), lv_obj_get_height(obj));
lv_obj_set_click(ext->img_record, true);
lv_obj_set_event_cb(ext->img_record, wechat_msg_record_button_event_cb);
lv_obj_set_adv_hittest(ext->img_record, false);
- //lv_obj_add_protect(ext->img_record, LV_PROTECT_PRESS_LOST);
+ lv_obj_add_protect(ext->img_record, LV_PROTECT_PRESS_LOST);
lv_watch_obj_add_element(ext->img_record);
lv_obj_align(ext->img_record, cont, LV_ALIGN_IN_BOTTOM_MID, 0, -8);