From 8d1f12b449212e4be9746b8f9b0ef2ee6d1262b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Fri, 14 Jun 2024 08:03:41 +0000 Subject: [PATCH] Merge #282 into sdk602patch0521 from refs/changes/282/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 主界面活动卡片增加 * refs/changes/282/head: (1 commits squashed) - 主界面活动卡片增加 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/282 --- .../wearable/fd230app/CMakeLists.txt | 1 + .../nativelauncher/include/UiConfig.h | 3 +- .../nativeui/goal/include/goalControlView.h | 27 ++++++ .../fd230app/nativeui/goal/include/goalview.h | 4 +- .../nativeui/goal/src/goalControlView.cpp | 84 +++++++++++++++++++ .../fd230app/nativeui/goal/src/goalmodel.cpp | 7 +- .../fd230app/nativeui/goal/src/goalview.cpp | 65 +++++++++++--- .../nativeui/main/include/MainViewSample.h | 8 ++ .../fd230app/nativeui/main/src/MainModel.cpp | 1 + .../nativeui/main/src/MainViewSample.cpp | 27 +++++- .../service/msg_center/CMakeLists.txt | 2 + .../msg_center/src/msg_center_customer.cpp | 14 +++- .../fd230/fs/user/res/step/step_b.bin | 3 + 13 files changed, 225 insertions(+), 21 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/step/step_b.bin diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index c0534909a..f17a04364 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -651,6 +651,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/Maingoalview.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalother.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalhint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalControlView.cpp #${CMAKE_CURRENT_SOURCE_DIR} /service/acc_service.c ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 0e3820e06..073804def 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -25,7 +25,8 @@ namespace OHOS WEATHER, TRAINING, ACTIVITY, - SETCARD, + SETCARD, + GOAL, MAX_CARD, } CardId; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h new file mode 100644 index 000000000..f112ca19d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h @@ -0,0 +1,27 @@ +#ifndef GOAL_CONTROL_VIEW_H +#define GOAL_CONTROL_VIEW_H +/*该视图主要放在主视图*/ + +#include "components/root_view.h" +#include "components/ui_card_page.h" +#include "wearable_log.h" +#include "goal/include/Maingoalview.h" +namespace OHOS +{ + class goalControlView : public UICardPage + { + public: + goalControlView(); + virtual ~goalControlView(); + bool InitView(void); + void PreLoad(void) override; + void UnLoad(void) override; + + private: + void ClearAll(void); + MaingoalrView *maingoalView{nullptr}; + UISwipeView::OnSwipeListener *goalOnSwipeListener{nullptr}; + bool viewiInitStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalview.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalview.h index 9d4ad693c..f5ed139d4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalview.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalview.h @@ -39,7 +39,7 @@ namespace OHOS void ClearAll(); bool GetInitViewState(void); void GoalViewrefresh(); - + private: UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight); @@ -53,7 +53,7 @@ namespace OHOS UILabelExt *goalTitle{nullptr}; // 目标 UILabelExt *goalstepLabel{nullptr}; // 目标 UILabelExt *nowstepLabel{nullptr}; // 完成 - + UIImageView* circleProgressimage{nullptr}; UIImageAnimatorView *PullUpAnimatorView{nullptr}; // 上拉动画 UIImageAnimatorView *stepAnimatorView{nullptr}; // 走路动画 const char **PullUpPathsArray{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp new file mode 100644 index 000000000..78d8b438c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp @@ -0,0 +1,84 @@ +#include "goal/include/goalControlView.h" +#include "goal/include/Maingoalpresenter.h" +namespace OHOS +{ + goalControlView::goalControlView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::goalControlView"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + } + + goalControlView::~goalControlView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::~goalControlView"); + ClearAll(); + } + + void goalControlView::ClearAll(void) + { + if (viewiInitStatus == true) + { + RemoveAll(); + if (maingoalView != nullptr) + { + if (goalOnSwipeListener != nullptr) + { + delete goalOnSwipeListener; + goalOnSwipeListener = nullptr; + } + + if (maingoalView != nullptr) + { + delete maingoalView; + maingoalView = nullptr; + } + } + } + } + + bool goalControlView::InitView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goalControlView::InitView"); + maingoalView = new MaingoalrView(); + if (maingoalView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new mainweatherView fail!"); + return false; + } + + + UISwipeView *goalSwipView = dynamic_cast(maingoalView->GetGoalPageView()); + if (goalSwipView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mainWeatherView->MainWeatherViewInit() == nullptr!!"); + return false; + } + + goalOnSwipeListener = static_cast(new GoalControlViewOnSwipeListener()); + if (goalOnSwipeListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnSwipeListener new fail"); + return false; + } + goalSwipView->SetOnSwipeListener(goalOnSwipeListener); + Add(goalSwipView); + + return true; + } + + void goalControlView::PreLoad(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goalControlView::PreLoad"); + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + + void goalControlView::UnLoad(void) + { + // Weather's usage scenes is complicated, so we do not release it's resources inner slice. + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index bef09fbb2..d7e8a460e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -28,7 +28,12 @@ namespace OHOS { int stepgoal= ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); int stepdata= OHOS::ActivityModel::GetInstance()->GetStepCounter(); - return stepdata/stepgoal *100; + int value= stepdata/stepgoal *100; + if(value>100) + { + value=100; + } + return value; } char stepgoalstr[20]; char* GoalModel::getstepGoal() diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp index efc442fdb..387ddd721 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp @@ -47,9 +47,10 @@ namespace OHOS { nowstepLabel->SetText(GoalModel::GetInstance().getstepnew()); goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal()); - circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue()); + RootView::GetInstance()->Invalidate(); + } void GoalView::ClearAll() @@ -86,6 +87,13 @@ namespace OHOS delete PullUpAnimatorView; PullUpAnimatorView = nullptr; } + if (circleProgressimage != nullptr) + { + + delete circleProgressimage; + circleProgressimage = nullptr; + } + FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES); FreeImagePathsArray(PullUpPathsArray, 20); @@ -177,32 +185,59 @@ namespace OHOS /*----------------------------------------------------------------------------- */ + // Add ImageView to App + if (circleProgressimage == nullptr) { + circleProgressimage = new UIImageView(); + } + circleProgressimage->SetPosition(28, 80); // widget's left position and top position + circleProgressimage->Resize(100, 100); // widget's width and height + circleProgressimage->SetViewId("image5");// Set style + + + char* image5imagesPath = "/user/res/step/step_b.bin"; + + circleProgressimage->SetSrc(image5imagesPath); + + // Add to rootView + + circleProgressimage->SetVisible(true); + if(circleProgressimage!=NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "circleProgressimage"); + } + + if (circleProgress1_ == nullptr) { - circleProgress1_ = new UICircleProgress(); + circleProgress1_ = new UICircleProgress(); } - circleProgress1_->SetPosition(0, 0); // widget's left position and top position + circleProgress1_->SetPosition(-1, 0); // widget's left position and top position circleProgress1_->Resize(466, 466); // widget's width and height circleProgress1_->SetViewId("circleProgress1");// Set style circleProgress1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - circleProgress1_->SetStyle(STYLE_BORDER_WIDTH, 10); // Set additional property // Set BackgroundStyle circleProgress1_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - circleProgress1_->SetBackgroundStyle(STYLE_LINE_WIDTH, 16); + circleProgress1_->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + circleProgress1_->SetBackgroundStyle(STYLE_LINE_HEIGHT, 200); + circleProgress1_->SetBackgroundStyle(STYLE_LINE_WIDTH, 21); + circleProgress1_->SetBackgroundStyle(STYLE_LINE_OPA, 0x00); + + // Set ForegroundStyle - circleProgress1_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195f6); - circleProgress1_->SetForegroundStyle(STYLE_BORDER_WIDTH, 80); - circleProgress1_->SetForegroundStyle(STYLE_BORDER_RADIUS, 16); - circleProgress1_->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff); + circleProgress1_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); + circleProgress1_->SetForegroundStyle(STYLE_BORDER_WIDTH, 200); + circleProgress1_->SetForegroundStyle(STYLE_BORDER_RADIUS, 200); + circleProgress1_->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); circleProgress1_->SetForegroundStyle(STYLE_LINE_HEIGHT, 35); circleProgress1_->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45ff5d); - circleProgress1_->SetForegroundStyle(STYLE_LINE_WIDTH, 16); - circleProgress1_->SetCenterPosition(224, 220); - circleProgress1_->SetRadius(195); + circleProgress1_->SetForegroundStyle(STYLE_LINE_WIDTH, 20); + circleProgress1_->SetCenterPosition(233, 229); + circleProgress1_->SetRadius(205); circleProgress1_->SetStartAngle(40); circleProgress1_->SetEndAngle(320); - circleProgress1_->SetValue(1); + circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue()); + circleProgress1_->SetBackgroundImagePosition(36, 26); /*----------------------------------------------------------------------------- */ goalPathsArray = CreateImagePathsArray(stepPaths, "bin", 20); @@ -259,12 +294,16 @@ namespace OHOS PullUpAnimatorView->Start(); } /* -------------------------------- 将组件添加到根视图 ------------------------------- */ + Add(circleProgressimage); + Add(circleProgress1_); + Add(goalstepLabel); Add(nowstepLabel); Add(PullUpAnimatorView); Add(goalTitle); Add(stepAnimatorView); + viewInitStatus = true; return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h index 85e765acb..f6a9dee65 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h @@ -36,6 +36,8 @@ #include "traing/training_card/include/Training_CardView.h" // #include "ApplistCardView.h" #include "weather/include/WeatherControlView.h" +#include "goal/include/goalControlView.h" + #include "message/include/MessageCardView.h" #include "set_card/include/SetMainView.h" namespace OHOS @@ -59,6 +61,8 @@ namespace OHOS UICardPage *InitMusicPlayerPage(void); UICardPage *InitBloodOxygenPage(void); UICardPage *InitWeatherPage(void); + UICardPage *InitGoalPage(void); + UICardPage *InitTrainingPage(void); UICardPage *InitApplistPage(void); UICardPage *InitSetMainPage(void); @@ -104,9 +108,13 @@ namespace OHOS CompassControlView *compassControlView{nullptr}; HeartRateView *heartRateView{nullptr}; BloodCardView *bloodView{nullptr}; + WeatherControlView *weatherControlView{nullptr}; + goalControlView *GoalControlView{nullptr}; + Training_CardView *traingView{nullptr}; SetMainView *setmainView{nullptr}; + // ApplistCardView *applistCardView{nullptr}; UIButton *changebut{nullptr}; UIImageView *disturbIcon{nullptr}; // 勿扰图标 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp index d0a781570..9d0e6f17e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp @@ -25,6 +25,7 @@ namespace OHOS {TRAINING, PNG_SET_CARD_TRAIN}, {ACTIVITY, PNG_SET_CARD_ACTIVITY}, {SETCARD, PNG_SET_CARD_ACTIVITY}, + {GOAL, PNG_SET_CARD_TRAIN}, }; /*自定义map?*/ const DialInfo dialInfoMap[] = { 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 1073acd65..cb289a8cf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -37,7 +37,8 @@ namespace OHOS {WEATHER, &MainViewSample::InitWeatherPage}, {TRAINING, &MainViewSample::InitTrainingPage}, {ACTIVITY, &MainViewSample::InitActivityPage}, - {SETCARD, &MainViewSample::InitSetMainPage}, + {SETCARD, &MainViewSample::InitSetMainPage}, + {GOAL, &MainViewSample::InitGoalPage}, }; MainViewSample::MainViewSample() { @@ -126,11 +127,18 @@ namespace OHOS delete bloodView; bloodView = nullptr; } + if (traingView != nullptr) { traingView->RemoveAll(); - delete traingView; + delete traingView; traingView = nullptr; + } + if (GoalControlView != nullptr) + { + GoalControlView->RemoveAll(); + delete GoalControlView; + GoalControlView = nullptr; } // if (applistCardView != nullptr) // { @@ -426,6 +434,7 @@ namespace OHOS } return traingView; } + // 主界面天气卡片 UICardPage *MainViewSample::InitWeatherPage(void) { @@ -436,7 +445,19 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainweatherView new fail"); return nullptr; } - return weatherControlView; + return weatherControlView; + } + + UICardPage *MainViewSample::InitGoalPage(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitWeatherPage"); + GoalControlView = new goalControlView(); + if (GoalControlView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainweatherView new fail"); + return nullptr; + } + return GoalControlView; } // 主界面心率卡片 UICardPage *MainViewSample::InitHeartRatePage(void) diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index cdb46e334..a58b970bd 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -24,6 +24,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativelauncher/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/goal/include ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits @@ -128,6 +129,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/player/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativelauncher/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/goal/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps ${CMAKE_CURRENT_SOURCE_DIR}/../../CustomUIComponentTool/uicomponents/ diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 68252f18e..bad1b0da3 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -47,6 +47,8 @@ #include "producttest/include/testcat1.h" #endif #include + +#include "goalview.h" //#include "Systemupgrade.h" namespace OHOS { @@ -278,8 +280,17 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) calories_history_save(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据"); distances_history_save(); +} - +void MsgCenterNotifystepProc(const Topic topic, Request* req) +{ + unused(req); + if(OHOS::GoalView::GetInstance()) + { + OHOS::GoalView::GetInstance()->GoalViewrefresh(); + } + // The alarm notification is not displayed if the incoming call notification is already being processed + // cywee_save_data(); } @@ -1029,6 +1040,7 @@ void MsgCenterNotifybleTransmit(const Topic topic, Request* req) static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc}, {TOPIC_EVENT_ON_TIME, MsgCenterNotifyONtimeProc},//增加整点保存数据 + {TOPIC_EVENT_STEPDATA_UPDATE, MsgCenterNotifystepProc}, {TOPIC_EVENT_NEXTDAY_UPDATE, MsgCenterNotifyNextDayProc}, {TOPIC_EVENT_HFP_INCOMMING, MsgCenterNotifyHfpIncomingProc}, {TOPIC_EVENT_HFP_PHONE_ACTIVE, MsgCenterNotifyHfpPhoneProc}, diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/step/step_b.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/step/step_b.bin new file mode 100644 index 000000000..06b11e4bb --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/step/step_b.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa5fbb908c94f811a58664a8d03f44091e4098e6de2b0609101af23c74269c84 +size 98280 -- 2.17.1