From: 罗正yun <1732036298@qq.com> Date: Thu, 25 Jan 2024 02:40:06 +0000 (+0800) Subject: 系统视图修改 X-Git-Tag: release_V1.2.70_20241020_135402~1331 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=5d39f7ccce36e6456b33f05edfabc0a7c04014aa;p=mirrors%2FFD230.git 系统视图修改 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 225c5cf01..55a1d84b5 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -215,8 +215,7 @@ 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/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/SystemSuperviseView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemLanguageView.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 ae9a2b643..8ef146e42 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -46,7 +46,6 @@ typedef enum : uint16_t VIEW_FUTURE_WEATHER, // 未来天气 VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败 VIEW_SYSTEM, // 系统 - VIEW_SYSTEM_SYSTEM_LANGUAGE, // 系统:系统语言 VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 VIEW_SOUND_VIBRATION, // 声音与震动 VIEW_SYSTEM_VOLUME, // 系统音量 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index f83153d23..2b334b65e 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -50,7 +50,6 @@ namespace OHOS void InitGetWeatherDataErrorSlice(void); /* -------------------------------------------------------------------------- */ void InitSystemSlice(void); - void InitSystemLanguageSlice(void); void InitSystemFactoryResetSlice(void); /* -------------------------------------------------------------------------- */ void InitSoundAndVibrationSlice(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index bda871f26..b82253864 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -71,8 +71,6 @@ #include "system/include/SystemPresenter.h" #include "system/include/SystemView.h" -#include "system/include/SystemLanguagePresenter.h" -#include "system/include/SystemLanguageView.h" #include "system/include/SystemFactoryResetPresenter.h" #include "system/include/SystemFactoryResetView.h" @@ -142,7 +140,6 @@ namespace OHOS {VIEW_FUTURE_WEATHER, &NativeLauncher::InitFutureWeatherSlice}, // 未来天气 {VIEW_GET_WEATHER_DATA_ERROR, &NativeLauncher::InitGetWeatherDataErrorSlice}, // 获取天气数据失败 {VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址 - {VIEW_SYSTEM_SYSTEM_LANGUAGE, &NativeLauncher::InitSystemLanguageSlice}, // 系统:系统语言实例化地址 {VIEW_SYSTEM_FACTORY_RESET, &NativeLauncher::InitSystemFactoryResetSlice}, // 系统:恢复出厂设置实例化地址 {VIEW_SOUND_VIBRATION, &NativeLauncher::InitSoundAndVibrationSlice}, // 声音与震动实例化地址 {VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice}, // 系统音量 @@ -485,24 +482,16 @@ namespace OHOS void NativeLauncher::InitSystemSlice(void) // 系统 { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSystemSlice"); SliceProxy *system = new AbilitySliceProxy; if (system == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "system is nullptr!"); return; } NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM, system); } - void NativeLauncher::InitSystemLanguageSlice(void) // 系统:系统语言 - { - SliceProxy *systemlanguage = new AbilitySliceProxy; - if (systemlanguage == nullptr) - { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_SYSTEM_LANGUAGE, systemlanguage); - } - void NativeLauncher::InitSystemFactoryResetSlice(void) // 系统:恢复出厂设置 { SliceProxy *systemfactoryreset = new AbilitySliceProxy; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguagePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguagePresenter.h deleted file mode 100644 index f4406d4e7..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguagePresenter.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef SYSTEM_LANGUAGE_PRESENTER_H -#define SYSTEM_LANGUAGE_PRESENTER_H - -#include "Presenter.h" -#include "SystemLanguageView.h" -#include "components/ui_checkbox.h" -namespace OHOS -{ - class SystemLanguageView; - - class SystemLanguagePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - SystemLanguagePresenter(); - SystemLanguagePresenter(UICheckBox *checkbox1, UICheckBox *checkbox2) : m_checkbox1(checkbox1), m_checkbox2(checkbox2) {} - virtual ~SystemLanguagePresenter(); - - void UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected); - //void ToggleCheckBoxState(UICheckBox &checkbox); - - public: - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SystemLanguagePresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - - private: - UICheckBox *m_checkbox1 = nullptr; - UICheckBox *m_checkbox2 = nullptr; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguageView.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguageView.h index 7e251b5cb..afb6b9800 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguageView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemLanguageView.h @@ -3,11 +3,9 @@ #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_checkbox.h" +#include "components/ui_radio_button.h" #include "components/ui_image_view.h" namespace OHOS { @@ -15,37 +13,58 @@ namespace OHOS static const char *ENGLISH_BUTTON = "EnglishButton"; // English button static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 checkbox static const char *ENGLISH_CHECKBOX = "EnglishCheckBox"; // English checkbox - - class SystemLanguagePresenter; - class SystemLanguageView : public View + 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); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - void InitView(void); - void DeInitView(void); - - void init(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: - UIViewGroup *container_ = nullptr; UIScrollView *scrollView = nullptr; - UILabel *LanguageLabel = nullptr; - UIImageView *SimplifiedChineseImage = nullptr; - UICheckBox *SimplifiedChineseCheckBox = nullptr; - UIImageView *EnglishImage = nullptr; + UILabel *Title = nullptr; // 标题 + UIImageView *Background[2]{nullptr}; // 放组件的背景 UILabel *SimplifiedChineseLabel = nullptr; UILabel *EnglishLabel = nullptr; - UICheckBox *EnglishCheckBox = nullptr; + UIRadioButton *SimplifiedChineseRadioButton = nullptr; + UIRadioButton *EnglishRadioButton = nullptr; + bool initViewStatus{false}; }; } // namespace OHOS -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file +#endif \ 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 8a8c86fbc..4e9a968a2 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemView.h @@ -11,6 +11,7 @@ #include "components/ui_button.h" #include "system/include/SystemAboutTheWatchView.h" #include "system/include/SystemSuperviseView.h" +#include "system/include/SystemLanguageView.h" namespace OHOS { static const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 @@ -46,6 +47,7 @@ namespace OHOS bool ChangeSystemView(int16_t thisView); bool ChangeSystemAboutView(int16_t thisView); bool ChangeSystemSuperviseView(int16_t thisView); + bool ChangeSystemLanguageView(int16_t thisView); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); private: @@ -56,14 +58,13 @@ namespace OHOS UIButton * SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; SystemSuperviseView *p_SystemSuperviseView{nullptr}; + SystemLanguageView *p_SystemLanguageView{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}; + UIButton *FactoryResetButton{nullptr}; bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguagePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguagePresenter.cpp deleted file mode 100644 index 7fb76a69a..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguagePresenter.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "graphic_math.h" -#include "string.h" -#include "system/include/SystemLanguagePresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static SystemLanguagePresenter *g_pSystemLanguagePresenter = nullptr; - int count = 1; - SystemLanguagePresenter::SystemLanguagePresenter() - { - - g_pSystemLanguagePresenter = this; - } - - SystemLanguagePresenter::~SystemLanguagePresenter() - { - - g_pSystemLanguagePresenter = nullptr; - } - - SystemLanguagePresenter *SystemLanguagePresenter::GetInstance() - { - - return g_pSystemLanguagePresenter; - } - - void SystemLanguagePresenter::OnStart() - { - - Presenter::OnStart(); - } - - void SystemLanguagePresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void SystemLanguagePresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void SystemLanguagePresenter::OnStop(void) - { - - Presenter::OnStop(); - } - bool SystemLanguagePresenter::OnDrag(UIView &view, const DragEvent &event) - { - UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); - return true; - } - return false; - } - - bool SystemLanguagePresenter::OnClick(UIView &view, const ClickEvent &event) - { - if (strcmp(view.GetViewId(), SIMPLIFIED_CHINESE_CHECKBOX) == 0) - { - - m_checkbox1->SetState(UICheckBox::SELECTED); - UpdateCheckBoxState(*m_checkbox2, false); - - return true; - } - else if (strcmp(view.GetViewId(), ENGLISH_CHECKBOX) == 0) - { - m_checkbox2->SetState(UICheckBox::SELECTED); - UpdateCheckBoxState(*m_checkbox1, false); - return true; - } - return false; - } - - // 根据传入的选中状态更新复选框的状态 - void SystemLanguagePresenter::UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected) - { - checkbox.SetState(isSelected ? UICheckBox::SELECTED : UICheckBox::UNSELECTED); - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguageView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguageView.cpp index 035f37761..5d11053ea 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguageView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemLanguageView.cpp @@ -1,8 +1,9 @@ #include "system/include/SystemLanguageView.h" -#include "system/include/SystemLanguagePresenter.h" +#include "system/include/SystemPresenter.h" #include "string.h" #include "UiConfig.h" -#include "ui_view.h" +#include "wearable_log.h" + namespace OHOS { @@ -10,261 +11,223 @@ namespace OHOS SystemLanguageView::SystemLanguageView() { - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::SystemLanguageView"); g_pSystemLanguageView = this; } SystemLanguageView::~SystemLanguageView() { - DeInitView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::~SystemLanguageView"); + ClearAll(); g_pSystemLanguageView = nullptr; } SystemLanguageView *SystemLanguageView::GetInstance() { - return g_pSystemLanguageView; } - void SystemLanguageView::InitView() + void SystemLanguageView::ClearAll() { - if (container_ == nullptr) + if (initViewStatus == true) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - UIView::OnDragListener *draglistener = static_cast(SystemLanguagePresenter::GetInstance()); - if (draglistener == nullptr) + scrollView->RemoveAll(); + delete Title; + Title = nullptr; + for (int i = 0; i < 2; i++) { - return; + delete Background[i]; + Background[i] = nullptr; } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); - } - /***********************************************************************************************************/ - if (scrollView == nullptr) - { - scrollView = new UIScrollView(); - } - scrollView->SetPosition(0, 0); - scrollView->Resize(466, 466); - scrollView->SetViewId("scrollView"); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); - container_->Add(scrollView); - scrollView->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App - if (LanguageLabel == nullptr) - { - LanguageLabel = new UILabel(); - } - LanguageLabel->SetPosition(203, 52); // widget's left position and top position - LanguageLabel->Resize(200, 60); // widget's width and height - LanguageLabel->SetViewId("LanguageLabel"); // Set style - LanguageLabel->SetStyle(STYLE_TEXT_FONT, 30); - LanguageLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property - LanguageLabel->SetText("语言"); - LanguageLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - LanguageLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - LanguageLabel->SetRollSpeed(0); - LanguageLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView->Add(LanguageLabel); - LanguageLabel->SetVisible(true); - /***********************************************************************************************************/ - if (SimplifiedChineseImage == nullptr) - { - SimplifiedChineseImage = new UIImageView(); - } - SimplifiedChineseImage->SetPosition(43, 120); - SimplifiedChineseImage->Resize(380, 100); - SimplifiedChineseImage->SetViewId(SIMPLIFIED_CHINESE_BUTTON); - SimplifiedChineseImage->SetStyle(STYLE_BORDER_RADIUS, 50); - SimplifiedChineseImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); - // Add to scrollView1 - scrollView->Add(SimplifiedChineseImage); - SimplifiedChineseImage->SetVisible(true); - /***********************************************************************************************************/ - if (SimplifiedChineseLabel == nullptr) - { - SimplifiedChineseLabel = new UILabel(); - } - SimplifiedChineseLabel->SetPosition(90, 153); - SimplifiedChineseLabel->Resize(120, 35); - SimplifiedChineseLabel->SetViewId("SimplifiedChineseLabel"); - SimplifiedChineseLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SimplifiedChineseLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SimplifiedChineseLabel->SetStyle(STYLE_TEXT_FONT, 30); - SimplifiedChineseLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property - SimplifiedChineseLabel->SetText("简体中文"); - SimplifiedChineseLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - SimplifiedChineseLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - SimplifiedChineseLabel->SetRollSpeed(0); - SimplifiedChineseLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // Add to scrollView1 - scrollView->Add(SimplifiedChineseLabel); - SimplifiedChineseLabel->SetVisible(true); - /***********************************************************************************************************/ - // Add CheckBox to App - if (SimplifiedChineseCheckBox == nullptr) - { - SimplifiedChineseCheckBox = new UICheckBox(); - } - SimplifiedChineseCheckBox->SetState(UICheckBox::SELECTED); - SimplifiedChineseCheckBox->SetPosition(300, 130); // widget's left position and top position - SimplifiedChineseCheckBox->Resize(80, 80); // widget's width and height - SimplifiedChineseCheckBox->SetViewId(SIMPLIFIED_CHINESE_CHECKBOX); // Set style - SimplifiedChineseCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SimplifiedChineseCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SimplifiedChineseCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); - // Add the CallBack about events - UIView::OnClickListener *SimplifiedChineseCheckBoxClick = static_cast(SystemLanguagePresenter::GetInstance()); - SimplifiedChineseCheckBox->SetOnClickListener(SimplifiedChineseCheckBoxClick); - // Add to scrollView1 - scrollView->Add(SimplifiedChineseCheckBox); - SimplifiedChineseCheckBox->SetVisible(true); - /***********************************************************************************************************/ - if (EnglishImage == nullptr) - { - EnglishImage = new UIImageView(); - } - EnglishImage->SetPosition(43, 240); - EnglishImage->Resize(380, 100); - EnglishImage->SetViewId(ENGLISH_BUTTON); - EnglishImage->SetStyle(STYLE_BORDER_RADIUS, 50); - EnglishImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); - scrollView->Add(EnglishImage); - EnglishImage->SetVisible(true); - /***********************************************************************************************************/ - if (EnglishLabel == nullptr) - { - EnglishLabel = new UILabel(); + delete SimplifiedChineseLabel; + SimplifiedChineseLabel = nullptr; + delete EnglishLabel; + EnglishLabel = nullptr; + delete SimplifiedChineseRadioButton; + SimplifiedChineseRadioButton = nullptr; + delete EnglishRadioButton; + EnglishRadioButton = nullptr; + delete scrollView; + scrollView = nullptr; } - EnglishLabel->SetPosition(90, 273); // widget's left position and top position - EnglishLabel->Resize(126, 35); // widget's width and height - EnglishLabel->SetViewId("EnglishLabel"); // Set style - EnglishLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - EnglishLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - EnglishLabel->SetStyle(STYLE_TEXT_FONT, 30); - EnglishLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - - // Set additional property - EnglishLabel->SetText("ENGLISH"); - EnglishLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - EnglishLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - EnglishLabel->SetRollSpeed(0); - EnglishLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to scrollView1 - scrollView->Add(EnglishLabel); - EnglishLabel->SetVisible(true); + } - // Add CheckBox to App - if (EnglishCheckBox == nullptr) + // 设置图片 + UIImageView *SystemLanguageView::SetUpImageVIew(ImageConfig &imageconfig) + { + UIImageView *Image = new UIImageView(); + if (Image == nullptr) { - EnglishCheckBox = new UICheckBox(); + return nullptr; } - EnglishCheckBox->SetPosition(300, 250); - EnglishCheckBox->Resize(80, 80); - EnglishCheckBox->SetViewId(ENGLISH_CHECKBOX); - EnglishCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - EnglishCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - EnglishCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE); - - // Add the CallBack about events - UIView::OnClickListener *EnglishCheckBoxClick = static_cast(SystemLanguagePresenter::GetInstance()); - EnglishCheckBox->SetOnClickListener(EnglishCheckBoxClick); - // Add to scrollView1 - scrollView->Add(EnglishCheckBox); - EnglishCheckBox->SetVisible(true); + Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h); + Image->SetSrc(imageconfig.ImageSrc); + return Image; + } - /***********************************************************************************************************/ - // Add the CallBack about SimplifiedChineseImage sevents - UIView::OnClickListener *ButtonClick = static_cast(new SystemLanguagePresenter(SimplifiedChineseCheckBox, EnglishCheckBox)); - SimplifiedChineseCheckBox->SetOnClickListener(ButtonClick); - EnglishCheckBox->SetOnClickListener(ButtonClick); + // 设置标签 + 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; } - void SystemLanguageView::DeInitView() + // 设置单选按钮 + UIRadioButton *SystemLanguageView::SetUpRadioButton(RadioButtonConfig &radioButtonconfig) { - if (container_ != nullptr) + UIRadioButton *radiobutton = new UIRadioButton(radioButtonconfig.name); + if (radiobutton == nullptr) { - container_->RemoveAll(); - delete container_; - container_ = nullptr; + return nullptr; } - if (scrollView != nullptr) - { - delete scrollView; - scrollView = nullptr; - } - if (LanguageLabel != nullptr) - { - delete LanguageLabel; - LanguageLabel = nullptr; - } - if (SimplifiedChineseImage != 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) { - delete SimplifiedChineseImage; - SimplifiedChineseImage = nullptr; + radiobutton.SetState(UICheckBox::SELECTED); } - if (SimplifiedChineseCheckBox != nullptr) + else { - delete SimplifiedChineseCheckBox; - SimplifiedChineseCheckBox = nullptr; + radiobutton.SetState(UICheckBox::UNSELECTED); } - if (EnglishImage != nullptr) + } + + UIScrollView *SystemLanguageView::SystemLanguageViewInit(void) + { + /* ------------------------------- scrollView ------------------------------- */ + scrollView = new UIScrollView(); + if (scrollView == nullptr) { - delete EnglishImage; - EnglishImage = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::scrollView new fail!"); } - if (SimplifiedChineseLabel != nullptr) + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + scrollView->SetVisible(true); + 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 UILabel(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::Title new fail!"); + return nullptr; + } + Title->SetPosition(203, 52); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + Title->SetText("语言"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + 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) { - delete SimplifiedChineseLabel; - SimplifiedChineseLabel = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::SimplifiedChineseLabel new fail!"); + return nullptr; } - if (EnglishLabel != nullptr) - { - delete EnglishLabel; - EnglishLabel = nullptr; - } - if (EnglishCheckBox != nullptr) + scrollView->Add(SimplifiedChineseLabel); + /* ------------------------------ EnglishLabel ------------------------------ */ + labelconfig.top = 273; + labelconfig.text = "ENGLISH"; + EnglishLabel = SetUpLabel(labelconfig); + if (EnglishLabel == nullptr) { - delete EnglishCheckBox; - EnglishCheckBox = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::EnglishLabel new fail!"); + return nullptr; } - } - - void SystemLanguageView::OnStart() - { - View::OnStart(); - InitView(); - // container_容器属性 add - RootView::GetInstance()->Add(container_); - } - - void SystemLanguageView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void SystemLanguageView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void SystemLanguageView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; + scrollView->Add(EnglishLabel); + /* ---------------------- SimplifiedChineseRadioButton ---------------------- */ + RadioButtonConfig radioButtonConfig = { + .left = 300, + .top = 120, + .width = 100, + .height = 100, + .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); + scrollView->Add(SimplifiedChineseRadioButton); + /* --------------------------- EnglishRadioButton --------------------------- */ + radioButtonConfig.left = 300; + radioButtonConfig.top = 240; + radioButtonConfig.viewId = ENGLISH_CHECKBOX; + EnglishRadioButton = SetUpRadioButton(radioButtonConfig); + if (EnglishRadioButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemLanguageView::EnglishRadioButton new fail!"); + return nullptr; + } + scrollView->Add(EnglishRadioButton); + initViewStatus = true; + return scrollView; } } \ 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 61653686a..9a3152243 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -73,17 +73,17 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) { - SystemView::GetInstance()->ChangeView(0,1); + SystemView::GetInstance()->ChangeView(0, 1); return true; } else if (strcmp(view.GetViewId(), SUPERVISE) == 0) { - SystemView::GetInstance()->ChangeView(0,2); + SystemView::GetInstance()->ChangeView(0, 2); return true; } else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_SYSTEM_LANGUAGE); + SystemView::GetInstance()->ChangeView(0, 3); return true; } else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) 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 b16c7df4c..10b994873 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp @@ -40,7 +40,7 @@ namespace OHOS SystemScrollView[0]->SetScrollBlankSize(35); SystemScrollView[0]->SetReboundSize(50); SystemScrollView[0]->SetDirection(1); - draglistener = static_cast(SystemPresenter::GetInstance()); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); if (draglistener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); @@ -109,7 +109,7 @@ namespace OHOS return; } /* -------------------------------------------------------------------------- */ - clickListener = static_cast(SystemPresenter::GetInstance()); + UIView::OnClickListener *clickListener = static_cast(SystemPresenter::GetInstance()); /* -------------------------------------------------------------------------- */ ButtonConfig buttonconfig; buttonconfig.x = 43; @@ -161,11 +161,12 @@ namespace OHOS if (initViewStatus == true) { SystemScrollView[0]->RemoveAll(); - for (int i = 0; i < 3; i++) - { - delete SystemScrollView[i]; - SystemScrollView[i] = nullptr; - } + delete p_SystemAboutTheWatchView; + p_SystemAboutTheWatchView = nullptr; + delete p_SystemSuperviseView; + p_SystemSuperviseView = nullptr; + delete p_SystemLanguageView; + p_SystemLanguageView = nullptr; delete SystemLabel; SystemLabel = nullptr; delete AboutTheWatchButton; @@ -179,13 +180,15 @@ namespace OHOS } } + // 0.跳转到系统视图,其他视图都市通过这个视图跳转 bool SystemView::ChangeSystemView(int16_t thisView) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemView"); RootView::GetInstance()->Add(SystemScrollView[thisView]); return true; } - //跳转到关于手表 + // 1.跳转到关于手表 bool SystemView::ChangeSystemAboutView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -198,19 +201,12 @@ namespace OHOS return false; } SystemScrollView[thisView] = p_SystemAboutTheWatchView->SystemAbouTheWatchtInitIView(); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + RootView::GetInstance()->Add(SystemScrollView[thisView]); } return true; } - /* -------------------------------------------------------------------------- */ - // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 - struct SystemViewMapper - { - const int16_t viewId; - bool (SystemView::*func)(int16_t thisView); - }; - //跳转到系统监管 + // 2.跳转到系统监管 bool SystemView::ChangeSystemSuperviseView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -223,16 +219,44 @@ namespace OHOS return false; } SystemScrollView[thisView] = p_SystemSuperviseView->SystemSuperviseViewInit(); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + RootView::GetInstance()->Add(SystemScrollView[thisView]); + } + return true; + } + + // 3.跳转到系统语言界面 + bool SystemView::ChangeSystemLanguageView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(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]); } return true; } + + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + struct SystemViewMapper + { + const int16_t viewId; + bool (SystemView::*func)(int16_t thisView); + }; + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 static const SystemViewMapper ViewMapper[] = { {0, &SystemView::ChangeSystemView}, {1, &SystemView::ChangeSystemAboutView}, - {2, &SystemView::ChangeSystemSuperviseView} + {2, &SystemView::ChangeSystemSuperviseView}, + {3, &SystemView::ChangeSystemLanguageView}, }; // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 @@ -257,9 +281,9 @@ namespace OHOS // 4.切换视图 void SystemView::ChangeView(int16_t hideView, int16_t showView) { - if (hideView > 4) + if (hideView > 5) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: StopWatchViewId Overstep ones bounds"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); return; } SystemScrollView[hideView]->SetVisible(false); @@ -267,6 +291,7 @@ namespace OHOS SystemScrollView[showView]->SetVisible(true); Draw(); } + /* -------------------------------------------------------------------------- */ void SystemView::OnStart() { diff --git a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c index 14051ee50..0d90e0c48 100755 --- a/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c +++ b/code/sdk/open_source/openharmony/base/startup/syspara_lite/src/hal_sys_param.c @@ -39,7 +39,7 @@ const char g_roBuildOs[] = {"OpenHarmony-3.2.11.9"}; const char g_roBuildVerShow[] = {"1.0.0"}; const int g_roFirstApiLevel = 1; const char INCREMENTAL_VERSION[] = {"version"}; -const char BUILD_TYPE[] = {"debug"}; +const char BUILD_TYPE[] = {"release"}; const char BUILD_USER[] = {"luozheng"}; const char BUILD_HOST[] = {"linux"}; const char BUILD_TIME[] = {"2024111"};