bool getbind_status();
bool Get_is_ln_get_device_token_success();
+
+ // 日程提醒处理函数
+ void HandleScheduleReminder(const char* title, const char* content);
+
+ // 任务提醒处理函数
+ void HandleTaskReminder(const char* scheduleName);
private:
ThunderBirdModel();
// 音量/进度调节接口(用于 THUNDERBIRD_REMINDERVIEW_VOLUME)
void AdjustRemindProgress(int16_t delta); // 正数增加,负数减少
void SetRemindProgress(int16_t value);
+
+ // 任务提醒文本更新接口(用于 THUNDERBIRD_REMINDERVIEW_TASK_REMINDER)
+ void UpdateTaskReminderText(const char* title, const char* content);
enum : int16_t {
THUNDERBIRD_REMINDERVIEW_VOLUME = 0, // 音量调节
// ws_register_ai_answer_callback(ws_register_ai_answer_cb);
}
+ void ThunderBirdModel::HandleScheduleReminder(const char* title, const char* content)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleScheduleReminder");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title: %s", title ? title : "NULL");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Content: %s", content ? content : "NULL");
+
+ // 示例:通过图形服务显示提醒
+ if (title && content) {
+ // 可以在这里调用UI相关的显示逻辑
+ int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER);
+
+ // 更新任务提醒的文本内容
+ if (ThunderBirdReminderView::GetInstance()) {
+ ThunderBirdReminderView::GetInstance()->UpdateTaskReminderText(content,nullptr);
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Processing schedule reminder: %s - %s", title, content);
+ }
+ }
+
+ void ThunderBirdModel::HandleTaskReminder(const char* scheduleName)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleTaskReminder");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleName: %s", scheduleName ? scheduleName : "NULL");
+
+ // 这里可以添加具体的任务提醒处理逻辑
+ // 例如:显示任务提醒界面、播放提醒音、更新任务列表等
+
+ // 示例:通过图形服务显示任务提醒
+ if (scheduleName) {
+ // 可以在这里调用UI相关的显示逻辑
+ int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER);
+
+ // 更新任务提醒的文本内容
+ if (ThunderBirdReminderView::GetInstance()) {
+ ThunderBirdReminderView::GetInstance()->UpdateTaskReminderText(scheduleName,nullptr);
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Processing task reminder: %s", scheduleName);
+ }
+ }
+
}
\ No newline at end of file
if (RemindButton) { RemindButton->SetVisible(true); }
}
+ void ThunderBirdReminderView::UpdateTaskReminderText(const char* title, const char* content)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdReminderView::UpdateTaskReminderText");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title: %s, Content: %s", title ? title : "NULL", content ? content : "NULL");
+
+ if (TextLabel == nullptr) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TextLabel is null, cannot update task reminder text");
+ return;
+ }
+
+ if (title && content) {
+ // 组合标题和内容,用换行符分隔
+ char combinedText[512] = {0};
+ snprintf(combinedText, sizeof(combinedText) - 1, "%s\n%s", title, content);
+ TextLabel->SetText(combinedText);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updated task reminder text: %s", combinedText);
+ } else if (title) {
+ // 只有标题
+ TextLabel->SetText(title);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updated task reminder text with title only: %s", title);
+ } else if (content) {
+ // 只有内容
+ TextLabel->SetText(content);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updated task reminder text with content only: %s", content);
+ } else {
+ // 都没有,使用默认文本
+ TextLabel->SetText("11点了该睡觉了");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updated task reminder text with default text");
+ }
+ }
+
}
// 日程提醒通知
void HandScheduleReminderNotify(Request *request)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScheduleReminderNotify msg_id = %d",request->msgId);
- int status = *(int *)request->data;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScheduleReminderNotify msg_id = %d", request->msgId);
+
+ if (request->data == nullptr || request->len <= 0) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScheduleReminderNotify: invalid data");
+ return;
+ }
+
+ // 解析接收到的数据:标题和内容(以'\n'分隔)
+ // 使用 std::string 创建安全的数据副本
+ std::string payload(static_cast<char*>(request->data), request->len);
+
+ // 查找分隔符'\n'
+ size_t newlinePos = payload.find('\n');
+ if (newlinePos == std::string::npos) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScheduleReminderNotify: no separator found");
+ return;
+ }
+
+ // 分离标题和内容
+ std::string title = payload.substr(0, newlinePos);
+ std::string content = payload.substr(newlinePos + 1);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScheduleReminderNotify title = %s, content = %s", title.c_str(), content.c_str());
+
+ // 通过图形服务调用 ThunderBirdModel 的处理函数
+ GraphicService::GetInstance()->PostGraphicEvent(
+ [title, content]() {
+ if (OHOS::ThunderBirdModel::GetInstance()) {
+ OHOS::ThunderBirdModel::GetInstance()->HandleScheduleReminder(title.c_str(), content.c_str());
+ }
+ });
}
// 任务提醒通知
void HandTaskReminderNotify(Request *request)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandTaskReminderNotify msg_id = %d",request->msgId);
- int status = *(int *)request->data;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandTaskReminderNotify msg_id = %d", request->msgId);
+
+ if (request->data == nullptr || request->len <= 0) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandTaskReminderNotify: invalid data");
+ return;
+ }
+
+ // 解析接收到的数据:只有一个参数 scheduleName
+ // 使用 std::string 创建安全的数据副本
+ std::string scheduleName(static_cast<char*>(request->data), request->len);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandTaskReminderNotify scheduleName = %s", scheduleName.c_str());
+
+ // 通过图形服务调用 ThunderBirdModel 的处理函数
+ GraphicService::GetInstance()->PostGraphicEvent(
+ [scheduleName]() {
+ if (OHOS::ThunderBirdModel::GetInstance()) {
+ OHOS::ThunderBirdModel::GetInstance()->HandleTaskReminder(scheduleName.c_str());
+ }
+ });
}
/* -------------------------------------------------------------------------- */
#ifdef __cplusplus