267 lines
9.2 KiB
C
267 lines
9.2 KiB
C
#include "include.h"
|
||
#include "func.h"
|
||
#include "ble_protocol_msg.h"
|
||
#include "app_variable.h"
|
||
#include "spirit_island_api.h"
|
||
#if TRACE_EN
|
||
#define TRACE(...) printf(__VA_ARGS__)
|
||
#else
|
||
#define TRACE(...)
|
||
#endif
|
||
|
||
|
||
enum {
|
||
COMPO_ID_CARDBOX = 1,
|
||
COMPO_ID_CARDBOX_VIEW = 2,
|
||
COMPO_ID_CARDBOX_IGNORE = 3,
|
||
COMPO_ID_CARDBOX_ID_CNT = 4,
|
||
};
|
||
|
||
typedef struct f_message_push_t_ {
|
||
|
||
} f_message_push_t;
|
||
|
||
static BleProtocol_Msg_t *g_message = NULL;
|
||
|
||
|
||
|
||
const compo_message_item_t tbl_message_list[] = {
|
||
{MsgType_SMS, STR_MESSAGE},
|
||
{MsgType_QQ, STR_MESSAGE_QQ},
|
||
{MsgType_WeChat, STR_MESSAGE_WECHAT},
|
||
{MsgType_Facebook, STR_MESSAGE_FACEBOOK},
|
||
{MsgType_Twitter, STR_MESSAGE_TWITTER},
|
||
{MsgType_Linkedin, STR_LINKEDIN},
|
||
{MsgType_WhatsApp, STR_MESSAGE_WHATSAPP},
|
||
{MsgType_Line, STR_LINE},
|
||
{MsgType_KakaoTalk, STR_KAKAOTALK},
|
||
{MsgType_Messenger, STR_MESSENGER},
|
||
{MsgType_Instagram, STR_INSTAGRAM},
|
||
{MsgType_WhatsAppBusiness, STR_WHATSAPPBUSINESS},
|
||
{MsgType_Viber, STR_VIBER},
|
||
{MsgType_Telegram, STR_TELEGRAM},
|
||
{MsgType_SnapChat, STR_SNAPCHAT},
|
||
{MsgType_Zalo, STR_ZALO},
|
||
{MsgType_Outlook, STR_OUTLOOK},
|
||
{MsgType_SinaWeibo, STR_WEIBO},
|
||
{MsgType_VK, STR_VK},
|
||
{MsgType_Youtube, STR_YOUTUBE},
|
||
{MsgType_Tiktok, STR_TIKTOK},
|
||
{MsgType_Skype, STR_SKYPE},
|
||
|
||
};
|
||
|
||
|
||
|
||
int tjd_strtol(char *str) {
|
||
int tmp = 0;
|
||
while (*str != '\0') { /* 遇到结束符结束循环 */
|
||
if (*str >= '0' && *str <= '9') {
|
||
tmp = tmp * 10 + (*str - '0');
|
||
}
|
||
str++;
|
||
}
|
||
return tmp;
|
||
}
|
||
|
||
//创建消息窗体
|
||
compo_form_t *func_message_push_form_create(void)
|
||
{
|
||
//新建窗体
|
||
compo_cardbox_t *cardbox;
|
||
compo_button_t *btn;
|
||
|
||
g_message = &SysVariable.Message[SysVariable.Stroage_type].MsgContent[SysVariable.messageIndex];
|
||
//设置标题栏
|
||
|
||
//创建遮罩层
|
||
compo_form_t *frm = compo_form_create(true);
|
||
compo_shape_t *masklayer = compo_shape_create(frm, COMPO_SHAPE_TYPE_RECTANGLE);
|
||
compo_shape_set_color(masklayer, COLOR_BLACK);
|
||
compo_shape_set_location(masklayer, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y, GUI_SCREEN_WIDTH, GUI_SCREEN_HEIGHT);
|
||
compo_shape_set_alpha(masklayer, 200);
|
||
|
||
//消息
|
||
cardbox = compo_cardbox_create(frm, 1, 1, 3, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 76+15);
|
||
compo_cardbox_set_pos(cardbox, GUI_SCREEN_CENTER_X, 33+38-10);
|
||
compo_cardbox_rect_set_location(cardbox, 0, 0, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 76+15, 20);
|
||
compo_cardbox_rect_set_color(cardbox, 0,make_color(48, 48, 48));
|
||
compo_setid(cardbox, COMPO_ID_CARDBOX);
|
||
// compo_cardbox_icon_set(cardbox, 0, UI_BUF_ICON_CALENDAR_BIN); //图标
|
||
// compo_cardbox_icon_set_location(cardbox, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12-241, 612-631, 72, 72);
|
||
compo_cardbox_text_set_location(cardbox, 0, 10, -20-15, GUI_SCREEN_CENTER_X, 20);
|
||
// compo_cardbox_text_set_font(cardbox, 0, UI_BUF_0FONT_FONT_BIN);
|
||
compo_cardbox_text_set(cardbox, 0, g_message->msg_time); //心率值--------->>>todo
|
||
// compo_cardbox_text_set_font(cardbox, 1, UI_BUF_0FONT_FONT_BIN);
|
||
// compo_cardbox_text_set_location(cardbox, 1, -73, -15, 186, 20);
|
||
// compo_cardbox_text_set(cardbox, 1, i18n[STR_CALENDAR]); //日历
|
||
// compo_cardbox_text_set_font(cardbox, 2, UI_BUF_0FONT_FONT_BIN);
|
||
// compo_cardbox_text_set_location(cardbox, 2, 0, 15, 186, 60);
|
||
// compo_cardbox_text_set(cardbox, 2, g_message->pdata); //日历
|
||
|
||
compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_MESSAGE_SHOW_TYPE_BIN);
|
||
compo_picturebox_cut(pic, get_message_icon(g_message->type), MESSAGE_ITEM_CNT);
|
||
// pic = compo_picturebox_create(frm, tbl_message_list[get_message_icon(g_message->type)].res_addr);
|
||
compo_picturebox_set_pos(pic, 28, 28-10);
|
||
|
||
compo_textbox_t *txt = compo_textbox_create(frm, Msg_Data_Max_Len);
|
||
// compo_textbox_set_font(txt, UI_BUF_0FONT_FONT_BIN);
|
||
compo_textbox_set_multiline(txt, true);
|
||
compo_textbox_set_location(txt, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y-14, GUI_SCREEN_WIDTH-8*2, 50);
|
||
compo_textbox_set(txt, g_message->pdata); // 消息详情
|
||
|
||
|
||
cardbox = compo_cardbox_create(frm, 1, 0, 1, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 18);
|
||
compo_cardbox_set_pos(cardbox, GUI_SCREEN_CENTER_X, 120);
|
||
compo_cardbox_rect_set_location(cardbox, 0, 0, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 18, 9);
|
||
compo_cardbox_rect_set_color(cardbox, 0,make_color(54, 153, 255));
|
||
compo_setid(cardbox, COMPO_ID_CARDBOX_VIEW);
|
||
compo_cardbox_text_set_font(cardbox, 0, UI_BUF_0FONT_FONT_BIN);
|
||
compo_cardbox_text_set_location(cardbox, 0, 0, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 20);
|
||
compo_cardbox_text_set(cardbox, 0, i18n[STR_VIEW]); //日历
|
||
|
||
cardbox = compo_cardbox_create(frm, 1, 0, 1, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 18);
|
||
compo_cardbox_set_pos(cardbox, GUI_SCREEN_CENTER_X, 142);
|
||
compo_cardbox_rect_set_location(cardbox, 0, 0, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 18, 9);
|
||
compo_cardbox_rect_set_color(cardbox, 0,make_color(48, 48, 48));
|
||
compo_setid(cardbox, COMPO_ID_CARDBOX_IGNORE);
|
||
compo_cardbox_text_set_font(cardbox, 0, UI_BUF_0FONT_FONT_BIN);
|
||
compo_cardbox_text_set_location(cardbox, 0, 0, 0, GUI_SCREEN_WIDTH-GUI_SCREEN_WIDTH/12, 20);
|
||
compo_cardbox_text_set(cardbox, 0, i18n[STR_IGNORE]); //日历
|
||
|
||
return frm;
|
||
}
|
||
|
||
static void func_message_push_icon_click(void)
|
||
{
|
||
int icon_idx = 0;
|
||
f_message_push_t *f_msg = (f_message_push_t *)func_cb.f_cb;
|
||
|
||
char *msg = g_message->pdata;
|
||
char *title = NULL;
|
||
compo_cardbox_t *cardbox;
|
||
rect_t rect;
|
||
u8 func_jump = FUNC_NULL;
|
||
int res = 0;
|
||
point_t pt = ctp_get_sxy();
|
||
u16 id = 0;
|
||
for(u8 i= COMPO_ID_CARDBOX; i < COMPO_ID_CARDBOX_ID_CNT; i++) {
|
||
if (compo_cardbox_btn_is(compo_getobj_byid(i), pt)) {
|
||
id = i;
|
||
}
|
||
}
|
||
|
||
printf("click id:%d\n", id);
|
||
|
||
|
||
switch (id) {
|
||
case COMPO_ID_CARDBOX_VIEW:
|
||
SysVariable.Message[SysVariable.Stroage_type].MsgContent[SysVariable.messageIndex].is_noread = false;
|
||
res = msgbox(msg, title, MSGBOX_MODE_BTN_DIRECT_DELETE, g_message->type);
|
||
if (res == MSGBOX_RES_DELETE) {
|
||
//TODO: delete msg
|
||
printf("delete msg:%d\n", id);
|
||
BleProtocol_Message_StroageClear_index(SysVariable.Stroage_type,SysVariable.messageIndex);
|
||
func_back_to();
|
||
}
|
||
break;
|
||
|
||
case COMPO_ID_CARDBOX_IGNORE:
|
||
func_back_to();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
//刷新右滑组件Widget(时间、温度、图标等)
|
||
void func_message_push_update(void)
|
||
{
|
||
// printf("func_message_update[%d,%d,%d]\n",f_sidebar->message_number,MsgStorageCnt,Refresh);
|
||
if(SysVariable.New_message_arrive)
|
||
{
|
||
if (SysVariable.notification_light_up || !sys_cb.gui_sleep_sta)
|
||
{
|
||
sys_cb.wkp_flag = true;
|
||
}
|
||
SysVariable.New_message_arrive = 0;
|
||
compo_form_t *frm = func_cb.frm_main;
|
||
compo_form_destroy(frm);
|
||
func_cb.frm_main = func_message_push_form_create();
|
||
}
|
||
}
|
||
|
||
|
||
//消息功能事件处理
|
||
static void func_message_push_process(void)
|
||
{
|
||
func_message_push_update();
|
||
func_process();
|
||
}
|
||
|
||
//消息功能消息处理
|
||
static void func_message_push_message(size_msg_t msg)
|
||
{
|
||
|
||
|
||
switch (msg) {
|
||
case MSG_CTP_CLICK:
|
||
func_message_push_icon_click();
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_UP:
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_DOWN:
|
||
break;
|
||
|
||
case MSG_CTP_LONG:
|
||
break;
|
||
|
||
default:
|
||
func_message(msg);
|
||
break;
|
||
}
|
||
}
|
||
|
||
//进入消息功能
|
||
static void func_message_push_enter(void)
|
||
{
|
||
func_cb.f_cb = func_zalloc(sizeof(f_message_push_t));
|
||
func_cb.frm_main = func_message_push_form_create();
|
||
|
||
/* 产品定义:消息触发的亮屏时长固定为5秒 */
|
||
reset_sleep_delay_message_display();
|
||
}
|
||
|
||
//退出消息功能
|
||
static void func_message_push_exit(void)
|
||
{
|
||
f_message_push_t *f_msg = (f_message_push_t *)func_cb.f_cb;
|
||
|
||
if (SysVariable.password_allow_push)
|
||
SysVariable.password_allow_push = false;
|
||
|
||
func_cb.last = FUNC_MESSAGE_PUSH;
|
||
if(!BleProtocol_Message_Judge_Noread())
|
||
{
|
||
#if defined(TJD_GUI_SPIRIT_ISLAND_SHOW)
|
||
si_delet_task(message);
|
||
#endif
|
||
}
|
||
}
|
||
|
||
//消息功能
|
||
void func_message_push(void)
|
||
{
|
||
printf("%s\n", __func__);
|
||
|
||
func_message_push_enter();
|
||
while (func_cb.sta == FUNC_MESSAGE_PUSH) {
|
||
func_message_push_process();
|
||
func_message_push_message(msg_dequeue());
|
||
}
|
||
func_message_push_exit();
|
||
}
|