From 04bbfae0af26fb6fea81b63636395bf3b91f6d2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Sat, 10 Aug 2024 11:03:27 +0000 Subject: [PATCH] Merge #673 into sdk602patch0626 from refs/changes/673/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/673/head: (39 commits squashed) - 屏蔽血氧监测过程中的数值显示 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 增加表盘星期string类model - 增加血氧&心率数据重启之后恢复 - 筛选表盘血氧无效数据 - 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 - 适配早安闹钟小睡功能 - 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 - 增加新的表盘数据类型 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 更新表盘配置 详情见dial_readme - 同步表盘lzma文件更新 - 更新表盘原资源文件 - 增加离线表盘开发指南 - 优化组件初始化函数 - 优化 UIViewGroup Add 函数 添加错误可以查看组件信息 - 删除缓存文件 - 增加Dial星期数据类型 - 增加日期Dial数据类型 - 增加时间的4个数据位数据类型 - 设置表盘界面增加表盘控制:目前只有覆盖流生效 - DialLabel关闭不必要的打印 增加新数据类型 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 修改遥控拍照的析构适配 - 训练记录修改析构适配 - 优化控件初始化函数 - 对应组件进行nullptr初始化 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 优化省电模式进入UI;并且适配按键回退 - 实现消息列表自适应大小 - 修改动画的反应速度为80ms - 关闭主界面到applist的动画效果 - 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/673 --- .../uicomponents/UIComponents.cpp | 83 ++++- .../bloodoxygen/include/BloodDetectionView.h | 10 +- .../bloodoxygen/include/BloodResultView.h | 2 +- .../nativeui/heart_blood/BloodCardView.h | 2 +- .../heartrate/include/HeartDetectionView.h | 10 +- .../heartrate/include/HeartResultView.h | 2 +- .../nativeui/key/src/KeyInputListener.cpp | 97 +++--- .../nativeui/main/src/MainViewSample.cpp | 6 +- .../nativeui/message/include/MessageAdapter.h | 10 +- .../message/include/MessageCardView.h | 1 + .../message/include/MessageItemView.h | 8 + .../message/include/MessageLackView.h | 6 + .../message/include/MessageShowView.h | 14 +- .../nativeui/message/include/MessageView.h | 21 +- .../nativeui/message/src/MessageAdapter.cpp | 47 ++- .../nativeui/message/src/MessageCardView.cpp | 48 ++- .../message/src/MessageControlView.cpp | 25 +- .../nativeui/message/src/MessageItemView.cpp | 84 +++-- .../nativeui/message/src/MessageShowView.cpp | 3 +- .../nativeui/message/src/MessageView.cpp | 57 ++- .../saveele/include/SaveElePresenter.h | 48 +-- .../nativeui/saveele/include/SaveEleView.h | 30 +- .../nativeui/saveele/src/SaveElePresenter.cpp | 43 ++- .../nativeui/saveele/src/SaveEleView.cpp | 328 ++++-------------- .../takephotos/src/TakephotosView.cpp | 41 +-- .../traing/include/TrainingSetCaluliView.h | 2 +- .../traing/include/TrainingSetMileView.h | 8 +- .../traing/include/TrainingSetStepView.h | 2 +- .../traing/include/TrainingSetTimeView.h | 8 +- .../traingrecord/src/TraingRecordView.cpp | 46 ++- .../src/transition/ZoomTransition.cpp | 4 +- 31 files changed, 497 insertions(+), 599 deletions(-) diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index bc3df8d6f..6b8011647 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -31,9 +31,18 @@ namespace OHOS bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) { // 检查标签指针是否为空 - label = new UILabel(); if (label == nullptr) { + label = new UILabel(); + if (label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is error"); + return false; // 内存分配失败,返回false + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is not nullptr"); return false; // 内存分配失败,返回false } // 设置标签的位置和大小 @@ -68,11 +77,18 @@ namespace OHOS bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) { // 检查标签指针是否为空 - - label = new UILabelExt(); if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error"); + label = new UILabelExt(); + if (label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error"); + return false; // 内存分配失败,返回false + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is not nullptr"); return false; // 内存分配失败,返回false } // 设置标签的位置和大小 @@ -94,10 +110,18 @@ namespace OHOS bool InitLabelAdapt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) { // 检查标签指针是否为空 - label = new UILabelExt(); if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error"); + label = new UILabelExt(); + if (label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error"); + return false; // 内存分配失败,返回false + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is not nullptr"); return false; // 内存分配失败,返回false } // 设置标签的位置和大小 @@ -133,10 +157,18 @@ namespace OHOS bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize) { // 检查标签指针是否为空 - label = new UILabelExt(); if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is error"); + label = new UILabelExt(); + if (label == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is error"); + return false; // 内存分配失败,返回false + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is not nullptr"); return false; // 内存分配失败,返回false } // 设置标签的位置和大小 @@ -179,6 +211,11 @@ namespace OHOS return false; // 内存分配失败,返回false } } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UILabelButtonExt UILabelButtonExt is not nullptr"); + return false; // 内存分配失败,返回false + } button->SetPosition(left, top); button->Resize(width, height); button->SetViewId(viewId); @@ -198,6 +235,7 @@ namespace OHOS { if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateLabelText label is nullptr"); return nullptr; } /*取Id对应的字符串*/ @@ -232,7 +270,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error"); return nullptr; } - std::string str = UpdateLabelText(label, std::to_string(num), id); return str; } @@ -255,6 +292,7 @@ namespace OHOS { if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error"); return; } @@ -285,10 +323,18 @@ namespace OHOS bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) { // 创建新按钮(如果当前按钮为空) - button = new UIButton(); if (button == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new UIButton fail"); + button = new UIButton(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new UIButton fail"); + return false; // 内存分配失败,返回false + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is not nullptr"); return false; // 内存分配失败,返回false } button->SetPosition(left, top); @@ -314,11 +360,20 @@ namespace OHOS */ bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) { - imageView = new UIImageView(); + // 创建新图片(如果当前图片为空) if (imageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath); - return false; + imageView = new UIImageView(); + if (imageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath); + return false; + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is not nullptr"); + return false; // 内存分配失败,返回false } if (imagePath == nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h index 0add3eef7..639175408 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h @@ -53,11 +53,11 @@ namespace OHOS void UpShowBloodText(void); private: - UIImageAnimatorView *imageAnimator; - UILabelExt *titleLabel; - UILabel *Spo2Text; - UIScrollView *BloodDetectionScrollView; - UILabelButtonExt *testButton; + UIImageAnimatorView *imageAnimator{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabel *Spo2Text{nullptr}; + UIScrollView *BloodDetectionScrollView{nullptr}; + UILabelButtonExt *testButton{nullptr}; uint32_t spo2_; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h index 29b220dc5..a29d6c896 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h @@ -63,7 +63,7 @@ namespace OHOS UILabelExt *titleLabel = nullptr; UILabelExt *timeLabel = nullptr; UILabel *bloodLabel = nullptr; - UILabelButtonExt *checkButton; + UILabelButtonExt *checkButton{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h index 8678423ce..0d187552b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h @@ -68,7 +68,7 @@ namespace OHOS UILabelExt *timeLabel = nullptr; UILabel *bloodLabel = nullptr; - UILabelButtonExt *checkButton; + UILabelButtonExt *checkButton{nullptr}; bool viewiInitStatus{false}; bool resLoadStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartDetectionView.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartDetectionView.h index 76d57ef29..a8d92f550 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartDetectionView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartDetectionView.h @@ -65,11 +65,11 @@ namespace OHOS void UpShowHeartText(void); private: - UIImageAnimatorView *imageAnimator; - UILabelExt *titleLabel; - UILabel *HeartText; - UIScrollView *HeartDetectionScrollView; - UILabelButtonExt *testButton; + UIImageAnimatorView *imageAnimator{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabel *HeartText{nullptr}; + UIScrollView *HeartDetectionScrollView{nullptr}; + UILabelButtonExt *testButton{nullptr}; uint32_t heart_; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartResultView.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartResultView.h index 6ce0b9094..06227c4f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartResultView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartResultView.h @@ -45,7 +45,7 @@ namespace OHOS UILabelExt *titleLabel = nullptr; UILabelExt *timeLabel = nullptr; UILabel *heartLabel = nullptr; - UILabelButtonExt *checkButton; + UILabelButtonExt *checkButton{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index c6163d9d7..55f9ec153 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -9,7 +9,7 @@ #include "common/key_code.h" #include "AppViewIDs.h" #include "components/ui_label_ext.h" -#include"ui_resource_string.h" +#include "ui_resource_string.h" #include "View.h" #include "MainViewSample.h" #include "wearable_log.h" @@ -62,8 +62,8 @@ namespace OHOS uint16 keyID = event.GetKeyId(); if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 - // 切换到关机/重启卡片 - // NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); + // 切换到关机/重启卡片 + // NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // 功能按键 @@ -72,42 +72,53 @@ namespace OHOS return; } -void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) -{ - if (MainCallingPresenter::GetInstance() != nullptr && CallerLogModel::GetInstance()->GetCallStatus()) { - if (CallerLogModel::GetInstance()->GetVolumeScreenStatus()) { - VolumeSettingView *settingView = MainCallingPresenter::GetInstance()->GetvolumeSetting(); - if (settingView == nullptr) { - return; + void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) + { + if (MainCallingPresenter::GetInstance() != nullptr && CallerLogModel::GetInstance()->GetCallStatus()) + { + if (CallerLogModel::GetInstance()->GetVolumeScreenStatus()) + { + VolumeSettingView *settingView = MainCallingPresenter::GetInstance()->GetvolumeSetting(); + if (settingView == nullptr) + { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); + if (volumeSliderEventListener == nullptr) + { + return; + } + volumeSliderEventListener->ChangeVolume(status); } - volumeSliderEventListener = settingView->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - return; + else + { + MainCallingPresenter::GetInstance()->HonrsViewChange(); + CallerLogModel::GetInstance()->SetVolumeScreenStatus(true); } - volumeSliderEventListener->ChangeVolume(status); - } else { - MainCallingPresenter::GetInstance()->HonrsViewChange(); - CallerLogModel::GetInstance()->SetVolumeScreenStatus(true); } - } - if (IsNotifyCallStatus()) { - if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) { - VolumeSettingView *settingView = GetvolumeSetting(); - if (settingView == nullptr) { - return; + if (IsNotifyCallStatus()) + { + if (NotificationManager::GetInstance()->GetVolumeScreenStatus()) + { + VolumeSettingView *settingView = GetvolumeSetting(); + if (settingView == nullptr) + { + return; + } + volumeSliderEventListener = settingView->GetVolumeEventListener(); + if (volumeSliderEventListener == nullptr) + { + return; + } + volumeSliderEventListener->ChangeVolume(status); } - volumeSliderEventListener = settingView->GetVolumeEventListener(); - if (volumeSliderEventListener == nullptr) { - return; + else + { + HonrsViewChange(); + NotificationManager::GetInstance()->SetVolumeScreenStatus(true); } - volumeSliderEventListener->ChangeVolume(status); - } else { - HonrsViewChange(); - NotificationManager::GetInstance()->SetVolumeScreenStatus(true); } } -} - extern "C" { @@ -125,17 +136,19 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) if (longPressFlag == 0 && pressFlag == 1) { // 如果当前页面是音量卡片或正在通话中,则执行音量+操作 - if (currentViewId == VIEW_INCOMING_CALL || - NotificationManager::GetInstance()->GetWatchCallStatus()) { // 音量卡片 + if (currentViewId == VIEW_INCOMING_CALL || + NotificationManager::GetInstance()->GetWatchCallStatus()) + { // 音量卡片 // 音量+ - CallVolumeDipSwitchControl(VOLUMEUP); + CallVolumeDipSwitchControl(VOLUMEUP); } else if (currentViewId != VIEW_MAIN) // 如果当前页面不是主表盘,如果屏幕亮起,则先处理闹钟通知再切换到主表盘页面 { if (mcu_pms_is_screen_on()) { PressAlarmNotify(); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); } } else // 如果当前页面是主表盘: @@ -149,7 +162,8 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); // NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); } } @@ -162,17 +176,18 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) if (longPressFlag == 0 && pressFlag == 1) { // 如果当前页面是音量卡片或正在通话中,则执行音量减操作 - if (currentViewId == VIEW_INCOMING_CALL || - NotificationManager::GetInstance()->GetWatchCallStatus()) { // 音量卡片 + if (currentViewId == VIEW_INCOMING_CALL || + NotificationManager::GetInstance()->GetWatchCallStatus()) + { // 音量卡片 // 音量- - CallVolumeDipSwitchControl(VOLUMEDOWN); + CallVolumeDipSwitchControl(VOLUMEDOWN); } else if (currentViewId != VIEW_MAIN) // 如果当前页面不是主表盘,如果屏幕亮起,则先处理闹钟通知再切换到主表盘页面。 { if (mcu_pms_is_screen_on()) { PressAlarmNotify(); - //NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); + // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_ZOOM); } } else // 如果当前页面是主表盘,如果屏幕亮起,则先处理闹钟通知再切换到用户配置的快捷卡片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index 247c87cd6..a9f1aac9e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -308,10 +308,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); return; } - if (MessageLable == nullptr) - { - MessageLable = new UILabel(); - } messageView->SetViewId("messageView"); messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); messageView->PreLoad(); @@ -392,6 +388,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); return nullptr; } + /*增加勿扰图标*/ InitImageView(disturbIcon, 213, 0, 40, 40, "disturbIcon", DISTURBICON); /*获取勿扰状态*/ @@ -399,6 +396,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "disturb:state[%d]\r\n", state); disturbIcon->SetVisible(state); mainClockView->Add(disturbIcon); + return mainClockView; } // 指南针卡片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageAdapter.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageAdapter.h index 98a35217a..5ac2f8fa9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageAdapter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageAdapter.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-28 19:21:39 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 11:44:39 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageAdapter.h + */ /*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com @@ -22,6 +28,7 @@ #include "components/ui_label.h" #include "components/ui_label_ext.h" #include "components/ui_checkbox.h" +#include "components/ui_label_button_ext.h" namespace OHOS { @@ -30,7 +37,7 @@ namespace OHOS { int index; bool read; // 是否未读 - std::string labeltitle; // 来信标签 + std::string labeltitle; // 来信人 std::string labeldetails; // 信息内容 std::string labeltime; // 来信时间 } MessageListItem; @@ -57,6 +64,7 @@ namespace OHOS private: std::list listData; UIView::OnClickListener *itemClickListener{nullptr}; + UILabelButtonExt *DeleteButton{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h index 25ca11047..c1737a9f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h @@ -65,6 +65,7 @@ namespace OHOS UIList *MessageList = nullptr; UILabelButtonExt *DeleteButton = nullptr; // 删除按键 MessageModel *p_MessageModel{nullptr}; + UIImageView *imageline{nullptr}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h index 50b860357..51330cb59 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 11:55:24 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h + */ /*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com @@ -25,6 +31,7 @@ namespace OHOS virtual ~MessageItemView(); virtual void SetItemInfo(const MessageListItem itemInfo); virtual void SetUpChild(); + void TearDownChild(); int GetMessageListIndex(); private: @@ -35,6 +42,7 @@ namespace OHOS UILabel stime; // 时间 UILabelButton sLabelButton; // 按键 MessageListItem sItemInfo = {0, false, nullptr, nullptr, nullptr}; + bool isSetupChild{false}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageLackView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageLackView.h index c882fbfdb..a6174653a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageLackView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageLackView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-19 17:04:12 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-10 16:50:28 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageLackView.h + */ /*** * @Date: 2024-06-19 17:04:12 * @LastEditors: Caisking 3449750381@qq.com diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageShowView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageShowView.h index 2205141f7..8db3664dd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageShowView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageShowView.h @@ -1,4 +1,9 @@ - +/*** + * @Date: 2024-06-21 09:56:18 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 18:56:33 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageShowView.h + */ #ifndef MessageShow_VIEW_H #define MessageShow_VIEW_H @@ -49,10 +54,13 @@ namespace OHOS UILabel *time{nullptr}; UILabel *message{nullptr}; - UILabelButton *messageButton; // 消息 - UILabelButtonExt *deleteButton; // 清除按键 + UILabelButton *messageButton{nullptr}; // 消息 + UILabelButtonExt *deleteButton{nullptr}; // 清除按键 bool viewInitStatus{false}; + std::string titleStr; + std::string timeStr; + std::string messageStr; }; } // namespace OHOS #endif \ No newline at end of file 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 93356a60b..1a56c244d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h @@ -1,21 +1,4 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-05 18:36:27 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-21 17:13:44 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-19 10:54:53 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageView.h - */ + #ifndef Message_VIEW_H #define Message_VIEW_H @@ -88,7 +71,7 @@ namespace OHOS bool viewInitStatus{false}; - MessageModel *g_MessageModel; + MessageModel *g_MessageModel{nullptr}; }; } // namespace OHOS #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp index 9b05ec775..58b017885 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageAdapter.cpp @@ -1,4 +1,4 @@ -/*** +/*** * @Author: Caisking 3449750381@qq.com * @Date: 2024-01-29 19:58:37 * @LastEditors: Caisking 3449750381@qq.com @@ -10,7 +10,10 @@ #include "message/include/MessageAdapter.h" #include "message/include/MessageItemView.h" #include "wearable_log.h" +#include "message/include/MessagePresenter.h" +#include "message/include/MessageModel.h" +#include "uicomponents/UIComponents.h" namespace OHOS { MessageListAdapter::MessageListAdapter() {} @@ -22,7 +25,7 @@ namespace OHOS uint16_t MessageListAdapter::GetCount(void) { - return listData.size(); + return listData.size() + 1; } void MessageListAdapter::SetData(std::list &data) @@ -38,38 +41,56 @@ namespace OHOS } } - /// @brief + /// @brief /// @param inView 一个指向已存在的视图对象的指 /// @param index 要创建的视图在列表中的索引l。 /// @return 返回该视图对象 UIView *MessageListAdapter::GetView(UIView *inView, int16_t index) { - - //1.先检查列表数据是否为空,若为空则返回空指针 + // 1.先检查列表数据是否为空,若为空则返回空指针 if (listData.empty()) { return nullptr; } - //2.接着检查索引是否小于0,若小于0则返回空指针 + // 2.接着检查索引是否小于0,若小于0则返回空指针 if (index < 0) { return nullptr; } - //3.检查是否超出列表数据大小,若超出则返回空指针 + printf("GetView : index %d\r\n", index); + // 3.检查是否超出列表数据大小,若超出则返回空指针 size_t uindex = index; - if (uindex >= listData.size()) - { + if (uindex > listData.size()) return nullptr; + + MessageItemView *item = nullptr; + if (uindex == listData.size()) + { + if (inView == nullptr) + { + item = new MessageItemView(); + } + else + { + item = static_cast(inView); + // item->TearDownChild(); + item->RemoveAll(); + } + InitButtonExt(DeleteButton, 0, 0, 380, 100, DELETEALLDATA, STR_CLEANALL, 30); + DeleteButton->SetOnClickListener(itemClickListener); + item->Add(DeleteButton); + item->SetViewIndex(index); + item->SetOnClickListener(nullptr); + return item; } - //4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 + // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量 std::list::iterator it = listData.begin(); for (int i = 0; i < index; i++) { it++; } MessageListItem itemData = *it; - MessageItemView *item = nullptr; - //5.根据传入的inView参数是否已经存在一个视图对象,若为空则创建一个新的MessageItemView对象,否则将inView转换成MessageItemView类型的指针 + // 5.根据传入的inView参数是否已经存在一个视图对象,若为空则创建一个新的MessageItemView对象,否则将inView转换成MessageItemView类型的指针 if (inView == nullptr) { item = new MessageItemView(); @@ -77,7 +98,9 @@ namespace OHOS else { item = static_cast(inView); + item->RemoveAll(); } + item->SetUpChild(); item->SetItemInfo(itemData); item->SetViewIndex(index); item->SetOnClickListener(itemClickListener); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp index e4f57fd3b..0df538133 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp @@ -17,12 +17,14 @@ namespace OHOS static MessageCardView *g_pMessageCardView = nullptr; static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; static constexpr int16_t MORE_LIST_POSITION_X = 43; - static constexpr int16_t MORE_LIST_POSITION_Y = 120; + static constexpr int16_t MORE_LIST_POSITION_Y = 95; static constexpr int16_t MORE_SCROLLBLANKSIZE = 35; // 设置此滚动视图的空白大小。 static constexpr int16 MAX_SCR_DIS = 1000; static constexpr int16 LIST_POS = 20; static constexpr int16 SNUM_2 = 2; static constexpr uint8_t NUM_2 = 2; + + static constexpr char *lineimagePath = "/user/res/message/Line.bin"; MessageCardView::MessageCardView() { SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); @@ -39,10 +41,10 @@ namespace OHOS void MessageCardView::ClearAll(void) { RemoveAll(); - if (title != nullptr) + if (imageline != nullptr) { - delete title; - title = nullptr; + delete imageline; + imageline = nullptr; } if (MessageList != nullptr) { @@ -64,9 +66,10 @@ namespace OHOS bool MessageCardView::InitPage(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPage is begin"); - /*初始化label*/ - InitLabelExt(title, 83, 50, 300, 35, "labletitle", STR_MESSAGE_NOTIFICATION, DEFAULT_VECTOR_FONT_FILENAME, 30); - Add(title); + + /*初始化image*/ + InitImageView(imageline, 193, 30, 365, 35, "image", lineimagePath); + Add(imageline); // UIList 的适配器 p_MessageListAdapter = new MessageListAdapter(); @@ -76,34 +79,24 @@ namespace OHOS MessageList = new UIList(); } MessageList->SetPosition(MORE_LIST_POSITION_X, MORE_LIST_POSITION_Y, 466, 466); - // MessageList->SetScrollStateListener(this); + MessageList->SetScrollBlankSize(35); + MessageList->SetReboundSize(50); MessageList->SetThrowDrag(true); MessageList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - // 设置手指抬起屏幕后的最大滚动距离 MessageList->SetMaxScrollDistance(1000); // 1000: max scroll distance - // 设置手指抬起屏幕后的补偿距离 - MessageList->SetSwipeACCLevel(800); // 800: compensation distance - // 设置拖动加速 - MessageList->SetDragACCLevel(5); // 5: drag acceleration - MessageList->SetYScrollBarVisible(true); + MessageList->SetSwipeACCLevel(800); // 800: compensation distance + MessageList->SetDragACCLevel(5); // 5: drag acceleration MessageList->SetViewId(MAINMESSAGEVIEW); - - // SetYScrollBarVisible(true); // 设置滑动滚动条 - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MessageControlPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddButton::OnStart clickListener NULL"); - return false; - } - MessageList->SetOnClickListener(clickListener); - UIView::OnDragListener *Messagedraglistener = (UIView::OnDragListener *)(MessageControlPresenter::GetInstance()); + MessageList->SetOnClickListener((UIView::OnClickListener *)OHOS::MessageControlPresenter::GetInstance()); + MessageList->SetIntercept(true); Add(MessageList); MessageList->SetAdapter(p_MessageListAdapter); - MessageList->RefreshList(); - SetDraggable(false); - SetTouchable(false); + // MessageList->RefreshList(); + // SetDraggable(true); + // SetTouchable(true); + initViewStatus = true; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitPage is end"); return true; @@ -150,7 +143,6 @@ namespace OHOS } void MessageCardView::UpdateMessageCard() { - } UIList *MessageCardView::GetList() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp index e6f4d07b6..d7347151c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp @@ -1,27 +1,4 @@ -/*** - * @Date: 2024-07-11 14:52:39 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-25 10:28:36 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp - */ -/*** - * @Date: 2024-07-11 14:52:39 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-25 09:41:22 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp - */ -/*** - * @Date: 2024-07-11 14:52:39 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-25 09:32:03 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlView.cpp - */ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: MessageControlView.cpp - * Author: - * Create: 2022-04-02 - */ + #include "message/include/MessageControlView.h" #include "message/include/MessageModel.h" #include "message/include/MessageControlPresenter.h" diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp index d860e7313..c7b85fd17 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp @@ -4,22 +4,24 @@ namespace OHOS { static constexpr const char *ICON_IMAGE = "user/res/message/Icon.bin"; +#define SELF_ADAPTION 1 + #define RECTANGLE_WIDTH 380 -// 定义不同大小矩形的长度常量 +// 定义不同大小背景矩形的长度常量 #define SMALL_RECTANGLE_LENGTH 180 #define MEDIUM_RECTANGLE_LENGTH 210 #define BIG_RECTANGLE_LENGTH 240 // 定义不同大小标签的长度常量 #define SMALL_LABEL_LENGTH 30 -#define MEDIUM_LABEL_LENGTH 70 -#define BIG_LABEL_LENGTH 105 +#define MEDIUM_LABEL_LENGTH 80 +#define BIG_LABEL_LENGTH 115 // 时间的top -#define SMALL_TIMELABEL_LENGTH 108 -#define MEDIUM_TIMELABEL_LENGTH 139 -#define BIG_LABELTIME_LENGTH 171 +#define SMALL_TIMELABEL_LENGTH 110 +#define MEDIUM_TIMELABEL_LENGTH 141 +#define BIG_LABELTIME_LENGTH 173 // 定义全局变量 static int item_length = BIG_RECTANGLE_LENGTH; @@ -29,66 +31,75 @@ namespace OHOS MessageItemView::MessageItemView() { SetPosition(0, 0, RECTANGLE_WIDTH, item_length); + // SetStyle(STYLE_BACKGROUND_COLOR, 0xff303030); SetStyle(STYLE_BACKGROUND_OPA, 255); SetStyle(STYLE_BORDER_RADIUS, 20); SetTouchable(true); - SetUpChild(); - - Add(&sLabelButton); - Add(&sIcon); - Add(&stitle); - Add(&smessgae); - Add(&stime); } MessageItemView::~MessageItemView() { - Remove(&sIcon); - Remove(&stitle); - Remove(&smessgae); - Remove(&stime); - Remove(&sLabelButton); + RemoveAll(); } void MessageItemView::SetItemInfo(const MessageListItem itemInfo) { sItemInfo = itemInfo; -#if 0 +#if SELF_ADAPTION // 根据 labeldetails 的大小设置矩形和标签的长度 - if (itemInfo.labeldetails.size() <= 10) + printf("itemInfo.labeldetails.size():%d\r\n", itemInfo.labeldetails.size()); + if (itemInfo.labeldetails.size() <= 30) // 一行 { - label_length = SMALL_LABEL_LENGTH; item_length = SMALL_RECTANGLE_LENGTH; + label_length = SMALL_LABEL_LENGTH; time_top = SMALL_TIMELABEL_LENGTH; } - else if (itemInfo.labeldetails.size() > 10 && itemInfo.labeldetails.size() <= 20) + else if (itemInfo.labeldetails.size() > 30 && itemInfo.labeldetails.size() <= 60) // 两行 { - label_length = MEDIUM_LABEL_LENGTH; item_length = MEDIUM_RECTANGLE_LENGTH; + label_length = MEDIUM_LABEL_LENGTH; time_top = MEDIUM_TIMELABEL_LENGTH; } else { - label_length = BIG_LABEL_LENGTH; item_length = BIG_RECTANGLE_LENGTH; + label_length = BIG_LABEL_LENGTH; time_top = BIG_LABELTIME_LENGTH; } - + /* 自适应消息列表配置 测试中 */ SetPosition(0, 0, RECTANGLE_WIDTH, item_length); + smessgae.SetPosition(40, 69, 300, label_length); + stime.SetPosition(40, time_top, 300, 33); + sLabelButton.SetPosition(0, 0, 380, item_length - 20); #endif - if (!itemInfo.read) - { - sIcon.SetSrc(ICON_IMAGE); - } + sIcon.SetSrc(ICON_IMAGE); stitle.SetText(itemInfo.labeltitle.c_str()); smessgae.SetText(itemInfo.labeldetails.c_str()); stime.SetText(itemInfo.labeltime.c_str()); + // 设置图标可见性 + sIcon.SetVisible(!itemInfo.read); - // printf("%d %s %s %s\r\n", itemInfo.read, itemInfo.labeltitle.c_str(), itemInfo.labeldetails.c_str(), itemInfo.labeltime.c_str()); + printf("MessageItemView itemInfo %d %s %s\r\n", itemInfo.read, itemInfo.labeltitle.c_str(), itemInfo.labeldetails.c_str(), itemInfo.labeltime.c_str()); + printf("MessageItemView size %d %d %d\r\n", label_length, item_length, time_top); } + void MessageItemView::TearDownChild() + { + if (!isSetupChild) + return; + Remove(&sIcon); + Remove(&stitle); + Remove(&smessgae); + Remove(&stime); + Remove(&sLabelButton); + + isSetupChild = false; + } void MessageItemView::SetUpChild() { + if (isSetupChild) + return; + sIcon.SetPosition(40, 43); sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); @@ -99,12 +110,10 @@ namespace OHOS stitle.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); stitle.SetRollSpeed(70); - smessgae.SetPosition(40, 69, 300, label_length); smessgae.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); smessgae.SetTextColor(Color::Gray()); smessgae.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - stime.SetPosition(40, time_top, 300, 33); stime.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); stime.SetTextColor(Color::Gray()); stime.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); @@ -112,9 +121,18 @@ namespace OHOS sLabelButton.SetPosition(0, 0, 380, item_length - 20); sLabelButton.SetStyle(STYLE_BACKGROUND_COLOR, 0xff303030); sLabelButton.SetStyle(STYLE_BORDER_RADIUS, 20); - sLabelButton.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + sLabelButton.SetStyleForState(STYLE_BORDER_RADIUS, 20, UIButton::PRESSED); + sLabelButton.SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); sLabelButton.SetTouchable(true); + + Add(&sLabelButton); + Add(&sIcon); + Add(&stitle); + Add(&smessgae); + Add(&stime); + + isSetupChild = false; } int MessageItemView::GetMessageListIndex() diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp index c2bcc40f2..b3c7eb8cc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp @@ -41,7 +41,6 @@ namespace OHOS std::string timeStr = "2023.12.26 17:23"; std::string messageStr = "【铁路12306】系统已自动为您生成订单EC09828333,04月23日G2231次,深圳北站13:31开。请您在2小时内完成支付。您可通过以下链接进行支付。https://www.12306.cn/index/"; #endif - std::string titleStr, timeStr, messageStr; MessageShowView::MessageShowView() { @@ -159,6 +158,7 @@ namespace OHOS container_->Add(messageButton); container_->Add(deleteButton); /* -------------------------------------------------------------------------- */ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitView is ok!"); // UpdateMessage(); } @@ -200,7 +200,6 @@ namespace OHOS PreLoad(); - RootView::GetInstance()->Add(container_); SetContainerView(container_); RootView::GetInstance()->SetOnKeyActListener(presenter_); 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 7d9ed0860..9e86c6b53 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp @@ -1,4 +1,9 @@ - +/*** + * @Date: 2024-07-12 11:19:45 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 14:03:51 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp + */ #include "message/include/MessageView.h" #include "message/include/MessagePresenter.h" @@ -30,10 +35,13 @@ namespace OHOS MessageView::~MessageView() { - if (viewInitStatus == true) - { - DeInitView(); - } + // if (viewInitStatus == true) + // { + // DeInitView(); + // } + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pMessageView = nullptr; } @@ -130,7 +138,7 @@ namespace OHOS lackView->Add(labeltitle); lackView->Add(labelmeage); - RootView::GetInstance()->Add(lackView); + container_->Add(lackView); lackView->SetDraggable(true); lackView->SetTouchable(true); @@ -180,16 +188,7 @@ namespace OHOS MessageList->SetOnClickListener(presenter_); messageView->SetOnDragListener(presenter_); -#if 0 - /*删除按键*/ - int top = MessageList->GetHeight(); - 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); - InitButtonExt(DeleteButton, 43, top, 380, 100, DELETEALLDATA, STR_CLEANALL, 30); - DeleteButton->SetOnClickListener(presenter_); - messageView->Add(DeleteButton); -#endif + messageView->SetVisible(false); // 隐藏界面 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowmessageView end"); } @@ -205,27 +204,19 @@ namespace OHOS void MessageView::SetPopupViewStatus(PopupMessage view, bool status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); - UIView *popupView = nullptr; + if (view == PopupMessage::LackPopup) { - MessageModel::GetInstance().SetPopupViewState(false); // 设置状态为无记录 - popupView = lackView; + MessageModel::GetInstance().SetPopupViewState(false); // 设置状态为无消息 + lackView->SetVisible(true); // 隐藏界面 + messageView->SetVisible(false); // 隐藏界面 } else if (view == PopupMessage::MessagePopup) { - MessageModel::GetInstance().SetPopupViewState(true); // 设置状态为有记录 - popupView = messageView; - } - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - if (container_ != nullptr) - { - container_->SetVisible(!status); + MessageModel::GetInstance().SetPopupViewState(true); // 设置状态为有消息 + lackView->SetVisible(false); // 隐藏界面 + messageView->SetVisible(true); // 隐藏界面 } - popupView->SetVisible(status); } /// @brief 页面启动时需要执行的代码逻辑 @@ -245,7 +236,6 @@ namespace OHOS ShowMessageView(); PreLoad(); - RootView::GetInstance()->Add(container_); SetContainerView(container_); RootView::GetInstance()->SetOnKeyActListener(presenter_); @@ -266,8 +256,9 @@ namespace OHOS if (MessageModel::GetInstance().HasDataVector()) { messageView->Add(MessageList); + messageView->Add(DeleteButton); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageList is add"); - RootView::GetInstance()->Add(messageView); + container_->Add(messageView); MessageList->SetAdapter(p_MessageListAdapter); } Draw(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveElePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveElePresenter.h index 2a3894e48..56a6e0610 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveElePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveElePresenter.h @@ -1,35 +1,43 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 15:01:58 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveElePresenter.h + */ #ifndef _SAVEELE_PRESENTER_H #define _SAVEELE_PRESENTER_H - #include "Presenter.h" #include "SaveEleView.h" - + namespace OHOS { + static constexpr const char *SAVEBUTTONOK = "buttonok"; + static constexpr const char *SAVEBUTTONNO = "buttonno"; + class SaveEleView; - class SaveElePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnClickListener, + public UIView::OnDragListener, + public RootView::OnKeyActListener { public: SaveElePresenter(); virtual ~SaveElePresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SaveElePresenter *GetInstance(); - + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SaveElePresenter *GetInstance(); + private: - //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 }; -} //namespace OHOS - - -#endif //SLEEPDETAIL_PRESENTER_H \ No newline at end of file +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveEleView.h b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveEleView.h index 3464edced..b4602f97c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveEleView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveEleView.h @@ -3,12 +3,13 @@ #include "BaseView.h" #include "View.h" -#include + #include "components/ui_view_group.h" #include "components/ui_label.h" #include "components/ui_label_ext.h" #include "components/ui_image_view.h" #include "components/ui_button.h" +#include "components/ui_scroll_view.h" #include "SaveElePresenter.h" namespace OHOS @@ -26,32 +27,23 @@ namespace OHOS void OnSetUpView() override; void OnTearDownView() override; void OnStop() override; - void Init(); + void InitView(); void DeInit(); - UIView *GetView(); private: UIView::OnDragListener *draglistener{nullptr}; - // void InitImage(void); - // void InitLable(void); - - // 以下控件属性通过new实例化后,add到对应root属性上; - // SaveEleView(constSaveEleView &) = delete; - // SaveEleView &operator=(constSaveEleView &) = delete; SaveEleView(SaveEleView &&) = delete; SaveEleView &operator=(SaveEleView &&) = delete; - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - UIImageView *image2_ = nullptr; - UIImageView *image1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *labeltitle = nullptr; + UILabelExt *labelnote = nullptr; + UILabelExt *labelkown = nullptr; + UIButton *buttonok = nullptr; + UIButton *buttonno = nullptr; + UIImageView *iamgeicon = nullptr; + + UIScrollView *container_{nullptr}; }; } // namespace OHOS #endif // SaveEle_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp index 350f3eb08..963e645a0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp @@ -1,7 +1,16 @@ +/*** + * @Date: 2024-05-30 15:59:37 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 15:14:49 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp + */ #include "AppViewIDs.h" #include "components/ui_label_ext.h" -#include"ui_resource_string.h" +#include "ui_resource_string.h" #include "NativeAbility.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "common/key_code.h" #include "saveele/include/SaveElePresenter.h" @@ -56,27 +65,35 @@ namespace OHOS bool SaveElePresenter::OnDrag(UIView &view, const DragEvent &event) { - // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) - // { - // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - // } + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().Back(); + } UNUSED(view); return true; } bool SaveElePresenter::OnClick(UIView &view, const ClickEvent &event) { - // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), 控件ID) == 0) - if (strcmp(view.GetViewId(), "button1") == 0) + if (strcmp(view.GetViewId(), SAVEBUTTONNO) == 0) + { + NativeAbility::GetInstance().Back(); + } + if (strcmp(view.GetViewId(), SAVEBUTTONOK) == 0) { - // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().EnterSlice(VIEW_SAVEBAT); } - if (strcmp(view.GetViewId(), "button2") == 0) + return true; + } + bool SaveElePresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEBAT); + NativeAbility::GetInstance().Back(); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp index 967f2d8c5..14bbc29b7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp @@ -1,26 +1,41 @@ - +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-09 14:41:32 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveEleView.cpp + */ #include "saveele/include/SaveEleView.h" +#include "saveele/include/SaveElePresenter.h" #include "common/image_cache_manager.h" #include "UiConfig.h" #include "ui_resource_image.h" #include #include "components/ui_button.h" +#include "uicomponents/UIComponents.h" +#include "ui_resource_string.h" +#include "components/ui_scroll_view.h" + namespace OHOS { static SaveEleView *g_pSaveEleView{nullptr}; + static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; + + static constexpr char *iconImgPath = "/user/res/Save_Ele/SaveEle.bin"; + static constexpr char *butnoImgPath = "/user/res/Save_Ele/Save_Error.bin"; + static constexpr char *butokImgPath = "/user/res/Save_Ele/Save_Right.bin"; SaveEleView::SaveEleView() { - g_pSaveEleView = this; } SaveEleView::~SaveEleView() { - DeInit(); + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); g_pSaveEleView = nullptr; } @@ -29,306 +44,75 @@ namespace OHOS return g_pSaveEleView; } - void SaveEleView::Init() + void SaveEleView::InitView() { if (container_ == nullptr) { - container_ = new UIViewGroup(); + container_ = new UIScrollView(); container_->SetPosition(0, 0, 466, 466); container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } - // Add ScrollView to App - if (scrollView1_ == nullptr) - { - scrollView1_ = new UIScrollView(); - } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView1"); // Set style - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - // Set additional property - scrollView1_->SetDirection(1); - - // Add the CallBack about events - UIView::OnDragListener *scrollView1Drag = static_cast(SaveElePresenter::GetInstance()); - scrollView1_->SetOnDragListener(scrollView1Drag); - // Add to rootView - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(173, 52); // widget's left position and top position - label1_->Resize(120, 35); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 30); - label1_->SetStyle(STYLE_LINE_SPACE, 0); - label1_->SetStyle(STYLE_LETTER_SPACE, 1); - label1_->SetStyle(STYLE_LINE_HEIGHT, 35); - - // Set additional property - label1_->SetText("省电模式"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView1_->Add(label1_); - label1_->SetVisible(true); - - // Add Label to App - if (label3_ == nullptr) - { - label3_ = new UILabel(); - } - label3_->SetPosition(33, 440); // widget's left position and top position - label3_->Resize(200, 60); // widget's width and height - label3_->SetViewId("label3"); // Set style - label3_->SetStyle(STYLE_TEXT_FONT, 30); - label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + /*初始化label*/ + InitLabelExt(labeltitle, 83, 50, 300, 35, "labletitle", STR_POWER_SAVE_MODE, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(labelnote, 53, 217, 360, 200, "labletitle", STR_SAVENOTE, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(labelkown, 53, 385, 360, 100, "labelrecord", STR_SAVEBACK, DEFAULT_VECTOR_FONT_FILENAME, 30); + labelkown->SetTextColor(Color::Orange()); - // Set additional property - label3_->SetText("长按屏幕3秒以上或充电可退\n出省电模式"); - label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xc3, 0x00, 0xff)); - label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label3_->SetRollSpeed(0); - label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /*初始化图片*/ + InitImageView(iamgeicon, 188, 121, 80, 90, "saveicon", iconImgPath); - // Add to scrollView1 - scrollView1_->Add(label3_); - label3_->SetVisible(true); + /*初始化按键*/ + InitButton(buttonno, 110, 501, 100, 100, SAVEBUTTONNO); + buttonno->SetImageSrc(butnoImgPath, butnoImgPath); + buttonno->SetOnClickListener(presenter_); - // Add Label to App - if (label4_ == nullptr) - { - label4_ = new UILabel(); - } - label4_->SetPosition(173, 547); // widget's left position and top position - label4_->Resize(400, 395); // widget's width and height - label4_->SetViewId("label4"); // Set style - label4_->SetStyle(STYLE_TEXT_FONT, 30); - label4_->SetStyle(STYLE_LINE_HEIGHT, 35); - - // Set additional property - label4_->SetText("是否开启"); - label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label4_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); - label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label4_->SetRollSpeed(0); - label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView1_->Add(label4_); - label4_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) - { - button1_ = new UIButton(); - } - button1_->SetPosition(110, 636); // widget's left position and top position - button1_->Resize(100, 100); // widget's width and height - button1_->SetViewId("button1"); // Set style - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - char *button1defaultImgSrc = "/user/res/Save_Ele/Save_Error.bin"; - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff1919, UIButton::PRESSED); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(SaveElePresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to scrollView1 - scrollView1_->Add(button1_); - button1_->SetVisible(true); - - // Add Button to App - if (button2_ == nullptr) - { - button2_ = new UIButton(); - } - button2_->SetPosition(255, 636); // widget's left position and top position - button2_->Resize(100, 100); // widget's width and height - button2_->SetViewId("button2"); // Set style - button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - char *button2defaultImgSrc = "/user/res/Save_Ele/Save_Right.bin"; - char *button2triggeredImgSrc = nullptr; - button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); - button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff5e, UIButton::PRESSED); - button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *button2Click = static_cast(SaveElePresenter::GetInstance()); - button2_->SetOnClickListener(button2Click); - // Add to scrollView1 - scrollView1_->Add(button2_); - button2_->SetVisible(true); - - // Add ImageView to App - if (image2_ == nullptr) - { - image2_ = new UIImageView(); - } - image2_->SetPosition(183, 775); // widget's left position and top position - image2_->Resize(100, 100); // widget's width and height - image2_->SetViewId("image2"); // Set style - - // Set additional property - - // Add to scrollView1 - scrollView1_->Add(image2_); - image2_->SetVisible(true); - - // Add ImageView to App - if (image1_ == nullptr) - { - image1_ = new UIImageView(); - } - image1_->SetPosition(188, 121); // widget's left position and top position - image1_->Resize(90, 90); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Set additional property - char *image1imagesPath = "/user/res/Save_Ele/SaveEle.bin"; - image1_->SetSrc(image1imagesPath); - - // Add to scrollView1 - scrollView1_->Add(image1_); - image1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(33, 217); // widget's left position and top position - label2_->Resize(400, 395); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 30); - label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + InitButton(buttonok, 255, 501, 100, 100, SAVEBUTTONOK); + buttonok->SetImageSrc(butokImgPath, butokImgPath); + buttonok->SetOnClickListener(presenter_); - // Set additional property - label2_->SetText("开启省电模式会关闭非必要的\n蓝牙连接(通话/耳机蓝牙),以\n及传感器监测(心率监测及血\n氧监测等会停止)等功能\n 仅保留时间日期可查看"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView1_->Add(label2_); - label2_->SetVisible(true); - } - - void SaveEleView::DeInit() - { - scrollView1_->RemoveAll(); - container_->RemoveAll(); - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (label3_ != nullptr) - { - delete label3_; - label3_ = nullptr; - } - if (label4_ != nullptr) - { - delete label4_; - label4_ = nullptr; - } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - if (button2_ != nullptr) - { - delete button2_; - button2_ = nullptr; - } - if (image2_ != nullptr) - { - delete image2_; - image2_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } - if (container_ != nullptr) - { - delete container_; - container_ = nullptr; - } + container_->Add(labeltitle); + container_->Add(labelnote); + container_->Add(labelkown); + container_->Add(iamgeicon); + container_->Add(buttonno); + container_->Add(buttonok); } - UIView *SaveEleView::GetView() - { - Init(); - return container_; - } void SaveEleView::OnStart() { + + View::OnStart(); + container_ = new UIScrollView(); if (container_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); return; } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight() * 2); - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(SaveElePresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); + container_->SetScrollBlankSize(35); + container_->SetReboundSize(50); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); + container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - GetView(); - RootView::GetInstance()->Add(container_); + InitView(); + SetContainerView(container_); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } void SaveEleView::OnSetUpView() { - View::OnSetUpView(); Draw(); } void SaveEleView::OnTearDownView() { - View::OnTearDownView(); return; } @@ -336,6 +120,12 @@ namespace OHOS void SaveEleView::OnStop() { View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->RemoveAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp index d4cee4d8e..9e98813bc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp @@ -22,7 +22,14 @@ namespace OHOS TakephotosView::~TakephotosView() { - DeInit(); + // DeInit(); + + creamAnimator->Stop(); + smileAnimator->Start(); + + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pTakephotosView = nullptr; } @@ -140,7 +147,9 @@ namespace OHOS creamView->Add(labelnote_); creamView->Add(buttongo); - RootView::GetInstance()->Add(creamView); + // RootView::GetInstance()->Add(creamView); + container_->Add(creamView); + creamView->SetDraggable(true); creamView->SetTouchable(true); @@ -190,7 +199,9 @@ namespace OHOS takeView->Add(labelclick_); takeView->Add(buttontake); - RootView::GetInstance()->Add(takeView); + // RootView::GetInstance()->Add(takeView); + container_->Add(takeView); + takeView->SetDraggable(true); takeView->SetTouchable(true); @@ -208,32 +219,23 @@ namespace OHOS void TakephotosView::SetPopupViewStatus(PopupPhoto view, bool status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); - UIView *popupView = nullptr; + if (view == PopupPhoto::CreamPopup) { - popupView = creamView; + creamView->SetVisible(true); + takeView->SetVisible(false); + creamAnimator->Start(); smileAnimator->Stop(); } else if (view == PopupPhoto::TakePopup) { - popupView = takeView; + takeView->SetVisible(true); + creamView->SetVisible(false); + smileAnimator->Start(); creamAnimator->Stop(); } - - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - - if (container_ != nullptr) - { - container_->SetVisible(!status); - } - - popupView->SetVisible(status); } void TakephotosView::OnStart() @@ -248,7 +250,6 @@ namespace OHOS ShowTakeView(); PreLoad(); - RootView::GetInstance()->Add(container_); SetContainerView(container_); RootView::GetInstance()->SetOnKeyActListener(presenter_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetCaluliView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetCaluliView.h index 5edd7eeba..33ffda912 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetCaluliView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetCaluliView.h @@ -46,7 +46,7 @@ namespace OHOS UILabelButtonExt *buttonok_ = nullptr; UIPicker *Picker_ = nullptr; - UIScrollView *SetCaluliScrollView; + UIScrollView *SetCaluliScrollView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h index 412bdd468..da510dd8c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-18 11:59:51 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-10 10:28:21 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h + */ /*** * @Date: 2024-04-18 11:59:51 * @LastEditors: Caisking 3449750381@qq.com @@ -52,7 +58,7 @@ namespace OHOS UILabelButtonExt *buttonok_ = nullptr; UIPicker *Picker_ = nullptr; - UIScrollView *SetMileScrollView; + UIScrollView *SetMileScrollView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetStepView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetStepView.h index 66862e0ee..23bc49d8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetStepView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetStepView.h @@ -52,7 +52,7 @@ namespace OHOS UILabelButtonExt *buttonok_ = nullptr; UIPicker *Picker_ = nullptr; - UIScrollView *SetStepScrollView; + UIScrollView *SetStepScrollView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h index 27a3b6a0c..763ad2871 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-18 11:58:41 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-10 10:28:35 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h + */ /*** * @Date: 2024-04-18 10:57:45 * @LastEditors: Caisking 3449750381@qq.com @@ -45,7 +51,7 @@ namespace OHOS UILabelButtonExt*buttonok_ = nullptr; UIPicker *Picker_ = nullptr; - UIScrollView *SetTimeScrollView; + UIScrollView *SetTimeScrollView{nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index b91e8da50..3b8a85d8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -29,7 +29,10 @@ namespace OHOS TraingRecordView::~TraingRecordView() { - DeInit(); + // DeInit(); + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pTraingRecordView = nullptr; } @@ -63,6 +66,7 @@ namespace OHOS /* DeInit:删除组件 */ void TraingRecordView::DeInit() { + lackView->RemoveAll(); recordView->RemoveAll(); @@ -127,7 +131,10 @@ namespace OHOS lackView->Add(imagerecord); lackView->Add(buttongo); - RootView::GetInstance()->Add(lackView); + // RootView::GetInstance()->lackView + container_->Add(lackView); + printf("lackView Add\r\n"); + lackView->SetDraggable(true); lackView->SetTouchable(true); @@ -150,7 +157,7 @@ namespace OHOS return; } recordView->SetPosition(0, 0); - recordView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + recordView->Resize(466, 466); recordView->SetScrollBlankSize(20); recordView->SetReboundSize(50); recordView->SetDirection(1); @@ -192,27 +199,19 @@ namespace OHOS void TraingRecordView::SetPopupViewStatus(PopupRecord view, bool status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); - UIView *popupView = nullptr; + if (view == PopupRecord::LackPopup) { TraingRecordModel::GetInstance().SetPopupView(false); // 设置状态为无训练记录 - popupView = lackView; + lackView->SetVisible(true); // 隐藏界面 + recordView->SetVisible(false); // 隐藏界面 } else if (view == PopupRecord::RecordPopup) { TraingRecordModel::GetInstance().SetPopupView(true); // 设置状态为有训练记录 - popupView = recordView; - } - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - if (container_ != nullptr) - { - container_->SetVisible(!status); + lackView->SetVisible(false); // 隐藏界面 + recordView->SetVisible(true); // 隐藏界面 } - popupView->SetVisible(status); } // 获取目前的view void TraingRecordView::OnStart() @@ -226,13 +225,8 @@ namespace OHOS return; } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(TraingRecordPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); + + container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); @@ -241,8 +235,9 @@ namespace OHOS ShowLackView(); ShowRecordView(); PreLoad(); - RootView::GetInstance()->Add(container_); + SetContainerView(container_); + // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingRecordPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); @@ -258,7 +253,8 @@ namespace OHOS { recordView->Add(TraingRecordList); recordView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(recordView); + container_->Add(recordView); + printf("recordView Add\r\n"); TraingRecordList->SetAdapter(p_TraingRecordAdapter); } Draw(); diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/transition/ZoomTransition.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/transition/ZoomTransition.cpp index 6566f04ba..9d3e2da41 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/src/transition/ZoomTransition.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/transition/ZoomTransition.cpp @@ -1,7 +1,7 @@ /*** * @Date: 2024-05-30 15:59:37 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-04 19:20:34 + * @LastEditTime: 2024-08-10 15:24:43 * @FilePath: /FD230/code/sdk/application/wearable/nativeabilityfwk/src/transition/ZoomTransition.cpp */ /* @@ -17,7 +17,7 @@ namespace OHOS { static constexpr int16_t RANGE = 1000; -REGIST_TRANSITION(TransitionType::TRANSITION_ZOOM, ZoomTransition, 200, true, true); +REGIST_TRANSITION(TransitionType::TRANSITION_ZOOM, ZoomTransition, 80, true, true); void ZoomTransition::OnTransitionStart(UIImageView* current, UIImageView* target) { -- 2.17.1