From: luozheng <1732036298@qq.com> Date: Tue, 2 Apr 2024 08:28:25 +0000 (+0800) Subject: 1.将ConfigModel.json文件从/user/userdata移动到/system/分区,需要重新烧录json文件 X-Git-Tag: release_V1.2.70_20241020_135402~1233^2~6 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=929880af880ec56779c77c7c817270577fab1324;p=mirrors%2FFD230.git 1.将ConfigModel.json文件从/user/userdata移动到/system/分区,需要重新烧录json文件 2.将显示与亮度视图中4G能力开关恢复为抬腕亮屏,并在系统视图中添加4g能力按钮,通过button能够开启按钮 3.解决ConfigModel.h文件中WriteJsonToFile函数写完json字符串数据没有释放内存问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/ConfigModel.json b/code/sdk/application/wearable/fd230app/nativeui/config/ConfigModel.json index 55a811fad..03fdb6549 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/ConfigModel.json +++ b/code/sdk/application/wearable/fd230app/nativeui/config/ConfigModel.json @@ -9,5 +9,6 @@ "Language_Id": 0, "Language_Code": "zh", "VibrationReminder":false, - "SilentMode":false + "SilentMode":false, + "Cat1_4Gability": false } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index efbd9afb4..48693bd6d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -51,7 +51,7 @@ namespace OHOS void WriteJsonData_VectorDouble(cJSON *json_obj, const char *field_name, const std::vector &data); void WriteJsonData_VectorString(cJSON *json_obj, const char *field_name, const std::vector &data); - void WriteJsonToFile(const char *json_string, const char *file_path); + void WriteJsonToFile(char *json_string, const char *file_path); /* -------------------------------------------------------------------------- */ void ShowReadJsonData(void); void Init(void); @@ -82,6 +82,8 @@ namespace OHOS bool GetVibrationReminder(void); void SetSilentMode(bool state); bool GetSilentMode(void); + void SetCat1_4Gability(bool state); + bool GetCat1_4Gability(); // -------------------------------------------------------------------------- */ private: ConfigModel(); // 私有构造函数,确保无法在外部实例化 @@ -90,7 +92,7 @@ namespace OHOS ~ConfigModel(); private: - const std::string filePath = "/user/userdata/ConfigModel.json"; + const std::string filePath = "/system/ConfigModel.json"; cJSON *cjson_json{nullptr}; /* ------------------------------- json中要读取的键 ------------------------------- */ bool RaiseToBrightnessCheckBoxButtonState{false}; // 抬腕按钮状态 ,默认补选中 @@ -107,6 +109,7 @@ namespace OHOS std::string LanguageCode = "zh"; bool VibrationReminder{false}; // 震动提醒 bool SilentMode{false}; // 静音模式 + bool Cat1_4Gability{false}; // 4G能力开关 cat1_msg_config cat1_msg_config_t; /* -------------------------------------------------------------------------- */ }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 1203c032c..cd4903bb1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -87,7 +87,7 @@ namespace OHOS * @param {char*} 字段名 * @return {int} 读取到的数字 */ - int ConfigModel::ReadJsonData_Int(const cJSON *json_obj, const char *field_name) + int ConfigModel::ReadJsonData_Int(const cJSON *json_obj, const char *field_name) { const cJSON *field_item = cJSON_GetObjectItem(json_obj, field_name); if (field_item != NULL && cJSON_IsNumber(field_item)) @@ -313,7 +313,7 @@ namespace OHOS * @param {char} json字符串 * @param {char} json文件路径 */ - void ConfigModel::WriteJsonToFile(const char *json_string, const char *file_path) + void ConfigModel::WriteJsonToFile(char *json_string, const char *file_path) { if (json_string == NULL || file_path == NULL) { @@ -328,9 +328,16 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file: %s", file_path); return; } + else + { + if (fputs(json_string, fp) != EOF) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WriteJsonData to file success\n"); + } + fclose(fp); + free(json_string); + } - fputs(json_string, fp); - fclose(fp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JSON data written to file: %s", file_path); } @@ -571,6 +578,26 @@ namespace OHOS return SilentMode; } + /* + * @brief 设置4G能力是否开启 + * @param {bool} state + */ + void ConfigModel::SetCat1_4Gability(bool state) + { + Cat1_4Gability = state; + WriteJsonData_Bool(GetcJSON(), "Cat1_4Gability", Cat1_4Gability); // 应该放到开机时候读 + } + + /* + * @brief 获取4G能力是否开启 + * @return {bool} true 开启 false 关闭 + */ + bool ConfigModel::GetCat1_4Gability() + { + Cat1_4Gability = ReadJsonData_Bool(GetcJSON(), "Cat1_4Gability"); // 应该放到关机机时候写 + return Cat1_4Gability; + } + /* ------------------------------ ImageAnimator ----------------------------- */ ImageAnimator::ImageAnimator() diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp index 85c09a409..a154155c1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp @@ -2,7 +2,7 @@ #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "wearable_log.h" #include "cat1_ctl.h" -#include "../../../../../../drivers/peripheral/slip/cat1Service/cat1_ctl.h" + namespace OHOS { @@ -40,7 +40,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail"); return false; } - displayBrightnessPresent->SetRaiseToBrightnessState(uapi_cat1_get_power_stat()); // 抬腕按钮的状态 + displayBrightnessPresent->SetRaiseToBrightnessState(RaiseToBrightnessCheckBoxButtonState); // 抬腕按钮的状态 return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index e7b06f48d..624dc53f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -1,6 +1,6 @@ #include "AppViewIDs.h" #include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" +#include "language/font/ui_resource_string.h" #include "NativeAbility.h" #include "graphic_math.h" #include "string.h" @@ -163,49 +163,15 @@ namespace OHOS return false; } - extern "C" - { - uint32_t uapi_cat1_power_on(uint32_t pwron); - uint32_t uapi_cat1_reset(uint32_t pwron); - - void power_on_cat1(void) - { - uapi_cat1_power_on(1); - uapi_cat1_reset(0); - } - - void power_off_cat1(void) - { - uapi_cat1_reset(1); - uapi_cat1_power_on(0); - } - } - bool DisplayBrightnessPresenter::OnChange(UICheckBox::UICheckBoxState state) { -#if 0 - switch (state) - { - case UICheckBox::SELECTED: - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RaiseToBrightnessCheckBoxButton switched on!"); - break; - case UICheckBox::UNSELECTED: - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RaiseToBrightnessCheckBoxButton switched off!"); - break; - default: - break; - } - return true; -#endif switch (state) { case UICheckBox::SELECTED: - power_on_cat1(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Enabled"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched on!"); break; case UICheckBox::UNSELECTED: - power_off_cat1(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Disabled"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched off!"); break; default: break; diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp index 617122e74..c7dcd050c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -237,8 +237,8 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 393; - // labelconfig.text = "抬腕亮屏"; - labelconfig.text = "4G能力开关"; + labelconfig.text = "抬腕亮屏"; + //labelconfig.text = "4G能力开关"; RaiseToBrightnessLabel = SetUpLabel(labelconfig); if (RaiseToBrightnessLabel == nullptr) { 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 01c151e47..6c05a167c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 18:29:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-02 16:00:14 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h + */ #ifndef SYSTEM_PRESENTER_H #define SYSTEM_PRESENTER_H @@ -7,6 +14,7 @@ #include "system/include/SystemModel.h" #include "components/ui_radio_button.h" #include "KeyInputListener.h" +#include "../../../../../../drivers/peripheral/slip/cat1Service/cat1_ctl.h" namespace OHOS { @@ -60,6 +68,7 @@ namespace OHOS public UIView::OnClickListener, public RootView::OnKeyActListener, public UIView::OnDragListener, + public UICheckBox::OnChangeListener, public UIView::OnTouchListener { public: @@ -79,7 +88,8 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - bool OnPress(UIView &view, const PressEvent &event); + bool OnPress(UIView &view, const PressEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; private: SystemModel *systemModel; 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 89c7df986..c129f25a0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h @@ -6,7 +6,6 @@ #include "components/ui_view_group.h" #include "components/ui_scroll_view.h" -#include "components/ui_label.h" #include "components/ui_label_ext.h" #include "components/ui_image_view.h" #include "components/ui_button.h" @@ -16,6 +15,8 @@ #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"; // 关于手表 @@ -59,14 +60,13 @@ namespace OHOS const char *ViewId; const char *ImageSrc; - //label + // label int label_x; int label_y; uint8_t ALIGN; - int Fontsize; - + int Fontsize; }; - + bool ChangeSystemView(int16_t thisView); bool ChangeSystemAboutView(int16_t thisView); bool ChangeSystemSuperviseView(int16_t thisView); @@ -78,26 +78,23 @@ namespace OHOS UIScrollView *GetSystemScrollView(int ViewId); private: - void InitIView(void); - void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc); + void initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc); void ClearAll(void); bool SetTheSystemScrollView(void); bool SetTheTitle(void); - UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); + 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}; - UIScrollView *SystemScrollView[10]{nullptr}; - UILabel *SystemLabel{nullptr}; // 标题 - UIButton *AboutTheWatchButton{nullptr}; - UIButton *SuperviseButton = {nullptr}; - UIButton *SystemLanguageButton = {nullptr}; - UIButton *FactoryResetButton{nullptr}; - UILabelButtonExt *SystemUpgradeButtonExt{nullptr}; + UILabelExt *SystemLabel{nullptr}; // 标题 + + UILabelExt *Cat1_4Gability_Label{nullptr}; + UIImageView *Cat1_4Gability_ImageView{nullptr}; + UIToggleButton *Cat1_4Gability_ToggleButton{nullptr}; bool initViewStatus{false}; }; } // namespace OHOS 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 e5c31adf0..23ac8655a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -13,6 +13,7 @@ #include "custom_utils.h" #include "language/LanguageInit.h" #include "language/font/ui_resource_string.h" +#include "config/include/ConfigModel.h" namespace OHOS { @@ -64,6 +65,18 @@ namespace OHOS Presenter::OnPause(); } + void SystemPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + static uint32_t time = 0; static uint32_t OnClick_num = 0; @@ -72,16 +85,42 @@ namespace OHOS return true; } - void SystemPresenter::OnResume(void) + extern "C" { + uint32_t uapi_cat1_power_on(uint32_t pwron); + uint32_t uapi_cat1_reset(uint32_t pwron); - Presenter::OnResume(); - } + void power_on_cat1(void) + { + uapi_cat1_power_on(1); + uapi_cat1_reset(0); + } - void SystemPresenter::OnStop(void) + void power_off_cat1(void) + { + uapi_cat1_reset(1); + uapi_cat1_power_on(0); + } + } + + bool SystemPresenter::OnChange(UICheckBox::UICheckBoxState state) { - - Presenter::OnStop(); + switch (state) + { + case UICheckBox::SELECTED: + power_on_cat1(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Enabled"); + ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); + break; + case UICheckBox::UNSELECTED: + power_off_cat1(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Disabled"); + ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); + break; + default: + break; + } + return true; } bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event) 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 f8fdfa3e6..6bae1589d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -12,27 +12,21 @@ namespace OHOS struct SystemViewMapper_ext { - const int16_t viewId; - char *viewid_str; - char *Labe_str; - bool (SystemView::*func)(int16_t thisView); + const int16_t viewId; + const char *viewid_str; + const char *Labe_str; + bool (SystemView::*func)(int16_t thisView); }; - static UILabelButtonExt *button[10]={NULL}; - - // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 - 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, &SystemView::ChangeSystemAboutView}, - // {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView}, - // {SYSTEMLANGUAGEVIEW, &SystemView::ChangeSystemLanguageView}, - // {FACTORYRESETVIEW, &SystemView::ChangeSystemFactoryResetView}, + 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}, }; - + SystemView::SystemView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); @@ -62,24 +56,53 @@ namespace OHOS delete draglistener; draglistener = nullptr; } - delete p_SystemAboutTheWatchView; - p_SystemAboutTheWatchView = nullptr; - delete p_SystemSuperviseView; - p_SystemSuperviseView = nullptr; - delete p_SystemLanguageView; - p_SystemLanguageView = nullptr; - delete p_SystemFactoryResetView; - p_SystemFactoryResetView = nullptr; - delete SystemLabel; - SystemLabel = nullptr; - delete AboutTheWatchButton; - AboutTheWatchButton = nullptr; - delete SuperviseButton; - SuperviseButton = nullptr; - delete SystemLanguageButton; - SystemLanguageButton = nullptr; - delete FactoryResetButton; - FactoryResetButton = nullptr; + + if (p_SystemAboutTheWatchView != nullptr) + { + delete p_SystemAboutTheWatchView; + p_SystemAboutTheWatchView = nullptr; + } + if (p_SystemSuperviseView != nullptr) + { + delete p_SystemSuperviseView; + p_SystemSuperviseView = nullptr; + } + + if (p_SystemLanguageView != nullptr) + { + delete p_SystemLanguageView; + p_SystemLanguageView = nullptr; + } + + if (p_SystemFactoryResetView != nullptr) + { + delete p_SystemFactoryResetView; + p_SystemFactoryResetView = nullptr; + } + + if (SystemLabel != nullptr) + { + delete SystemLabel; + SystemLabel = nullptr; + } + + if (Cat1_4Gability_Label != nullptr) + { + delete Cat1_4Gability_Label; + Cat1_4Gability_Label = nullptr; + } + + if (Cat1_4Gability_ImageView != nullptr) + { + delete Cat1_4Gability_ImageView; + Cat1_4Gability_ImageView = nullptr; + } + + if (Cat1_4Gability_ToggleButton != nullptr) + { + delete Cat1_4Gability_ToggleButton; + Cat1_4Gability_ToggleButton = nullptr; + } delete SystemScrollView[SYSTEMVIEW]; SystemScrollView[SYSTEMVIEW] = nullptr; @@ -119,7 +142,7 @@ namespace OHOS /// @return true 设置成功,false 失败 bool SystemView::SetTheTitle(void) { - SystemLabel = new UILabel(); + SystemLabel = new UILabelExt(); if (SystemLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!"); @@ -137,25 +160,51 @@ namespace OHOS return true; } - /// @brief 设置按钮 - /// @param button - /// @return true 设置成功,false 失败 - UIButton *SystemView::SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener) + /*Cat14G能力开关视图初始化*/ + bool SystemView::Cat1_4GabilityButtonViewInit() { - UIButton *button = new UIButton(); - if (button == nullptr) + Cat1_4Gability_Label = new UILabelExt(); + if (Cat1_4Gability_Label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); - return nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Cat1_4Gability_Label new fail!!"); + return false; } - 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, buttonconfig.ImageSrc); - button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - button->SetOnClickListener(clickListener); - return button; + Cat1_4Gability_Label->SetPosition(83, 150, 200, 40); + Cat1_4Gability_Label->SetStyle(STYLE_TEXT_FONT, 30); + Cat1_4Gability_Label->SetStyle(STYLE_LINE_HEIGHT, 35); + Cat1_4Gability_Label->SetText("4G能力"); + Cat1_4Gability_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Cat1_4Gability_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Cat1_4Gability_Label->SetRollSpeed(0); + Cat1_4Gability_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* -------------------------------------------------------------------------- */ + Cat1_4Gability_ImageView = new UIImageView(); + if (Cat1_4Gability_ImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Cat1_4Gability_ImageView new fail!!"); + return false; + } + Cat1_4Gability_ImageView->SetPosition(43, 120, 380, 100); + Cat1_4Gability_ImageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + Cat1_4Gability_ImageView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + Cat1_4Gability_ImageView->SetStyle(STYLE_BORDER_RADIUS, 100); + /* -------------------------------------------------------------------------- */ + Cat1_4Gability_ToggleButton = new UIToggleButton(); + if (Cat1_4Gability_ToggleButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Cat1_4Gability_ToggleButton new fail!!"); + return false; + } + Cat1_4Gability_ToggleButton->SetState(uapi_cat1_get_power_stat()); + Cat1_4Gability_ToggleButton->SetPosition(298, 145, 100, 50); + Cat1_4Gability_ToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + Cat1_4Gability_ToggleButton->SetStyle(STYLE_BORDER_RADIUS, 50); + const char *toggleButtonselectedImg = "/user/res/TOGGLEBUTTON_ON.bin"; + const char *toggleButtonunSelectedImg = "/user/res/TOGGLEBUTTON_OFF.bin"; + Cat1_4Gability_ToggleButton->SetImages(toggleButtonselectedImg, toggleButtonunSelectedImg); + UICheckBox::OnChangeListener *listener = static_cast(SystemPresenter::GetInstance()); + Cat1_4Gability_ToggleButton->SetOnChangeListener(listener); + return true; } UILabelButtonExt *SystemView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) @@ -175,17 +224,15 @@ namespace OHOS button->SetText(buttonconfig.str); button->SetAlign(TEXT_ALIGNMENT_LEFT); - button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); - //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); button->SetImagePosition(326, 37); return button; } - - - void SystemView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc) + void SystemView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc) { if (!SetTheSystemScrollView()) { @@ -206,100 +253,21 @@ namespace OHOS buttonconfig.w = w; buttonconfig.h = h; - int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext); + int len = sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext); - for(int i=0;i(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) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::AboutTheWatchButton new fail!"); - return; - } - /* -------------------------------------------------------------------------- */ - buttonconfig.y = 240; - buttonconfig.ViewId = SUPERVISE; - buttonconfig.ImageSrc = SUPERVISE_IMAGESRC; - SuperviseButton = SetTheButton(buttonconfig, clickListener); - if (nullptr == SuperviseButton) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SuperviseButton new fail!"); - } - /* -------------------------------------------------------------------------- */ - buttonconfig.y = 360; - buttonconfig.ViewId = SYSTEM_LANGUAGE; - buttonconfig.ImageSrc = SYSTEM_LANGUAGE_IMAGESRC; - SystemLanguageButton = SetTheButton(buttonconfig, clickListener); - if (nullptr == SystemLanguageButton) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLanguageButton fail!"); - return; - } - /* -------------------------------------------------------------------------- */ - buttonconfig.y = 480; - buttonconfig.ViewId = FACTORY_RESET; - buttonconfig.ImageSrc = FACTORY_RESET_LANGUAGE_IMAGESRC; - FactoryResetButton = SetTheButton(buttonconfig, clickListener); - if (nullptr == FactoryResetButton) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FactoryResetButton fail!"); - return; + buttonconfig.y += interval; } /* -------------------------------------------------------------------------- */ - SystemUpgradeButtonExt = new UILabelButtonExt(); - if (SystemUpgradeButtonExt == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!"); - } - SystemUpgradeButtonExt->SetPosition(43, 600, 380, 100); - SystemUpgradeButtonExt->SetViewId(SYSTEM_UPGRADE); - SystemUpgradeButtonExt->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SystemUpgradeButtonExt->SetImagePosition(326, 37); - SystemUpgradeButtonExt->SetImageSrc("/user/res/SETTING_NEXT.bin", "/user/res/SETTING_NEXT.bin"); - SystemUpgradeButtonExt->SetText("系统升级"); - SystemUpgradeButtonExt->SetAlign(TEXT_ALIGNMENT_LEFT); - SystemUpgradeButtonExt->SetLabelPosition(45, 0); - SystemUpgradeButtonExt->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - SystemUpgradeButtonExt->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - SystemUpgradeButtonExt->SetOnClickListener(clickListener); - initViewStatus = true; } @@ -370,10 +338,6 @@ namespace OHOS return true; } - - - - // 4.跳转到恢复出厂设置界面 bool SystemView::ChangeSystemFactoryResetView(int16_t thisView) { @@ -392,6 +356,7 @@ namespace OHOS return true; } + // 5.跳转到系统升级界面 bool SystemView::ChangeSystemupgradeView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -409,7 +374,6 @@ namespace OHOS return true; } - UIScrollView *SystemView::GetSystemScrollView(int ViewId) { if (SystemScrollView[ViewId] == nullptr) @@ -473,9 +437,8 @@ namespace OHOS void SystemView::OnStart() { View::OnStart(); - //InitIView(); - initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin"); - + initView_ext(43, 240, 380, 100, 120, "/user/res/SETTING_NEXT.bin"); + Cat1_4GabilityButtonViewInit(); RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::SystemPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); } @@ -488,20 +451,18 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); return; } - + SystemScrollView[SYSTEMVIEW]->Add(SystemLabel); + SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_ImageView); + SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_Label); + SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_ToggleButton); - int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext); + int len = sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext); - for(int i=0;iAdd(button[i]); + SystemScrollView[SYSTEMVIEW]->Add(button[i]); } - // SystemScrollView[SYSTEMVIEW]->Add(SuperviseButton); - // SystemScrollView[SYSTEMVIEW]->Add(SystemLanguageButton); - // SystemScrollView[SYSTEMVIEW]->Add(FactoryResetButton); - // SystemScrollView[SYSTEMVIEW]->Add(SystemUpgradeButtonExt); - RootView::GetInstance()->Add(SystemScrollView[SYSTEMVIEW]); Draw(); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/ConfigModel.json b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/ConfigModel.json similarity index 87% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/ConfigModel.json rename to code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/ConfigModel.json index 55a811fad..03fdb6549 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/ConfigModel.json +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/ConfigModel.json @@ -9,5 +9,6 @@ "Language_Id": 0, "Language_Code": "zh", "VibrationReminder":false, - "SilentMode":false + "SilentMode":false, + "Cat1_4Gability": false } \ No newline at end of file