From: 罗正yun <1732036298@qq.com> Date: Tue, 23 Jan 2024 11:15:22 +0000 (+0800) Subject: 辅助功能添加 X-Git-Tag: release_V1.2.70_20241020_135402~1334^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=af314749eb88a12b2387ea3f931136b2b67935c6;p=mirrors%2FFD230.git 辅助功能添加 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index c41724743..048429a44 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -221,6 +221,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetView.cpp + #声音与震动 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SystemVolumePresenter.cpp @@ -230,6 +231,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/MediaVolumePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/MediaVolumeView.cpp + #显示与亮度 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -238,7 +240,17 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationView.cpp + #辅助功能 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/QuickAccessView.cpp + #指南针 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassModel.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index cc5c74a01..ae9a2b643 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -55,6 +55,10 @@ typedef enum : uint16_t VIEW_DISPLAY_BRIGHTNESS, // 屏幕与亮度 VIEW_BRIGHTNESS_CONTROL, // 亮度调节 VIEW_SCREEN_DURATION, // 亮屏时长 + VIEW_SECONDARY_FUNCTION, // 辅助功能 + VIEW_QUICK_ACCESS, // 快速访问 + VIEW_FAST_TRAINING, // 快速训练 + VIEW_FAST_TRAINING_ATTENTION,// 快速训练项目选择超出提示 /* ---------------------------------- 测试界面 ---------------------------------- */ VIEW_MESSAGE, // 信息通知 /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index beb6b22dd..f83153d23 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -60,8 +60,14 @@ namespace OHOS void InitMessageSlice(void); /* -------------------------------------------------------------------------- */ void InitUIDisplayBrightnessSlice(void); - void InitBrightnessControlSlice(void); - void InitScreenDurationSlice(void); + void InitBrightnessControlSlice(void); + void InitScreenDurationSlice(void); + /* -------------------------------------------------------------------------- */ + void InitSecondaryFunction(void); + void InitQuickAccessSlice(void); + void InitFastTrainingSlice(void); + void InitFastTrainingAttentionSlice(void); + private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index 27aa05f9f..f261847a7 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -207,19 +207,20 @@ namespace OHOS static constexpr const char *PNG_Message_Wechat = APP_RES_PATH "/message/WeChat-icon.bin"; // 微信消息 static constexpr const char *PNG_Message_QQ = APP_RES_PATH "/message/QQ-icon.bin"; // QQ消息 /* ---------------------------------- 通用图片 ---------------------------------- */ - static constexpr const char *PNG_CHECKBOX_OFF_IMAGE = APP_RES_PATH "/CHECKBOX_OFF.bin"; // checkbox未选中图片 - static constexpr const char *PNG_CHECKBOX_ON_IMAGE = APP_RES_PATH "/CHECKBOX_ON.bin"; // checkbox选中图片 - static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 - static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 - static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 - static constexpr const char *PNG_BRIGHTNESS_CONTROL_VECTOR = APP_RES_PATH "/BringhtnessContuolVector.bin"; // 调节亮度图片 - static constexpr const char *PNG_SYSTEM_CHECK_ON_IMAGE = APP_RES_PATH "/SYSTEM_CheckOn.bin"; // 勾 - static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin"; // 叉 - static constexpr const char *PNG_TOGGLEBUTTON_OFF_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_OFF.bin"; // togglebuttton未选中图片 - static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin"; // togglebuttton选中图片 - static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = APP_RES_PATH "/SYSTEM_VOLUME.bin"; // 系统音量 - static constexpr const char *PNG_CALL_VOLUME_IMAGE = APP_RES_PATH "/CALL_VOLUME.bin"; // 通话音量 - static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = APP_RES_PATH "/MEDIA_VOLUME.bin"; // 媒体音量 + static constexpr const char *PNG_CHECKBOX_OFF_IMAGE = APP_RES_PATH "/CHECKBOX_OFF.bin"; // checkbox未选中图片 + static constexpr const char *PNG_CHECKBOX_ON_IMAGE = APP_RES_PATH "/CHECKBOX_ON.bin"; // checkbox选中图片 + static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 + static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 + static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 + static constexpr const char *PNG_BRIGHTNESS_CONTROL_VECTOR = APP_RES_PATH "/BringhtnessContuolVector.bin"; // 调节亮度图片 + static constexpr const char *PNG_SYSTEM_CHECK_ON_IMAGE = APP_RES_PATH "/SYSTEM_CheckOn.bin"; // 勾 + static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin"; // 叉 + static constexpr const char *PNG_TOGGLEBUTTON_OFF_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_OFF.bin"; // togglebuttton未选中图片 + static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin"; // togglebuttton选中图片 + static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = APP_RES_PATH "/SYSTEM_VOLUME.bin"; // 系统音量 + static constexpr const char *PNG_CALL_VOLUME_IMAGE = APP_RES_PATH "/CALL_VOLUME.bin"; // 通话音量 + static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = APP_RES_PATH "/MEDIA_VOLUME.bin"; // 媒体音量 + static constexpr const char *PNG_FAST_TRAINING_ATTENTION_IMAGE = APP_RES_PATH "/FastTrainingAttentionVector.bin"; // 快速训练选中操过三个后出现 static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin"; static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin"; /* -------------------------------- 已删除的不必要图片 ------------------------------- */ diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 6c4662908..bda871f26 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -94,6 +94,15 @@ #include "message/include/MessageModel.h" #include "message/include/MessagePresenter.h" +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" +#include "secondaryfunction/include/SecondaryFunctionView.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "secondaryfunction/include/FastTrainingView.h" +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" +#include "secondaryfunction/include/FastTrainingAttentionView.h" +#include "secondaryfunction/include/QuickAccessPresenter.h" +#include "secondaryfunction/include/QuickAccessView.h" + #include "BluetoothHeadsetEvent.h" #include "graphic_hardware_config.h" #include "graphic_service.h" @@ -142,6 +151,11 @@ namespace OHOS {VIEW_BRIGHTNESS_CONTROL, &NativeLauncher::InitBrightnessControlSlice}, // 调节亮度的实例化地址 {VIEW_SCREEN_DURATION, &NativeLauncher::InitScreenDurationSlice}, // 亮屏时长实例化地址 + {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, + {VIEW_QUICK_ACCESS,&NativeLauncher::InitQuickAccessSlice}, //快速访问实例化地址 + {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, + {VIEW_FAST_TRAINING_ATTENTION, &NativeLauncher::InitFastTrainingAttentionSlice}, + {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice}, #if 0 @@ -562,4 +576,45 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_SCREEN_DURATION, ScreenDuration); } + + void NativeLauncher::InitSecondaryFunction(void) // 辅助功能 + { + SliceProxy *secondaryfunction = new AbilitySliceProxy; + if (secondaryfunction == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SECONDARY_FUNCTION, secondaryfunction); + } + + void NativeLauncher::InitQuickAccessSlice(void) // 快速访问 + { + SliceProxy *QuickAccess = new AbilitySliceProxy; + if (QuickAccess == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_QUICK_ACCESS, QuickAccess); + } + + void NativeLauncher::InitFastTrainingSlice(void) + { + SliceProxy *fasttraining = new AbilitySliceProxy; + if (fasttraining == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_FAST_TRAINING, fasttraining); + } + + void NativeLauncher::InitFastTrainingAttentionSlice(void) + { + SliceProxy *fasttrainingattention = new AbilitySliceProxy; + if (fasttrainingattention == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_FAST_TRAINING_ATTENTION, fasttrainingattention); + } + } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h new file mode 100644 index 000000000..27a42380f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionPresenter.h @@ -0,0 +1,32 @@ +#ifndef FAST_TRAINING_ATTENTION_PRESENTER_H +#define FAST_TRAINING_ATTENTION_PRESENTER_H + +#include "Presenter.h" + +#include "FastTrainingAttentionView.h" + +namespace OHOS +{ + class FastTrainingAttentionView; + + class FastTrainingAttentionPresenter : public Presenter, + public UIView::OnClickListener + { + public: + FastTrainingAttentionPresenter(); + virtual ~FastTrainingAttentionPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static FastTrainingAttentionPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + }; +} // namespace OHOS + +#endif // FastTrainingAttention_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h new file mode 100644 index 000000000..df1f7c28d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingAttentionView.h @@ -0,0 +1,42 @@ +#ifndef FAST_TRAINING_ATTENTION_VIEW_H +#define FAST_TRAINING_ATTENTION_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button.h" +namespace OHOS +{ + static const char *LABELBUTTON = "FastTrainingAttentionLabelButton"; + class FastTrainingAttentionPresenter; + class FastTrainingAttentionView : public View + { + + public: + FastTrainingAttentionView(); + virtual ~FastTrainingAttentionView(); + static FastTrainingAttentionView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + + void InitView(void); + void DeInitView(void); + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label15_ = nullptr; + UIImageView *image7_ = nullptr; + UILabel *label16_ = nullptr; + UILabelButton *FastTrainingAttentionLabelButton = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h new file mode 100644 index 000000000..bb88c0f83 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingPresenter.h @@ -0,0 +1,53 @@ +#ifndef FAST_TRAINING_PRESENTER_H +#define FAST_TRAINING_PRESENTER_H + +#include "Presenter.h" +#include "FastTrainingView.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + class FastTrainingView; + + class FastTrainingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UICheckBox::OnChangeListener + { + public: + FastTrainingPresenter(); + virtual ~FastTrainingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static FastTrainingPresenter *GetInstance(); + void setCheckbox(UICheckBox *checkBox1, UICheckBox *checkBox2, UICheckBox *checkBox3, UICheckBox *checkBox4, UICheckBox *checkBox5, UICheckBox *checkBox6) + { + m_checkBox1 = checkBox1; + m_checkBox2 = checkBox2; + m_checkBox3 = checkBox3; + m_checkBox4 = checkBox4; + m_checkBox5 = checkBox5; + m_checkBox6 = checkBox6; + } + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; + + private: + static int CheckBoxSelectCount; + UICheckBox *m_checkBox1 = nullptr; + UICheckBox *m_checkBox2 = nullptr; + UICheckBox *m_checkBox3 = nullptr; + UICheckBox *m_checkBox4 = nullptr; + UICheckBox *m_checkBox5 = nullptr; + UICheckBox *m_checkBox6 = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h new file mode 100644 index 000000000..193e980ca --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/FastTrainingView.h @@ -0,0 +1,78 @@ +#ifndef FAST_TRAINING_VIEW_H +#define FAST_TRAINING_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_checkbox.h" + +namespace OHOS +{ + static const char *CHECKBOX1 = "checkBox1"; + static const char *CHECKBOX2 = "checkBox2"; + static const char *CHECKBOX3 = "checkBox3"; + static const char *CHECKBOX4 = "checkBox4"; + static const char *CHECKBOX5 = "checkBox5"; + static const char *CHECKBOX6 = "checkBox6"; + class FastTrainingPresenter; + class FastTrainingView : public View + { + + public: + FastTrainingView(); + virtual ~FastTrainingView(); + static FastTrainingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + void InitImageLabelCheckbox(UIImageView *image, int image_x, int image_y, int image_w, int image_h, + UILabel *label, int label_x, int label_y, const char *labelText, + UICheckBox *checkbox, int check_x, int check_y, int check_w, int check_h, const char *checkboxID, + UICheckBox::OnChangeListener *ChangeListener, UIScrollView *scrollView); + + private: + UIView::OnDragListener *draglistener{nullptr}; + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView = nullptr; + UIImageView *image5_ = nullptr; + UIImageView *image6_ = nullptr; + UIImageView *image1 = nullptr; + UIImageView *image2 = nullptr; + UIImageView *image3 = nullptr; + UIImageView *image4 = nullptr; + UIImageView *image5 = nullptr; + UIImageView *image6 = nullptr; + UILabel *label = nullptr; + UILabel *label1 = nullptr; + UILabel *label2 = nullptr; + UILabel *label3 = nullptr; + UILabel *label4 = nullptr; + UILabel *label5 = nullptr; + UILabel *label6 = nullptr; + UICheckBox *checkBox1 = nullptr; + UICheckBox *checkBox2 = nullptr; + UICheckBox *checkBox3 = nullptr; + UICheckBox *checkBox4 = nullptr; + UICheckBox *checkBox5 = nullptr; + UICheckBox *checkBox6 = nullptr; + UICheckBox::OnChangeListener *ChangeListener1 = nullptr; + UICheckBox::OnChangeListener *ChangeListener2 = nullptr; + UICheckBox::OnChangeListener *ChangeListener3 = nullptr; + UICheckBox::OnChangeListener *ChangeListener4 = nullptr; + UICheckBox::OnChangeListener *ChangeListener5 = nullptr; + UICheckBox::OnChangeListener *ChangeListener6 = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessPresenter.h new file mode 100644 index 000000000..100e17357 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessPresenter.h @@ -0,0 +1,39 @@ +#ifndef QUICK_ACCESS_PRESENTER_H +#define QUICK_ACCESS_PRESENTER_H + +#include "Presenter.h" + +#include "QuickAccessView.h" + +namespace OHOS +{ + class QuickAccessView; + + class QuickAccessPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + QuickAccessPresenter(); + virtual ~QuickAccessPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static QuickAccessPresenter *GetInstance(); + + private: + //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} //namespace OHOS + + + + + + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessView.h new file mode 100644 index 000000000..4a9dc391c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/QuickAccessView.h @@ -0,0 +1,51 @@ +#ifndef QUICK_ACCESS_VIEW_H +#define QUICK_ACCESS_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_checkbox.h" +namespace OHOS +{ + static const char *HEART_RATE_DETECTION = "HeartRateDetectionCheckBox"; //心率检测 + static const char *BLOOD_OXYGEN_MONITOR = "BloodOxygenMonitoringCheckBox"; //血氧检测 + + class QuickAccessPresenter; + class QuickAccessView : public View + { + + public: + QuickAccessView(); + virtual ~QuickAccessView(); + static QuickAccessView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *QuickAccessScrollView = nullptr; + UIImageView *image1 = nullptr; + UILabel *QuickAccessLabel = nullptr; + UIImageView *image2 = nullptr; + UILabel *label = nullptr; + UIImageView *HeartRateDetectionImage = nullptr; + UICheckBox *HeartRateDetectionCheckBox = nullptr; + UILabel *HeartRateDetectionLabel = nullptr; + UIImageView *BloodOxygenMonitoringImage = nullptr; + UICheckBox *BloodOxygenMonitoringCheckBox = nullptr; + UILabel *BloodOxygenMonitoringLabel = nullptr; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h new file mode 100644 index 000000000..9e110bf19 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h @@ -0,0 +1,33 @@ +#ifndef SECONDARY_FUNCTION_PRESENTER_H +#define SECONDARY_FUNCTION_PRESENTER_H + +#include "Presenter.h" + +#include "SecondaryFunctionView.h" + +namespace OHOS +{ + class SecondaryFunctionView; + + class SecondaryFunctionPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SecondaryFunctionPresenter(); + virtual ~SecondaryFunctionPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SecondaryFunctionPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h new file mode 100644 index 000000000..5fe1c76b1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/include/SecondaryFunctionView.h @@ -0,0 +1,44 @@ +#ifndef SECONDARY_FUNCTION_VIEW_H +#define SECONDARY_FUNCTION_VIEW_H +/*辅助功能*/ +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char * SECONDARY_FUNCTION_BUTTON1ID = "SECONDARY_FUNCTION_BUTTON1"; + static const char * SECONDARY_FUNCTION_BUTTON2ID = "SECONDARY_FUNCTION_BUTTON2"; + class SecondaryFunctionPresenter; + class SecondaryFunctionView : public View + { + + public: + SecondaryFunctionView(); + virtual ~SecondaryFunctionView(); + static SecondaryFunctionView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + + private: + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIButton *SECONDARY_FUNCTION_BUTTON1 = nullptr; + UIImageView *image3_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *SECONDARY_FUNCTION_BUTTON2 = nullptr; + UIImageView *image4_ = nullptr; + UILabel *label4_ = nullptr; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp new file mode 100644 index 000000000..744b85ac3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp @@ -0,0 +1,63 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static FastTrainingAttentionPresenter *g_pFastTrainingAttentionPresenter = nullptr; + + FastTrainingAttentionPresenter::FastTrainingAttentionPresenter() + { + + g_pFastTrainingAttentionPresenter = this; + } + + FastTrainingAttentionPresenter::~FastTrainingAttentionPresenter() + { + + g_pFastTrainingAttentionPresenter = nullptr; + } + + FastTrainingAttentionPresenter *FastTrainingAttentionPresenter::GetInstance() + { + + return g_pFastTrainingAttentionPresenter; + } + + void FastTrainingAttentionPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void FastTrainingAttentionPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void FastTrainingAttentionPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void FastTrainingAttentionPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool FastTrainingAttentionPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), LABELBUTTON) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp new file mode 100644 index 000000000..b636311fc --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp @@ -0,0 +1,193 @@ +#include "secondaryfunction/include/FastTrainingAttentionView.h" +#include "secondaryfunction/include/FastTrainingAttentionPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static FastTrainingAttentionView *g_pFastTrainingAttentionView{nullptr}; + + FastTrainingAttentionView::FastTrainingAttentionView() + { + + g_pFastTrainingAttentionView = this; + } + + FastTrainingAttentionView::~FastTrainingAttentionView() + { + DeInitView(); + g_pFastTrainingAttentionView = nullptr; + } + + FastTrainingAttentionView *FastTrainingAttentionView::GetInstance() + { + + return g_pFastTrainingAttentionView; + } + + void FastTrainingAttentionView::InitView() + { + 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); + scrollView1_->Resize(466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label15_ == nullptr) + { + label15_ = new UILabel(); + } + label15_->SetPosition(203, 52); + label15_->Resize(200, 60); + label15_->SetStyle(STYLE_TEXT_FONT, 30); + label15_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label15_->SetText("注意"); + label15_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label15_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label15_->SetRollSpeed(0); + label15_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label15_); + label15_->SetVisible(true); + + // Add ImageView to App + if (image7_ == nullptr) + { + image7_ = new UIImageView(); + } + image7_->SetPosition(193, 121); + image7_->Resize(80, 80); + image7_->SetSrc(PNG_FAST_TRAINING_ATTENTION_IMAGE); + + // Add to scrollView1 + scrollView1_->Add(image7_); + image7_->SetVisible(true); + + // Add Label to App + if (label16_ == nullptr) + { + label16_ = new UILabel(); + } + label16_->SetPosition(128, 228); + label16_->Resize(200, 60); + label16_->SetStyle(STYLE_TEXT_FONT, 30); + label16_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label16_->SetText("最多只能选三个"); + label16_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label16_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label16_->SetRollSpeed(0); + label16_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label16_); + label16_->SetVisible(true); + + // Add LabelButtonExt to App + if (FastTrainingAttentionLabelButton == nullptr) + { + FastTrainingAttentionLabelButton = new UILabelButton(); + } + FastTrainingAttentionLabelButton->SetPosition(0, 366); + FastTrainingAttentionLabelButton->Resize(466, 100); + FastTrainingAttentionLabelButton->SetViewId(LABELBUTTON); + char *labelButton1triggeredImgSrc = nullptr; + FastTrainingAttentionLabelButton->SetImageSrc("/user/res/NEW_device.bin", nullptr); + FastTrainingAttentionLabelButton->SetText("知道了"); + FastTrainingAttentionLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + FastTrainingAttentionLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); + FastTrainingAttentionLabelButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *labelButton1Click = static_cast(FastTrainingAttentionPresenter::GetInstance()); + FastTrainingAttentionLabelButton->SetOnClickListener(labelButton1Click); + // Add to scrollView1 + scrollView1_->Add(FastTrainingAttentionLabelButton); + FastTrainingAttentionLabelButton->SetVisible(true); + } + + void FastTrainingAttentionView::DeInitView() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label15_ != nullptr) + { + delete label15_; + label15_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (label16_ != nullptr) + { + delete label16_; + label16_ = nullptr; + } + if (FastTrainingAttentionLabelButton != nullptr) + { + delete FastTrainingAttentionLabelButton; + FastTrainingAttentionLabelButton = nullptr; + } + delete container_; + container_ = nullptr; + } + + void FastTrainingAttentionView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void FastTrainingAttentionView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void FastTrainingAttentionView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void FastTrainingAttentionView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp new file mode 100644 index 000000000..a1a0d8f64 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp @@ -0,0 +1,92 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static FastTrainingPresenter *g_pFastTrainingPresenter = nullptr; + int FastTrainingPresenter::CheckBoxSelectCount = 0; // 复选框选中数量 + FastTrainingPresenter::FastTrainingPresenter() + { + + g_pFastTrainingPresenter = this; + } + + FastTrainingPresenter::~FastTrainingPresenter() + { + + g_pFastTrainingPresenter = nullptr; + } + + FastTrainingPresenter *FastTrainingPresenter::GetInstance() + { + + return g_pFastTrainingPresenter; + } + + void FastTrainingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void FastTrainingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void FastTrainingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void FastTrainingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool FastTrainingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SECONDARY_FUNCTION); + } + return true; + } + + bool FastTrainingPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + if (state == UICheckBox::UICheckBoxState::SELECTED) + { + CheckBoxSelectCount += 1; + printf("CheckBoxSelectCount:%d\n", CheckBoxSelectCount); + } + else + { + CheckBoxSelectCount -= 1; + printf("CheckBoxSelectCount:%d\n", CheckBoxSelectCount); + } + if (CheckBoxSelectCount > 3) + { + CheckBoxSelectCount = 0;//->测试用的到时候需要改因为复选框选中的状态需要被保存 + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING_ATTENTION); + } + return true; + } + + bool FastTrainingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp new file mode 100644 index 000000000..9f4eb8a27 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/FastTrainingView.cpp @@ -0,0 +1,235 @@ +#include "secondaryfunction/include/FastTrainingView.h" +#include "secondaryfunction/include/FastTrainingPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + static FastTrainingView *g_pFastTrainingView{nullptr}; + + FastTrainingView::FastTrainingView() + { + + g_pFastTrainingView = this; + } + + FastTrainingView::~FastTrainingView() + { + DeInitView(); + g_pFastTrainingView = nullptr; + } + + FastTrainingView *FastTrainingView::GetInstance() + { + + return g_pFastTrainingView; + } + void FastTrainingView::InitImageLabelCheckbox(UIImageView *image, int image_x, int image_y, int image_w, int image_h, + UILabel *label, int label_x, int label_y, const char *labelText, + UICheckBox *checkbox, int check_x, int check_y, int check_w, int check_h, const char *checkboxID, + UICheckBox::OnChangeListener *ChangeListener, UIScrollView *scrollView) + { + image = new UIImageView(); + image->SetPosition(image_x, image_y); + image->Resize(image_w, image_h); + image->SetStyle(STYLE_BORDER_RADIUS, 50); + image->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + scrollView->Add(image); + image->SetVisible(true); + /* -------------------------------------------------------------------------- */ + label = new UILabel(); + label->SetPosition(label_x, label_y); + label->SetStyle(STYLE_TEXT_FONT, 30); + label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label->SetText(labelText); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(label); + label->SetVisible(true); + /* -------------------------------------------------------------------------- */ + checkbox = new UICheckBox(); + checkbox->SetPosition(check_x, check_y); + checkbox->Resize(check_w, check_h); + checkbox->SetViewId(checkboxID); + checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + ChangeListener = static_cast(FastTrainingPresenter::GetInstance()); + checkbox->SetOnChangeListener(ChangeListener); + scrollView->Add(checkbox); + checkbox->SetVisible(true); + } + + void FastTrainingView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + draglistener = static_cast(FastTrainingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add ScrollView to App + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + } + scrollView->SetPosition(0, 0); + scrollView->Resize(466, 466); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView); + scrollView->SetVisible(true); + // Add Label to App + if (label == nullptr) + { + label = new UILabel(); + } + label->SetPosition(173, 52); + label->Resize(200, 60); + label->SetViewId("label9"); + label->SetStyle(STYLE_TEXT_FONT, 30); + label->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label->SetText("快速训练"); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView->Add(label); + label->SetVisible(true); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image1, 43, 120, 380, 100, label1, 90, 153, "骑行", checkBox1, 343, 148, 50, 50, "checkBox1", ChangeListener1, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image2, 43, 240, 380, 100, label2, 90, 273, "户外跑步", checkBox2, 343, 268, 50, 50, "checkBox2", ChangeListener2, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image3, 43, 360, 380, 100, label3, 90, 393, "健走", checkBox3, 343, 388, 50, 50, "checkBox3", ChangeListener3, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image4, 43, 480, 380, 100, label4, 90, 513, "登山", checkBox4, 343, 508, 50, 50, "checkBox4", ChangeListener4, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image5, 43, 600, 380, 100, label5, 90, 633, "跳绳", checkBox5, 343, 628, 50, 50, "checkBox5", ChangeListener6, scrollView); + /* -------------------------------------------------------------------------- */ + InitImageLabelCheckbox(image6, 43, 720, 380, 100, label6, 90, 753, "乒乓球", checkBox6, 343, 748, 50, 50, "checkBox6", ChangeListener6, scrollView); + /* -------------------------------------------------------------------------- */ + FastTrainingPresenter::GetInstance()->setCheckbox(checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6); + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image5_ == nullptr) + { + image5_ = new UIImageView(); + } + image5_->SetPosition(183, 790); + image5_->Resize(100, 100); + scrollView->Add(image5_); + image5_->SetVisible(true); + // Add ImageView to App + if (image6_ == nullptr) + { + image6_ = new UIImageView(); + } + image6_->SetPosition(183, 19); + image6_->Resize(100, 100); + scrollView->Add(image6_); + image6_->SetVisible(true); + } + void FastTrainingView::DeInitView() + { + container_->RemoveAll(); + delete scrollView; + scrollView = nullptr; + delete image5_; + image5_ = nullptr; + delete image6_; + image6_ = nullptr; + delete image1; + image1 = nullptr; + delete image2; + image2 = nullptr; + delete image3; + image3 = nullptr; + delete image4; + image4 = nullptr; + delete image5; + image5 = nullptr; + delete image6; + image6 = nullptr; + delete label; + label = nullptr; + delete label1; + label1 = nullptr; + delete label2; + label2 = nullptr; + delete label3; + label3 = nullptr; + delete label4; + label4 = nullptr; + delete label5; + label5 = nullptr; + delete label6; + label6 = nullptr; + delete checkBox1; + checkBox1 = nullptr; + delete checkBox2; + checkBox2 = nullptr; + delete checkBox3; + checkBox3 = nullptr; + delete checkBox4; + checkBox4 = nullptr; + delete checkBox5; + checkBox5 = nullptr; + delete checkBox6; + checkBox6 = nullptr; + delete container_; + delete ChangeListener1; + ChangeListener1 = nullptr; + delete ChangeListener2; + ChangeListener2 = nullptr; + delete ChangeListener3; + ChangeListener3 = nullptr; + delete ChangeListener4; + ChangeListener4 = nullptr; + delete ChangeListener5; + ChangeListener5 = nullptr; + delete ChangeListener6; + ChangeListener6 = nullptr; + container_ = nullptr; + } + void FastTrainingView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void FastTrainingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void FastTrainingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void FastTrainingView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp new file mode 100644 index 000000000..c2b25c16f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp @@ -0,0 +1,84 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" + +#include "secondaryfunction/include/QuickAccessPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static QuickAccessPresenter *g_pQuickAccessPresenter = nullptr; + + QuickAccessPresenter::QuickAccessPresenter() + { + + g_pQuickAccessPresenter = this; + } + + QuickAccessPresenter::~QuickAccessPresenter() + { + + g_pQuickAccessPresenter = nullptr; + } + + QuickAccessPresenter *QuickAccessPresenter::GetInstance() + { + + return g_pQuickAccessPresenter; + } + + void QuickAccessPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void QuickAccessPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void QuickAccessPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void QuickAccessPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool QuickAccessPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SECONDARY_FUNCTION); + return true; + } + return false; + } + + bool QuickAccessPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), HEART_RATE_DETECTION) == 0) + { + + return true; + } + else if(strcmp(view.GetViewId(), BLOOD_OXYGEN_MONITOR) == 0) + { + + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessView.cpp new file mode 100644 index 000000000..d2c7e2ffb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/QuickAccessView.cpp @@ -0,0 +1,322 @@ +#include "UiConfig.h" + +#include "secondaryfunction/include/QuickAccessView.h" +#include "secondaryfunction/include/QuickAccessPresenter.h" +namespace OHOS +{ + + static QuickAccessView *g_pQuickAccessView{nullptr}; + + QuickAccessView::QuickAccessView() + { + + g_pQuickAccessView = this; + } + + QuickAccessView::~QuickAccessView() + { + DeInitView(); + g_pQuickAccessView = nullptr; + } + + QuickAccessView *QuickAccessView::GetInstance() + { + + return g_pQuickAccessView; + } + + void QuickAccessView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(QuickAccessPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + /***********************************************************************************************************/ + // Add QuickAccessScrollView to App + if (QuickAccessScrollView == nullptr) + { + QuickAccessScrollView = new UIScrollView(); + } + QuickAccessScrollView->SetPosition(0, 0); + QuickAccessScrollView->Resize(466, 466); + QuickAccessScrollView->SetViewId("QuickAccessScrollView"); + QuickAccessScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(QuickAccessScrollView); + QuickAccessScrollView->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (QuickAccessLabel == nullptr) + { + QuickAccessLabel = new UILabel(); + } + QuickAccessLabel->SetPosition(173, 52); + QuickAccessLabel->Resize(120, 35); + QuickAccessLabel->SetViewId("QuickAccessLabel"); + QuickAccessLabel->SetStyle(STYLE_TEXT_FONT, 30); + QuickAccessLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + QuickAccessLabel->SetText("快速访问"); + QuickAccessLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + QuickAccessLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + QuickAccessLabel->SetRollSpeed(6); + QuickAccessLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(QuickAccessLabel); + QuickAccessLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (label == nullptr) + { + label = new UILabel(); + } + label->SetPosition(86, 126); + label->Resize(286, 60); + label->SetViewId("label"); + label->SetStyle(STYLE_TEXT_FONT, 26); + label->SetStyle(STYLE_LINE_HEIGHT, 30); + // Set additional property + label->SetText("此功能可设置右下方按钮\n快速访问的APP"); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetTextColor(Color::GetColorFromRGBA(0xbb, 0xbb, 0xbb, 0xff)); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(6); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + // Add to scrollView3 + QuickAccessScrollView->Add(label); + label->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (HeartRateDetectionImage == nullptr) + { + HeartRateDetectionImage = new UIImageView(); + } + HeartRateDetectionImage->SetPosition(43, 220); // widget's left position and top position + HeartRateDetectionImage->Resize(380, 100); // widget's width and height + HeartRateDetectionImage->SetViewId("HeartRateDetectionImage"); // Set style + HeartRateDetectionImage->SetStyle(STYLE_BORDER_RADIUS, 50); + HeartRateDetectionImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionImage); + HeartRateDetectionImage->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (HeartRateDetectionLabel == nullptr) + { + HeartRateDetectionLabel = new UILabel(); + } + HeartRateDetectionLabel->SetPosition(103, 253); + HeartRateDetectionLabel->Resize(120, 35); + HeartRateDetectionLabel->SetViewId("HeartRateDetectionLabel"); + HeartRateDetectionLabel->SetStyle(STYLE_TEXT_FONT, 30); + HeartRateDetectionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + HeartRateDetectionLabel->SetText("心率监测"); + HeartRateDetectionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + HeartRateDetectionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + HeartRateDetectionLabel->SetRollSpeed(6); + HeartRateDetectionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionLabel); + HeartRateDetectionLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add CheckBox to App + if (HeartRateDetectionCheckBox == nullptr) + { + HeartRateDetectionCheckBox = new UICheckBox(); + } + HeartRateDetectionCheckBox->SetPosition(343, 250); + HeartRateDetectionCheckBox->Resize(40, 40); + HeartRateDetectionCheckBox->SetViewId(HEART_RATE_DETECTION); + HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Set additional property + HeartRateDetectionCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *HeartRateDetectionCheckBoxClick = static_cast(QuickAccessPresenter::GetInstance()); + HeartRateDetectionCheckBox->SetOnClickListener(HeartRateDetectionCheckBoxClick); + // Add to scrollView3 + QuickAccessScrollView->Add(HeartRateDetectionCheckBox); + HeartRateDetectionCheckBox->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (BloodOxygenMonitoringImage == nullptr) + { + BloodOxygenMonitoringImage = new UIImageView(); + } + BloodOxygenMonitoringImage->SetPosition(43, 340); + BloodOxygenMonitoringImage->Resize(380, 100); + BloodOxygenMonitoringImage->SetViewId("BloodOxygenMonitoringImage"); + BloodOxygenMonitoringImage->SetStyle(STYLE_BORDER_RADIUS, 50); + // Set additional property + BloodOxygenMonitoringImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringImage); + BloodOxygenMonitoringImage->SetVisible(true); + /***********************************************************************************************************/ + // Add CheckBox to App + if (BloodOxygenMonitoringCheckBox == nullptr) + { + BloodOxygenMonitoringCheckBox = new UICheckBox(); + } + BloodOxygenMonitoringCheckBox->SetPosition(343, 370); + BloodOxygenMonitoringCheckBox->Resize(50, 50); + BloodOxygenMonitoringCheckBox->SetViewId(BLOOD_OXYGEN_MONITOR); + BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BloodOxygenMonitoringCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); + // Add the CallBack about events + UIView::OnClickListener *BloodOxygenMonitoringCheckBoxClick = static_cast(QuickAccessPresenter::GetInstance()); + BloodOxygenMonitoringCheckBox->SetOnClickListener(BloodOxygenMonitoringCheckBoxClick); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringCheckBox); + BloodOxygenMonitoringCheckBox->SetVisible(true); + /***********************************************************************************************************/ + // Add Label to App + if (BloodOxygenMonitoringLabel == nullptr) + { + BloodOxygenMonitoringLabel = new UILabel(); + } + BloodOxygenMonitoringLabel->SetPosition(103, 373); + BloodOxygenMonitoringLabel->Resize(120, 35); + BloodOxygenMonitoringLabel->SetViewId("BloodOxygenMonitoringLabel"); + BloodOxygenMonitoringLabel->SetStyle(STYLE_TEXT_FONT, 30); + BloodOxygenMonitoringLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + BloodOxygenMonitoringLabel->SetText("血氧监测"); + BloodOxygenMonitoringLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + BloodOxygenMonitoringLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + BloodOxygenMonitoringLabel->SetRollSpeed(6); + BloodOxygenMonitoringLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView3 + QuickAccessScrollView->Add(BloodOxygenMonitoringLabel); + BloodOxygenMonitoringLabel->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image1 == nullptr) + { + image1 = new UIImageView(); + } + image1->SetPosition(183, 23); + image1->Resize(100, 100); + image1->SetViewId("image1"); + + QuickAccessScrollView->Add(image1); + image1->SetVisible(true); + /***********************************************************************************************************/ + // Add ImageView to App + if (image2 == nullptr) + { + image2 = new UIImageView(); + } + image2->SetPosition(183, 423); + image2->Resize(100, 100); + image2->SetViewId("image2"); + QuickAccessScrollView->Add(image2); + image2->SetVisible(true); + } + + void QuickAccessView::DeInitView(void) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (QuickAccessScrollView != nullptr) + { + delete QuickAccessScrollView; + QuickAccessScrollView = nullptr; + } + if (image1 != nullptr) + { + delete image1; + image1 = nullptr; + } + if (QuickAccessLabel != nullptr) + { + delete QuickAccessLabel; + QuickAccessLabel = nullptr; + } + if (image2 != nullptr) + { + delete image2; + image2 = nullptr; + } + if (label != nullptr) + { + delete label; + label = nullptr; + } + if (HeartRateDetectionImage != nullptr) + { + delete HeartRateDetectionImage; + HeartRateDetectionImage = nullptr; + } + if (HeartRateDetectionCheckBox != nullptr) + { + delete HeartRateDetectionCheckBox; + HeartRateDetectionCheckBox = nullptr; + } + if (HeartRateDetectionLabel != nullptr) + { + delete HeartRateDetectionLabel; + HeartRateDetectionLabel = nullptr; + } + if (BloodOxygenMonitoringImage != nullptr) + { + delete BloodOxygenMonitoringImage; + BloodOxygenMonitoringImage = nullptr; + } + if (BloodOxygenMonitoringCheckBox != nullptr) + { + delete BloodOxygenMonitoringCheckBox; + BloodOxygenMonitoringCheckBox = nullptr; + } + if (BloodOxygenMonitoringLabel != nullptr) + { + delete BloodOxygenMonitoringLabel; + BloodOxygenMonitoringLabel = nullptr; + } + } + + void QuickAccessView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void QuickAccessView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void QuickAccessView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void QuickAccessView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp new file mode 100644 index 000000000..5a36922a2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp @@ -0,0 +1,85 @@ + +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SecondaryFunctionPresenter *g_pSecondaryFunctionPresenter = nullptr; + + SecondaryFunctionPresenter::SecondaryFunctionPresenter() + { + + g_pSecondaryFunctionPresenter = this; + } + + SecondaryFunctionPresenter::~SecondaryFunctionPresenter() + { + + g_pSecondaryFunctionPresenter = nullptr; + } + + SecondaryFunctionPresenter *SecondaryFunctionPresenter::GetInstance() + { + + return g_pSecondaryFunctionPresenter; + } + + void SecondaryFunctionPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SecondaryFunctionPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SecondaryFunctionPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SecondaryFunctionPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SecondaryFunctionPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + return true; + } + return false; + } + + bool SecondaryFunctionPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), SECONDARY_FUNCTION_BUTTON1ID) == 0) + { + + NativeAbility::GetInstance().ChangeSlice(VIEW_QUICK_ACCESS); + return true; + } + else if (strcmp(view.GetViewId(), SECONDARY_FUNCTION_BUTTON2ID) == 0) + { + + NativeAbility::GetInstance().ChangeSlice(VIEW_FAST_TRAINING); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp new file mode 100644 index 000000000..7912a133d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp @@ -0,0 +1,237 @@ +#include "secondaryfunction/include/SecondaryFunctionView.h" +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" + +#include "UiConfig.h" +namespace OHOS +{ + + static SecondaryFunctionView *g_pSecondaryFunctionView{nullptr}; + + SecondaryFunctionView::SecondaryFunctionView() + { + + g_pSecondaryFunctionView = this; + } + + SecondaryFunctionView::~SecondaryFunctionView() + { + DeInitView(); + g_pSecondaryFunctionView = nullptr; + } + + SecondaryFunctionView *SecondaryFunctionView::GetInstance() + { + + return g_pSecondaryFunctionView; + } + + void SecondaryFunctionView::InitView(void) + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + UIView::OnDragListener *draglistener = static_cast(SecondaryFunctionPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + } + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(172, 52); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + label1_->SetText("辅助功能"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Button to App + if (SECONDARY_FUNCTION_BUTTON1 == nullptr) + { + SECONDARY_FUNCTION_BUTTON1 = new UIButton(); + } + SECONDARY_FUNCTION_BUTTON1->SetPosition(43, 120); + SECONDARY_FUNCTION_BUTTON1->Resize(380, 100); + SECONDARY_FUNCTION_BUTTON1->SetViewId(SECONDARY_FUNCTION_BUTTON1ID); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + SECONDARY_FUNCTION_BUTTON1->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffafafa, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(SecondaryFunctionPresenter::GetInstance()); + SECONDARY_FUNCTION_BUTTON1->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(SECONDARY_FUNCTION_BUTTON1); + SECONDARY_FUNCTION_BUTTON1->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(90, 153); + label2_->SetStyle(STYLE_TEXT_FONT, 30); + label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label2_->SetText("快速访问"); + 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 ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(369, 157); + image3_->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to rootView + container_->Add(image3_); + image3_->SetVisible(true); + + // Add Button to App + if (SECONDARY_FUNCTION_BUTTON2 == nullptr) + { + SECONDARY_FUNCTION_BUTTON2 = new UIButton(); + } + SECONDARY_FUNCTION_BUTTON2->SetPosition(43, 240); + SECONDARY_FUNCTION_BUTTON2->Resize(380, 100); + SECONDARY_FUNCTION_BUTTON2->SetViewId(SECONDARY_FUNCTION_BUTTON2ID); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_OPA, 0x00); + SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_COLOR, 0xffffffff); + SECONDARY_FUNCTION_BUTTON2->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr); + SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(SecondaryFunctionPresenter::GetInstance()); + SECONDARY_FUNCTION_BUTTON2->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(SECONDARY_FUNCTION_BUTTON2); + SECONDARY_FUNCTION_BUTTON2->SetVisible(true); + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(90, 273); + label4_->SetStyle(STYLE_TEXT_FONT, 30); + label4_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // 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 ImageView to App + if (image4_ == nullptr) + { + image4_ = new UIImageView(); + } + image4_->SetPosition(369, 277); + image4_->SetSrc(PNG_SETTING_NEXT_IMAGE); + // Add to rootView + container_->Add(image4_); + image4_->SetVisible(true); + } + void SecondaryFunctionView::DeInitView(void) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (SECONDARY_FUNCTION_BUTTON1 != nullptr) + { + delete SECONDARY_FUNCTION_BUTTON1; + SECONDARY_FUNCTION_BUTTON1 = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (SECONDARY_FUNCTION_BUTTON2 != nullptr) + { + delete SECONDARY_FUNCTION_BUTTON2; + SECONDARY_FUNCTION_BUTTON2 = nullptr; + } + if (image4_ != nullptr) + { + delete image4_; + image4_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + delete container_; + container_ = nullptr; + } + + void SecondaryFunctionView::OnStart() + { + View::OnStart(); + InitView(); + RootView::GetInstance()->Add(container_); + } + + void SecondaryFunctionView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SecondaryFunctionView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SecondaryFunctionView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp index 93a5ff537..3dda499fe 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -31,7 +31,7 @@ namespace OHOS settingIdToViewId.insert(std::pair(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS)); settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_BLUETOOTH_EARPHONE)); settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_SYSTEM)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_SECONDARY_FUNCTION)); settingIdToViewId.insert(std::pair(SETTING_ITEM_FOUR, VIEW_SYSTEM)); settingIdToViewId.insert(std::pair(SETTING_ITEM_FIVE, VIEW_SHUTDOWN_OR_REBOOT)); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/FastTrainingAttentionVector.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/FastTrainingAttentionVector.bin new file mode 100644 index 000000000..b8120b857 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/FastTrainingAttentionVector.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_DEVICE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_DEVICE.bin deleted file mode 100644 index 437402ac4..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_DEVICE.bin and /dev/null differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_device.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_device.bin new file mode 100644 index 000000000..b3180e934 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/NEW_device.bin differ diff --git a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c index 0cda4a998..14051ee50 100755 --- a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c +++ b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c @@ -282,14 +282,18 @@ char* HalGetHardwareProfile(void) char* HalGetSerial(void) { - char* value = (char*)malloc(strlen(OHOS_SERIAL) + 1); + unsigned char sn_buf[32] = {0}; + unsigned int len = 0; + unsigned int ret = zh_get_sn(sn_buf,&len); + char* value = (char*)malloc(strlen(sn_buf) + 1); if (value == NULL) { return NULL; } - if (strcpy_s(value, strlen(OHOS_SERIAL) + 1, OHOS_SERIAL) != 0) { + if (strcpy_s(value, strlen(sn_buf) + 1, sn_buf) != 0) { free(value); return NULL; } + return value; }