From: luozheng <1732036298@qq.com> Date: Mon, 6 May 2024 12:44:58 +0000 (+0800) Subject: 修改系统视图删除不必要的图片和代码,解决内存泄漏问题 X-Git-Tag: release_V1.2.70_20241020_135402~1113^2~20 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=423550c1264ffdb0e83dd26d26f7dfe3435c788f;p=mirrors%2FFD230.git 修改系统视图删除不必要的图片和代码,解决内存泄漏问题 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index dbbe46a20..f914e30b9 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -360,7 +360,6 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemModel.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/SystemLanguageView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/Systemupgrade.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt index c4042f1f6..1ed32637b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt @@ -301,4 +301,10 @@ STR_LIST_DISPLAY$List display STR_GRID_DISPLAY$Grid Display STR_CELLULAR_DISPLAY$Cellular Display STR_AUTO_DETECT$Auto Detect +STR_ABOUT_WATCH$About Watch +STR_WATCH_QR_CODE$watch QR code +STR_SYSTEM_LANGUAGE$System Language +STR_RESTART$ Restart +STR_SHUTDOWN$Shutdown +STR_FACTORY_RESET$Factory Reset STR_LANGUAGE$Language \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt index 6e435c7c5..230c8118a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt @@ -301,4 +301,10 @@ STR_LIST_DISPLAY$列表显示 STR_GRID_DISPLAY$网格显示 STR_CELLULAR_DISPLAY$蜂窝显示 STR_AUTO_DETECT$自动识别 +STR_ABOUT_WATCH$关于手表 +STR_WATCH_QR_CODE$手表二维码 +STR_SYSTEM_LANGUAGE$系统语言 +STR_RESTART$重启 +STR_SHUTDOWN$关机 +STR_FACTORY_RESET$恢复出厂 STR_LANGUAGE$语言 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml index bdddb5422..a8fbd3303 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml @@ -302,5 +302,11 @@ + + + + + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml index 6597a5a85..9b884e705 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml @@ -302,5 +302,11 @@ + + + + + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang index 75b51af23..e564ebbb6 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang index 00b01737d..7c3cc078d 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h index e26afe878..5bf80d159 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h @@ -314,8 +314,14 @@ enum UIResourceTextId : uint16_t { STR_GRID_DISPLAY = 301, STR_CELLULAR_DISPLAY = 302, STR_AUTO_DETECT = 303, - STR_LANGUAGE = 304, - STR_MAX_ID = 305, + STR_ABOUT_WATCH = 304, + STR_WATCH_QR_CODE = 305, + STR_SYSTEM_LANGUAGE = 306, + STR_RESTART = 307, + STR_SHUTDOWN = 308, + STR_FACTORY_RESET = 309, + STR_LANGUAGE = 310, + STR_MAX_ID = 311, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang index 3ba13c590..9e1c67a87 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h index e0fefb4a1..4335a6445 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-15 18:20:29 + * @LastEditTime: 2024-05-06 19:09:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h */ #ifndef SYSTEM_ABOUT_VIEW_H @@ -17,6 +17,7 @@ #include namespace OHOS { + static constexpr const char *SYSTEMABOUTTHEWATCHVIEWID = "SystemAboutTheWatchView"; // 关于手表 class SystemAboutTheWatchView { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLanguageView.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLanguageView.h deleted file mode 100644 index 72c5de6a7..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemLanguageView.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef SYSTEM_LANGUAGE_VIEW_H -#define SYSTEM_LANGUAGE_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_radio_button.h" -#include "components/ui_image_view.h" -#include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" -namespace OHOS -{ - class SystemLanguageView - { - - public: - struct ImageConfig - { - int x; - int y; - int w; - int h; - const char *ImageSrc; - }; - 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; // 断行模式。 - }; - struct RadioButtonConfig - { - int16_t left; - int16_t top; - int16_t width; - int16_t height; - const char *name; - const char *viewId; - const char *select; - const char *unselect; - }; - SystemLanguageView(); - virtual ~SystemLanguageView(); - static SystemLanguageView *GetInstance(void); - UIScrollView *SystemLanguageViewInit(void); // 系统语言视图初始化 - void ClearAll(void); // 清除所有组件 - UIImageView *SetUpImageVIew(ImageConfig &imageconfig); // 设置图片 - UILabel *SetUpLabel(LabelConfig &labelconfig); // 设置标签 - UIRadioButton *SetUpRadioButton(RadioButtonConfig &radiobutton); // 设置单选按钮 - void SetRadioButtonSelectStatus(UIRadioButton &radiobutton, bool state); // 设置单选框的选择状态 - private: - UIScrollView *scrollView = nullptr; - UILabelExt *Title = nullptr; // 标题 - UIImageView *Background[2]{nullptr}; // 放组件的背景 - UILabel *SimplifiedChineseLabel = nullptr; - UILabel *EnglishLabel = nullptr; - UIRadioButton *SimplifiedChineseRadioButton = nullptr; - UIRadioButton *EnglishRadioButton = nullptr; - bool initViewStatus{false}; - }; -} // namespace OHOS -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h index 6c05a167c..6216ba778 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 18:29:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-02 16:00:14 + * @LastEditTime: 2024-05-06 19:56:05 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h */ @@ -22,53 +22,23 @@ namespace OHOS { SYSTEMVIEW = 0, // 系统视图(slice) ABOUTTHEWATCHVIEW, // 关于手表视图(subView) - SUPERVISEVIEW, // 监管视图(subView) + SYSTEMLUPGRADE, // 系统升级(subView) + WATCHQRCODE, // 手表二维码视图(subView) SYSTEMLANGUAGEVIEW, // 系统语言视图(subView) FACTORYRESETVIEW, // 恢复出厂设置视图(subView)upgrade - SYSTEMLUPGRADE, TEST, MAX_SYSTEMVIEWID, } SYSTEMVIEWID; - /* ---------------------------- 系统语言界面单选按钮VIEWID ---------------------------- */ - static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 - static const char *ENGLISH_CHECKBOX = "EnglishCheckBox"; // English /* ---------------------------- 恢复出厂设置界面按钮的VIEWID --------------------------- */ static const char *FACTORYRESET_CHECKON = "ShoutDownButtonCheckOn"; // 确认 static const char *FACTORYRESET_CHECKOFF = "ShoutDownButtonCheckOff"; // 取消 - class RadiobuttonOnChangeListener : public UICheckBox::OnChangeListener - { - public: - RadiobuttonOnChangeListener(UIRadioButton *uiView, UILabelExt *label) - { - m_uiView = uiView; - m_label = label; - } - ~RadiobuttonOnChangeListener() {} - bool isChineseRadioButtonSelected(); - bool isEnglishRadioButtonSelected(); - bool OnChange(UICheckBox::UICheckBoxState state) override; - - private: - UIRadioButton *m_uiView{nullptr}; - UILabelExt *m_label{nullptr}; - }; - - class SystemViewOnDragListener : public UIView::OnDragListener - { - public: - SystemViewOnDragListener() {} - ~SystemViewOnDragListener() {} - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnDragEnd(UIView &view, const DragEvent &event) override; - }; class SystemView; class SystemPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, - public UIView::OnDragListener, - public UICheckBox::OnChangeListener, + public UIView::OnDragListener, public UIView::OnTouchListener { public: @@ -81,7 +51,8 @@ namespace OHOS void OnStop() override; static SystemPresenter *GetInstance(); - void set_key_falg(bool); + //void set_key_falg(bool); + private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; @@ -89,11 +60,11 @@ namespace OHOS bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 bool OnPress(UIView &view, const PressEvent &event) override; - bool OnChange(UICheckBox::UICheckBoxState state) override; private: SystemModel *systemModel; - bool isSystemUpgradeState{false};//是否处于升级状态 + //bool isSystemUpgradeState{false}; // 是否处于升级状态 + bool X_DRAG_FLAG{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h index 7036fff06..c906f84ca 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 18:29:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-06 20:35:44 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h + */ #ifndef SYSTEM_VIEW_H #define SYSTEM_VIEW_H @@ -12,22 +19,17 @@ #include "components/ui_label_button_ext.h" #include "system/include/SystemAboutTheWatchView.h" #include "system/include/SystemSuperviseView.h" -#include "system/include/SystemLanguageView.h" #include "system/include/SystemFactoryResetView.h" #include "system/include/Systemupgrade.h" #include "components/ui_toggle_button.h" namespace OHOS { - static const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 - static const char *SUPERVISE = "SuperviseButton"; // 监管 - static const char *SYSTEM_LANGUAGE = "SystemLanguageButton"; // 系统语言 - static const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 - static const char *SYSTEM_UPGRADE = "SystemUpgradeButtonExt"; // 系统升级 - 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"; + static constexpr const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 + static constexpr const char *SYSTEM_UPGRADE = "SystemUpgradeButtonExt"; // 系统升级 + static constexpr const char *WATCH_QR_CODE = "WatchqrcodeButton"; // 手表二维码 + static constexpr const char *SYSTEM_LANGUAGE = "SystemLanguageButton"; // 系统语言 + static constexpr const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 class SystemPresenter; class SystemView : public View { @@ -41,22 +43,15 @@ 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; - }; + struct ButtonConfig_ext_t { int x; int y; int w; int h; - const char *str; + // const char *str; + uint16_t textId; const char *ViewId; const char *ImageSrc; @@ -69,7 +64,7 @@ namespace OHOS bool ChangeSystemView(int16_t thisView); bool ChangeSystemAboutView(int16_t thisView); - bool ChangeSystemSuperviseView(int16_t thisView); + bool ChangeWatchQRCodeView(int16_t thisView); bool ChangeSystemLanguageView(int16_t thisView); bool ChangeSystemFactoryResetView(int16_t thisView); bool ChangeSystemupgradeView(int16_t thisView); @@ -82,16 +77,14 @@ namespace OHOS void ClearAll(void); bool SetTheSystemScrollView(void); bool SetTheTitle(void); - bool Cat1_4GabilityButtonViewInit(); UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &ButtonConfig_ext, UIView::OnClickListener *clickListener); - SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; - SystemSuperviseView *p_SystemSuperviseView{nullptr}; - SystemLanguageView *p_SystemLanguageView{nullptr}; - SystemFactoryResetView *p_SystemFactoryResetView{nullptr}; - SystemupgradeView *p_SystemupgradeView{nullptr}; + SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; // 关于手表 + SystemupgradeView *p_SystemupgradeView{nullptr}; // 系统升级 + SystemSuperviseView *p_WatchQRCodeView{nullptr}; // 手表二维码 + SystemFactoryResetView *p_SystemFactoryResetView{nullptr}; // 恢复出厂设置 UIScrollView *SystemScrollView[10]{nullptr}; - UILabelExt *SystemLabel{nullptr}; // 标题 - bool initViewStatus{false}; + UILabelExt *Title{nullptr}; // 标题 + UILabelButtonExt *SystemViewButton[5]{nullptr}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp index feab9bcb4..6eed99b36 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp @@ -177,7 +177,7 @@ namespace OHOS SystemAboutTheWatchScrollView->SetTouchable(true); SystemAboutTheWatchScrollView->SetDraggable(true); - SystemAboutTheWatchScrollView->SetViewId("SystemAboutTheWatchTitle"); + SystemAboutTheWatchScrollView->SetViewId(SYSTEMABOUTTHEWATCHVIEWID); UIView::OnClickListener *touch = static_cast(SystemPresenter::GetInstance()); SystemAboutTheWatchScrollView->SetOnClickListener(touch); return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp deleted file mode 100644 index 08452c61e..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "system/include/SystemLanguageView.h" -#include "system/include/SystemPresenter.h" -#include "string.h" -#include "UiConfig.h" -#include "wearable_log.h" - -namespace OHOS -{ - - static SystemLanguageView *g_pSystemLanguageView{nullptr}; - - SystemLanguageView::SystemLanguageView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::SystemLanguageView"); - g_pSystemLanguageView = this; - } - - SystemLanguageView::~SystemLanguageView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::~SystemLanguageView"); - ClearAll(); - g_pSystemLanguageView = nullptr; - } - - SystemLanguageView *SystemLanguageView::GetInstance() - { - return g_pSystemLanguageView; - } - - void SystemLanguageView::ClearAll() - { - if (initViewStatus == true) - { - scrollView->RemoveAll(); - delete Title; - Title = nullptr; - for (int i = 0; i < 2; i++) - { - delete Background[i]; - Background[i] = nullptr; - } - delete SimplifiedChineseLabel; - SimplifiedChineseLabel = nullptr; - delete EnglishLabel; - EnglishLabel = nullptr; - delete SimplifiedChineseRadioButton; - SimplifiedChineseRadioButton = nullptr; - delete EnglishRadioButton; - EnglishRadioButton = nullptr; - delete scrollView; - scrollView = nullptr; - } - } - - // 设置图片 - UIImageView *SystemLanguageView::SetUpImageVIew(ImageConfig &imageconfig) - { - UIImageView *Image = new UIImageView(); - if (Image == nullptr) - { - return nullptr; - } - Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h); - Image->SetSrc(imageconfig.ImageSrc); - return Image; - } - - // 设置标签 - UILabel *SystemLanguageView::SetUpLabel(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; - } - - // 设置单选按钮 - UIRadioButton *SystemLanguageView::SetUpRadioButton(RadioButtonConfig &radioButtonconfig) - { - UIRadioButton *radiobutton = new UIRadioButton(radioButtonconfig.name); - if (radiobutton == nullptr) - { - return nullptr; - } - radiobutton->SetPosition(radioButtonconfig.left, radioButtonconfig.top, radioButtonconfig.width, radioButtonconfig.height); - radiobutton->SetViewId(radioButtonconfig.viewId); - radiobutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - radiobutton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - radiobutton->SetImages(radioButtonconfig.select, radioButtonconfig.unselect); - return radiobutton; - } - - // 设置单选框的选择状态 - void SystemLanguageView::SetRadioButtonSelectStatus(UIRadioButton &radiobutton, bool state) - { - if (state == true) - { - radiobutton.SetState(UICheckBox::SELECTED); - } - else - { - radiobutton.SetState(UICheckBox::UNSELECTED); - } - } - - UIScrollView *SystemLanguageView::SystemLanguageViewInit(void) - { - /* ------------------------------- scrollView ------------------------------- */ - scrollView = new UIScrollView(); - if (scrollView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::scrollView new fail!"); - } - scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); - UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); - if (draglistener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "function = %s,Line = %d,draglistener can not be nullptr!", __FUNCTION__, __LINE__); - return nullptr; - } - scrollView->SetOnDragListener(draglistener); - /* ---------------------------------- Title --------------------------------- */ - Title = new UILabelExt(); - if (Title == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::Title new fail!"); - return nullptr; - } - Title->SetPosition(203, 52, 200, 35); - Title->SetTextId(0); - // Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView->Add(Title); - /* ------------------------------- Background ------------------------------- */ - ImageConfig imageconfig = { - .x = 43, - .y = 120, - .w = 380, - .h = 100, - .ImageSrc = "/user/res/SETTING_BACKGROUND.bin", - }; - Background[0] = SetUpImageVIew(imageconfig); - if (Background[0] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::Background[0] new fail!"); - return nullptr; - } - imageconfig.y = 240; - Background[1] = SetUpImageVIew(imageconfig); - if (Background[1] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::Background[1] new fail!"); - return nullptr; - } - scrollView->Add(Background[0]); - scrollView->Add(Background[1]); - /* ------------------------- SimplifiedChineseLabel ------------------------- */ - LabelConfig labelconfig = { - .left = 90, - .top = 153, - .width = 200, - .height = 60, - .fontSize = 30, - .lineHeigh = 35, - .text = "简体中文", - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, - }; - SimplifiedChineseLabel = SetUpLabel(labelconfig); - if (SimplifiedChineseLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::SimplifiedChineseLabel new fail!"); - return nullptr; - } - scrollView->Add(SimplifiedChineseLabel); - /* ------------------------------ EnglishLabel ------------------------------ */ - labelconfig.top = 273; - labelconfig.text = "ENGLISH"; - EnglishLabel = SetUpLabel(labelconfig); - if (EnglishLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::EnglishLabel new fail!"); - return nullptr; - } - scrollView->Add(EnglishLabel); - /* ---------------------- SimplifiedChineseRadioButton ---------------------- */ - RadioButtonConfig radioButtonConfig = { - .left = 300, - .top = 130, - .width = 80, - .height = 80, - .name = "LanguageCategory", - .viewId = SIMPLIFIED_CHINESE_CHECKBOX, - .select = "/user/res/CHECKBOX_ON.bin", - .unselect = "/user/res/CHECKBOX_OFF.bin", - }; - SimplifiedChineseRadioButton = SetUpRadioButton(radioButtonConfig); - if (SimplifiedChineseRadioButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::SimplifiedChineseRadioButton new fail!"); - return nullptr; - } - SetRadioButtonSelectStatus(*SimplifiedChineseRadioButton, true); - UICheckBox::OnChangeListener *SimplifiedChineseRadioButtonChange = static_cast(new RadiobuttonOnChangeListener(SimplifiedChineseRadioButton, Title)); - SimplifiedChineseRadioButton->SetOnChangeListener(SimplifiedChineseRadioButtonChange); - scrollView->Add(SimplifiedChineseRadioButton); - /* --------------------------- EnglishRadioButton --------------------------- */ - radioButtonConfig.left = 300; - radioButtonConfig.top = 250; - radioButtonConfig.viewId = ENGLISH_CHECKBOX; - EnglishRadioButton = SetUpRadioButton(radioButtonConfig); - if (EnglishRadioButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::EnglishRadioButton new fail!"); - return nullptr; - } - UICheckBox::OnChangeListener *EnglishRadioButtonChange = static_cast(new RadiobuttonOnChangeListener(EnglishRadioButton, Title)); - EnglishRadioButton->SetOnChangeListener(EnglishRadioButtonChange); - scrollView->Add(EnglishRadioButton); - initViewStatus = true; - return scrollView; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index 6829336ab..96c45f3c3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -17,21 +17,6 @@ namespace OHOS { - struct SystemView_ext_p - { - const int16_t viewId; - char *viewid_str; - bool enable_falg; - }; - - static SystemView_ext_p ViewMapper_t[] = { - {ABOUTTHEWATCHVIEW, "AboutTheWatchButton", true}, - {SUPERVISEVIEW, "SuperviseButton", true}, - {SYSTEMLANGUAGEVIEW, "SystemLanguageButton", false}, - {FACTORYRESETVIEW, "FactoryResetButton", true}, - {SYSTEMLUPGRADE, "systemupgread", true}, - }; - // 当前Presenter属性实例化的内存指针 static SystemPresenter *g_pSystemPresenter = nullptr; @@ -85,29 +70,49 @@ namespace OHOS return true; } - bool SystemPresenter::OnChange(UICheckBox::UICheckBoxState state) - { - return true; - } - bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SystemPresenter::X_DRAG_FLAG = true; + } return true; } bool SystemPresenter::OnDragEnd(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnDragEnd"); SystemView *p_SystemView = SystemView::GetInstance(); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + if (p_SystemView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::GetInstance fail!"); + return false; + } + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SystemPresenter::X_DRAG_FLAG) { - for (int i = 1; i < MAX_SYSTEMVIEWID; i++) + if (&view == p_SystemView->GetSystemScrollView(SYSTEMVIEW)) { - if (p_SystemView->GetSystemScrollView(i) != nullptr && p_SystemView->GetSystemScrollView(i)->IsVisible() == true) - { - p_SystemView->ChangeView(i, SYSTEMVIEW); - break; - } + NativeAbility::GetInstance().Back(); } + else if (&view == p_SystemView->GetSystemScrollView(ABOUTTHEWATCHVIEW)) + { + p_SystemView->ChangeView(ABOUTTHEWATCHVIEW, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(SYSTEMLUPGRADE)) + { + p_SystemView->ChangeView(SYSTEMLUPGRADE, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(WATCHQRCODE)) + { + p_SystemView->ChangeView(WATCHQRCODE, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(FACTORYRESETVIEW)) + { + p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); + } + SystemPresenter::X_DRAG_FLAG = false; return true; } return false; @@ -116,12 +121,15 @@ namespace OHOS // 该点击回调主要用于在系统视图界面进行跳转视图 bool SystemPresenter::OnClick(UIView &view, const ClickEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnClick"); SystemView *p_SystemView = SystemView::GetInstance(); - int len = sizeof(ViewMapper_t) / sizeof(SystemView_ext_p); - // int len=5; - // 根据控件id查找是哪个控件触发了点击回调 + if (p_SystemView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::GetInstance fail!"); + return false; + } - if (strcmp(view.GetViewId(), "SystemAboutTheWatchTitle") == 0) + if (strcmp(view.GetViewId(), SYSTEMABOUTTHEWATCHVIEWID) == 0) // 连续点击进入产测模式 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchTitle"); if (time == 0) @@ -149,153 +157,70 @@ namespace OHOS } return true; } - - if (strcmp(view.GetViewId(), "SystemLanguageButton") == 0) + else if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) // 点击进入关于手表界面 { - NativeAbility::GetInstance().EnterSlice(VIEW_LANGUAGE_SWITCH); + p_SystemView->ChangeView(SYSTEMVIEW, ABOUTTHEWATCHVIEW); return true; } - - for (int i = 0; i < len; i++) + else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) // 点击进入系统升级视图 { - if (strcmp(view.GetViewId(), ViewMapper_t[i].viewid_str) == 0) - { - if (i == 5) - { - - break; - } - - if (ViewMapper_t[i].enable_falg == true) - SystemView::GetInstance()->ChangeView(SYSTEMVIEW, ViewMapper_t[i].viewId); - time = 0; - return true; - } + p_SystemView->ChangeView(SYSTEMVIEW, SYSTEMLUPGRADE); + return true; } - - if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) + else if (strcmp(view.GetViewId(), WATCH_QR_CODE) == 0) // 点击进入手表二维码视图 { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING,NULL,0); + p_SystemView->ChangeView(SYSTEMVIEW, WATCHQRCODE); return true; } - else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKOFF) == 0) + else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) // 点击进入系统语言界面 { - p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); + NativeAbility::GetInstance().EnterSlice(VIEW_LANGUAGE_SWITCH); return true; } - - if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) + else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) // 点击进入恢复出厂设置界面 { - isSystemUpgradeState = true; - SystemupgradeView::GetInstance()->statr_down_fwpkg(); + p_SystemView->ChangeView(SYSTEMVIEW, FACTORYRESETVIEW); + return true; } - if (strcmp(view.GetViewId(), "labelButton1_exit") == 0) + else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) // 恢复出厂设置确认 { - // SystemView::GetInstance()->ChangeSlice(VIEW_SETTING);; - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - isSystemUpgradeState = false; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0); + return true; } - return true; - } - - // 该拖拽是用来处理系统视图(slice)的左滑退出事件和子视图的左滑退出到系统视图区分开 - bool SystemViewOnDragListener::OnDrag(UIView &view, const DragEvent &event) - { - return true; - } - - bool SystemViewOnDragListener::OnDragEnd(UIView &view, const DragEvent &event) - { - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)) + else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKOFF) == 0) // 恢复出厂设置取消 { - SystemPresenter::GetInstance()->set_key_falg(false); - NativeAbility::GetInstance().Back(); + p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); + return true; } - return true; - } - /// @brief 简体中文单选按钮被选中 - /// @param void - /// @return true 表示选中 ,false 表示未选中 - bool RadiobuttonOnChangeListener::isChineseRadioButtonSelected(void) - { - if (m_uiView->GetState() == UICheckBox::SELECTED && m_uiView->GetViewId() == SIMPLIFIED_CHINESE_CHECKBOX) + + if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) //点击是否立即升级 { - return true; + SystemupgradeView::GetInstance()->statr_down_fwpkg(); } - RootView::GetInstance()->Invalidate(); - return false; - } - - /// @brief 英语单选按钮被选中 - /// @param void - /// @return true 表示选中 ,false 表示未选中 - bool RadiobuttonOnChangeListener::isEnglishRadioButtonSelected(void) - { - if (m_uiView->GetState() == UICheckBox::SELECTED && m_uiView->GetViewId() == ENGLISH_CHECKBOX) + if (strcmp(view.GetViewId(), "labelButton1_exit") == 0) //稍后再说 { - return true; + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); } - return false; - } - - /* -------------------------------------------------------------------------- */ - // 获取语言类 - //language *g_planguage = new language(); - /* -------------------------------------------------------------------------- */ - // 用来监听语言切换 - bool RadiobuttonOnChangeListener::OnChange(UICheckBox::UICheckBoxState state) - { - // language *g_planguage; - // // static const char *en = "user/res/font/en.lang"; - // // static const char *zh_CN = "user/res/font/zh.lang"; - // switch (state) - // { - // case UICheckBox::SELECTED: - // if (isChineseRadioButtonSelected()) - // { - // // 中文文本 - // g_planguage->ChangeLanguage(LanguageId::ZH_CN); - // } - // else if (isEnglishRadioButtonSelected()) - // { - // // 英语文本 - // g_planguage->ChangeLanguage(LanguageId::EN); - // } - // m_label->SetTextId(0); - // // 强制刷新 - // m_label->ForceResetText(); - // RootView::GetInstance()->Invalidate(); - // break; - // case UICheckBox::UNSELECTED: - // // Handle unselected state if needed - // break; - // default: - // break; - // } return true; } bool SystemPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 { - if (!isSystemUpgradeState) - { // 如果处于系统升级状态power键返回功能无效 - UNUSED(view); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnKeyAct"); - uint16 keyID = event.GetKeyId(); - uint16 keyState = event.GetState(); - // 如果是power键,且是亮屏状态,按键释放就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) - { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().Back(); - } + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnKeyAct"); + uint16 keyID = event.GetKeyId(); + uint16 keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); } return true; } - void SystemPresenter::set_key_falg(bool falg) // 增加按键事件 - { - isSystemUpgradeState = falg; - } + // void SystemPresenter::set_key_falg(bool falg) // 增加按键事件 + // { + // isSystemUpgradeState = falg; + // } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index dd4a526ec..88384fca8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -3,6 +3,7 @@ #include "wearable_log.h" #include "bleService.h" #include "battery_hal.h" +#include "language/font/ui_resource_string.h" extern uint8_t battery_get_voltage(float *voltage); namespace OHOS { @@ -13,19 +14,53 @@ namespace OHOS { const int16_t viewId; const char *viewid_str; - const char *Labe_str; + // const char *Labe_str; + uint16_t textId; bool (SystemView::*func)(int16_t thisView); }; - static UILabelButtonExt *button[10] = {NULL}; SystemViewMapper_ext ViewMapper_t[] = { - {ABOUTTHEWATCHVIEW, "AboutTheWatchButton", "关于手表", &SystemView::ChangeSystemAboutView}, - {SUPERVISEVIEW, "SuperviseButton", "监管模式", &SystemView::ChangeSystemSuperviseView}, - {SYSTEMLANGUAGEVIEW, "SystemLanguageButton", "切换语言", &SystemView::ChangeSystemLanguageView}, - {FACTORYRESETVIEW, "FactoryResetButton", "恢复出厂", &SystemView::ChangeSystemFactoryResetView}, - {SYSTEMLUPGRADE, "systemupgread", "系统升级", &SystemView::ChangeSystemupgradeView}, + {ABOUTTHEWATCHVIEW, ABOUT_THE_WATCH, STR_ABOUT_WATCH, &SystemView::ChangeSystemAboutView}, + {SYSTEMLUPGRADE, SYSTEM_UPGRADE, STR_SYSTEM_UPDATE, &SystemView::ChangeSystemupgradeView}, + {WATCHQRCODE, WATCH_QR_CODE, STR_WATCH_QR_CODE, &SystemView::ChangeWatchQRCodeView}, + {SYSTEMLANGUAGEVIEW, SYSTEM_LANGUAGE, STR_SYSTEM_LANGUAGE, &SystemView::ChangeSystemLanguageView}, + {FACTORYRESETVIEW, FACTORY_RESET, STR_FACTORY_RESET, &SystemView::ChangeSystemFactoryResetView}, + }; + // 根据传入的interface参数执行相应视图ID关联的成员函数。 + bool SystemView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper_t) / sizeof(ViewMapper_t[SYSTEMVIEW]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper_t[i].viewId) + { + bool jug = (this->*(ViewMapper_t[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + // 切换视图 + void SystemView::ChangeView(int16_t hideView, int16_t showView) + { + if (hideView > MAX_SYSTEMVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); + return; + } + SystemScrollView[hideView]->SetVisible(false); + ClickFunc(showView); + SystemScrollView[showView]->SetVisible(true); + Draw(); + } + SystemView::SystemView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); @@ -46,14 +81,20 @@ namespace OHOS void SystemView::ClearAll() { - if (initViewStatus == true) + if (SystemScrollView[SYSTEMVIEW] != nullptr) { SystemScrollView[SYSTEMVIEW]->RemoveAll(); - UIView::OnDragListener *draglistener = SystemScrollView[SYSTEMVIEW]->GetOnDragListener(); - if (draglistener != nullptr) + + if (Title != nullptr) { - delete draglistener; - draglistener = nullptr; + delete Title; + Title = nullptr; + } + + for (int i = 0; i < (sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext)); i++) + { + delete SystemViewButton[i]; + SystemViewButton[i] = nullptr; } if (p_SystemAboutTheWatchView != nullptr) @@ -61,16 +102,17 @@ namespace OHOS delete p_SystemAboutTheWatchView; p_SystemAboutTheWatchView = nullptr; } - if (p_SystemSuperviseView != nullptr) + + if (p_SystemupgradeView != nullptr) { - delete p_SystemSuperviseView; - p_SystemSuperviseView = nullptr; + delete p_SystemupgradeView; + p_SystemupgradeView = nullptr; } - if (p_SystemLanguageView != nullptr) + if (p_WatchQRCodeView != nullptr) { - delete p_SystemLanguageView; - p_SystemLanguageView = nullptr; + delete p_WatchQRCodeView; + p_WatchQRCodeView = nullptr; } if (p_SystemFactoryResetView != nullptr) @@ -79,12 +121,6 @@ namespace OHOS p_SystemFactoryResetView = nullptr; } - if (SystemLabel != nullptr) - { - delete SystemLabel; - SystemLabel = nullptr; - } - delete SystemScrollView[SYSTEMVIEW]; SystemScrollView[SYSTEMVIEW] = nullptr; } @@ -106,7 +142,7 @@ namespace OHOS SystemScrollView[SYSTEMVIEW]->SetScrollBlankSize(35); SystemScrollView[SYSTEMVIEW]->SetReboundSize(50); SystemScrollView[SYSTEMVIEW]->SetDirection(1); - UIView::OnDragListener *draglistener = static_cast(new SystemViewOnDragListener()); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); if (draglistener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); @@ -123,21 +159,22 @@ namespace OHOS /// @return true 设置成功,false 失败 bool SystemView::SetTheTitle(void) { - SystemLabel = new UILabelExt(); - if (SystemLabel == nullptr) + Title = new UILabelExt(); + if (Title == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::Title new fail!"); return false; } - SystemLabel->SetPosition(203, 52); - SystemLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemLabel->SetStyle(STYLE_TEXT_FONT, 30); - SystemLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - 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); + Title->SetPosition(83, 52, 300, 35); + Title->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + // Title->SetText("系统"); + Title->SetTextId(STR_SYSTEM); + Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + // Title->SetRollSpeed(6); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); return true; } @@ -156,7 +193,8 @@ namespace OHOS button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); button->SetOnClickListener(clickListener); - button->SetText(buttonconfig.str); + // button->SetText(buttonconfig.str); + button->SetTextId(buttonconfig.textId); button->SetAlign(TEXT_ALIGNMENT_LEFT); button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); @@ -191,18 +229,17 @@ namespace OHOS for (int i = 0; i < len; i++) { - buttonconfig.str = ViewMapper_t[i].Labe_str; + // buttonconfig.str = ViewMapper_t[i].Labe_str; + buttonconfig.textId = ViewMapper_t[i].textId; buttonconfig.ViewId = ViewMapper_t[i].viewid_str; buttonconfig.ImageSrc = imagsrc; buttonconfig.label_x = 40; buttonconfig.label_y = 0; buttonconfig.Fontsize = 30; buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT; - button[i] = SetTheButton_ext(buttonconfig, clickListener); + SystemViewButton[i] = SetTheButton_ext(buttonconfig, clickListener); buttonconfig.y += interval; } - /* -------------------------------------------------------------------------- */ - initViewStatus = true; } // 0.跳转到系统视图,其他视图都市通过这个视图跳转 @@ -234,19 +271,19 @@ namespace OHOS return true; } - // 2.跳转到系统监管 - bool SystemView::ChangeSystemSuperviseView(int16_t thisView) + // 2.跳转到手表二维码 + bool SystemView::ChangeWatchQRCodeView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemSuperviseView"); - p_SystemSuperviseView = new SystemSuperviseView(); - if (p_SystemSuperviseView == nullptr) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeWatchQRCodeView"); + p_WatchQRCodeView = new SystemSuperviseView(); + if (p_WatchQRCodeView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); return false; } - SystemScrollView[thisView] = p_SystemSuperviseView->SystemSuperviseViewInit(); + SystemScrollView[thisView] = p_WatchQRCodeView->SystemSuperviseViewInit(); RootView::GetInstance()->Add(SystemScrollView[thisView]); } return true; @@ -255,20 +292,6 @@ namespace OHOS // 3.跳转到系统语言界面 bool SystemView::ChangeSystemLanguageView(int16_t thisView) { -#if 1 - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemLanguageView"); - p_SystemLanguageView = new SystemLanguageView(); - if (p_SystemLanguageView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = p_SystemLanguageView->SystemLanguageViewInit(); - RootView::GetInstance()->Add(SystemScrollView[thisView]); - } -#endif return true; } @@ -295,7 +318,7 @@ namespace OHOS { if (SystemScrollView[thisView] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemFactoryResetView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemupgradeView"); p_SystemupgradeView = new SystemupgradeView(); if (p_SystemupgradeView == nullptr) { @@ -317,57 +340,6 @@ namespace OHOS return SystemScrollView[ViewId]; } - /* -------------------------------------------------------------------------- */ - // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 - struct SystemViewMapper - { - const int16_t viewId; - bool (SystemView::*func)(int16_t thisView); - }; - - // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 - static const SystemViewMapper ViewMapper[] = { - {SYSTEMVIEW, &SystemView::ChangeSystemView}, - {ABOUTTHEWATCHVIEW, &SystemView::ChangeSystemAboutView}, - {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView}, - {SYSTEMLANGUAGEVIEW, &SystemView::ChangeSystemLanguageView}, - {FACTORYRESETVIEW, &SystemView::ChangeSystemFactoryResetView}, - }; - - // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 - bool SystemView::ClickFunc(int16_t interface) - { - int funcSize = sizeof(ViewMapper_t) / sizeof(ViewMapper_t[SYSTEMVIEW]); - for (int i = 0; i < funcSize; i++) - { - if (interface == ViewMapper_t[i].viewId) - { - bool jug = (this->*(ViewMapper_t[i].func))(interface); - if (jug == false) - { - return false; - } - return true; - } - } - return false; - } - - // 4.切换视图 - void SystemView::ChangeView(int16_t hideView, int16_t showView) - { - if (hideView > MAX_SYSTEMVIEWID) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); - return; - } - SystemScrollView[hideView]->SetVisible(false); - ClickFunc(showView); - SystemScrollView[showView]->SetVisible(true); - Draw(); - } - /* -------------------------------------------------------------------------- */ - void SystemView::OnStart() { View::OnStart(); @@ -385,12 +357,12 @@ namespace OHOS return; } - SystemScrollView[SYSTEMVIEW]->Add(SystemLabel); + SystemScrollView[SYSTEMVIEW]->Add(Title); int len = sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext); for (int i = 0; i < len; i++) { - SystemScrollView[SYSTEMVIEW]->Add(button[i]); + SystemScrollView[SYSTEMVIEW]->Add(SystemViewButton[i]); } RootView::GetInstance()->Add(SystemScrollView[SYSTEMVIEW]); Draw(); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index 75b51af23..e564ebbb6 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang index 00b01737d..7c3cc078d 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index e26afe878..5bf80d159 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -314,8 +314,14 @@ enum UIResourceTextId : uint16_t { STR_GRID_DISPLAY = 301, STR_CELLULAR_DISPLAY = 302, STR_AUTO_DETECT = 303, - STR_LANGUAGE = 304, - STR_MAX_ID = 305, + STR_ABOUT_WATCH = 304, + STR_WATCH_QR_CODE = 305, + STR_SYSTEM_LANGUAGE = 306, + STR_RESTART = 307, + STR_SHUTDOWN = 308, + STR_FACTORY_RESET = 309, + STR_LANGUAGE = 310, + STR_MAX_ID = 311, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang index 3ba13c590..9e1c67a87 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/KUMILOGO.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/KUMILOGO.bin new file mode 100644 index 000000000..399e9cfbf --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/KUMILOGO.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:992905e904b5e96cc6e86d1da6060d4f091469cd5360fd55e2606c3d5b64de4b +size 24984 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_ABOUT_THE_WATCH.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_ABOUT_THE_WATCH.bin deleted file mode 100644 index 196d9ee23..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_ABOUT_THE_WATCH.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:efdea91c4ef6371d11becb8651e5f1b952bed953af0e1e4610bb71cf1017048a -size 25624 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_FACTORY_RESET.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_FACTORY_RESET.bin deleted file mode 100644 index 2753f5242..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_FACTORY_RESET.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7b2eaa958d59789b0398505a7e2ed21c58059c5186ebe8839641ee443ca192ef -size 25624 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SUPERVISE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SUPERVISE.bin deleted file mode 100644 index d8e8b6fc8..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SUPERVISE.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d9e67bc841ccc0ea2ad23a091e80b620412c1ab85a412e6830ee6ee9d439b5cf -size 25624 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SYSTEM_LANGUAGE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SYSTEM_LANGUAGE.bin deleted file mode 100644 index 5d36f5be0..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/SYSTEM_SYSTEM_LANGUAGE.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ff7a6c1c5266019f052011cb76163eb8fed71444f29736d3ced050bafde87d6 -size 25624 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/factoryreset.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/factoryreset.bin deleted file mode 100644 index 12ea1d168..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/system/factoryreset.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:979a740e2a057ed4d32eb31900c671070c7929d924a6d91d1e27485cd57482e0 -size 146040