From fdc0d0de321e302ca2d79c15f83d53c810f29b6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Tue, 9 Jul 2024 04:26:42 +0000 Subject: [PATCH] Merge #484 into sdk602patch0626 from refs/changes/484/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/484/head: (3 commits squashed) - 走查部分代码 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 增加读取信息错误的默认 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/484 --- .../nativeui/heartrate/src/HeartModel.cpp | 4 ++-- .../nativeui/message/include/MessageModel.h | 6 +++--- .../nativeui/message/include/MessageView.h | 1 + .../nativeui/message/src/MessageModel.cpp | 16 +++++++++------- .../nativeui/message/src/MessagePresenter.cpp | 1 + .../nativeui/message/src/MessageView.cpp | 8 ++++++++ .../src/notify/message_notification.cpp | 12 +++++++++--- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index c9d61d00c..426e957d0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -94,7 +94,7 @@ extern "C" { free(heartInfo); heartInfo = nullptr; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s heartRateData fail! ret = %d", rets); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s heartRateData fail! ret = %d", rets); return; } #endif @@ -631,7 +631,7 @@ namespace OHOS if (disvalid_counter_ >= MAX_DISVALID_HRS_COUNT) { // 结束本次测试 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"MAX_DISVALID_HRS_COUNT\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"MAX_DISVALID_HRS_COUNT"); Heart_Stop(); // 关闭自动检测心率 如果有其他高级心率检测在进行,则不会进行关闭[低优先级] HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h index ddbc5bc08..68d3ddba5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h @@ -1,8 +1,8 @@ /*** * @Date: 2024-06-21 09:56:18 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-22 18:13:06 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h + * @LastEditTime: 2024-07-08 09:22:12 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageModel.h */ /*** * @Date: 2024-04-15 10:55:58 @@ -67,7 +67,7 @@ namespace OHOS virtual ~MessageModel(); uint8_t numberOfItems; // 项数 - static const uint16_t MaxMessageListCount = 11; // 消息列表最大数量 + static const uint16_t MaxMessageListCount = 10; // 消息列表最大数量 MessageListItem Messages[MaxMessageListCount] = {0, false, nullptr, nullptr, nullptr}; // 消息列表 uint8_t indexCurrent; // 选择的项 diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h index 80d2e3813..93356a60b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h @@ -68,6 +68,7 @@ namespace OHOS bool InitPage(); bool SetupViewPage(MessageView *messageView); + void UpdataButton(int num); private: /*无消息界面*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp index a73fd48c0..0dfc1a595 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -51,7 +51,7 @@ namespace OHOS uint8_t MessageModel::GetMessageCount() const { - return numberOfItems; + return (numberOfItems != 0 ? numberOfItems : MaxMessageListCount); } void MessageModel::PrintData(MessageData messagedata) @@ -105,7 +105,7 @@ namespace OHOS cJSON *root = cJSON_Parse(jsonData.c_str()); cJSON *dataArray = cJSON_GetObjectItem(root, "infor"); int dataCount = cJSON_GetArraySize(dataArray); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dataCount is %d", dataCount); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "dataCount is %d", dataCount); std::vector MessageVector; for (int i = 0; i < dataCount; i++) @@ -145,9 +145,8 @@ namespace OHOS if (!messageVector.empty()) { numberOfItems = messageVector.size(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the numberOfItems is %d", numberOfItems); - // Messages[numberOfItems] = {numberOfItems, true, "", " 全部删除", ""}; - for (int i = numberOfItems - 1, count = 0; i >= 0 && count < MaxMessageListCount - 1; i--, count++) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "the numberOfItems is %d", numberOfItems); + for (int i = numberOfItems - 1, count = 0; i >= 0 && count < MaxMessageListCount; i--, count++) { MessageData messageData; messageData.isRead = messageVector[i].isRead; @@ -291,8 +290,11 @@ namespace OHOS std::vector messageVector = LoadMessageData(); numberOfItems = messageVector.size(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the numberOfItems is %d", numberOfItems); - - return &messageVector[numberOfItems - 1]; + if (numberOfItems >= 0) + { + return &messageVector[numberOfItems - 1]; + } + return nullptr; } // 设置当前项 void MessageModel::SetCurrentIndex(uint8_t index) diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp index 64e8e1190..5da9c526b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp @@ -76,6 +76,7 @@ namespace OHOS { view_->AddMessageToList(itemInfo[i]); } + // MessageView::GetInstance()->UpdataButton(p_MessageModel->GetMessageCount()); } Presenter::OnResume(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp index d49dd74a1..729e8daf9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp @@ -234,6 +234,14 @@ namespace OHOS messageView->SetVisible(false); // 隐藏界面 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowmessageView end"); } + void MessageView::UpdataButton(int num) + { + int top = num * 240; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "old top %d", top); + top > 466 ? top += 130 : top -= 100; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new top %d", top); + DeleteButton->SetPosition(43, top); + } /*控制显示界面*/ void MessageView::SetPopupViewStatus(PopupMessage view, bool status) { diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp index 0ccbe24f7..e4b1463e9 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp @@ -93,7 +93,7 @@ namespace OHOS return nullptr; } MessageGroupView->SetOnDragListener(dragListener); - #ifdef FD230 +#ifdef FD230 /*获取最新message*/ MessageData *data = MessageModel::GetInstance().GetNewestData(); if (data != nullptr) @@ -102,7 +102,13 @@ namespace OHOS timeStr = data->labelTime; messageStr = data->labelDetails; } - #endif + else + { + titleStr = "--"; + timeStr = "--"; + messageStr = "--"; + } +#endif /*初始化label*/ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitView"); /* -------------------------------------------------------------------------- */ @@ -164,7 +170,7 @@ namespace OHOS return nullptr; // 内存分配失败,返回 } deleteButton->SetPosition(0, 366); - deleteButton->Resize(466,100); + deleteButton->Resize(466, 100); deleteButton->SetViewId(DELETEBUTTON); deleteButton->SetText("Close"); deleteButton->SetStyle(STYLE_TEXT_FONT, 30); -- 2.17.1