From: Caisking <3449750381@qq.com> Date: Sat, 25 Nov 2023 09:47:48 +0000 (+0800) Subject: 表盘切换 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e26bca59db50d804501d1c49e88ae2ba5698441a;p=mirrors%2FFD230.git 表盘切换 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 728cc8418..a8d77cd19 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -92,6 +92,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/applist/src/ApplistPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/applist/src/ApplistView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/src/MainClockView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/src/DialUserView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodOxygenView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodBandoffView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index de1c566c0..8639114de 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -109,6 +109,7 @@ typedef enum : uint16_t VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 VIEW_BRIGHTNESS_CONTROL, // 亮度调节 VIEW_SCREEN_DURATION, // 亮屏时长 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index f33932db3..870836ff0 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -255,7 +255,8 @@ namespace OHOS // 血氧 static constexpr const char *PNG_BLOOD_ERROR_IMAGE = APP_RES_PATH "/Blood/Error.bin"; static constexpr const char *PNG_BLOOD_NOTE_IMAGE = APP_RES_PATH "/Blood/boutton.bin"; - + //表盘切换 + static constexpr const char *PNG_DIAL_USER_IMAGE = APP_RES_PATH "/Dial/Diallogo.bin"; static constexpr const char *PNG_PHONE_FINGER_IMAGE = APP_RES_PATH "/Save_Ele/finger.bin"; static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH "/VOICE_ASSISTANT_01.bin"; static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH "/VOICE_ASSISTANT_02.bin"; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorPresenter.h new file mode 100644 index 000000000..c79028f9c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorPresenter.h @@ -0,0 +1,33 @@ +#ifndef _BloodError_PRESENTER_H +#define _BloodError_PRESENTER_H + +#include "Presenter.h" +#include "BloodErrorView.h" + +namespace OHOS +{ + class BloodErrorView; + + class BloodErrorPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BloodErrorPresenter(); + virtual ~BloodErrorPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BloodErrorPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorView.h new file mode 100644 index 000000000..81406218c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodErrorView.h @@ -0,0 +1,56 @@ +#ifndef _BloodError_VIEW_H +#define _BloodError_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "BloodErrorPresenter.h" +namespace OHOS +{ +#define LABELBUTTONRE "labelButton1" // 重新检测 +#define LABELBUTTONSTOP "labelButton2" // 停止检测 + + class BloodErrorPresenter; + class BloodErrorView : public View + { + + public: + BloodErrorView(); + virtual ~BloodErrorView(); + static BloodErrorView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodErrorView(BloodErrorView &&) = delete; + BloodErrorView &operator=(BloodErrorView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image3_ = nullptr; + UILabelButtonExt *labelButton1_ = nullptr; + UILabelButtonExt *labelButton2_ = nullptr; + }; +} // namespace OHOS +#endif // BloodError_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNotePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNotePresenter.h new file mode 100644 index 000000000..1d62525f5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNotePresenter.h @@ -0,0 +1,33 @@ +#ifndef _BloodNote_PRESENTER_H +#define _BloodNote_PRESENTER_H + +#include "Presenter.h" +#include "BloodNoteView.h" + +namespace OHOS +{ + class BloodNoteView; + + class BloodNotePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + BloodNotePresenter(); + virtual ~BloodNotePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static BloodNotePresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNoteView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNoteView.h new file mode 100644 index 000000000..be20126b7 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodNoteView.h @@ -0,0 +1,52 @@ +#ifndef _BloodNote_VIEW_H +#define _BloodNote_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "BloodNotePresenter.h" +namespace OHOS +{ +#define NOTEBUTTON "Button1" // 退出按键 + + + class BloodNotePresenter; + class BloodNoteView : public View + { + + public: + BloodNoteView(); + virtual ~BloodNoteView(); + static BloodNoteView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodNoteView(BloodNoteView &&) = delete; + BloodNoteView &operator=(BloodNoteView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label4_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // BloodNote_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp new file mode 100644 index 000000000..744a59d68 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "/blood/include/BloodErrorPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static BloodErrorPresenter *g_pBloodErrorPresenter = nullptr; + + BloodErrorPresenter::BloodErrorPresenter() + { + + g_pBloodErrorPresenter = this; + } + + BloodErrorPresenter::~BloodErrorPresenter() + { + + g_pBloodErrorPresenter = nullptr; + } + + BloodErrorPresenter *BloodErrorPresenter::GetInstance() + { + + return g_pBloodErrorPresenter; + } + + void BloodErrorPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void BloodErrorPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BloodErrorPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BloodErrorPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool BloodErrorPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool BloodErrorPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), LABELBUTTONRE) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODCHECK); + } + if (strcmp(view.GetViewId(), LABELBUTTONSTOP) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + } + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorView.cpp new file mode 100644 index 000000000..4bfba9226 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorView.cpp @@ -0,0 +1,343 @@ + + +#include "/blood/include/BloodErrorView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static BloodErrorView *g_pBloodErrorView{nullptr}; + + BloodErrorView::BloodErrorView() + { + + g_pBloodErrorView = this; + } + + BloodErrorView::~BloodErrorView() + { + DeInit(); + g_pBloodErrorView = nullptr; + } + + BloodErrorView *BloodErrorView::GetInstance() + { + + return g_pBloodErrorView; + } + void BloodErrorView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + 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 + + // Add the CallBack about events + UIView::OnDragListener *scrollView1Drag = static_cast(BloodErrorPresenter::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(143, 52); // widget's left position and top position + label1_->Resize(180, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 111); // widget's left position and top position + image1_->Resize(80, 80); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Blood/Error.bin"; +#else + const char *image1imagesPath = PNG_BLOOD_ERROR_IMAGE; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(58, 208); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("请确认已带上手表,并保持"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 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); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(43, 243); // 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); + + // Set additional property + label3_->SetText("静止,准备好后点击下方按钮"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(148, 278); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label4_->SetText("进行重新检测"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 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 LabelButtonExt to App + if (labelButton1_ == nullptr) + { + labelButton1_ = new UILabelButtonExt(); + } + labelButton1_->SetPosition(118, 434); // widget's left position and top position + labelButton1_->Resize(230, 80); // widget's width and height + labelButton1_->SetViewId(LABELBUTTONSTOP); // Set style + labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + + // Set additional property + labelButton1_->SetText("停止检测"); + labelButton1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton1Click = static_cast(BloodErrorPresenter::GetInstance()); + labelButton1_->SetOnClickListener(labelButton1Click); + // Add to scrollView1 + scrollView1_->Add(labelButton1_); + labelButton1_->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton2_ == nullptr) + { + labelButton2_ = new UILabelButtonExt(); + } + labelButton2_->SetPosition(110, 334); // widget's left position and top position + labelButton2_->Resize(230, 80); // widget's width and height + labelButton2_->SetViewId(LABELBUTTONRE); // Set style + labelButton2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff8a36); + + // Set additional property + labelButton2_->SetText("重新检测"); + labelButton2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + labelButton2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton2Click = static_cast(BloodErrorPresenter::GetInstance()); + labelButton2_->SetOnClickListener(labelButton2Click); + // Add to scrollView1 + scrollView1_->Add(labelButton2_); + labelButton2_->SetVisible(true); + // Add ImageView to App + if (image2_ == nullptr) + { + image2_ = new UIImageView(); + } + image2_->SetPosition(183, 550); // 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 (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(183, -100); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property + + // Add to scrollView1 + scrollView1_->Add(image3_); + image3_->SetVisible(true); + } + + void BloodErrorView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (labelButton1_ != nullptr) + { + delete labelButton1_; + labelButton1_ = nullptr; + } + if (labelButton2_ != nullptr) + { + delete labelButton2_; + labelButton2_ = nullptr; + } + } + + UIView *BloodErrorView::GetView() + { + Init(); + return container_; + } + + void BloodErrorView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(BloodErrorPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void BloodErrorView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void BloodErrorView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void BloodErrorView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp new file mode 100644 index 000000000..870bfc79e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp @@ -0,0 +1,76 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "/blood/include/BloodNotePresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static BloodNotePresenter *g_pBloodNotePresenter = nullptr; + + BloodNotePresenter::BloodNotePresenter() + { + + g_pBloodNotePresenter = this; + } + + BloodNotePresenter::~BloodNotePresenter() + { + + g_pBloodNotePresenter = nullptr; + } + + BloodNotePresenter *BloodNotePresenter::GetInstance() + { + + return g_pBloodNotePresenter; + } + + void BloodNotePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void BloodNotePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void BloodNotePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void BloodNotePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool BloodNotePresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + // { + // printf("draglistene is ok!\n"); + // NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + // } + UNUSED(view); + return true; + } + + bool BloodNotePresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), NOTEBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + } + + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNoteView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNoteView.cpp new file mode 100644 index 000000000..4aa2db730 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNoteView.cpp @@ -0,0 +1,268 @@ + + +#include "/blood/include/BloodNoteView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static BloodNoteView *g_pBloodNoteView{nullptr}; + + BloodNoteView::BloodNoteView() + { + + g_pBloodNoteView = this; + } + + BloodNoteView::~BloodNoteView() + { + DeInit(); + g_pBloodNoteView = nullptr; + } + + BloodNoteView *BloodNoteView::GetInstance() + { + + return g_pBloodNoteView; + } + void BloodNoteView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // 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 rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 121); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Blood/error.bin"; +#else + const char *image1imagesPath = PNG_BLOOD_ERROR_IMAGE; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(341, 234); // 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); + + // Set additional property + label3_->SetText("95%"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(67, 235); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("当前血氧含量已低于\n"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(128, 276); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label4_->SetText("请注意身体健康"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label4_); + label4_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(0, 366); // widget's left position and top position + button1_->Resize(466, 100); // widget's width and height + button1_->SetViewId(NOTEBUTTON); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Blood/boutton.bin"; +#else + const char *button1defaultImgSrc = PNG_BLOOD_NOTE_IMAGE; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(BloodNotePresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + } + + void BloodNoteView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *BloodNoteView::GetView() + { + Init(); + return container_; + } + + void BloodNoteView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(BloodNotePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void BloodNoteView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void BloodNoteView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void BloodNoteView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 5ca62c2d2..24ef5b752 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -22,6 +22,7 @@ #include "ActivityWeekView.h" #include "CompassControlView.h" #include "MainClockView.h" +#include "DialUserView.h" #include "PlayersView.h" #include "MainPresenterSample.h" #include "HeartRateView.h" @@ -68,6 +69,7 @@ private: UICardPage *messageView{nullptr}; UILabel *messageLable{nullptr}; MainClockView *mainClockView{nullptr}; + DialUserView *dialUserView{nullptr}; ActivityWeekView *activityWeekView{nullptr}; PlayersView *playersView{nullptr}; CompassControlView *compassControlView{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp index adfa835a4..0d0803db1 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp @@ -140,7 +140,7 @@ bool MainSwipeViewGroup::OnDragEndEvent(const DragEvent& event) } else if (swipeDirect == VERTICAL_SWIPE) { vertical->OnDragEndEvent(event); if (vertical->GetCurrentPage() == VER_MAIN_CLOCK_VIEW) { - vertical->GetViewByIndex(pullIndex)->ClearBackgroundBlur(); + vertical->GetViewByIndex(pullIndex)->ClearBackgroundBlur(); RootView::GetInstance()->Invalidate(); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEndEvent, index: %d", vertical->GetCurrentPage()); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 4c03c18b0..212b53a50 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -245,12 +245,25 @@ void MainViewSample::OnStop() UICardPage *MainViewSample::InitWatchFacePage(void) { + #if 0 + dialUserView = new DialUserView(); + //dialUserView->PreLoad(); + if ( dialUserView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialUserView new fail"); + return nullptr; + } + printf("creat dial succes!!\n"); + return dialUserView; + #endif + + #if 1 mainClockView = new MainClockView(); if (mainClockView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); return nullptr; } return mainClockView; + #endif } UICardPage *MainViewSample::InitHeartRatePage(void) diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a index 6145db3d2..f7b7b4756 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_api.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a index f7a7bae10..735273d1d 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_core.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a index dddf258ca..08f396b2b 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_drv.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a index ea52cf6a9..ee2825064 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a index cdad8c421..71ac4cd90 100644 Binary files a/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a and b/code/sdk/interim_binary/brandy/libs/audio/evb4_standard/liteos/libaudio_vendor.a differ diff --git a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a index 2e5418f9c..cdfdabde5 100644 Binary files a/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a and b/code/sdk/interim_binary/brandy/libs/bt/evb_standard/liteos/br/libbt_host_brandy_sample.a differ diff --git a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a index 897f63758..eaf693b2a 100644 Binary files a/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a and b/code/sdk/interim_binary/brandy/libs/gpu/evb_standard/libgpu.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a index 013e4495e..3334de6aa 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_captuer.a differ diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a index d61991057..340c06d3f 100644 Binary files a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a and b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_player.a differ