From 8fc9bf3ce6689b53d632fe0dd6eb3be52919f287 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Thu, 12 Sep 2024 01:56:24 +0000 Subject: [PATCH] Merge #944 into sdk602patch0626 from refs/changes/944/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/944/head: (10 commits squashed) - 修复 训练健身类多余的项 - #637手表,遥控拍照,APP先退出会导致手表卡死机(必现) - #389密码-最后一个数字没有动画效果 - 修复密码锁的错误处理 - #456睡眠界面,紫色进度条外面有刻度未遮挡完全 - #657手表,运动-健身类-滑倒最底部点击,室内运动,黑屏后电源键无法唤醒问题 - 睡眠进度条优化 - 优化睡眠进度条背景的线条 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 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/944 --- .../codedlock/include/CodedLockModel.h | 2 + .../nativeui/codedlock/src/CodedLockModel.cpp | 19 +- .../codedlock/src/CodedLockPresenter.cpp | 51 +- .../nativeui/codedlock/src/CodedLockView.cpp | 505 ++++++++-------- .../fd230app/nativeui/sleep/src/SleepView.cpp | 17 +- .../takephotos/src/TakephotosModel.cpp | 2 +- .../takephotos/src/TakephotosPresenter.cpp | 4 + .../takephotos/src/TakephotosView.cpp | 563 +++++++++--------- .../include/TraingFitnessModel.h | 3 +- 9 files changed, 580 insertions(+), 586 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h index 995b85ccd..ff260ae41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h @@ -37,6 +37,8 @@ namespace OHOS void ResetLockState(); // 获取已经点击个数 uint8_t GetPointNum(); + //配置已经点击的个数 + void SetPointNum(uint8_t num); // 配置用户密码 void SetUserPassWord(const std::string &password); // ble进行解锁 diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp index 40175f14a..dca516bdf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp @@ -66,9 +66,13 @@ namespace OHOS passcount++; inputpassword_ += std::to_string(num); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前inputpassword_: %s", inputpassword_.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前inputpassword_: %s %d ", inputpassword_.c_str(),passcount); - // 检查当前输入密码的长度 + /* + 检查当前输入密码的长度 等于6个 会进行清除 + 但是不设置passcount==0 + 我需要传一个6过去显示 然后过一秒再配置0 + */ if (passcount >= PASSWORDNUM) { if (IsPasswordMatch()) @@ -81,7 +85,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码不匹配,已清空输入"); } - passcount = 0; // 重置输入计数 + // passcount = 0; // 重置输入计数 ClearPassword(); // 清空输入密码 } } @@ -126,6 +130,15 @@ namespace OHOS return passcount; } + /** + * @brief 设置当前输入的数字个数 + * @param uint8_t 当前输入的数字个数 + */ + void CodedLockModel::SetPointNum(uint8_t num) + { + passcount = num; + } + // ================== 输入密码管理 ================== /** diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp index ed91c90b3..7cc54073e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp @@ -64,29 +64,36 @@ namespace OHOS { Presenter::OnStop(); } - void CodedLockPresenter::JudgeMatch() - { - /*进行现状密码打印*/ - // CodedLockModel::GetInstance()->GetInputPassword(); - // CodedLockModel::GetInstance()->GetPassword(); - - /*每次点击完成 更新 点击图片*/ - int num = CodedLockModel::GetInstance()->GetPointNum(); - CodedLockView::GetInstance()->UpdatePointShow(num); - - /*每次点击完成判断 是否 完成密码匹配*/ - if (CodedLockModel::GetInstance()->IsLockState()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "回到主界面"); - /*关锁*/ - uapi_dev_runtime_set_lock_status(0); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - /*设置表盘状态*/ - MainModel::GetInstance().setDialState(DialState::LOCK, false); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok"); - } + void CodedLockPresenter::JudgeMatch() + { + const int REQUIRED_POINTS = 6; + int num = CodedLockModel::GetInstance()->GetPointNum(); + CodedLockView::GetInstance()->UpdatePointShow(num); + + if (num == REQUIRED_POINTS) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "num is 6, sleeping for 1s"); + CodedLockModel::GetInstance()->SetPointNum(0); + + if (CodedLockModel::GetInstance()->IsLockState()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Returning to main interface"); + //解锁 + uapi_dev_runtime_set_lock_status(0); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + //恢复表盘状态 + MainModel::GetInstance().setDialState(DialState::LOCK, false); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK); + } + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok"); + } + bool CodedLockPresenter::OnClick(UIView &view, const ClickEvent &event) { if (strcmp(view.GetViewId(), LOCK_BUTTON_ONE) == 0) diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp index 92f2f54dc..84f23c01d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp @@ -2,288 +2,283 @@ * @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/codedlock/src/CodedLockView.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp */ #include "codedlock/include/CodedLockView.h" #include "codedlock/include/CodedLockPresenter.h" -#include "common/image_cache_manager.h" #include "UiConfig.h" -#include "ui_resource_image.h" +#include "common/image_cache_manager.h" #include "components/ui_button.h" -#include "uicomponents/UIComponents.h" -#include "ui_resource_string.h" #include "components/ui_scroll_view.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" +#include "uicomponents/UIComponents.h" -namespace OHOS -{ +namespace OHOS { - static CodedLockView *g_pCodedLockView{nullptr}; +static CodedLockView *g_pCodedLockView{nullptr}; - static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; +static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; - // 定义默认颜色和激活颜色 - static const uint32_t activeColor = 0xffaaaaaa; - static const uint32_t defaultColor = 0xff191919; +// 定义默认颜色和激活颜色 +static const uint32_t activeColor = 0xffaaaaaa; +static const uint32_t defaultColor = 0xff191919; #define UI_IMAGE_TEST 1 - CodedLockView::CodedLockView() - { - g_pCodedLockView = this; - } +CodedLockView::CodedLockView() { g_pCodedLockView = this; } - CodedLockView::~CodedLockView() - { - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); - g_pCodedLockView = nullptr; - } +CodedLockView::~CodedLockView() { + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pCodedLockView = nullptr; +} - CodedLockView *CodedLockView::GetInstance() - { - return g_pCodedLockView; - } +CodedLockView *CodedLockView::GetInstance() { return g_pCodedLockView; } - void CodedLockView::InitButtonsView() - { - // 第一行 - InitLabelButton(button_one, 30, 90, 130, 88, LOCK_BUTTON_ONE, "1", 40); - button_one->SetOnClickListener(presenter_); - container_->Add(button_one); - - InitLabelButton(button_two, 168, 90, 130, 88, LOCK_BUTTON_TWO, "2", 40); - button_two->SetOnClickListener(presenter_); - container_->Add(button_two); - - InitLabelButton(button_three, 305, 90, 130, 88, LOCK_BUTTON_THREE, "3", 40); - button_three->SetOnClickListener(presenter_); - container_->Add(button_three); - - // 第二行 - InitLabelButton(button_four, 30, 185, 130, 88, LOCK_BUTTON_FOUR, "4", 40); - button_four->SetOnClickListener(presenter_); - container_->Add(button_four); - - InitLabelButton(button_five, 168, 185, 130, 88, LOCK_BUTTON_FIVE, "5", 40); - button_five->SetOnClickListener(presenter_); - container_->Add(button_five); - - InitLabelButton(button_six, 305, 185, 130, 88, LOCK_BUTTON_SIX, "6", 40); - button_six->SetOnClickListener(presenter_); - container_->Add(button_six); - - // 第三行 - InitLabelButton(button_seven, 30, 280, 130, 88, LOCK_BUTTON_SEVEN, "7", 40); - button_seven->SetOnClickListener(presenter_); - container_->Add(button_seven); - - InitLabelButton(button_eight, 168, 280, 130, 88, LOCK_BUTTON_EIGHT, "8", 40); - button_eight->SetOnClickListener(presenter_); - container_->Add(button_eight); - - InitLabelButton(button_nine, 305, 280, 130, 88, LOCK_BUTTON_NINE, "9", 40); - button_nine->SetOnClickListener(presenter_); - container_->Add(button_nine); - - // 第四行 (0) - InitLabelButton(button_zero, 168, 375, 130, 88, LOCK_BUTTON_ZERO, "0", 40); - button_zero->SetOnClickListener(presenter_); - container_->Add(button_zero); - - // InitLabelButton(button_delete, 230, 390, 130, 88, LOCK_BUTTON_DELETE, " ", 40); - // button_delete->SetOnClickListener(presenter_); - // container_->Add(button_delete); - } - void CodedLockView::InitImagesView() - { - std::vector points = { - {&point_one, 140, 55, "image1", defaultColor, 0xff, 100}, - {&point_two, 175, 55, "image1", defaultColor, 0xff, 100}, - {&point_three, 210, 55, "image1", defaultColor, 0xff, 100}, - {&point_four, 245, 55, "image1", defaultColor, 0xff, 100}, - {&point_five, 280, 55, "image1", defaultColor, 0xff, 100}, - {&point_six, 310, 55, "image1", defaultColor, 0xff, 100}, - }; - - for (const auto &config : points) - { - InitializePoint(config.imageView, config.x, config.y, (config.viewId).c_str(), config.backgroundColor, config.backgroundOpa, config.borderRadius); - } - } +void CodedLockView::InitButtonsView() { + // 第一行 + InitLabelButton(button_one, 30, 90, 130, 88, LOCK_BUTTON_ONE, "1", 40); + button_one->SetOnClickListener(presenter_); + container_->Add(button_one); - void CodedLockView::InitializePoint(UIImageView **imageView, int x, int y, const char *viewId, uint32_t backgroundColor, uint8_t backgroundOpa, int borderRadius) - { - if (*imageView == nullptr) - { - *imageView = new UIImageView(); - } - - (*imageView)->SetPosition(x, y); - (*imageView)->Resize(20, 20); - (*imageView)->SetViewId(viewId); - (*imageView)->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - (*imageView)->SetStyle(STYLE_BACKGROUND_OPA, backgroundOpa); - (*imageView)->SetStyle(STYLE_BORDER_RADIUS, borderRadius); - - container_->Add(*imageView); - } - void CodedLockView::UpdatePointShow(int num) - { + InitLabelButton(button_two, 168, 90, 130, 88, LOCK_BUTTON_TWO, "2", 40); + button_two->SetOnClickListener(presenter_); + container_->Add(button_two); + + InitLabelButton(button_three, 305, 90, 130, 88, LOCK_BUTTON_THREE, "3", 40); + button_three->SetOnClickListener(presenter_); + container_->Add(button_three); + + // 第二行 + InitLabelButton(button_four, 30, 185, 130, 88, LOCK_BUTTON_FOUR, "4", 40); + button_four->SetOnClickListener(presenter_); + container_->Add(button_four); + + InitLabelButton(button_five, 168, 185, 130, 88, LOCK_BUTTON_FIVE, "5", 40); + button_five->SetOnClickListener(presenter_); + container_->Add(button_five); + + InitLabelButton(button_six, 305, 185, 130, 88, LOCK_BUTTON_SIX, "6", 40); + button_six->SetOnClickListener(presenter_); + container_->Add(button_six); + + // 第三行 + InitLabelButton(button_seven, 30, 280, 130, 88, LOCK_BUTTON_SEVEN, "7", 40); + button_seven->SetOnClickListener(presenter_); + container_->Add(button_seven); + + InitLabelButton(button_eight, 168, 280, 130, 88, LOCK_BUTTON_EIGHT, "8", 40); + button_eight->SetOnClickListener(presenter_); + container_->Add(button_eight); - if (point_one == nullptr || point_two == nullptr || point_three == nullptr || - point_four == nullptr || point_five == nullptr || point_six == nullptr) - return; + InitLabelButton(button_nine, 305, 280, 130, 88, LOCK_BUTTON_NINE, "9", 40); + button_nine->SetOnClickListener(presenter_); + container_->Add(button_nine); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdatePointShow Num %d", num); + // 第四行 (0) + InitLabelButton(button_zero, 168, 375, 130, 88, LOCK_BUTTON_ZERO, "0", 40); + button_zero->SetOnClickListener(presenter_); + container_->Add(button_zero); + + // InitLabelButton(button_delete, 230, 390, 130, 88, LOCK_BUTTON_DELETE, " ", + // 40); button_delete->SetOnClickListener(presenter_); + // container_->Add(button_delete); +} +void CodedLockView::InitImagesView() { + std::vector points = { + {&point_one, 140, 55, "image1", defaultColor, 0xff, 100}, + {&point_two, 175, 55, "image1", defaultColor, 0xff, 100}, + {&point_three, 210, 55, "image1", defaultColor, 0xff, 100}, + {&point_four, 245, 55, "image1", defaultColor, 0xff, 100}, + {&point_five, 280, 55, "image1", defaultColor, 0xff, 100}, + {&point_six, 310, 55, "image1", defaultColor, 0xff, 100}, + }; + + for (const auto &config : points) { + InitializePoint(config.imageView, config.x, config.y, + (config.viewId).c_str(), config.backgroundColor, + config.backgroundOpa, config.borderRadius); + } +} + +void CodedLockView::InitializePoint(UIImageView **imageView, int x, int y, + const char *viewId, + uint32_t backgroundColor, + uint8_t backgroundOpa, int borderRadius) { + if (*imageView == nullptr) { + *imageView = new UIImageView(); + } + + (*imageView)->SetPosition(x, y); + (*imageView)->Resize(20, 20); + (*imageView)->SetViewId(viewId); + (*imageView)->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); + (*imageView)->SetStyle(STYLE_BACKGROUND_OPA, backgroundOpa); + (*imageView)->SetStyle(STYLE_BORDER_RADIUS, borderRadius); + + container_->Add(*imageView); +} +void CodedLockView::UpdatePointShow(int num) { + + if (point_one == nullptr || point_two == nullptr || point_three == nullptr || + point_four == nullptr || point_five == nullptr || point_six == nullptr) + return; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdatePointShow Num %d", num); #if UI_IMAGE_TEST - switch (num) - { - case 0: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - break; - case 1: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 2: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 3: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 4: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 5: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 6: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_six->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - default: - break; - } + switch (num) { + case 0: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 1: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 2: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 3: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 4: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 5: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 6: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + break; + default: + break; + } #else - // 更新所有点的颜色 - for (int i = 1; i <= 6; ++i) - { - UIImageView *point = nullptr; - switch (i) - { - case 1: - point = point_one; - break; - case 2: - point = point_two; - break; - case 3: - point = point_three; - break; - case 4: - point = point_four; - break; - case 5: - point = point_five; - break; - case 6: - point = point_six; - break; - default: - continue; - } - - if (point != nullptr) - { - if (i <= num) - { - // 如果是前 num 个点,则设置为激活颜色 - point->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - } - else - { - // 其他点设置为默认颜色 - point->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - } - } - } -#endif - /*ui刷新*/ - point_one->Invalidate(); - point_two->Invalidate(); - point_three->Invalidate(); - point_four->Invalidate(); - point_five->Invalidate(); - point_six->Invalidate(); + // 更新所有点的颜色 + for (int i = 1; i <= 6; ++i) { + UIImageView *point = nullptr; + switch (i) { + case 1: + point = point_one; + break; + case 2: + point = point_two; + break; + case 3: + point = point_three; + break; + case 4: + point = point_four; + break; + case 5: + point = point_five; + break; + case 6: + point = point_six; + break; + default: + continue; } - void CodedLockView::OnStart() - { - View::OnStart(); - - container_ = new UIScrollView(); - if (container_ == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); - return; - } - container_->SetScrollBlankSize(35); - container_->SetReboundSize(50); - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - - container_->SetTouchable(false); - container_->SetDraggable(false); - container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); - container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - - InitButtonsView(); - InitImagesView(); - - SetContainerView(container_); + if (point != nullptr) { + if (i <= num) { + // 如果是前 num 个点,则设置为激活颜色 + point->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + } else { + // 其他点设置为默认颜色 + point->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + } } + } +#endif + /*ui刷新*/ + point_one->Invalidate(); + point_two->Invalidate(); + point_three->Invalidate(); + point_four->Invalidate(); + point_five->Invalidate(); + point_six->Invalidate(); +} - void CodedLockView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } +void CodedLockView::OnStart() { + View::OnStart(); - void CodedLockView::OnTearDownView() - { - View::OnTearDownView(); - return; - } + container_ = new UIScrollView(); + if (container_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); + return; + } + container_->SetScrollBlankSize(35); + container_->SetReboundSize(50); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); - void CodedLockView::OnStop() - { - View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - RootView::GetInstance()->RemoveAll(); - return; - } + container_->SetTouchable(false); + container_->SetDraggable(false); + container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + + InitButtonsView(); + InitImagesView(); + + SetContainerView(container_); +} + +void CodedLockView::OnSetUpView() { + View::OnSetUpView(); + Draw(); +} + +void CodedLockView::OnTearDownView() { + View::OnTearDownView(); + return; +} + +void CodedLockView::OnStop() { + View::OnStop(); + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->RemoveAll(); + return; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp index 1256ec558..1c8499c98 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp @@ -166,28 +166,23 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "circleProgress new fail"); return false; } - circleProgress_->SetPosition(-1, 0); - circleProgress_->Resize(466, 466); - circleProgress_->SetViewId("circleProgress"); + circleProgress_->SetPosition(0, 0); + circleProgress_->Resize(466, 466); + circleProgress_->SetViewId("circleProgress1"); circleProgress_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); circleProgress_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); circleProgress_->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); - circleProgress_->SetBackgroundStyle(STYLE_LINE_HEIGHT, 200); - circleProgress_->SetBackgroundStyle(STYLE_LINE_WIDTH, 21); + circleProgress_->SetBackgroundStyle(STYLE_BORDER_OPA, 0x00); circleProgress_->SetBackgroundStyle(STYLE_LINE_OPA, 0x00); circleProgress_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); - circleProgress_->SetForegroundStyle(STYLE_BORDER_WIDTH, 200); - circleProgress_->SetForegroundStyle(STYLE_BORDER_RADIUS, 200); circleProgress_->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); - circleProgress_->SetForegroundStyle(STYLE_LINE_HEIGHT, 35); - circleProgress_->SetForegroundStyle(STYLE_LINE_COLOR, 0xff5320E2); + circleProgress_->SetForegroundStyle(STYLE_LINE_COLOR, 0xff5320e2); circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH, 20); circleProgress_->SetCenterPosition(233, 229); circleProgress_->SetRadius(205); circleProgress_->SetStartAngle(320); circleProgress_->SetEndAngle(40); - circleProgress_->SetValue(0); - circleProgress_->SetBackgroundImagePosition(36, 26); + circleProgress_->SetCapType(CAP_ROUND); /* -------------------------------- 将组件添加到根视图 ------------------------------- */ Add(progress_image); Add(circleProgress_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp index 195e97e66..a99952098 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosModel.cpp @@ -98,9 +98,9 @@ extern "C" // 退出拍照 if (request->msgId == TOPIC_EVENT_CANCEL_CMAERA) { - TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); NativeAbility::GetInstance().Back(); cameraSend(3); + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); } } #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp index 0c839ce93..86d2f3ced 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosPresenter.cpp @@ -77,10 +77,14 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { + NativeAbility::GetInstance().Back(); + /*如果是拍照界面需要发送拍照结束的消息*/ if (TakephotosModel::GetInstance()->GetPopStaust() == PopupPhoto::TakePopup) { + //设置状态为 cream + TakephotosModel::GetInstance()->SetPopStaust(PopupPhoto::CreamPopup); cameraSend(3); } } 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 79eea0918..8813516dd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp @@ -2,305 +2,282 @@ * @Date: 2024-08-29 19:34:29 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-30 19:46:48 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp */ #include "takephotos/include/TakephotosView.h" #include "takephotos/include/TakephotosModel.h" -#include "common/image_cache_manager.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "ui_resource_image.h" #include "uicomponents/UIComponents.h" -#include "UiConfig.h" -namespace OHOS -{ - static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; - - static TakephotosView *g_pTakephotosView{nullptr}; - - TakephotosView::TakephotosView() - { - g_pTakephotosView = this; - } - - TakephotosView::~TakephotosView() - { - // DeInit(); - PopupPhoto staust = TakephotosModel::GetInstance()->GetPopStaust(); - if (staust == PopupPhoto::CreamPopup) - { - creamAnimator->Stop(); - FreeImageInfoArray(creamimageInfos, creambasePath.c_str(), 50); - } - else - { - smileAnimator->Stop(); - FreeImageInfoArray(smileimageInfos, smilebasePath.c_str(), 50); - } - ReleaseImageAnimatorSource(smileimageAnimatorInfo, 50); - ReleaseImageAnimatorSource(creamimageAnimatorInfo, 50); - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); - - g_pTakephotosView = nullptr; - } - - TakephotosView *TakephotosView::GetInstance() - { - return g_pTakephotosView; - } - - /* InitView:初始化界面*/ - void TakephotosView ::InitView() - { - if (container_ == nullptr) - { - container_ = new UIScrollView(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - PopupPhoto staust = TakephotosModel::GetInstance()->GetPopStaust(); - SetPopupViewStatus(staust, true); - } - - /* DeInit:删除组件 */ - void TakephotosView::DeInit() - { - creamView->RemoveAll(); - takeView->RemoveAll(); - - delete labeltitle_; - labeltitle_ = nullptr; - - delete labelnote_; - labelnote_ = nullptr; - - delete labeltake_; - labeltake_ = nullptr; - - delete labelclick_; - labelclick_ = nullptr; - - delete buttontake; - buttontake = nullptr; - - delete buttongo; - buttongo = nullptr; - - smileAnimator->Stop(); - delete smileAnimator; - smileAnimator = nullptr; - - creamAnimator->Stop(); - delete creamAnimator; - creamAnimator = nullptr; - - delete creamView; - creamView = nullptr; - - delete takeView; - takeView = nullptr; - } - - void TakephotosView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - } - /*显示拍照界面*/ - void TakephotosView::ShowCreamView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView start"); - creamView = new UIScrollView(); - if (creamView == nullptr) - { - return; - } - creamView->SetPosition(0, 0); - creamView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - creamView->SetScrollBlankSize(20); - creamView->SetReboundSize(50); - creamView->SetDirection(1); - /*初始化label*/ - InitLabelExt(labeltitle_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - - // 设置标签的位置和大小 - labelnote_ = new UILabel(); - labelnote_->SetPosition(53, 250); - labelnote_->Resize(360, 200); - // 设置标签的视图 ID - labelnote_->SetViewId("labelTake"); - // 设置标签的样式 - labelnote_->SetStyle(STYLE_TEXT_FONT, 30); - labelnote_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // 设置标签的文本和其他属性 - labelnote_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - labelnote_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - SetLabelId(labelnote_, STR_TACK); - - /*初始化image*/ - // InitImageView(imageTake, 174, 120, 118, 120, "image", RECOED_IMAGE); - /*初始化按键*/ - InitButtonExt(buttongo, 0, 366, 466, 100, BUTTONGO, STR_KONW, 30); - buttongo->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); - buttongo->SetOnClickListener(static_cast(TakephotosPresenter::GetInstance())); - - // 初始化图片数组以及动画 - creamimageInfos = CreateImageInfoArray(creambasePath.c_str(), 50); - InitImageAnimatorSource(creamAnimator, creamimageAnimatorInfo, creamimageInfos, 50, 163, 103, 140, 140, "imageAnimator", 100); - - creamView->Add(creamAnimator); - creamView->Add(labeltitle_); - creamView->Add(labelnote_); - creamView->Add(buttongo); - - // RootView::GetInstance()->Add(creamView); - container_->Add(creamView); - - creamView->SetDraggable(true); - creamView->SetTouchable(true); - - UIView::OnDragListener *draglistener = static_cast(TakephotosPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - creamView->SetOnDragListener(draglistener); - - creamView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView end"); - } - /*遥控拍照界面*/ - void TakephotosView::ShowTakeView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView start"); - takeView = new UIScrollView(); - if (takeView == nullptr) - { - return; - } - takeView->SetPosition(0, 0); - takeView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - takeView->SetScrollBlankSize(20); - takeView->SetReboundSize(50); - takeView->SetDirection(1); - - /*初始化label*/ - InitLabelExt(labeltake_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabelExt(labelclick_, 53, 278, 360, 70, "labelclick_", STR_TACKNUM, DEFAULT_VECTOR_FONT_FILENAME, 30); - UpdateLabel(labelclick_, 0, STR_TACKNUM); // 初始化为0 - - /*初始化按键*/ - InitButtonExt(buttontake, 93, 330, 280, 90, BUTTONTAKE, STR_CLICK, 26); - buttontake->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 设置按键颜色 - buttontake->SetOnClickListener(static_cast(TakephotosPresenter::GetInstance())); - - // 初始化图片数组以及动画 {修改为统一动画} - smileimageInfos = CreateImageInfoArray(smilebasePath.c_str(), 50); - InitImageAnimatorSource(smileAnimator, smileimageAnimatorInfo, smileimageInfos, 50, 163, 140, 140, 140, "imageAnimator", 100); - - takeView->Add(smileAnimator); - takeView->Add(labeltake_); - takeView->Add(labelclick_); - takeView->Add(buttontake); - - // RootView::GetInstance()->Add(takeView); - container_->Add(takeView); - - takeView->SetDraggable(true); - takeView->SetTouchable(true); - - UIView::OnDragListener *draglistener = static_cast(TakephotosPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - takeView->SetOnDragListener(draglistener); - - takeView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView end"); - } - /*控制显示界面*/ - void TakephotosView::SetPopupViewStatus(PopupPhoto view, bool status) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); - - if (view == PopupPhoto::CreamPopup) - { - creamView->SetVisible(true); - takeView->SetVisible(false); - - creamAnimator->Start(); - smileAnimator->Stop(); - } - else if (view == PopupPhoto::TakePopup) - { - takeView->SetVisible(true); - creamView->SetVisible(false); - - smileAnimator->Start(); - creamAnimator->Stop(); - } - } - - void TakephotosView::OnStart() - { - container_ = new UIScrollView(); - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - container_->SetOnDragListener(presenter_); - container_->SetTouchable(true); - container_->SetDraggable(true); - - ShowCreamView(); - ShowTakeView(); - PreLoad(); - - SetContainerView(container_); - - RootView::GetInstance()->SetOnKeyActListener(presenter_); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosView OnStart is ok"); - } - - UILabel *TakephotosView::GetClileLabel() - { - return labelclick_; - } - void TakephotosView::Updatenum(int num) - { - if (smileAnimator->GetState() == true && labelclick_ != nullptr) - { - UpdateLabel(labelclick_, num, STR_TACKNUM); - labelclick_->Invalidate(); - } - } - void TakephotosView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void TakephotosView::OnTearDownView() - { - View::OnTearDownView(); - return; - } - - void TakephotosView::OnStop() - { - View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - RootView::GetInstance()->RemoveAll(); - return; - } +#include +namespace OHOS { +static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; + +static TakephotosView *g_pTakephotosView{nullptr}; + +TakephotosView::TakephotosView() { g_pTakephotosView = this; } + +TakephotosView::~TakephotosView() { + // DeInit(); + if (creamimageInfos != nullptr) + FreeImageInfoArray(creamimageInfos, creambasePath.c_str(), 50); + if (smileimageInfos != nullptr) + FreeImageInfoArray(smileimageInfos, smilebasePath.c_str(), 50); + + creamAnimator->Stop(); + smileAnimator->Stop(); + ReleaseImageAnimatorSource(smileimageAnimatorInfo, 50); + ReleaseImageAnimatorSource(creamimageAnimatorInfo, 50); + + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + g_pTakephotosView = nullptr; +} + +TakephotosView *TakephotosView::GetInstance() { return g_pTakephotosView; } + +/* InitView:初始化界面*/ +void TakephotosView ::InitView() { + if (container_ == nullptr) { + container_ = new UIScrollView(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + //设置进入弹窗 + PopupPhoto staust = TakephotosModel::GetInstance()->GetPopStaust(); + SetPopupViewStatus(staust, true); +} + +/* DeInit:删除组件 */ +void TakephotosView::DeInit() { + creamView->RemoveAll(); + takeView->RemoveAll(); + + delete labeltitle_; + labeltitle_ = nullptr; + + delete labelnote_; + labelnote_ = nullptr; + + delete labeltake_; + labeltake_ = nullptr; + + delete labelclick_; + labelclick_ = nullptr; + + delete buttontake; + buttontake = nullptr; + + delete buttongo; + buttongo = nullptr; + + smileAnimator->Stop(); + delete smileAnimator; + smileAnimator = nullptr; + + creamAnimator->Stop(); + delete creamAnimator; + creamAnimator = nullptr; + + delete creamView; + creamView = nullptr; + + delete takeView; + takeView = nullptr; +} + +void TakephotosView::PreLoad(void) { + if (!viewiInitStatus) { + InitView(); + viewiInitStatus = true; + } +} +/*显示拍照界面*/ +void TakephotosView::ShowCreamView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView start"); + creamView = new UIScrollView(); + if (creamView == nullptr) { + return; + } + creamView->SetPosition(0, 0); + creamView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + creamView->SetScrollBlankSize(20); + creamView->SetReboundSize(50); + creamView->SetDirection(1); + /*初始化label*/ + InitLabelExt(labeltitle_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + + // 设置标签的位置和大小 + labelnote_ = new UILabel(); + labelnote_->SetPosition(53, 250); + labelnote_->Resize(360, 200); + // 设置标签的视图 ID + labelnote_->SetViewId("labelTake"); + // 设置标签的样式 + labelnote_->SetStyle(STYLE_TEXT_FONT, 30); + labelnote_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置标签的文本和其他属性 + labelnote_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + labelnote_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + SetLabelId(labelnote_, STR_TACK); + + /*初始化image*/ + // InitImageView(imageTake, 174, 120, 118, 120, "image", RECOED_IMAGE); + /*初始化按键*/ + InitButtonExt(buttongo, 0, 366, 466, 100, BUTTONGO, STR_KONW, 30); + buttongo->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); + buttongo->SetOnClickListener(static_cast( + TakephotosPresenter::GetInstance())); + + // 初始化图片数组以及动画 + creamimageInfos = CreateImageInfoArray(creambasePath.c_str(), 50); + InitImageAnimatorSource(creamAnimator, creamimageAnimatorInfo, + creamimageInfos, 50, 163, 103, 140, 140, + "imageAnimator", 100); + + creamView->Add(creamAnimator); + creamView->Add(labeltitle_); + creamView->Add(labelnote_); + creamView->Add(buttongo); + + // RootView::GetInstance()->Add(creamView); + container_->Add(creamView); + + creamView->SetDraggable(true); + creamView->SetTouchable(true); + + UIView::OnDragListener *draglistener = + static_cast(TakephotosPresenter::GetInstance()); + if (draglistener == nullptr) { + return; + } + creamView->SetOnDragListener(draglistener); + + creamView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowcreamView end"); +} +/*遥控拍照界面*/ +void TakephotosView::ShowTakeView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView start"); + takeView = new UIScrollView(); + if (takeView == nullptr) { + return; + } + takeView->SetPosition(0, 0); + takeView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + takeView->SetScrollBlankSize(20); + takeView->SetReboundSize(50); + takeView->SetDirection(1); + + /*初始化label*/ + InitLabelExt(labeltake_, 83, 50, 300, 35, "labletitle", STR_REMOTE_SHOOTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(labelclick_, 53, 278, 360, 70, "labelclick_", STR_TACKNUM, + DEFAULT_VECTOR_FONT_FILENAME, 30); + UpdateLabel(labelclick_, 0, STR_TACKNUM); // 初始化为0 + + /*初始化按键*/ + InitButtonExt(buttontake, 93, 330, 280, 90, BUTTONTAKE, STR_CLICK, 26); + buttontake->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 设置按键颜色 + buttontake->SetOnClickListener(static_cast( + TakephotosPresenter::GetInstance())); + + // 初始化图片数组以及动画 {修改为统一动画} + smileimageInfos = CreateImageInfoArray(smilebasePath.c_str(), 50); + InitImageAnimatorSource(smileAnimator, smileimageAnimatorInfo, + smileimageInfos, 50, 163, 140, 140, 140, + "imageAnimator", 100); + + takeView->Add(smileAnimator); + takeView->Add(labeltake_); + takeView->Add(labelclick_); + takeView->Add(buttontake); + + // RootView::GetInstance()->Add(takeView); + container_->Add(takeView); + + takeView->SetDraggable(true); + takeView->SetTouchable(true); + + UIView::OnDragListener *draglistener = + static_cast(TakephotosPresenter::GetInstance()); + if (draglistener == nullptr) { + return; + } + takeView->SetOnDragListener(draglistener); + + takeView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowTakeView end"); +} +/*控制显示界面*/ +void TakephotosView::SetPopupViewStatus(PopupPhoto view, bool status) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); + + if (view == PopupPhoto::CreamPopup) { + creamView->SetVisible(true); + takeView->SetVisible(false); + + creamAnimator->Start(); + smileAnimator->Stop(); + } else if (view == PopupPhoto::TakePopup) { + takeView->SetVisible(true); + creamView->SetVisible(false); + + smileAnimator->Start(); + creamAnimator->Stop(); + } +} + +void TakephotosView::OnStart() { + container_ = new UIScrollView(); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); + + ShowCreamView(); + ShowTakeView(); + PreLoad(); + + SetContainerView(container_); + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TakephotosView OnStart is ok"); +} + +UILabel *TakephotosView::GetClileLabel() { return labelclick_; } +void TakephotosView::Updatenum(int num) { + if (smileAnimator->GetState() == true && labelclick_ != nullptr) { + UpdateLabel(labelclick_, num, STR_TACKNUM); + labelclick_->Invalidate(); + } +} +void TakephotosView::OnSetUpView() { + View::OnSetUpView(); + Draw(); +} + +void TakephotosView::OnTearDownView() { + View::OnTearDownView(); + return; +} + +void TakephotosView::OnStop() { + View::OnStop(); + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->RemoveAll(); + return; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h index 9eeefd0a6..5221662ca 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h @@ -31,7 +31,8 @@ namespace OHOS TraingFitnessModel(const TraingFitnessModel &); TraingFitnessModel &operator=(const TraingFitnessModel &); virtual ~TraingFitnessModel(); - static const uint16_t TraingFitnessListMaxNum = 58; + static const uint16_t TraingFitnessListMaxNum = 57; + TraingFitnessItem TraingFitnesss[TraingFitnessListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL}; // std::map TraingFitnessIdToViewId; bool btConnectStatus{false}; -- 2.17.1