From: 罗正 <1732036298@qq.com> Date: Sat, 12 Oct 2024 13:25:57 +0000 (+0000) Subject: Merge #1172 into sdk602patch0911 from refs/changes/1172/head X-Git-Tag: release_V1.2.70_20241020_135402~60^2~3^2~6 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6868e7d22af2a6680083d94f91d6114ece81922e;p=mirrors%2FFD230.git Merge #1172 into sdk602patch0911 from refs/changes/1172/head Code review from 罗正 * refs/changes/1172/head: (7 commits squashed) - #99解决,,给可以滚动视图添加表冠控制旋转表冠一直触发(需求) - 关机动画使用IMG_SRC_FILE_PATH而不用IMG_SRC_IMAGE_INFO ,解决关机动画出现慢问题 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - #429,解决弧形列表风格,功能界面返回列表界面默认回到列表头部位置(需求) - #969,解决,韩语,秒表计时界面有遮挡bug - 查找手机增加打印,方便分析出现查找手机为什么会有失灵的情况 - 运动识别添加设置弹窗优先级 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1172 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h index 8474614d6..9bd793f41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h @@ -45,6 +45,10 @@ public: uint16_t GetStartIndex(void); void SetHeadItemY(int index); int GetHeadItemY(void); + void SetArcListStartIndex(uint16_t index); + uint16_t GetArcListStartIndex(void); + void GetArcListHeadItemY(int y); + int GetArcListHeadItemY(void); void ApplistUpdate(void); void SetPresenter(ApplistPresenter *p); AppListStyle GetCurrentStyle(void); @@ -61,8 +65,10 @@ private: int32 bundleLen = 0; uint8 appLen = 0; - uint16_t startIndex = 0; - int headItemY = 0; + uint16_t arcListstartIndex = 0; // 圆弧列表起始位置 + int arcListheadItemY = 0; // 圆弧列表头部位置 + uint16_t startIndex = 0; // 列表起始位置 + int headItemY = 0; // 列表头部位置 bool initFlag{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h index 29d65a1ad..f68c1f5a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h @@ -35,6 +35,10 @@ namespace OHOS { uint16_t GetStartIndex(void); void SetHeadItemY(int y); int GetHeadItemY(void); + void SetArcListStartIndex(uint16_t index); + uint16_t GetArcListStartIndex(void); + void SetArcListHeadItemY(int y); + int GetArcListHeadItemY(void); uint8_t GetListItemNum(void); ApplistView* GetAppListView(); AppListStyle GetCurrentStyle(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 6602e7967..ae71146af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -227,6 +227,29 @@ namespace OHOS return headItemY; } + //设置弧形列表的起始位置 + void ApplistModel::SetArcListStartIndex(uint16_t index) + { + arcListstartIndex = index; + } + + //获取弧形列表的起始位置 + uint16_t ApplistModel::GetArcListStartIndex(void) + { + return arcListstartIndex; + } + + //设置弧形列表的头部位置 + void ApplistModel::GetArcListHeadItemY(int y) + { + arcListheadItemY = y; + } + //获取弧形列表的头部位置 + int ApplistModel::GetArcListHeadItemY(void) + { + return arcListheadItemY; + } + void ApplistModel::ApplistUpdate(void) { ResolvingJSAppItems(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 564c30999..9269219d4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -239,6 +239,31 @@ namespace OHOS return model->GetHeadItemY(); } + //设置弧形列表起始索引 + void ApplistPresenter::SetArcListStartIndex(uint16_t index) + { + model->SetArcListStartIndex(index); + return; + } + + //获取弧形列表起始索引 + uint16_t ApplistPresenter::GetArcListStartIndex(void) + { + return model->GetArcListStartIndex(); + } + + //设置弧形列表头部Item的Y坐标 + void ApplistPresenter::SetArcListHeadItemY(int y) + { + model->GetArcListHeadItemY(y); + } + + //获取弧形列表头部Item的Y坐标 + int ApplistPresenter::GetArcListHeadItemY(void) + { + return model->GetArcListHeadItemY(); + } + uint8_t ApplistPresenter::GetListItemNum(void) { return model->GetAppListNum(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index 897e2edd3..285147d24 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -288,7 +288,7 @@ void ApplistView::ArcScaleListStyleOnStart(void) ArcScaleList_->SetPosition(ARC_SCALE_LIST_X, ARC_SCALE_LIST_Y, ARC_SCALE_LIST_WIDTH, ARC_SCALE_LIST_HEIGHT); ArcScaleList_->SetItemTransformFunc(&TransformItemBaseOnPosition); - ArcScaleList_->SetAdapter(ArcScaleListAdapter_); + // ArcScaleList_->SetAdapter(ArcScaleListAdapter_); ArcScaleList_->SetDraggable(true); ArcScaleList_->SetThrowDrag(true); ArcScaleList_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); @@ -365,8 +365,15 @@ void ApplistView::ListStyleOnSetUpView() startIndex = presenter_->GetListItemNum() - 1; headY = VERTICAL_RESOLUTION / NUM_2; } else { - startIndex = presenter_->GetStartIndex(); - headY = presenter_->GetHeadItemY(); + uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId(); + if (presliceId == VIEW_MAIN) //如果是从主页进入的,那么startIndex = 0,headY = 0 + { + startIndex = 0; + headY = 0; + } else { + startIndex = presenter_->GetStartIndex(); + headY = presenter_->GetHeadItemY(); + } if (headY == 0) { headY = VERTICAL_RESOLUTION / NUM_2; } @@ -379,7 +386,35 @@ void ApplistView::ListStyleOnSetUpView() void ApplistView::ArcScaleListStyleOnSetUpView(void) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::ArcScaleListStyleOnSetUpView [%d]", __LINE__); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ArcScaleListStyleOnSetUpView [%d]", __LINE__); + if (ArcScaleList_ == nullptr || ArcScaleListAdapter_ == nullptr) { + return; + } + + uint16_t startIndex = 0; + int16_t headY = 0; + if (presenter_->GetArcListStartIndex() >= presenter_->GetListItemNum()) { + startIndex = presenter_->GetListItemNum() - 1; + headY = VERTICAL_RESOLUTION / NUM_2; + } else { + uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId(); + if (presliceId == VIEW_MAIN) //如果是从主页进入的,那么startIndex = 0,headY = 0 + { + startIndex = 0; + headY = 0; + } else { //如果是从其他页面进入的,那么startIndex = presenter_->GetArcListStartIndex(),headY = presenter_->GetArcListHeadItemY() + startIndex = presenter_->GetArcListStartIndex(); + headY = presenter_->GetArcListHeadItemY(); + } + if (headY == 0) { + headY = VERTICAL_RESOLUTION / NUM_2; + } + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[%d],startIndex = %d,headY = %d", __LINE__,startIndex,headY); + ArcScaleList_->SetStartIndex(startIndex);//设置起始索引。 + ArcScaleList_->SetAdapter(ArcScaleListAdapter_); + ArcScaleList_->ScrollBy(headY);//滚动到指定的 headY 位置。 + return; } void ApplistView::OnTearDownView() @@ -489,6 +524,12 @@ void ApplistView::ArcScaleListStyleOnStop(void) // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::ArcScaleListStyleOnStop [%d]", __LINE__); ArcScaleListGroup_->RemoveAll(); } + int16_t arclistHeadY = ArcScaleList_->GetChildrenHead()->GetY(); + int16_t arclistHeadIndex = ArcScaleList_->GetChildrenHead()->GetViewIndex(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[%d],listHeadY = %d,listHeadIndex = %d", __LINE__,arclistHeadY,arclistHeadIndex); + presenter_->SetArcListHeadItemY(arclistHeadY); //设置头部Y坐标 + presenter_->SetArcListStartIndex(arclistHeadIndex); //设置头部Index + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnStop end..."); } void ApplistView::AddAppItemToList(const AppItem &item) diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h b/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h index 0418fd11d..92cffcc85 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h @@ -2,11 +2,12 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 15:21:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-30 11:10:19 + * @LastEditTime: 2024-10-12 17:22:50 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h */ #ifndef FINDPHONE_MODEL_H #define FINDPHONE_MODEL_H +#include "cstdint" namespace OHOS { @@ -16,7 +17,7 @@ namespace OHOS static FindPhoneModel &GetInstance(); void SetBlueToothConnectedState(bool state); bool GetBlueToothConnectedState(); - void start_or_stop_find_phone(int val); + void start_or_stop_find_phone(uint8_t val); private: FindPhoneModel() {} ~FindPhoneModel() {} diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp index eb54d6463..aa6df22ba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 15:21:30 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-30 11:11:00 + * @LastEditTime: 2024-10-12 17:18:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp */ @@ -39,12 +39,17 @@ namespace OHOS } // 开始或停止查找手机 - void FindPhoneModel::start_or_stop_find_phone(int val) + void FindPhoneModel::start_or_stop_find_phone(uint8_t val) { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "start_or_stop_find_phone %d", val); // 发送指令停止震动 if (FindPhoneModel::GetInstance().GetBlueToothConnectedState()) { senfindphoneSend(val); } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start_or_stop_find_phone not connected"); + } } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp index 4635d256c..d8e920deb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 10:47:46 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-05 10:16:43 + * @LastEditTime: 2024-10-12 17:13:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp */ #include "findphone/include/FindPhoneView.h" @@ -283,11 +283,13 @@ namespace OHOS if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态 { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phone is connected"); FindPhoneViewInit_BlueToothConnected(); FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_START); } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phone is not connected"); FindPhoneViewInit_BlueToothDisConnected(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h index dc906baa6..01c4560ef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-04 15:13:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-20 11:25:11 + * @LastEditTime: 2024-10-12 16:05:30 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h */ #ifndef MAIN_STOPWATCH_PRESENTER_H @@ -66,6 +66,7 @@ namespace OHOS uint64_t lastRecordTime = 0; // 上次记录时间 int RecordCycleNumber{0}; // 用来记录计时圈数 bool X_DRAG_FLAG{false}; + bool isStartMark{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index b950eec17..97a5d9ca9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -88,7 +88,7 @@ namespace OHOS label->SetPosition(x, y); label->SetStyle(STYLE_TEXT_FONT, TextFont); label->SetStyle(STYLE_LINE_HEIGHT, LineHeight); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TextFont); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, TextFont); label->Invalidate(); } @@ -171,7 +171,7 @@ namespace OHOS UNUSED(view); MainStopWatchView *mainStopWatchView = MainStopWatchView::GetInstance(); const char *clickedViewId = view.GetViewId(); - if (strcmp(clickedViewId, ResetOrMarkButton_MARK_VIEWID) == 0) + if (strcmp(clickedViewId, ResetOrMarkButton_MARK_VIEWID) == 0) // 点击标记按钮 { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordCycleNumber:%d\n", RecordCycleNumber); if (RecordCycleNumber >= MAX_RECORD_LOOPS) // 到达最高记录圈数 @@ -184,10 +184,16 @@ namespace OHOS { RecordCycleNumber += 1; } - mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, false); - SetShowTimeLableStyle(m_showTimelabel, 93, 60, 65, 78); - mainStopWatchView->SetViewIsVisible(m_list, true); - mainStopWatchView->SetViewIsVisible(m_image, true); + + if (isStartMark == false) // 第一次标记 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "isStartMark = %d", isStartMark); + mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, false); + SetShowTimeLableStyle(m_showTimelabel, 0, 60, 65, 78); + mainStopWatchView->SetViewIsVisible(m_list, true); + mainStopWatchView->SetViewIsVisible(m_image, true); + isStartMark = true; + } uint64_t currentRecordTime = TimeStrToMilliseconds(MainStopWatchView::GetInstance()->GetShowTimelabel()->GetText()); // 获取当前时间 uint64_t timeDifference = 0; // 时间差值 @@ -219,7 +225,7 @@ namespace OHOS lastRecordTime = currentRecordTime; return true; } - else if (strcmp(clickedViewId, ResetOrMarkButton_RESET2_VIEWID) == 0) + else if (strcmp(clickedViewId, ResetOrMarkButton_RESET2_VIEWID) == 0) // 点击重置按钮 { StopWatchModel::GetInstance()->StopWatch_StopTimer(); // 停止定时器 mainStopWatchView->GetShowTimelabel()->SetText("00:00.00"); @@ -229,15 +235,21 @@ namespace OHOS m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1); m_button->Invalidate(); - mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, true); - SetShowTimeLableStyle(m_showTimelabel, 68, 160, 84, 94); - mainStopWatchView->SetViewIsVisible(m_image, false); - mainStopWatchView->SetViewIsVisible(m_list, false); + if (isStartMark == true) // 重置标记 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "isStartMark = %d", isStartMark); + mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, true); + SetShowTimeLableStyle(m_showTimelabel, 0, 160, 84, 94); + mainStopWatchView->SetViewIsVisible(m_image, false); + mainStopWatchView->SetViewIsVisible(m_list, false); + isStartMark = false; + } if (m_listdata != nullptr) { for (int i = 0; i < m_listdata->Size(); i++) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%d", i); char *p = (char *)(m_listdata->Tail()->data_); free(p); } @@ -250,11 +262,11 @@ namespace OHOS } RecordCycleNumber = 0; } - else if (strcmp(clickedViewId, CycleToLimitReturnButton_VIEWID) == 0) + else if (strcmp(clickedViewId, CycleToLimitReturnButton_VIEWID) == 0) // 点击返回按钮 { mainStopWatchView->ChangeView(STOPWATCH_RECORD_CYCLE_TO_LIMIT, MAIN_STOPWATCH); } - else if (strcmp(clickedViewId, TimeToLimitReturnButton_VIEWID) == 0) + else if (strcmp(clickedViewId, TimeToLimitReturnButton_VIEWID) == 0) // 点击返回按钮 { mainStopWatchView->ChangeView(STOPWATCH_RECORD_TIME_TO_LIMIT, MAIN_STOPWATCH); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp index fd4848626..89538ec79 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -273,11 +273,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showTimelabel new fail!!"); return; } - showTimelabel->SetPosition(68, 160); + showTimelabel->SetPosition(0, 160,466, 94); showTimelabel->SetStyle(STYLE_TEXT_FONT, 84); showTimelabel->SetStyle(STYLE_LINE_HEIGHT, 94); showTimelabel->SetText("00:00.00"); - showTimelabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + showTimelabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP); showTimelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); showTimelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 84); /* -------------------------------- LineImage ------------------------------- */ @@ -316,7 +316,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listadapter new fail!!"); return; } - listadapter->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + listadapter->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 28); /* -------------------------------- listdata -------------------------------- */ listdata = new List(); if (listdata == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp index 0bb93fbc9..b37b7f66e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp @@ -17,7 +17,7 @@ namespace OHOS /* ----------------------------------- 定时器 ---------------------------------- */ // 声明定时器变量 - static osTimerId_t g_timer = NULL; + static osTimerId_t g_timer = nullptr; static int g_StopWatchTimes = {0}; static constexpr int32 NUM_TEN = 10; // 主要用于格式化输出,当小时、分钟或秒小于10时,在其前面添加一个’0’以保持常规时间格式 static constexpr int16 ERROR = 0; @@ -25,7 +25,7 @@ namespace OHOS static constexpr int16 NUM_TIME_MIN = 60; static constexpr int16 NUM_TIME_HOUR = 3600; static constexpr int32 NUM_TIME_DAY = 86400; - static constexpr int32 MAX_NUM_TIME = (99 * 60 * 1000) + (59 * 1000) + 990; // 99分59秒990毫秒 + static constexpr int32 MAX_STOPWATCH_TIME = (99 * 60 * 1000) + (59 * 1000) + 990; // 99分59秒990毫秒 static uint64_t g_timerStartTimestamp = 0; // 添加一个全局变量来存储定时器开始的时间戳 /* * @brief 显示倒计时(分钟、秒、毫秒),毫秒显示为两位数 @@ -81,28 +81,13 @@ namespace OHOS */ static void StopWatch_TimerCallbackProc(int data) { - g_StopWatchTimes += 10; // 每次回调增加10毫秒 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_StopWatchTimes:%d\n", g_StopWatchTimes); - - if (MainStopWatchView::GetInstance() == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[StopWatch_TimerCallbackProc] GetInstance is NULL"); - return; - } - - if (MainStopWatchView::GetInstance()->GetShowTimelabel() == nullptr) + if (MainStopWatchView::GetInstance() == nullptr || MainStopWatchView::GetInstance()->GetShowTimelabel() == nullptr || StopWatchModel::GetInstance()->DisplayStopWatchDuration() == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[StopWatch_TimerCallbackProc] GetInstance()->GetShowTimelabel is NULL"); return; } - if (StopWatchModel::GetInstance()->DisplayStopWatchDuration() == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[StopWatch_TimerCallbackProc] DisplayStopWatchDuration is NULL"); - return; - } + if ((g_StopWatchTimes) >= MAX_STOPWATCH_TIME) // 达到最大时间 - if ((g_StopWatchTimes) >= MAX_NUM_TIME) // 5999990 = 99分59秒99的毫秒数 { MainStopWatchView::GetInstance()->GetPlayOrPausecheckBox()->SetState(UICheckBox::UNSELECTED); MainStopWatchView::GetInstance()->ChangeRecordTimeToLimitView(); @@ -118,6 +103,7 @@ namespace OHOS */ static void StopWatch_TimerCallback(int data) { + g_StopWatchTimes += 10; // 每次回调增加10毫秒 GraphicService::GetInstance()->PostGraphicEvent(std::bind(StopWatch_TimerCallbackProc, data)); } @@ -128,16 +114,16 @@ namespace OHOS void StopWatchModel::StopWatch_StartTimer(uint32_t interval) { /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ - if (g_timer != NULL) + if (g_timer != nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopWatchModel::StopWatch_StartTimer Timer already exists!!"); return; } /* --------------------------------- 2.创建定时器 -------------------------------- */ - g_timer = osTimerNew((osTimerFunc_t)StopWatch_TimerCallback, osTimerPeriodic, NULL, NULL); + g_timer = osTimerNew((osTimerFunc_t)StopWatch_TimerCallback, osTimerPeriodic, nullptr, nullptr); // 检查定时器创建是否成功 - if (g_timer == NULL) + if (g_timer == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopWatchModel::StopWatch_StartTimer Timer create failed!!"); return; @@ -149,15 +135,15 @@ namespace OHOS /* --------------------------------- 4.启动定时器 -------------------------------- */ // g_timerStartTimestamp = GetCurrentTimestamp(); // 假设GetCurrentTimestamp()是获取当前时间戳的函数 osStatus_t ret = osTimerStart(g_timer, tick); - /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */ + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */ if (ret != osOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[StopWatch_StartTimer]osTimerDelete failed, ret = %lx!!", ret); - if (g_timer != NULL) + if (g_timer != nullptr) { ret = osTimerDelete(g_timer); } - g_timer = NULL; + g_timer = nullptr; return; } return; @@ -169,16 +155,16 @@ namespace OHOS void StopWatchModel::StopWatch_StopTimer(void) { // 检查定时器是否存在 - if (g_timer != NULL) + if (g_timer != nullptr) { osTimerStop(g_timer); - // 删除定时器并置为 NULL + // 删除定时器并置为 nullptr osStatus_t ret = osTimerDelete(g_timer); if (ret != osOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret); } - g_timer = NULL; + g_timer = nullptr; g_StopWatchTimes = 0; } } @@ -188,7 +174,7 @@ namespace OHOS void StopWatchModel::StopWatch_PauseTimer(void) { // 检查定时器是否存在 - if (g_timer != NULL) + if (g_timer != nullptr) { // 暂停定时器,但不删除它 osStatus_t ret = osTimerStop(g_timer); @@ -205,7 +191,7 @@ namespace OHOS void StopWatchModel::StopWatch_ResumeTimer(uint32_t interval) { // 检查定时器是否存在 - if (g_timer != NULL) + if (g_timer != nullptr) { int tick = osMs2Tick(interval); // 恢复定时器 diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 9a3d984a4..310882796 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -1202,6 +1202,10 @@ void MsgCenterNotifyFindWatchProc(const Topic topic, Request* req) NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); NotificationManager::GetInstance()->ShowNotify(showFindWatchNotify, (uint16_t)topic, true); } + else + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyPriority = %d ",NotificationManager::GetInstance()->GetNotifyPriority()); + } } //取消查找手表通知 @@ -1335,6 +1339,7 @@ void MsgCenterNotifyArAlertProc(const Topic topic, Request* req) if (CheckPriority(topic)) { MotionRecognitionViewEventListener::GetInstance().SetMotionTypeId(*motionType); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); NotificationManager::GetInstance()->ShowNotify(showMotionRecognitionNotify, (uint16_t)topic, true); }