From 9d2d8831efe2c53a0ea6b2d25b1ba149b2d2c43b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Mon, 30 Sep 2024 09:56:52 +0000 Subject: [PATCH] Merge #1070 into sdk602patch0626 from refs/changes/1070/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1070/head: (18 commits squashed) - 修改第一次启动时进入界面逻辑。不再根据手机是否连接做判断条件 - 解决,#695,手表,弧形列表使用编码器上下滑动时没有和列表显示一样增加震动反馈bug - 解决,#878,手表,恢复出厂设置时,频繁点击按钮会持续震动bug 恢复出厂添加关机动画 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 语言界面修改 - 指南针界面多国语言翻译 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 1.解决勿扰模式内存泄漏问题 2.解决勿扰模式界面中label在切换成其他国语言导致字体遮盖下面的Button问题 3.勿扰模式界面添加编码器控制界面问题 4.解决勿扰模式内存泄漏问题 - 解决,#883手表,闹钟响铃没有按照文档中设定40秒响铃,目前测试实际响铃50秒bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 指南针背景图片修改 - 解决#832手表与APP蓝牙断连,手表端点击找手机,界面不会弹出蓝牙断连提示bug 查找手机界面会根据手机蓝牙是否有无连接显示不同界面 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #880,在二维码扫码页面添加 电池百分比显示 - 解决,#843,录音文件排序错乱bug - 解决#802录音列表有遮挡显示不全bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 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/1070 --- .../findphone/include/FindPhoneModel.h | 3 +- .../findphone/include/FindPhoneView.h | 3 +- .../nativeui/findphone/src/FindPhoneModel.cpp | 21 ++- .../findphone/src/FindPhonePresenter.cpp | 18 +- .../nativeui/findphone/src/FindPhoneView.cpp | 131 ++++++-------- .../nativeui/main/src/MainPresenterSample.cpp | 7 +- .../nativeui/record/src/RecordListView.cpp | 6 +- .../nativeui/record/src/RecordingModel.cpp | 17 ++ .../watchQRcode/include/WatchQRCodeView.h | 11 +- .../watchQRcode/src/WatchQRCodePresenter.cpp | 7 +- .../watchQRcode/src/WatchQRCodeView.cpp | 162 ++++++++++++++++-- .../src/notify/alarm_notification.cpp | 4 +- .../fd230/fs/user/res/MainCard/compass.bin | 2 +- 13 files changed, 263 insertions(+), 129 deletions(-) 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 af97544e7..0418fd11d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 15:21:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-10 16:23:41 + * @LastEditTime: 2024-09-30 11:10:19 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h */ #ifndef FINDPHONE_MODEL_H @@ -16,6 +16,7 @@ namespace OHOS static FindPhoneModel &GetInstance(); void SetBlueToothConnectedState(bool state); bool GetBlueToothConnectedState(); + void start_or_stop_find_phone(int val); private: FindPhoneModel() {} ~FindPhoneModel() {} diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h b/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h index 940f76b64..7a0f7f8a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-31 09:52:34 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-31 16:38:04 + * @LastEditTime: 2024-09-30 11:15:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -51,7 +51,6 @@ namespace OHOS UIImageView *FindPhoneImageView{nullptr}; const ImageInfo **FindPhonePathsArray{nullptr}; ImageAnimatorInfo FindPhoneImageInfo[FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - bool viewInitStatus{false}; }; } // namespace OHOS #endif \ No newline at end of file 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 b2cbdeea3..eb54d6463 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-05-10 17:00:42 + * @LastEditTime: 2024-09-30 11:11:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp */ @@ -10,6 +10,7 @@ #include "bletest.h" #include #include "wearable_log.h" +#include "bleEvent.h" namespace OHOS { @@ -28,12 +29,22 @@ namespace OHOS /*获取与手机蓝牙是否已连接*/ bool FindPhoneModel::GetBlueToothConnectedState() { - //return ble_is_ready() && ble_is_connect_ready(); + // return ble_is_ready() && ble_is_connect_ready(); uint8_t ret = uapi_dev_runtime_get_ble_connect_stat(); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret); if (ret == 1) - return true; - else - return false; + return true; + else + return false; + } + + // 开始或停止查找手机 + void FindPhoneModel::start_or_stop_find_phone(int val) + { + // 发送指令停止震动 + if (FindPhoneModel::GetInstance().GetBlueToothConnectedState()) + { + senfindphoneSend(val); + } } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp index 941ba0dd4..635b86ad3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 10:47:40 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-31 16:43:28 + * @LastEditTime: 2024-09-30 11:13:11 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp */ #include "AppViewIDs.h" @@ -60,6 +60,7 @@ namespace OHOS void FindPhonePresenter::OnStop(void) { Presenter::OnStop(); + FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_STOP); // 发送指令停止震动 } bool FindPhonePresenter::OnClick(UIView &view, const ClickEvent &event) @@ -68,11 +69,6 @@ namespace OHOS UNUSED(event); if (strcmp(view.GetViewId(), FINDPHONE_LABELBUTTON) == 0) { - // 发送指令停止震动 - if (FindPhoneModel::GetInstance().GetBlueToothConnectedState()) - { - senfindphoneSend(FINDPHONE_STOP); - } NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; @@ -96,11 +92,6 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && FindPhonePresenter::X_DRAG_FLAG) { NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); - // 发送指令停止震动 - if (FindPhoneModel::GetInstance().GetBlueToothConnectedState()) - { - senfindphoneSend(FINDPHONE_STOP); - } FindPhonePresenter::X_DRAG_FLAG = false; } return true; @@ -115,11 +106,6 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { - // 发送指令停止震动 - if (FindPhoneModel::GetInstance().GetBlueToothConnectedState()) - { - senfindphoneSend(FINDPHONE_STOP); - } NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; 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 758763a55..706259f02 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-08-31 18:27:22 + * @LastEditTime: 2024-09-30 11:31:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp */ #include "findphone/include/FindPhoneView.h" @@ -45,54 +45,47 @@ namespace OHOS void FindPhoneView::ClearAll() { - if (viewInitStatus == true) + if (container_ != nullptr) { - // UIViewGroup *tmpGroup = dynamic_cast(container_); - // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); - // FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + + if (FindPhoneGroupView != nullptr) + { + FindPhoneGroupView->RemoveAll(); - if (container_ != nullptr) + if (FindPhoneTitleLabel != nullptr) { - container_->RemoveAll(); - delete container_; - container_ = nullptr; + delete FindPhoneTitleLabel; + FindPhoneTitleLabel = nullptr; } - if (FindPhoneGroupView != nullptr) + if (FindPhoneImageView != nullptr) { - FindPhoneGroupView->RemoveAll(); - - if (FindPhoneTitleLabel != nullptr) - { - delete FindPhoneTitleLabel; - FindPhoneTitleLabel = nullptr; - } - if (FindPhoneImageView != nullptr) - { - delete FindPhoneImageView; - FindPhoneImageView = nullptr; - } - if (FindPhoneImageAnimator != nullptr) - { - FindPhoneImageAnimator->Stop(); - delete FindPhoneImageAnimator; - FindPhoneImageAnimator = nullptr; - // FreeImagePathsArray(FindPhonePathsArray, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - } - if (FindPhoneLabel != nullptr) - { - delete FindPhoneLabel; - FindPhoneLabel = nullptr; - } - if (FindPhoneLabelButton != nullptr) - { - delete FindPhoneLabelButton; - FindPhoneLabelButton = nullptr; - } - delete FindPhoneGroupView; - FindPhoneGroupView = nullptr; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!"); + delete FindPhoneImageView; + FindPhoneImageView = nullptr; + } + if (FindPhoneImageAnimator != nullptr) + { + FindPhoneImageAnimator->Stop(); + delete FindPhoneImageAnimator; + FindPhoneImageAnimator = nullptr; + FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } + if (FindPhoneLabel != nullptr) + { + delete FindPhoneLabel; + FindPhoneLabel = nullptr; } + if (FindPhoneLabelButton != nullptr) + { + delete FindPhoneLabelButton; + FindPhoneLabelButton = nullptr; + } + delete FindPhoneGroupView; + FindPhoneGroupView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!"); } } @@ -121,12 +114,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!"); return; } - FindPhoneTitleLabel->SetPosition(133, 51, 200, 40); + FindPhoneTitleLabel->SetPosition(83, 50, 300, 35); FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // FindPhoneTitleLabel->SetText("查找手机"); - FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE); - FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机 + FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* ----------------------- FindPhoneImageView ---------------------- */ @@ -145,12 +137,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail"); return; } - FindPhoneLabel->SetPosition(33, 270, 400, 40); + FindPhoneLabel->SetPosition(53, 270, 360, 35); FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30); FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // FindPhoneLabel->SetText("蓝牙未连接"); - FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED); - FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);//蓝牙未连接 + FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -164,8 +155,7 @@ namespace OHOS FindPhoneLabelButton->SetPosition(0, 366, 466, 100); FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON); FindPhoneLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); - // FindPhoneLabelButton->SetText("关闭"); - FindPhoneLabelButton->SetTextId(STR_CLOSE); + FindPhoneLabelButton->SetTextId(STR_CLOSE);//关闭 FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); @@ -177,7 +167,6 @@ namespace OHOS FindPhoneGroupView->Add(FindPhoneLabelButton); container_->Add(FindPhoneGroupView); } - viewInitStatus = true; } /*蓝牙如果是已连接状态将初始化这个视图*/ @@ -205,12 +194,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!"); return; } - FindPhoneTitleLabel->SetPosition(133, 51, 200, 40); + FindPhoneTitleLabel->SetPosition(83, 50, 300, 35); FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // FindPhoneTitleLabel->SetText("查找手机"); - FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE); - FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机 + FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* ----------------------- FindPhoneImageAnimator ---------------------- */ @@ -247,12 +235,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail"); return; } - FindPhoneLabel->SetPosition(33, 270, 400, 40); + FindPhoneLabel->SetPosition(53, 270, 360, 35); FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30); FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // FindPhoneLabel->SetText("手机正在响铃/震动"); - FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING); - FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);//手机正在响铃/震动 + FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -279,21 +266,11 @@ namespace OHOS FindPhoneGroupView->Add(FindPhoneLabelButton); container_->Add(FindPhoneGroupView); } - viewInitStatus = true; } void FindPhoneView::OnStart() { View::OnStart(); - // if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态 - // { - // FindPhoneViewInit_BlueToothConnected(); - // senfindphoneSend(FINDPHONE_START); - // } - // else - // { - // FindPhoneViewInit_BlueToothDisConnected(); - // } SetContainerView(new UIViewGroup()); if (GetContainer() == nullptr) { @@ -304,12 +281,16 @@ namespace OHOS container_->SetTouchable(true); container_->SetDraggable(true); - if (!viewInitStatus) + if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态 { FindPhoneViewInit_BlueToothConnected(); - senfindphoneSend(FINDPHONE_START); - viewInitStatus = true; + FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_START); } + else + { + FindPhoneViewInit_BlueToothDisConnected(); + } + RootView::GetInstance()->SetOnKeyActListener(presenter_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index 166bf839b..d6dcb5cf5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -660,15 +660,12 @@ namespace OHOS } else //亮屏状态下每2s刷新一次下拉数据 { - MainPresenterSample::g_PullUpDownTimes = UPDATETIME; if (PullUpDownView::GetInstance() != nullptr) { PullUpDownView::GetInstance()->UpdateSignalStrengthStatusAndBatteryPosition(); } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetInstance fail!!"); - } + if (MainPresenterSample::g_PullUpDownTimes != UPDATETIME) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME)则恢复 + MainPresenterSample::g_PullUpDownTimes = UPDATETIME; } return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp index ef4c677d9..4075e9ea7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-02 09:57:10 + * @LastEditTime: 2024-09-30 17:06:25 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp */ @@ -276,7 +276,7 @@ namespace OHOS return false; } } - recordList->SetPosition(43, 120, 380, 340); + recordList->SetPosition(43, 100, 380, 330); recordList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); recordList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 recordList->SetTouchable(true); @@ -285,7 +285,7 @@ namespace OHOS recordList->SetDragACCLevel(5); recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ recordList->SetReboundSize(30); - // recordList->SetScrollBlankSize(30); + recordList->SetScrollBlankSize(20); recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。 recordList->SetAdapter(p_RecordingListAdapter); RecordListScrollView->Add(recordList); diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp index 9aa2e6ea2..8b98d97fa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp @@ -13,6 +13,7 @@ #include #include #include "ConfigModel.h" +#include "cstring" namespace OHOS { std::string RecordingModel::recordTempDuration = 0; @@ -568,6 +569,19 @@ namespace OHOS } closedir(dir); } + // 使用冒泡排序进行排序 + for (int i = 0; i < mp3FileCount - 1; i++) + { + for (int j = 0; j < mp3FileCount - i - 1; j++) + { + if (strcmp(info[j].recordingFileName, info[j + 1].recordingFileName) < 0) + { + RecordingInfo temp = info[j]; + info[j] = info[j + 1]; + info[j + 1] = temp; + } + } + } } /* @@ -576,6 +590,7 @@ namespace OHOS void RecordingModel::InitRecordingListItem(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem"); + /* ---------------------------------- 清空操作 --------------------------------- */ if (!Recordings.empty()) { Recordings.clear(); @@ -591,6 +606,8 @@ namespace OHOS memset(info[i].recordingTime, 0, sizeof(info[i].recordingTime)); } RecordingMp3FileCount = 0; + MaxRecordingNumber = 0; + /* -------------------------------------------------------------------------- */ SearchFiles(directory, Recordings, RecordingMp3FileCount); if (RecordingMp3FileCount != 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h index 44843ea90..5d5b47d6f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-17 16:21:55 + * @LastEditTime: 2024-09-30 15:48:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h */ #ifndef WATCH_QR_CODE_VIEW_H @@ -14,6 +14,7 @@ #include "components/ui_label_ext.h" namespace OHOS { + static constexpr const char *WATCHQRCODEVIEWID = "WatchQRCodeView"; class WatchQRCodePresenter; class WatchQRCodeView : public View { @@ -28,6 +29,14 @@ namespace OHOS virtual void OnTearDownView() override; virtual void OnStop() override; + /* -------------------------------------------------------------------------- */ + static uint8_t refresh_time; + std::string get_voltage_and_version_string(void); + void update_label(void); + void start_refresh_timer(uint32_t interval = 2000); + void stop_refresh_timer(void); + /* -------------------------------------------------------------------------- */ + private: void WatchQRCodeViewInit(); bool WatchQRCodeInitViewGroup(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp index 35feb1913..f732f9804 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodePresenter.cpp @@ -51,8 +51,13 @@ namespace OHOS bool WatchQRCodePresenter::OnClick(UIView &view, const ClickEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDrag"); - UNUSED(view); UNUSED(event); + std::string viewId = view.GetViewId(); + if (viewId == WATCHQRCODEVIEWID) + { + if (view_) + view_->start_refresh_timer(); + } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp index 9f1d7ee64..f97b78347 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp @@ -5,6 +5,9 @@ #include "ui_resource_string.h" #include "iostream" #include "string" +#include "graphic_service.h" +#include +#include namespace OHOS { @@ -51,18 +54,16 @@ namespace OHOS DeviceNameLabel = nullptr; } - if (WatchQRCodeGroupView != nullptr) - { - delete WatchQRCodeGroupView; - WatchQRCodeGroupView = nullptr; - } + delete WatchQRCodeGroupView; + WatchQRCodeGroupView = nullptr; } } extern "C" { #include "build_version.h" - +#include "battery_hal.h" + extern uint8_t battery_get_voltage(float *voltage); const char *get_version_string(void); } @@ -76,16 +77,12 @@ namespace OHOS return false; } WatchQRCodeGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + WatchQRCodeGroupView->SetViewId(WATCHQRCODEVIEWID); WatchQRCodeGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); WatchQRCodeGroupView->SetTouchable(true); WatchQRCodeGroupView->SetDraggable(true); - UIView::OnDragListener *dragListener = static_cast(WatchQRCodePresenter::GetInstance()); - if (dragListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::dragListener new fail!"); - return false; - } - WatchQRCodeGroupView->SetOnDragListener(dragListener); + WatchQRCodeGroupView->SetOnDragListener(presenter_); + WatchQRCodeGroupView->SetOnClickListener(presenter_); return true; } @@ -137,10 +134,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail"); return false; } - std::string temp = get_version_string(); - std::string version_string = "V" + temp; - DeviceNameLabel->SetText(version_string.c_str()); - DeviceNameLabel->SetPosition(83, 402, 300, 35); + DeviceNameLabel->SetText(get_voltage_and_version_string().c_str()); + DeviceNameLabel->SetPosition(83, 390, 300, 35); DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30); DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35); DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -174,6 +169,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStart"); View::OnStart(); + start_refresh_timer(); WatchQRCodeViewInit(); /* --------------------------------- 添加按键监听 --------------------------------- */ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::WatchQRCodePresenter::GetInstance(); @@ -206,10 +202,142 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStop"); View::OnStop(); + stop_refresh_timer(); RootView::GetInstance()->RemoveAll(); RootView::GetInstance()->ClearOnKeyActListener(); ClearAll(); return; } + std::string WatchQRCodeView::get_voltage_and_version_string(void) + { + // 电量: + float voltage = 0.0F; + uint8_t value = 0; + value = battery_get_voltage(&voltage); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value); + + // 版本号: + std::string temp = get_version_string(); + std::string version_string = "V" + temp; + std::string str = "bat:" + std::to_string(value) + "%" + " " + version_string; + return str; + } + + void WatchQRCodeView::update_label(void) + { + if (DeviceNameLabel) + { + std::string str = get_voltage_and_version_string(); + DeviceNameLabel->SetText(str.c_str()); + DeviceNameLabel->Invalidate(); + } + } + + // 声明定时器变量 + static osTimerId_t g_timer = nullptr; + static uint8_t UPDATETIME_OUT = 30; // 30秒 + uint8_t WatchQRCodeView::refresh_time = UPDATETIME_OUT; + /*定时器到期时的处理*/ + static void QRCodeView_TimerCallbackProc(int data) + { + if (uapi_get_screen_state() == 0) // 如果在亮屏状态 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 0"); + if (WatchQRCodeView::GetInstance()) + { + WatchQRCodeView::GetInstance()->update_label(); + } + if (WatchQRCodeView::refresh_time != UPDATETIME_OUT) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME_OUT)则恢复 + { + WatchQRCodeView::refresh_time = UPDATETIME_OUT; + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 1"); + WatchQRCodeView::refresh_time -= 2; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", WatchQRCodeView::refresh_time); + if (WatchQRCodeView::refresh_time <= 0) // 息屏状态下超时删除定时器 + { + if (WatchQRCodeView::GetInstance()) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&WatchQRCodeView::stop_refresh_timer, WatchQRCodeView::GetInstance())); + } + } + else + { + if (WatchQRCodeView::GetInstance()) + { + WatchQRCodeView::GetInstance()->update_label(); + } + } + } + return; + } + + /* + * @brief 回调函数 + */ + static void QRCodeView_TimerCallback(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(QRCodeView_TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void WatchQRCodeView::start_refresh_timer(uint32_t interval) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start_refresh_timer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Timer already exists!!"); + return; + } + /* --------------------------------- 2.创建定时器 -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)QRCodeView_TimerCallback, osTimerPeriodic, nullptr, nullptr); + // 检查定时器创建是否成功 + if (g_timer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ + int tick = osMs2Tick(interval); + /* --------------------------------- 4.启动定时器 -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != nullptr) + { + ret = osTimerDelete(g_timer); + } + g_timer = nullptr; + return; + } + return; + } + + void WatchQRCodeView::stop_refresh_timer(void) + { + // 检查定时器是否存在 + if (g_timer != nullptr) + { + osTimerStop(g_timer); + // 删除定时器并置为 nullptr + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_timer stop success"); + refresh_time = UPDATETIME_OUT; + } + } } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp index dc5540376..d8170acde 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp @@ -26,7 +26,7 @@ namespace OHOS constexpr int32_t NOTIFY_ONE_SECOND = 1000; constexpr int32_t NOTIFY_THIRTY_SECONDS = 30 * 1000; // 30秒 constexpr int32_t NOTIFY_ONE_MINUTE = 60 * 1000; - static int popalarm_time = 50; + static int popalarm_time = 40; constexpr int32_t NOTOFY_NO_OPERATE_TIME = 30 * 1000; // 无操作30s超时时间 osTimerId_t g_notifyStopHandle = nullptr; // timer of close view and alarm ring view osTimerId_t g_alarmRing = nullptr; // timer of alarm view @@ -211,7 +211,7 @@ namespace OHOS return; } g_alarmRing = nullptr; - popalarm_time = 50; + popalarm_time = 40; } break; default: diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/compass.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/compass.bin index 287c4a5e0..0f338f9d8 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/compass.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/compass.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c2c3a169bd01830d76de6bba0f282b4f34179255751879c7c4fb2a9279c8f2a +oid sha256:71cb249158bffd0944ae9221c2d3d4211f1df1fbd9530288e963494b665c2da4 size 149896 -- 2.17.1