From: 罗正yun <1732036298@qq.com> Date: Tue, 23 Jan 2024 07:53:24 +0000 (+0800) Subject: 修改系统视图 X-Git-Tag: release_V1.2.70_20241020_135402~1338^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e5b5450f7cb6e97658b8f84995cd106e34f3b8cb;p=mirrors%2FFD230.git 修改系统视图 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 55aa8296d..2ec334443 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -214,17 +214,11 @@ set(SOURCES #系统 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemAboutPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemAboutView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemSupervisePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemAboutTheWatchView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemSuperviseView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemLanguagePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemLanguageView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemRebootPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemRebootView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemShoutDownPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemShoutDownView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 8cdaf6c7a..6ef0c96c5 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -45,11 +45,7 @@ typedef enum : uint16_t VIEW_FUTURE_WEATHER, // 未来天气 VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败 VIEW_SYSTEM, // 系统 - VIEW_SYSTEM_ABOUT_WATCH, // 系统:关于手表 - VIEW_SYSTEM_SUPERVISE, // 系统:监管 VIEW_SYSTEM_SYSTEM_LANGUAGE, // 系统:系统语言 - VIEW_SYSTEM_REBOOT, // 系统:重新启动 - VIEW_SYSTEM_SHOUTDOWN, // 系统:关机 VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 /* -------------------------------------------------------------------------- */ VIEW_MAIN_TEMP, // 体温界面(暂时不用) diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index cda756770..2bdb0d662 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -47,12 +47,8 @@ namespace OHOS void InitFutureWeatherSlice(void); void InitGetWeatherDataErrorSlice(void); /* -------------------------------------------------------------------------- */ - void InitSystemSlice(void); - void InitSystemAboutWatchSlice(void); - void InitSystemSuperviseSlice(void); - void InitSystemLanguageSlice(void); - void InitSystemRebootSlice(void); - void InitSystemShoutDownSlice(void); + void InitSystemSlice(void); + void InitSystemLanguageSlice(void); void InitSystemFactoryResetSlice(void); private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 7763c66ed..6ad398e5c 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -71,16 +71,8 @@ #include "system/include/SystemPresenter.h" #include "system/include/SystemView.h" -#include "system/include/SystemAboutPresenter.h" -#include "system/include/SystemAboutView.h" -#include "system/include/SystemSupervisePresenter.h" -#include "system/include/SystemSuperviseView.h" #include "system/include/SystemLanguagePresenter.h" #include "system/include/SystemLanguageView.h" -#include "system/include/SystemRebootPresenter.h" -#include "system/include/SystemRebootView.h" -#include "system/include/SystemShoutDownPresenter.h" -#include "system/include/SystemShoutDownView.h" #include "system/include/SystemFactoryResetPresenter.h" #include "system/include/SystemFactoryResetView.h" @@ -123,11 +115,7 @@ namespace OHOS {VIEW_FUTURE_WEATHER, &NativeLauncher::InitFutureWeatherSlice}, // 未来天气 {VIEW_GET_WEATHER_DATA_ERROR, &NativeLauncher::InitGetWeatherDataErrorSlice}, // 获取天气数据失败 {VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址 - {VIEW_SYSTEM_ABOUT_WATCH, &NativeLauncher::InitSystemAboutWatchSlice}, // 系统:关于手表实例化地址 - {VIEW_SYSTEM_SUPERVISE, &NativeLauncher::InitSystemSuperviseSlice}, // 系统:监管实例化地址 {VIEW_SYSTEM_SYSTEM_LANGUAGE, &NativeLauncher::InitSystemLanguageSlice}, // 系统:系统语言实例化地址 - {VIEW_SYSTEM_REBOOT, &NativeLauncher::InitSystemRebootSlice}, // 系统:重启实例化地址 - {VIEW_SYSTEM_SHOUTDOWN, &NativeLauncher::InitSystemShoutDownSlice}, // 系统:关机实例化地址 {VIEW_SYSTEM_FACTORY_RESET, &NativeLauncher::InitSystemFactoryResetSlice}, // 系统:恢复出厂设置实例化地址 //{VIEW_MAIN_ACTIVITY, &NativeLauncher::InitActivitySlice}, //{VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice}, @@ -461,25 +449,6 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM, system); } - void NativeLauncher::InitSystemAboutWatchSlice(void) // 系统:关于手表 - { - SliceProxy *systemaboutwatch = new AbilitySliceProxy; - if (systemaboutwatch == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_ABOUT_WATCH, systemaboutwatch); - } - - void NativeLauncher::InitSystemSuperviseSlice(void) // 系统:监管 - { - SliceProxy *systemsupervise = new AbilitySliceProxy; - if (systemsupervise == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SUPERVISE, systemsupervise); - } void NativeLauncher::InitSystemLanguageSlice(void) // 系统:系统语言 { @@ -490,24 +459,7 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SYSTEM_LANGUAGE, systemlanguage); } - void NativeLauncher::InitSystemRebootSlice(void) // 系统:重新启动 - { - SliceProxy *systemreboot = new AbilitySliceProxy; - if (systemreboot == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_REBOOT, systemreboot); - } - void NativeLauncher::InitSystemShoutDownSlice(void) // 系统:关机 - { - SliceProxy *systemshoutdown = new AbilitySliceProxy; - if (systemshoutdown == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SHOUTDOWN, systemshoutdown); - } + void NativeLauncher::InitSystemFactoryResetSlice(void) // 系统:恢复出厂设置 { SliceProxy *systemfactoryreset = new AbilitySliceProxy; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutPresenter.h deleted file mode 100644 index 4938e2846..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutPresenter.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef SYSTEM_ABOUT_PRESENTER_H -#define SYSTEM_ABOUT_PRESENTER_H - -#include "Presenter.h" - -#include "SystemAboutView.h" - -namespace OHOS -{ - class SystemAboutView; - - class SystemAboutPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - SystemAboutPresenter(); - virtual ~SystemAboutPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SystemAboutPresenter *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/system/include/SystemAboutTheWatchView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutTheWatchView.h new file mode 100644 index 000000000..916f3b5ea --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutTheWatchView.h @@ -0,0 +1,55 @@ +#ifndef SYSTEM_ABOUT_VIEW_H +#define SYSTEM_ABOUT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include +namespace OHOS +{ + class SystemAboutTheWatchView + { + + public: + SystemAboutTheWatchView(); + virtual ~SystemAboutTheWatchView(); + static SystemAboutTheWatchView *GetInstance(void); + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + UIScrollView *SystemAbouTheWatchtInitIView(void); + void ClearAll(void); + UILabel *InitLabel(LabelConfig &labelConfig); + + private: + bool SetSystemAboutTheWatchScrollView(void); + UIScrollView *SystemAboutTheWatchScrollView{nullptr}; + UILabel *SystemAboutTheWatchTitle{nullptr}; // “关于” + UILabel *WatchNameTitle{nullptr}; // “手表名称” + UILabel *WatchName{nullptr}; + UILabel *FirmwareVersionTitle{nullptr}; // "固件版本" + UILabel *FirmwareVersion{nullptr}; + UILabel *AlgorithmVersionTitle{nullptr}; // “算法版本” + UILabel *AlgorithmVersion{nullptr}; + UILabel *BluetoothAddressTitle{nullptr}; // “蓝牙地址” + UILabel *BluetoothAddress{nullptr}; + UILabel *LANAddressTitle{nullptr}; // “局域网地址” + UILabel *LANAddress = nullptr; + UILabel *FONTTitle = nullptr; + UILabel *FONT = nullptr; + + UIImageView *image = nullptr; + UIView::OnDragListener *draglistener{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutView.h deleted file mode 100644 index 6a6812338..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemAboutView.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef SYSTEM_ABOUT_VIEW_H -#define SYSTEM_ABOUT_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" -namespace OHOS -{ - class SystemAboutPresenter; - class SystemAboutView : public View - { - - public: - SystemAboutView(); - virtual ~SystemAboutView(); - static SystemAboutView *GetInstance(void); - - UILabel *InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed); - - public: - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - void SystemAboutInitIView(void); - void DeSystemAboutInitIView(void); - - private: - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; - UILabel *label6_ = nullptr; - UILabel *label7_ = nullptr; - UILabel *label8_ = nullptr; - UILabel *label9_ = nullptr; - UILabel *label10_ = nullptr; - UILabel *label11_ = nullptr; - UILabel *label12_ = nullptr; - UILabel *label13_ = nullptr; - - UIImageView *image = nullptr; - }; -} // namespace OHOS -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h index 2a84cd2ed..7a827129e 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h @@ -27,7 +27,8 @@ namespace OHOS private: //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; }; } //namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemRebootPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemRebootPresenter.h deleted file mode 100644 index 9970612bb..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemRebootPresenter.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SYSTEM_REBOOT_PRESENTER_H -#define SYSTEM_REBOOT_PRESENTER_H - -#include "Presenter.h" - -#include "SystemRebootView.h" - -namespace OHOS -{ - class SystemRebootView; - - class SystemRebootPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - SystemRebootPresenter(); - virtual ~SystemRebootPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SystemRebootPresenter *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/system/include/SystemRebootView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemRebootView.h deleted file mode 100644 index 5b25a8807..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemRebootView.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SYSTEM_REBOOT_VIEW_H -#define SYSTEM_REBOOT_VIEW_H - -#include "BaseView.h" -#include "View.h" - -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" -namespace OHOS -{ - static const char *REBOOT_CHECKON = "ShoutDownButtonCheckOn";//确认 - static const char *REBOOT_CHECKOFF = "ShoutDownButtonCheckOff";//取消 - class SystemRebootPresenter; - class SystemRebootView : public View - { - - public: - SystemRebootView(); - virtual ~SystemRebootView(); - static SystemRebootView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - - void InitView(void); - void DeInitView(void); - - UIViewGroup *container_ = nullptr; - UIImageView *RebootImage = nullptr; - UIButton *RebootButtonCheckOn = nullptr; - UIButton *RebootButtonCheckOff = nullptr; - }; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemShoutDownPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemShoutDownPresenter.h deleted file mode 100644 index c18289e79..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemShoutDownPresenter.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SYSTEM_SHOUTDOWN_PRESENTER_H -#define SYSTEM_SHOUTDOWN_PRESENTER_H - -#include "Presenter.h" - -#include "SystemShoutDownView.h" - -namespace OHOS -{ - class SystemShoutDownView; - - class SystemShoutDownPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - SystemShoutDownPresenter(); - virtual ~SystemShoutDownPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SystemShoutDownPresenter *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/system/include/SystemShoutDownView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemShoutDownView.h deleted file mode 100644 index d36151317..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemShoutDownView.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SYSTEM_SHOUTDOWN_VIEW_H -#define SYSTEM_SHOUTDOWN_VIEW_H - -#include "BaseView.h" -#include "View.h" - -#include "components/ui_view_group.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" -namespace OHOS -{ - static const char *SHOUTDOWN_BUTTON_CHECKON = "ShoutDownButtonCheckOn";//确认 - static const char *SHOUTDOWN_BUTTON_CHECKOFF = "ShoutDownButtonCheckOff";//取消 - class SystemShoutDownPresenter; - class SystemShoutDownView : public View - { - - public: - SystemShoutDownView(); - virtual ~SystemShoutDownView(); - static SystemShoutDownView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - - void InitView(void); - void DeInitView(void); - - UIViewGroup *container_ = nullptr; - UIImageView *ShoutDownImage = nullptr; - UIButton *ShoutDownButtonCheckOn = nullptr; - UIButton *ShoutDownButtonCheckOff = nullptr; - }; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSupervisePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSupervisePresenter.h deleted file mode 100644 index df8183ce7..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSupervisePresenter.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SYSTEM_SUPERVISE_PRESENTER_H -#define SYSTEM_SUPERVISE_PRESENTER_H - -#include "Presenter.h" - -#include "SystemSuperviseView.h" - -namespace OHOS -{ - class SystemSuperviseView; - - class SystemSupervisePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - SystemSupervisePresenter(); - virtual ~SystemSupervisePresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SystemSupervisePresenter *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/system/include/SystemSuperviseView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSuperviseView.h index ba426fbe2..2939f4e87 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSuperviseView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemSuperviseView.h @@ -9,32 +9,26 @@ #include "components/ui_label.h" namespace OHOS { - class SystemSupervisePresenter; - class SystemSuperviseView : public View - { + class SystemSuperviseView + { public: SystemSuperviseView(); virtual ~SystemSuperviseView(); static SystemSuperviseView *GetInstance(void); UILabel *InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - void InitView(void); - void DeInitView(void); + UIScrollView *SystemSuperviseViewInit(void); + void ClearAll(void); private: UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; + UIScrollView *SystemSuperviseViewScrollView = nullptr; + UIView::OnDragListener *draglistener{nullptr}; + UILabel *Title = nullptr; + UILabel *ProductModel = nullptr; + UILabel *ProductModelName = nullptr; + UILabel *CMIT = nullptr; + UILabel *CMITName = nullptr; }; } // namespace OHOS #endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h index a135aec23..8a8c86fbc 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h @@ -9,15 +9,18 @@ #include "components/ui_label.h" #include "components/ui_image_view.h" #include "components/ui_button.h" - +#include "system/include/SystemAboutTheWatchView.h" +#include "system/include/SystemSuperviseView.h" namespace OHOS { static const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 static const char *SUPERVISE = "SuperviseButton"; // 监管 static const char *SYSTEM_LANGUAGE = "SystemLanguageButton"; // 系统语言 - static const char *REBOOT = "RebootButton"; // 重启 - static const char *SHOUTDOWM = "ShoutdownButton"; // 关机 static const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 + static const char *ABOUT_THE_WATCH_IMAGESRC = "/user/res/system/SYSTEM_ABOUT_THE_WATCH.bin"; + static const char *SUPERVISE_IMAGESRC = "/user/res/system/SYSTEM_SUPERVISE.bin"; + static const char *SYSTEM_LANGUAGE_IMAGESRC = "/user/res/system/SYSTEM_SYSTEM_LANGUAGE.bin"; + static const char *FACTORY_RESET_LANGUAGE_IMAGESRC = "/user/res/system/SYSTEM_FACTORY_RESET.bin"; class SystemPresenter; class SystemView : public View { @@ -31,25 +34,37 @@ namespace OHOS void OnSetUpView() override; void OnTearDownView() override; void OnStop() override; - + struct ButtonConfig + { + int x; + int y; + int w; + int h; + const char *ViewId; + const char *ImageSrc; + }; + bool ChangeSystemView(int16_t thisView); + bool ChangeSystemAboutView(int16_t thisView); + bool ChangeSystemSuperviseView(int16_t thisView); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); private: - UIView::OnDragListener *draglistener{nullptr}; - void InitIView(void); - void DeInitView(void); - - private: - UIViewGroup *container_ = nullptr; - UIScrollView *SystemScrollView = nullptr; - UILabel *SystemLabel = nullptr; - UIImageView *image2_ = nullptr; - UIImageView *image1_ = nullptr; - UIButton *FactoryResetButton = nullptr; - UIButton *ShoutdownButton = nullptr; - UIButton *RebootButton = nullptr; - UIButton *AboutTheWatchButton = nullptr; - UIButton *SuperviseButton = nullptr; - UIButton *SystemLanguageButton = nullptr; + void ClearAll(void); + bool SetTheSystemScrollView(void); + bool SetTheTitle(void); + UIButton * SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); + SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; + SystemSuperviseView *p_SystemSuperviseView{nullptr}; + UIScrollView *SystemScrollView[5]{nullptr}; + UILabel *SystemLabel{nullptr}; // 标题 + UIButton *FactoryResetButton{nullptr}; + UIButton *AboutTheWatchButton{nullptr}; + UIButton *SuperviseButton = {nullptr}; + UIButton *SystemLanguageButton = {nullptr}; + UIView::OnDragListener *draglistener{nullptr}; + UIView::OnClickListener *clickListener{nullptr}; + bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutPresenter.cpp deleted file mode 100644 index c302d4c40..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutPresenter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "system/include/SystemAboutPresenter.h" -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static SystemAboutPresenter *g_pSystemAboutPresenter = nullptr; - - SystemAboutPresenter::SystemAboutPresenter() - { - - g_pSystemAboutPresenter = this; - } - - SystemAboutPresenter::~SystemAboutPresenter() - { - - g_pSystemAboutPresenter = nullptr; - } - - SystemAboutPresenter *SystemAboutPresenter::GetInstance() - { - - return g_pSystemAboutPresenter; - } - - void SystemAboutPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void SystemAboutPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void SystemAboutPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void SystemAboutPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool SystemAboutPresenter::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_SYSTEM); - return true; - } - return false; - } - - bool SystemAboutPresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), 控件ID) == 0) - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp new file mode 100644 index 000000000..a961a8719 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp @@ -0,0 +1,353 @@ +#include "system/include/SystemAboutTheWatchView.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" +namespace OHOS +{ + + static SystemAboutTheWatchView *g_pSystemAboutTheWatchView{nullptr}; + + SystemAboutTheWatchView::SystemAboutTheWatchView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + SystemAboutTheWatchView::~SystemAboutTheWatchView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView"); + ClearAll(); + g_pSystemAboutTheWatchView = nullptr; + } + + SystemAboutTheWatchView *SystemAboutTheWatchView::GetInstance() + { + + return g_pSystemAboutTheWatchView; + } + + UILabel *SystemAboutTheWatchView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + + bool SystemAboutTheWatchView::SetSystemAboutTheWatchScrollView(void) + { + SystemAboutTheWatchScrollView = new UIScrollView(); + if (SystemAboutTheWatchScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchScrollView new fail!"); + return false; + } + SystemAboutTheWatchScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemAboutTheWatchScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemAboutTheWatchScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + SystemAboutTheWatchScrollView->SetScrollBlankSize(35); + SystemAboutTheWatchScrollView->SetReboundSize(50); + SystemAboutTheWatchScrollView->SetDirection(1); + draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + return false; + } + SystemAboutTheWatchScrollView->SetOnDragListener(draglistener); + SystemAboutTheWatchScrollView->SetTouchable(true); + SystemAboutTheWatchScrollView->SetDraggable(true); + return true; + } + + UIScrollView *SystemAboutTheWatchView::SystemAbouTheWatchtInitIView() + { + if (!SetSystemAboutTheWatchScrollView()) + { + return nullptr; + } + /* -------------------------------------------------------------------------- */ + LabelConfig Config = { + .left = 203, + .top = 52, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "关于", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + SystemAboutTheWatchTitle = InitLabel(Config); + if (SystemAboutTheWatchTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(SystemAboutTheWatchTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 160, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "手表名称", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + WatchNameTitle = InitLabel(Config); + if (WatchNameTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::WatchNameTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(WatchNameTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 216, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "Watch Soar", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + WatchName = InitLabel(Config); + if (WatchName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::WatchName new fail!"); + return nullptr; + } + WatchName->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(WatchName); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 305, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "固件版本", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + FirmwareVersionTitle = InitLabel(Config); + if (FirmwareVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(FirmwareVersionTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 361, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "V1.0", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + FirmwareVersion = InitLabel(Config); + if (FirmwareVersion == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!"); + return nullptr; + } + FirmwareVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(FirmwareVersion); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 450, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "算法版本", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + AlgorithmVersionTitle = InitLabel(Config); + if (AlgorithmVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::AlgorithmVersionTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(AlgorithmVersionTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 506, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "V02.03.01 OTA88", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + AlgorithmVersion = InitLabel(Config); + if (AlgorithmVersion == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::AlgorithmVersion new fail!"); + return nullptr; + } + AlgorithmVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(AlgorithmVersion); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 595, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "蓝牙地址", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + BluetoothAddressTitle = InitLabel(Config); + if (BluetoothAddressTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::BluetoothAddressTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(BluetoothAddressTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 651, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "D4:FF:E3:12:00:A4", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + BluetoothAddress = InitLabel(Config); + if (BluetoothAddress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::BluetoothAddress new fail!"); + return nullptr; + } + BluetoothAddress->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(BluetoothAddress); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 740, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "局域网地址", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + LANAddressTitle = InitLabel(Config); + if (LANAddressTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::LANAddressTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(LANAddressTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 796, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "D4:FF:E3:12:00:A4", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + LANAddress = InitLabel(Config); + if (LANAddress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::LANAddress new fail!"); + return nullptr; + } + LANAddress->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(LANAddress); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 173, + .top = 885, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "FONTS", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + FONTTitle = InitLabel(Config); + if (FONTTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FONTTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(FONTTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = 37, + .top = 941, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = "HarmonyOS Sans", + .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, + }; + LANAddress = InitLabel(Config); + if (LANAddress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::LANAddress new fail!"); + return nullptr; + } + LANAddress->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(LANAddress); + + return SystemAboutTheWatchScrollView; + } + + void SystemAboutTheWatchView::ClearAll() + { + SystemAboutTheWatchScrollView->RemoveAll(); + delete SystemAboutTheWatchTitle; + SystemAboutTheWatchTitle = nullptr; + delete WatchNameTitle; + WatchNameTitle = nullptr; + delete WatchName; + WatchName = nullptr; + delete FirmwareVersionTitle; + FirmwareVersionTitle = nullptr; + delete FirmwareVersion; + FirmwareVersion = nullptr; + delete AlgorithmVersionTitle; + AlgorithmVersionTitle = nullptr; + delete AlgorithmVersion; + AlgorithmVersion = nullptr; + delete BluetoothAddressTitle; + BluetoothAddressTitle = nullptr; + delete BluetoothAddress; + BluetoothAddress = nullptr; + delete LANAddressTitle; + LANAddressTitle = nullptr; + delete LANAddress; + LANAddress = nullptr; + delete FONTTitle; + FONTTitle = nullptr; + delete FONT; + FONT = nullptr; + delete SystemAboutTheWatchScrollView; + SystemAboutTheWatchScrollView = nullptr; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutView.cpp deleted file mode 100644 index 514016d4d..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemAboutView.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "system/include/SystemAboutView.h" -#include "system/include/SystemAboutPresenter.h" -#include "UiConfig.h" - -namespace OHOS -{ - - static SystemAboutView *g_pSystemAboutView{nullptr}; - - SystemAboutView::SystemAboutView() - { - - g_pSystemAboutView = this; - } - - SystemAboutView::~SystemAboutView() - { - - g_pSystemAboutView = nullptr; - } - - SystemAboutView *SystemAboutView::GetInstance() - { - - return g_pSystemAboutView; - } - UILabel *SystemAboutView::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed) - { - UILabel *label = new UILabel(); - label->SetPosition(left, top); // 位置 - label->Resize(width, height); // 大小 - label->SetViewId(viewId); // id - label->SetStyle(STYLE_TEXT_FONT, fontSize); // 字体大小 - label->SetStyle(STYLE_LINE_HEIGHT, fontlineHeigh); // 字体行高 - label->SetText(text); // 内容 - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(speed); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); - - return label; - } - - void SystemAboutView::SystemAboutInitIView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - UIView::OnDragListener *draglistener = static_cast(SystemAboutPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); - } - - if (scrollView1_ == nullptr) - { - scrollView1_ = new UIScrollView(); - } - scrollView1_->SetPosition(0, 0); - scrollView1_->Resize(466, 466); - scrollView1_->SetViewId("scrollView"); - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView1_->SetStyle(STYLE_BORDER_RADIUS, 1294); - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - /***********************************************************************************************************/ - if (label1_ == nullptr) - { - label1_ = InitLabel(203, 52, 60, 35, "关于", "label1", 30, 35, 6); - } - scrollView1_->Add(label1_); - label1_->SetVisible(true); - /***********************************************************************************************************/ - if (label2_ == nullptr) - { - label2_ = InitLabel(173, 160, 120, 35, "手表名称", "label2", 30, 35, 6); - } - scrollView1_->Add(label2_); - label2_->SetVisible(true); - /***********************************************************************************************************/ - if (label3_ == nullptr) - { - label3_ = InitLabel(97, 217, 263, 30, "周冰鸿的 Smart Watch", "label3", 26, 30, 6); - } - label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label3_); - label3_->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App - if (label4_ == nullptr) - { - label4_ = InitLabel(173, 305, 120, 35, "固件版本", "label4", 30, 35, 6); - } - scrollView1_->Add(label4_); - label4_->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App - if (label5_ == nullptr) - { - label5_ = InitLabel(174, 361, 119, 30, "V02.03.01", "label5", 26, 30, 6); - } - label5_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label5_); - label5_->SetVisible(true); - /***********************************************************************************************************/ - if (label6_ == nullptr) - { - label6_ = InitLabel(173, 450, 120, 35, "算法版本", "label6", 30, 35, 6); - } - scrollView1_->Add(label6_); - label6_->SetVisible(true); - RootView::GetInstance()->Add(container_); - /***********************************************************************************************************/ - if (label7_ == nullptr) - { - label7_ = InitLabel(131, 506, 204, 30, "V02.03.01 OTA88", "label7", 26, 30, 6); - } - label7_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label7_); - label7_->SetVisible(true); - /***********************************************************************************************************/ - if (label8_ == nullptr) - { - label8_ = InitLabel(173, 595, 120, 35, "蓝牙地址", "label8", 30, 35, 6); - } - - scrollView1_->Add(label8_); - label8_->SetVisible(true); - /***********************************************************************************************************/ - if (label9_ == nullptr) - { - label9_ = InitLabel(123, 651, 220, 30, "D4:FF:E3:12:00:A4", "label9", 26, 30, 6); - } - - label9_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label9_); - label9_->SetVisible(true); - /***********************************************************************************************************/ - if (label10_ == nullptr) - { - label10_ = InitLabel(158, 740, 120, 35, "局域网地址", "label10", 30, 35, 6); - } - scrollView1_->Add(label10_); - label10_->SetVisible(true); - /***********************************************************************************************************/ - if (label11_ == nullptr) - { - label11_ = InitLabel(123, 796, 220, 30, "D4:FF:E3:12:00:A4", "label11", 26, 30, 6); - } - label11_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label11_); - label11_->SetVisible(true); - /***********************************************************************************************************/ - if (label12_ == nullptr) - { - label12_ = InitLabel(185, 885, 97, 35, "FONTS", "label12", 30, 35, 6); - } - scrollView1_->Add(label12_); - label12_->SetVisible(true); - /***********************************************************************************************************/ - if (label13_ == nullptr) - { - label13_ = InitLabel(130, 941, 207, 30, "HarmonyOS Sans", "label13", 26, 30, 6); - } - label13_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label13_); - label13_->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (image == nullptr) - { - image = new UIImageView(); - } - image->SetPosition(183, 941); - image->Resize(100, 100); - image->SetViewId("image"); - - scrollView1_->Add(image); - image->SetVisible(true); - } - void SystemAboutView::DeSystemAboutInitIView() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (scrollView1_ != nullptr) - { - delete scrollView1_; - scrollView1_ = nullptr; - } - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (label2_ != nullptr) - { - delete label2_; - label2_ = nullptr; - } - if (label3_ != nullptr) - { - delete label3_; - label3_ = nullptr; - } - if (label4_ != nullptr) - { - delete label4_; - label4_ = nullptr; - } - if (label5_ != nullptr) - { - delete label5_; - label5_ = nullptr; - } - if (label6_ != nullptr) - { - delete label6_; - label6_ = nullptr; - } - if (label7_ != nullptr) - { - delete label7_; - label7_ = nullptr; - } - if (label8_ != nullptr) - { - delete label8_; - label8_ = nullptr; - } - if (label9_ != nullptr) - { - delete label9_; - label9_ = nullptr; - } - if (label10_ != nullptr) - { - delete label10_; - label10_ = nullptr; - } - if (label11_ != nullptr) - { - delete label11_; - label11_ = nullptr; - } - if (label12_ != nullptr) - { - delete label12_; - label12_ = nullptr; - } - if (label13_ != nullptr) - { - delete label13_; - label13_ = nullptr; - } - if (image != nullptr) - { - delete image; - image = nullptr; - } - } - - void SystemAboutView::OnStart() - { - SystemAboutInitIView(); - RootView::GetInstance()->Add(container_); - } - - void SystemAboutView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void SystemAboutView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void SystemAboutView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp index db7203920..61653686a 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -52,10 +52,14 @@ namespace OHOS } bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event) + { + return true; + } + + bool SystemPresenter::OnDragEnd(UIView &view, const DragEvent &event) { - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); return true; @@ -69,12 +73,12 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_ABOUT_WATCH); - return true; + SystemView::GetInstance()->ChangeView(0,1); + return true; } else if (strcmp(view.GetViewId(), SUPERVISE) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SUPERVISE); + SystemView::GetInstance()->ChangeView(0,2); return true; } else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) @@ -82,16 +86,6 @@ namespace OHOS NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SYSTEM_LANGUAGE); return true; } - else if (strcmp(view.GetViewId(), REBOOT) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_REBOOT); - return true; - } - else if (strcmp(view.GetViewId(), SHOUTDOWM) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SHOUTDOWN); - return true; - } else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) { NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_FACTORY_RESET); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootPresenter.cpp deleted file mode 100644 index ffe00720b..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootPresenter.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "system/include/SystemRebootPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static SystemRebootPresenter *g_pSystemRebootPresenter = nullptr; - - SystemRebootPresenter::SystemRebootPresenter() - { - - g_pSystemRebootPresenter = this; - } - - SystemRebootPresenter::~SystemRebootPresenter() - { - - g_pSystemRebootPresenter = nullptr; - } - - SystemRebootPresenter *SystemRebootPresenter::GetInstance() - { - - return g_pSystemRebootPresenter; - } - - void SystemRebootPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void SystemRebootPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void SystemRebootPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void SystemRebootPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool SystemRebootPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - UNUSED(view); - UNUSED(event); - return true; - } - extern "C" - { - //重启 - uint32_t mcu_os_sys_reset(uint8_t *para, uint32_t para_len); - } - bool SystemRebootPresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), REBOOT_CHECKON) == 0) - { - mcu_os_sys_reset(NULL,NULL); - return true; - } - else if (strcmp(view.GetViewId(), REBOOT_CHECKOFF) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); - return true; - } - return false; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootView.cpp deleted file mode 100644 index 79e337fde..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemRebootView.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "system/include/SystemRebootView.h" -#include "system/include/SystemRebootPresenter.h" - -#include "UiConfig.h" - -namespace OHOS -{ - - static SystemRebootView *g_pSystemRebootView{nullptr}; - - SystemRebootView::SystemRebootView() - { - g_pSystemRebootView = this; - } - - SystemRebootView::~SystemRebootView() - { - DeInitView(); - g_pSystemRebootView = nullptr; - } - - SystemRebootView *SystemRebootView::GetInstance() - { - return g_pSystemRebootView; - } - - void SystemRebootView::InitView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - // Add ImageView to App - if (RebootImage == nullptr) - { - RebootImage = new UIImageView(); - } - RebootImage->SetPosition(0, 0); // widget's left position and top position - RebootImage->Resize(466, 466); // widget's width and height - RebootImage->SetViewId("RebootImage"); // Set style - RebootImage->SetStyle(STYLE_BORDER_RADIUS, 300); - RebootImage->SetSrc("/user/res/system/reboot.bin"); //重新启动 - // Add to rootView - container_->Add(RebootImage); - RebootImage->SetVisible(true); - - // Add Button to App - if (RebootButtonCheckOn == nullptr) - { - RebootButtonCheckOn = new UIButton(); - } - RebootButtonCheckOn->SetPosition(256, 299); // widget's left position and top position - RebootButtonCheckOn->Resize(100, 100); // widget's width and height - RebootButtonCheckOn->SetViewId(REBOOT_CHECKON); // Set style - RebootButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - RebootButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); - RebootButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); - RebootButtonCheckOn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *RebootButtonCheckOnClick = static_cast(SystemRebootPresenter::GetInstance()); - RebootButtonCheckOn->SetOnClickListener(RebootButtonCheckOnClick); - // Add to rootView - container_->Add(RebootButtonCheckOn); - RebootButtonCheckOn->SetVisible(true); - - // Add Button to App - if (RebootButtonCheckOff == nullptr) - { - RebootButtonCheckOff = new UIButton(); - } - RebootButtonCheckOff->SetPosition(111, 299); // widget's left position and top position - RebootButtonCheckOff->Resize(100, 100); // widget's width and height - RebootButtonCheckOff->SetViewId(REBOOT_CHECKOFF); // Set style - RebootButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - RebootButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); - RebootButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); - RebootButtonCheckOff->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *RebootButtonCheckOffClick = static_cast(SystemRebootPresenter::GetInstance()); - RebootButtonCheckOff->SetOnClickListener(RebootButtonCheckOffClick); - // Add to rootView - container_->Add(RebootButtonCheckOff); - RebootButtonCheckOff->SetVisible(true); - } - - void SystemRebootView::DeInitView() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (RebootImage != nullptr) - { - delete RebootImage; - RebootImage = nullptr; - } - if (RebootButtonCheckOn != nullptr) - { - delete RebootButtonCheckOn; - RebootButtonCheckOn = nullptr; - } - if (RebootButtonCheckOff != nullptr) - { - delete RebootButtonCheckOff; - RebootButtonCheckOff = nullptr; - } - } - - void SystemRebootView::OnStart() - { - View::OnStart(); - InitView(); - RootView::GetInstance()->Add(container_); - } - - void SystemRebootView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void SystemRebootView::OnTearDownView() - { - View::OnTearDownView(); - return; - } - - void SystemRebootView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownPresenter.cpp deleted file mode 100644 index b4f0ec387..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownPresenter.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "system/include/SystemShoutDownPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static SystemShoutDownPresenter *g_pSystemShoutDownPresenter = nullptr; - - SystemShoutDownPresenter::SystemShoutDownPresenter() - { - - g_pSystemShoutDownPresenter = this; - } - - SystemShoutDownPresenter::~SystemShoutDownPresenter() - { - - g_pSystemShoutDownPresenter = nullptr; - } - - SystemShoutDownPresenter *SystemShoutDownPresenter::GetInstance() - { - - return g_pSystemShoutDownPresenter; - } - - void SystemShoutDownPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void SystemShoutDownPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void SystemShoutDownPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void SystemShoutDownPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool SystemShoutDownPresenter::OnDrag(UIView &view, const DragEvent &event) - { - UNUSED(view); - UNUSED(event); - return true; - } - extern "C" { - //关机 - void uapi_sys_shipmode(uint32_t arg); - } - bool SystemShoutDownPresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), SHOUTDOWN_BUTTON_CHECKON) == 0) - { - uapi_sys_shipmode(0); - return true; - } - else if (strcmp(view.GetViewId(), SHOUTDOWN_BUTTON_CHECKOFF) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); - return true; - } - return false; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownView.cpp deleted file mode 100644 index 033635479..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemShoutDownView.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "system/include/SystemShoutDownView.h" -#include "system/include/SystemShoutDownPresenter.h" - -#include "UiConfig.h" - -namespace OHOS -{ - - static SystemShoutDownView *g_pSystemShoutDownView{nullptr}; - - SystemShoutDownView::SystemShoutDownView() - { - g_pSystemShoutDownView = this; - } - - SystemShoutDownView::~SystemShoutDownView() - { - DeInitView(); - g_pSystemShoutDownView = nullptr; - } - - SystemShoutDownView *SystemShoutDownView::GetInstance() - { - return g_pSystemShoutDownView; - } - - void SystemShoutDownView::InitView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - // Add ImageView to App - if (ShoutDownImage == nullptr) - { - ShoutDownImage = new UIImageView(); - } - ShoutDownImage->SetPosition(0, 0); // widget's left position and top position - ShoutDownImage->Resize(466, 466); // widget's width and height - ShoutDownImage->SetViewId("ShoutDownImage"); // Set style - ShoutDownImage->SetStyle(STYLE_BORDER_RADIUS, 300); - ShoutDownImage->SetSrc("/user/res/system/shoutdown.bin"); - // Add to rootView - container_->Add(ShoutDownImage); - ShoutDownImage->SetVisible(true); - - // Add Button to App - if (ShoutDownButtonCheckOn == nullptr) - { - ShoutDownButtonCheckOn = new UIButton(); - } - ShoutDownButtonCheckOn->SetPosition(256, 299); // widget's left position and top position - ShoutDownButtonCheckOn->Resize(100, 100); // widget's width and height - ShoutDownButtonCheckOn->SetViewId(SHOUTDOWN_BUTTON_CHECKON); // Set style - ShoutDownButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - ShoutDownButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, nullptr); - ShoutDownButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); - ShoutDownButtonCheckOn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *ShoutDownButtonCheckOnClick = static_cast(SystemShoutDownPresenter::GetInstance()); - ShoutDownButtonCheckOn->SetOnClickListener(ShoutDownButtonCheckOnClick); - // Add to rootView - container_->Add(ShoutDownButtonCheckOn); - ShoutDownButtonCheckOn->SetVisible(true); - - // Add Button to App - if (ShoutDownButtonCheckOff == nullptr) - { - ShoutDownButtonCheckOff = new UIButton(); - } - ShoutDownButtonCheckOff->SetPosition(111, 299); // widget's left position and top position - ShoutDownButtonCheckOff->Resize(100, 100); // widget's width and height - ShoutDownButtonCheckOff->SetViewId(SHOUTDOWN_BUTTON_CHECKOFF); // Set style - ShoutDownButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - ShoutDownButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, nullptr); - ShoutDownButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); - ShoutDownButtonCheckOff->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *ShoutDownButtonCheckOffClick = static_cast(SystemShoutDownPresenter::GetInstance()); - ShoutDownButtonCheckOff->SetOnClickListener(ShoutDownButtonCheckOffClick); - // Add to rootView - container_->Add(ShoutDownButtonCheckOff); - ShoutDownButtonCheckOff->SetVisible(true); - } - - void SystemShoutDownView::DeInitView() - { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (ShoutDownImage != nullptr) - { - delete ShoutDownImage; - ShoutDownImage = nullptr; - } - if (ShoutDownButtonCheckOn != nullptr) - { - delete ShoutDownButtonCheckOn; - ShoutDownButtonCheckOn = nullptr; - } - if (ShoutDownButtonCheckOff != nullptr) - { - delete ShoutDownButtonCheckOff; - ShoutDownButtonCheckOff = nullptr; - } - } - - void SystemShoutDownView::OnStart() - { - View::OnStart(); - InitView(); - RootView::GetInstance()->Add(container_); - } - - void SystemShoutDownView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void SystemShoutDownView::OnTearDownView() - { - View::OnTearDownView(); - return; - } - - void SystemShoutDownView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSupervisePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSupervisePresenter.cpp deleted file mode 100644 index 54050ed52..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSupervisePresenter.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "system/include/SystemSupervisePresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static SystemSupervisePresenter *g_pSystemSupervisePresenter = nullptr; - - SystemSupervisePresenter::SystemSupervisePresenter() - { - - g_pSystemSupervisePresenter = this; - } - - SystemSupervisePresenter::~SystemSupervisePresenter() - { - - g_pSystemSupervisePresenter = nullptr; - } - - SystemSupervisePresenter *SystemSupervisePresenter::GetInstance() - { - - return g_pSystemSupervisePresenter; - } - - void SystemSupervisePresenter::OnStart() - { - - Presenter::OnStart(); - } - - void SystemSupervisePresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void SystemSupervisePresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void SystemSupervisePresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool SystemSupervisePresenter::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_SYSTEM); - return true; - } - return false; - } - - bool SystemSupervisePresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), 控件ID) == 0) - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSuperviseView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSuperviseView.cpp index d410eab5d..39a20c958 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSuperviseView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemSuperviseView.cpp @@ -1,6 +1,6 @@ #include "system/include/SystemSuperviseView.h" -#include "system/include/SystemSupervisePresenter.h" - +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" namespace OHOS { @@ -8,19 +8,19 @@ namespace OHOS SystemSuperviseView::SystemSuperviseView() { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemSuperviseView::SystemSuperviseView"); g_pSystemSuperviseView = this; } SystemSuperviseView::~SystemSuperviseView() { - DeInitView(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemSuperviseView::~SystemSuperviseView"); + ClearAll(); g_pSystemSuperviseView = nullptr; } SystemSuperviseView *SystemSuperviseView::GetInstance() { - return g_pSystemSuperviseView; } UILabel *SystemSuperviseView::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed) @@ -40,137 +40,107 @@ namespace OHOS return label; } - void SystemSuperviseView::InitView() + UIScrollView *SystemSuperviseView::SystemSuperviseViewInit() { - if (container_ == nullptr) + if (SystemSuperviseViewScrollView == nullptr) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - UIView::OnDragListener *draglistener = static_cast(SystemSupervisePresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); + SystemSuperviseViewScrollView = new UIScrollView(); } - if (scrollView1_ == nullptr) + SystemSuperviseViewScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemSuperviseViewScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemSuperviseViewScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) { - scrollView1_ = new UIScrollView(); + return nullptr; } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView"); // Set style - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView1_->SetStyle(STYLE_BORDER_RADIUS, 1294); - - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - /***********************************************************************************************************/ - if (label1_ == nullptr) + SystemSuperviseViewScrollView->SetOnDragListener(draglistener); + SystemSuperviseViewScrollView->SetTouchable(true); + SystemSuperviseViewScrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + if (Title == nullptr) { - label1_ = InitLabel(203, 52, 60, 35, "监管", "label1", 30, 35, 6); + Title = InitLabel(203, 52, 60, 35, "监管", "Title", 30, 35, 6); } - scrollView1_->Add(label1_); - label1_->SetVisible(true); - /***********************************************************************************************************/ - if (label2_ == nullptr) + SystemSuperviseViewScrollView->Add(Title); + /* -------------------------------------------------------------------------- */ + if (ProductModel == nullptr) { - label2_ = InitLabel(203, 164, 60, 35, "型号", "label2", 30, 35, 6); + ProductModel = InitLabel(203, 164, 60, 35, "型号", "ProductModel", 30, 35, 6); } - scrollView1_->Add(label2_); - label2_->SetVisible(true); - /***********************************************************************************************************/ - if (label3_ == nullptr) + SystemSuperviseViewScrollView->Add(ProductModel); + /* -------------------------------------------------------------------------- */ + ProductModelName = new UILabel(); + if (ProductModelName == nullptr) { - label3_ = InitLabel(102, 221, 263, 30, "周冰鸿的 Smart Watch", "label3", 26, 30, 6); + return nullptr; } - label3_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label3_); - label3_->SetVisible(true); - /***********************************************************************************************************/ - if (label4_ == nullptr) + ProductModelName->SetPosition(37, 221, 400, 30); // 位置大小 + ProductModelName->SetStyle(STYLE_TEXT_FONT, 26); // 字体大小 + ProductModelName->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 + ProductModelName->SetText("Watch Soar"); // 内容 + ProductModelName->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 断行模式。 + ProductModelName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ProductModelName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ProductModelName->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemSuperviseViewScrollView->Add(ProductModelName); + /* -------------------------------------------------------------------------- */ + if (CMIT == nullptr) { - label4_ = InitLabel(198, 310, 71, 35, "CMIT", "label4", 30, 35, 6); + CMIT = InitLabel(198, 310, 71, 35, "CMIT", "CMIT", 30, 35, 6); } - scrollView1_->Add(label4_); - label4_->SetVisible(true); - /***********************************************************************************************************/ - if (label5_ == nullptr) + SystemSuperviseViewScrollView->Add(CMIT); + /* -------------------------------------------------------------------------- */ + CMITName = new UILabel(); + if (CMITName == nullptr) { - label5_ = InitLabel(175, 367, 119, 30, "V02.03.01", "label5", 26, 30, 6); + return nullptr; } - label5_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); - scrollView1_->Add(label5_); - label5_->SetVisible(true); + CMITName->SetPosition(37, 367, 400, 30); // 位置大小 + CMITName->SetStyle(STYLE_TEXT_FONT, 26); // 字体大小 + CMITName->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 + CMITName->SetText("V02.03.01"); // 内容 + CMITName->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 断行模式。 + CMITName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + CMITName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + CMITName->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemSuperviseViewScrollView->Add(CMITName); + + return SystemSuperviseViewScrollView; } - void SystemSuperviseView::DeInitView() + void SystemSuperviseView::ClearAll() { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (scrollView1_ != nullptr) + SystemSuperviseViewScrollView->RemoveAll(); + delete draglistener; + draglistener = nullptr; + if (Title != nullptr) { - delete scrollView1_; - scrollView1_ = nullptr; + delete Title; + Title = nullptr; } - if (label1_ != nullptr) + if (ProductModel != nullptr) { - delete label1_; - label1_ = nullptr; + delete ProductModel; + ProductModel = nullptr; } - if (label2_ != nullptr) + if (ProductModelName != nullptr) { - delete label2_; - label2_ = nullptr; + delete ProductModelName; + ProductModelName = nullptr; } - if (label3_ != nullptr) + if (CMIT != nullptr) { - delete label3_; - label3_ = nullptr; + delete CMIT; + CMIT = nullptr; } - if (label4_ != nullptr) + if (CMITName != nullptr) { - delete label4_; - label4_ = nullptr; + delete CMITName; + CMITName = nullptr; } - if (label5_ != nullptr) - { - delete label5_; - label5_ = nullptr; - } - } - - void SystemSuperviseView::OnStart() - { - InitView(); - RootView::GetInstance()->Add(container_); + delete SystemSuperviseViewScrollView; + SystemSuperviseViewScrollView = nullptr; } - void SystemSuperviseView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void SystemSuperviseView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void SystemSuperviseView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp index 029272039..b16c7df4c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp @@ -1,8 +1,6 @@ #include "system/include/SystemView.h" #include "system/include/SystemPresenter.h" - -#include "UiConfig.h" - +#include "wearable_log.h" namespace OHOS { @@ -10,295 +8,286 @@ namespace OHOS SystemView::SystemView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); g_pSystemView = this; } SystemView::~SystemView() { - DeInitView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::~SystemView"); + ClearAll(); g_pSystemView = nullptr; } SystemView *SystemView::GetInstance() { - return g_pSystemView; } - void SystemView::InitIView() + /// @brief 设置SystemScrollView + /// @param void + /// @return true 设置成功,false 失败 + bool SystemView::SetTheSystemScrollView(void) { - if (container_ == nullptr) + SystemScrollView[0] = new UIScrollView(); + if (SystemScrollView == nullptr) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemScrollView new fail!"); + return false; } - /***********************************************************************************************************/ - // Add ScrollView to App - if (SystemScrollView == nullptr) + SystemScrollView[0]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemScrollView[0]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemScrollView[0]->SetScrollBlankSize(35); + SystemScrollView[0]->SetReboundSize(50); + SystemScrollView[0]->SetDirection(1); + draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) { - SystemScrollView = new UIScrollView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + return false; } - SystemScrollView->SetPosition(0, 0); // widget's left position and top position - SystemScrollView->Resize(466, 466); // widget's width and height - SystemScrollView->SetViewId("SystemScrollView"); // Set style - SystemScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - container_->Add(SystemScrollView); - SystemScrollView->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App + SystemScrollView[0]->SetOnDragListener(draglistener); + SystemScrollView[0]->SetTouchable(true); + SystemScrollView[0]->SetDraggable(true); + return true; + } + + /// @brief 设置标题 + /// @param void + /// @return true 设置成功,false 失败 + bool SystemView::SetTheTitle(void) + { + SystemLabel = new UILabel(); if (SystemLabel == nullptr) { - SystemLabel = new UILabel(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!"); + return false; } - SystemLabel->SetPosition(203, 52); // widget's left position and top position - SystemLabel->Resize(200, 60); // widget's width and height - SystemLabel->SetViewId("SystemLabel"); // Set style + SystemLabel->SetPosition(203, 52); SystemLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); SystemLabel->SetStyle(STYLE_TEXT_FONT, 30); SystemLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property SystemLabel->SetText("系统"); SystemLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); SystemLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); SystemLabel->SetRollSpeed(6); SystemLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // Add to scrollView3 - SystemScrollView->Add(SystemLabel); - SystemLabel->SetVisible(true); - /***********************************************************************************************************/ - // Add Button to App - if (AboutTheWatchButton == nullptr) - { - AboutTheWatchButton = new UIButton(); - } - AboutTheWatchButton->SetPosition(43, 120); // widget's left position and top position - AboutTheWatchButton->Resize(380, 100); // widget's width and height - AboutTheWatchButton->SetViewId(ABOUT_THE_WATCH); // Set style //关于手表 - AboutTheWatchButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - AboutTheWatchButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + return true; + } - AboutTheWatchButton->SetImageSrc("/user/res/system/SYSTEM_ABOUT_THE_WATCH.bin", nullptr); - AboutTheWatchButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *AboutTheWatchButtonClick = static_cast(SystemPresenter::GetInstance()); - AboutTheWatchButton->SetOnClickListener(AboutTheWatchButtonClick); - // Add to scrollView3 - SystemScrollView->Add(AboutTheWatchButton); - AboutTheWatchButton->SetVisible(true); - /***********************************************************************************************************/ - // Add Button to App - if (SuperviseButton == nullptr) + /// @brief 设置按钮 + /// @param button + /// @return true 设置成功,false 失败 + UIButton *SystemView::SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener) + { + UIButton *button = new UIButton(); + if (button == nullptr) { - SuperviseButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return nullptr; } - SuperviseButton->SetPosition(43, 240); // widget's left position and top position - SuperviseButton->Resize(380, 100); // widget's width and height - SuperviseButton->SetViewId(SUPERVISE); // Set style //监管 - SuperviseButton->SetStyle(STYLE_BORDER_RADIUS, 50); - SuperviseButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - SuperviseButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - SuperviseButton->SetImageSrc("/user/res/system/SYSTEM_SUPERVISE.bin", nullptr); - SuperviseButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - SuperviseButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button->SetImageSrc(buttonconfig.ImageSrc, nullptr); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetOnClickListener(clickListener); + return button; + } - // Add the CallBack about events - UIView::OnClickListener *SuperviseButtonClick = static_cast(SystemPresenter::GetInstance()); - SuperviseButton->SetOnClickListener(SuperviseButtonClick); - // Add to scrollView3 - SystemScrollView->Add(SuperviseButton); - SuperviseButton->SetVisible(true); - /***********************************************************************************************************/ - // Add Button to App - if (SystemLanguageButton == nullptr) + void SystemView::InitIView(void) + { + if (!SetTheSystemScrollView()) { - SystemLanguageButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView() fail!"); + return; } - SystemLanguageButton->SetPosition(43, 360); // widget's left position and top position - SystemLanguageButton->Resize(380, 100); // widget's width and height - SystemLanguageButton->SetViewId(SYSTEM_LANGUAGE); // Set style //系统语言 - SystemLanguageButton->SetStyle(STYLE_BORDER_RADIUS, 50); - SystemLanguageButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - SystemLanguageButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - SystemLanguageButton->SetImageSrc("/user/res/system/SYSTEM_SYSTEM_LANGUAGE.bin", nullptr); - SystemLanguageButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - SystemLanguageButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *SystemLanguageButtonClick = static_cast(SystemPresenter::GetInstance()); - SystemLanguageButton->SetOnClickListener(SystemLanguageButtonClick); - // Add to scrollView3 - SystemScrollView->Add(SystemLanguageButton); - SystemLanguageButton->SetVisible(true); - /***********************************************************************************************************/ - // Add Button to App - if (RebootButton == nullptr) + if (!SetTheTitle()) { - RebootButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheTitle() fail!"); + return; } - RebootButton->SetPosition(43, 480); // widget's left position and top position - RebootButton->Resize(380, 100); // widget's width and height - RebootButton->SetViewId(REBOOT); // Set style //重启 - RebootButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - RebootButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - RebootButton->SetImageSrc("/user/res/system/SYSTEM_REBOOT.bin", nullptr); - RebootButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *RebootButtonClick = static_cast(SystemPresenter::GetInstance()); - RebootButton->SetOnClickListener(RebootButtonClick); - // Add to scrollView3 - SystemScrollView->Add(RebootButton); - RebootButton->SetVisible(true); - /***********************************************************************************************************/ - // Add Button to App - if (ShoutdownButton == nullptr) + /* -------------------------------------------------------------------------- */ + clickListener = static_cast(SystemPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig buttonconfig; + buttonconfig.x = 43; + buttonconfig.y = 120; + buttonconfig.w = 380; + buttonconfig.h = 100; + buttonconfig.ViewId = ABOUT_THE_WATCH; + buttonconfig.ImageSrc = ABOUT_THE_WATCH_IMAGESRC; + AboutTheWatchButton = SetTheButton(buttonconfig, clickListener); + if (nullptr == AboutTheWatchButton) { - ShoutdownButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::AboutTheWatchButton new fail!"); + return; } - ShoutdownButton->SetPosition(43, 600); // widget's left position and top position - ShoutdownButton->Resize(380, 100); // widget's width and height - ShoutdownButton->SetViewId(SHOUTDOWM); // Set style //关机 - ShoutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - ShoutdownButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - // Set additional property - char *button5triggeredImgSrc = nullptr; - ShoutdownButton->SetImageSrc("/user/res/system/SYSTEM_SHOUTDOWM.bin", nullptr); - ShoutdownButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *ShoutdownButtonClick = static_cast(SystemPresenter::GetInstance()); - ShoutdownButton->SetOnClickListener(ShoutdownButtonClick); - // Add to scrollView3 - SystemScrollView->Add(ShoutdownButton); - ShoutdownButton->SetVisible(true); - - /***********************************************************************************************************/ - // Add Button to App - if (FactoryResetButton == nullptr) + /* -------------------------------------------------------------------------- */ + buttonconfig.y = 240; + buttonconfig.ViewId = SUPERVISE; + buttonconfig.ImageSrc = SUPERVISE_IMAGESRC; + SuperviseButton = SetTheButton(buttonconfig, clickListener); + if (nullptr == SuperviseButton) { - FactoryResetButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SuperviseButton new fail!"); } - FactoryResetButton->SetPosition(43, 720); // widget's left position and top position - FactoryResetButton->Resize(380, 100); // widget's width and height - FactoryResetButton->SetViewId(FACTORY_RESET); // Set style //恢复出厂设置 - FactoryResetButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - FactoryResetButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - FactoryResetButton->SetImageSrc("/user/res/system/SYSTEM_FACTORY_RESET.bin", nullptr); - FactoryResetButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener *FactoryResetButtonClick = static_cast(SystemPresenter::GetInstance()); - FactoryResetButton->SetOnClickListener(FactoryResetButtonClick); - // Add to scrollView3 - SystemScrollView->Add(FactoryResetButton); - FactoryResetButton->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (image1_ == nullptr) + /* -------------------------------------------------------------------------- */ + buttonconfig.y = 360; + buttonconfig.ViewId = SYSTEM_LANGUAGE; + buttonconfig.ImageSrc = SYSTEM_LANGUAGE_IMAGESRC; + SystemLanguageButton = SetTheButton(buttonconfig, clickListener); + if (nullptr == SystemLanguageButton) { - image1_ = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLanguageButton fail!"); + return; } - image1_->SetPosition(171, 801); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1"); // Set style - - // Add to scrollView3 - SystemScrollView->Add(image1_); - image1_->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (image2_ == nullptr) + /* -------------------------------------------------------------------------- */ + buttonconfig.y = 480; + buttonconfig.ViewId = FACTORY_RESET; + buttonconfig.ImageSrc = FACTORY_RESET_LANGUAGE_IMAGESRC; + FactoryResetButton = SetTheButton(buttonconfig, clickListener); + if (nullptr == FactoryResetButton) { - image2_ = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FactoryResetButton fail!"); + return; } - image2_->SetPosition(183, 21); // widget's left position and top position - image2_->Resize(100, 100); // widget's width and height - image2_->SetViewId("image2"); // Set style - // Add to scrollView3 - SystemScrollView->Add(image2_); - image2_->SetVisible(true); + initViewStatus = true; } - void SystemView::DeInitView() + void SystemView::ClearAll() { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (SystemScrollView != nullptr) - { - delete SystemScrollView; - SystemScrollView = nullptr; - } - if (SystemLabel != nullptr) + if (initViewStatus == true) { + SystemScrollView[0]->RemoveAll(); + for (int i = 0; i < 3; i++) + { + delete SystemScrollView[i]; + SystemScrollView[i] = nullptr; + } delete SystemLabel; SystemLabel = nullptr; - } - if (image2_ != nullptr) - { - delete image2_; - image2_ = nullptr; - } - if (image1_ != nullptr) - { - delete image1_; - image1_ = nullptr; - } - if (FactoryResetButton != nullptr) - { + delete AboutTheWatchButton; + AboutTheWatchButton = nullptr; + delete SuperviseButton; + SuperviseButton = nullptr; + delete SystemLanguageButton; + SystemLanguageButton = nullptr; delete FactoryResetButton; FactoryResetButton = nullptr; } - if (ShoutdownButton != nullptr) + } + + bool SystemView::ChangeSystemView(int16_t thisView) + { + RootView::GetInstance()->Add(SystemScrollView[thisView]); + return true; + } + + //跳转到关于手表 + bool SystemView::ChangeSystemAboutView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) { - delete ShoutdownButton; - ShoutdownButton = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + p_SystemAboutTheWatchView = new SystemAboutTheWatchView(); + if (p_SystemAboutTheWatchView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemAboutTheWatchView->SystemAbouTheWatchtInitIView(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); } - if (RebootButton != nullptr) + return true; + } + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + struct SystemViewMapper + { + const int16_t viewId; + bool (SystemView::*func)(int16_t thisView); + }; + + //跳转到系统监管 + bool SystemView::ChangeSystemSuperviseView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) { - delete RebootButton; - RebootButton = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemSuperviseView"); + p_SystemSuperviseView = new SystemSuperviseView(); + if (p_SystemSuperviseView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemSuperviseView->SystemSuperviseViewInit(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); } - if (AboutTheWatchButton != nullptr) + return true; + } + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 + static const SystemViewMapper ViewMapper[] = { - delete AboutTheWatchButton; - AboutTheWatchButton = nullptr; - } - if (SuperviseButton != nullptr) + {0, &SystemView::ChangeSystemView}, + {1, &SystemView::ChangeSystemAboutView}, + {2, &SystemView::ChangeSystemSuperviseView} + }; + + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 + bool SystemView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) { - delete SuperviseButton; - SuperviseButton = nullptr; + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } } - if (SystemLanguageButton != nullptr) + return false; + } + + // 4.切换视图 + void SystemView::ChangeView(int16_t hideView, int16_t showView) + { + if (hideView > 4) { - delete SystemLanguageButton; - SystemLanguageButton = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: StopWatchViewId Overstep ones bounds"); + return; } + SystemScrollView[hideView]->SetVisible(false); + ClickFunc(showView); + SystemScrollView[showView]->SetVisible(true); + Draw(); } void SystemView::OnStart() { View::OnStart(); InitIView(); - RootView::GetInstance()->Add(container_); } void SystemView::OnSetUpView() { View::OnSetUpView(); + if (SystemScrollView[0] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); + return; + } + SystemScrollView[0]->Add(SystemLabel); + SystemScrollView[0]->Add(AboutTheWatchButton); + SystemScrollView[0]->Add(SuperviseButton); + SystemScrollView[0]->Add(SystemLanguageButton); + SystemScrollView[0]->Add(FactoryResetButton); + RootView::GetInstance()->Add(SystemScrollView[0]); Draw(); }