From 098714d17acdd913e6b4a3791dd81aa92f14d535 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Sat, 23 Nov 2024 06:20:59 +0000 Subject: [PATCH] Merge #1450 into sdk602patch0911 from refs/changes/1450/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1450/head: (23 commits squashed) - applsit拨号盘实现:目前,滑动一下屏幕APP转动一次,后续优化为多次转动 - 解决倒计时界面内存泄漏问题 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 修改显示方式页面多国语言显示问题 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 解决查找手表后变成长亮屏 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 拨号盘样式,实现跟手滑动效果 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 解决ChatGPT,设置Key后不能用问题 - 修改拨号盘图片显示bug - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - #865,手表与手机同时进行10分钟倒计时,手机倒计时已结束手表还剩余40秒bug - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 删除直线列表风格 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - debug界面弹窗内容不清空改为限制50条 - 解决#1189拨号盘风格,编码器旋转震动一次跳两个图标。旋转一个图标不会震动bug - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: Caisking <3449750381@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1450 --- .../nativeui/applist/include/ApplistView.h | 1 + .../nativeui/applist/src/ApplistView.cpp | 84 +++++++++++++++---- .../nativeui/system/include/SystemLogModel.h | 3 +- .../nativeui/system/src/SystemLogModel.cpp | 28 ++++++- 4 files changed, 96 insertions(+), 20 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h index e957f265a..f2024da7a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h @@ -166,6 +166,7 @@ private: UIImageView * PointImage{nullptr}; UIImageView * CircleListSelectImage{nullptr}; UIPicker * CircleListPicker{nullptr}; + UIScrollView * CircleListScrollView{nullptr}; int CircleListAPPNum{0}; }; } 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 5772aeb9c..9afda8964 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -14,6 +14,7 @@ #include "themestyle/include/ThemeStyleModel.h" #include "ModelListenerSample.h" #include "cmath" +#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" namespace OHOS { static constexpr int16 NUM_2 = 2; @@ -113,6 +114,11 @@ ApplistView::~ApplistView() delete CircleListPicker; CircleListPicker = nullptr; } + if(CircleListScrollView) + { + delete CircleListScrollView; + CircleListScrollView = nullptr; + } for(int i = 0;i < CircleListAPPNum;i++) { if(nullptr != CircleListAPP[i]) @@ -377,7 +383,7 @@ static const double PI_OVER_180 = M_PI / 180.0; // 180度对应的弧度 static const int native_big_app_size = 90; //大图标 static const int native_small_app_size = 72; //小图标 static int native_app_position_update_startflag = 0; //native_app_position_update函数开始更新的标志位 -static constexpr int angleIncrement = 5; +static constexpr int angleIncrement = 6; // 圆形表的圆心坐标和半径 static const int CIRCLE_CENTER_X = 233; @@ -1266,6 +1272,9 @@ public: bool OnDrag(UIView& view, const DragEvent& event) override { + isEncoderEvent = false; + isDragEvent = true; + int curX = event.GetCurrentPos().x; int curY = event.GetCurrentPos().y; int deltaX = abs(curX - preX); @@ -1332,6 +1341,11 @@ public: if(angle % 30 == 0) //不需要补偿角度 { OnDragEndFlag = 0; + if(isEncoderEvent) { + isEncoderEvent = false; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次"); + ui_api_vibrate_once_func(); + } } else { @@ -1364,22 +1378,41 @@ public: #endif } + bool OnRotateStart(UIView& view, const RotateEvent& event) + { + return false; + } + bool OnRotate(UIView& view, const RotateEvent& event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotate %d",event.GetRotate()); - if(event.GetRotate() > 0) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRotate回调次数%d",++RotateReportedCount); + isEncoderEvent = true; + isDragEvent = false; + if(RotateReportedCount > 4) { - isDirectRotateFlag = true; - angle += angleIncrement; - native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); - } - else - { - isDirectRotateFlag = false; - angle -= angleIncrement; - native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + if(event.GetRotate() > 0) + { + isDirectRotateFlag = true; + angle += angleIncrement; + native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + } + else + { + isDirectRotateFlag = false; + angle -= angleIncrement; + native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + } + + rotateangle += angleIncrement; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rotateangle:%d",rotateangle); + if(rotateangle >= 30 || rotateangle <= -30) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次"); + rotateangle = 0; + ui_api_vibrate_once_func(); + } } - return false; } bool OnRotateEnd(UIView& view, const RotateEvent& event) @@ -1393,6 +1426,8 @@ public: { OnDragEndFlag = 1; } + RotateReportedCount = 0; + rotateangle = 0; return false; } @@ -1406,6 +1441,10 @@ public: bool isDirectRotateFlag{false}; //是否是正向旋转的标志 int preX{0}; int preY{0}; + + bool isEncoderEvent{false}; //是否为编码器事件 + bool isDragEvent{false}; //是否为拖拽事件 + int RotateReportedCount{0}; }; void ApplistView::CircleListStyleOnStart(void) @@ -1450,7 +1489,24 @@ void ApplistView::CircleListStyleOnStart(void) int end = 3; CircleListPicker->SetValues(start,end); // printf("---%d\n",CircleListPicker->GetSelected()); - CircleListGroup_->Add(CircleListPicker); + // CircleListGroup_->Add(CircleListPicker); + } + /* -------------------------------------------------------------------------- */ + if(CircleListScrollView == nullptr) + { + CircleListScrollView = new UIScrollView(); + if(nullptr == CircleListScrollView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListScrollView failed!! [%d]", __LINE__); + return; + } + CircleListScrollView->SetPosition(213, 213, 40, 40); + CircleListScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + CircleListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + CircleListScrollView->SetStyle(STYLE_BORDER_RADIUS, 150); + CircleListScrollView->SetRotateFactor(1.0); + CircleListScrollView->RequestFocus(); + CircleListGroup_->Add(CircleListScrollView); } /* -------------------------------------------------------------------------- */ // if(CircleListImage1 == nullptr) @@ -1562,7 +1618,7 @@ void ApplistView::CircleListStyleOnStart(void) } } CircleListGroup_->SetOnDragListener(static_cast(AppCircleListOnDragListener_)); - CircleListPicker->SetOnRotateListener(static_cast(AppCircleListOnDragListener_)); + CircleListScrollView->SetOnRotateListener(static_cast(AppCircleListOnDragListener_)); /* -------------------------------------------------------------------------- */ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListStyleOnStart success!! [%d]", __LINE__); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h index 11ce5b1ab..0368b7faa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLogModel.h @@ -123,8 +123,7 @@ private: std::deque logData; // 存储日志数据 std::deque nextday_log; // 存储nextday时间戳 - std::deque - popup_windows_log; // 存储popup_windows时间戳 + std::deque popup_windows_log; // 存储popup_windows时间戳 bool uart_status{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp index e8276fb6b..231b4bd7d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp @@ -75,7 +75,7 @@ void start_report_nextday_log_end(void) { } // 清空popup_windows日志 void nextday_clear_popup_windows_log(void) { - OHOS::SystemLogModel::GetInstance()->clear_popup_windows_log(); + // OHOS::SystemLogModel::GetInstance()->clear_popup_windows_log(); } void save_popup_windows_log_c(int type) { @@ -340,8 +340,12 @@ bool SystemLogModel::save_popup_windows_log(popup_windows_log_data data) { // 保存新日志 popup_windows_log.push_back(data); + // 如果超过限制,删除最早的日志 + while (popup_windows_log.size() > 50) { + popup_windows_log.pop_front(); // 从前端删除最早的日志 + } // 将日志写入文件 - std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::app); + std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::trunc); if (!outFile) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open log file for writing"); @@ -349,7 +353,9 @@ bool SystemLogModel::save_popup_windows_log(popup_windows_log_data data) { } // 将结构体中的数据转换为字符串格式写入文件 - outFile << static_cast(data.type) << " " << data.timestamp << std::endl; + for (const auto &log : popup_windows_log) { + outFile << static_cast(log.type) << " " << log.timestamp << std::endl; + } outFile.close(); return true; } @@ -388,7 +394,20 @@ bool SystemLogModel::load_popup_windows_log() { popup_windows_log_data data; int typeInt; if (ss >> typeInt >> data.timestamp) { - data.type = static_cast(typeInt); + switch(typeInt) + { + case 0: + data.type = popup_windows_type::MOTION_RECOGNITION; + break; + case 1: + data.type = popup_windows_type::DRINK_WATER_REMINDER; + break; + case 2: + data.type = popup_windows_type::SEDENTARY_REMINDER; + break; + default: + break; + } popup_windows_log.push_back(data); } } @@ -403,6 +422,7 @@ SystemLogModel::get_popup_windows_log() const { } // 获取日志大小 size_t SystemLogModel::get_popup_windows_log_size() const { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"log size:%d",popup_windows_log.size()); return popup_windows_log.size(); } -- 2.17.1