From: hcj <1224667075@qq.com> Date: Thu, 7 Mar 2024 06:32:19 +0000 (+0800) Subject: 系统视图按键修改 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~19^2~7^2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=818509d3c865b187ecdadc07dfdc11b2bbe29e4a;p=mirrors%2FFD230.git 系统视图按键修改 --- 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 98362a6ed..c456417d6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h @@ -14,7 +14,8 @@ namespace OHOS ABOUTTHEWATCHVIEW, // 关于手表视图(subView) SUPERVISEVIEW, // 监管视图(subView) SYSTEMLANGUAGEVIEW, // 系统语言视图(subView) - FACTORYRESETVIEW, // 恢复出厂设置视图(subView) + FACTORYRESETVIEW, // 恢复出厂设置视图(subView)upgrade + SYSTEMLUPGRADE, MAX_SYSTEMVIEWID, } SYSTEMVIEWID; 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 971196756..c47602b50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h @@ -47,6 +47,24 @@ namespace OHOS const char *ViewId; const char *ImageSrc; }; + struct ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + const char *ImageSrc; + + //label + int label_x; + int label_y; + uint8_t ALIGN; + int Fontsize; + + }; + bool ChangeSystemView(int16_t thisView); bool ChangeSystemAboutView(int16_t thisView); bool ChangeSystemSuperviseView(int16_t thisView); @@ -58,10 +76,12 @@ namespace OHOS private: void InitIView(void); + 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); + UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &ButtonConfig_ext, UIView::OnClickListener *clickListener); SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; SystemSuperviseView *p_SystemSuperviseView{nullptr}; SystemLanguageView *p_SystemLanguageView{nullptr}; 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 5d8b16342..1b202bfff 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -11,6 +11,27 @@ namespace OHOS { + + struct SystemView_ext_p + { + const int16_t viewId; + char *viewid_str; + bool enable_falg; + }; + + + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 + static SystemView_ext_p ViewMapper_t[] = { + {ABOUTTHEWATCHVIEW,"AboutTheWatchButton",true}, + {SUPERVISEVIEW,"SuperviseButton",true}, + {SYSTEMLANGUAGEVIEW,"SystemLanguageButton",false}, + {FACTORYRESETVIEW,"FactoryResetButton",true}, + {SYSTEMLUPGRADE,"systemupgread",true}}; + + // {ABOUTTHEWATCHVIEW, &SystemView::ChangeSystemAboutView}, + // {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView}, + // {SYSTEMLANGUAGEVIEW, &SystemView::ChangeSystemLanguageView}, + // 当前Presenter属性实例化的内存指针 static SystemPresenter *g_pSystemPresenter = nullptr; @@ -84,30 +105,23 @@ namespace OHOS bool SystemPresenter::OnClick(UIView &view, const ClickEvent &event) { SystemView *p_SystemView = SystemView::GetInstance(); + int len=sizeof(ViewMapper_t)/sizeof(SystemView_ext_p); + //int len=5; // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) - { - SystemView::GetInstance()->ChangeView(SYSTEMVIEW, ABOUTTHEWATCHVIEW); - return true; - } - else if (strcmp(view.GetViewId(), SUPERVISE) == 0) - { - SystemView::GetInstance()->ChangeView(SYSTEMVIEW, SUPERVISEVIEW); - return true; - } -#if 0 - else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) - { - SystemView::GetInstance()->ChangeView(SYSTEMVIEW, SYSTEMLANGUAGEVIEW); - return true; - } -#endif - else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) + + for(int i=0;i<5;i++) { - SystemView::GetInstance()->ChangeView(SYSTEMVIEW, FACTORYRESETVIEW); - return true; + if(strcmp(view.GetViewId(),ViewMapper_t[i].viewid_str) == 0) + { + if(ViewMapper_t[i].enable_falg==true) + SystemView::GetInstance()->ChangeView(SYSTEMVIEW, ViewMapper_t[i].viewId); + return true; + } + } - else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) + + + if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) { return true; } 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 a897beb6f..e140474f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -6,6 +6,29 @@ namespace OHOS static SystemView *g_pSystemView{nullptr}; + struct SystemViewMapper_ext + { + const int16_t viewId; + char *viewid_str; + 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::ChangeSystemFactoryResetView}, + + // {ABOUTTHEWATCHVIEW, &SystemView::ChangeSystemAboutView}, + // {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView}, + // {SYSTEMLANGUAGEVIEW, &SystemView::ChangeSystemLanguageView}, + // {FACTORYRESETVIEW, &SystemView::ChangeSystemFactoryResetView}, + }; + SystemView::SystemView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); @@ -35,6 +58,12 @@ namespace OHOS delete draglistener; draglistener = nullptr; } + for(int i=0;iSetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetOnClickListener(clickListener); + + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + 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->SetImagePosition(326, 37); + return button; + } + + + + void SystemView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc) + { + if (!SetTheSystemScrollView()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView() fail!"); + return; + } + if (!SetTheTitle()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheTitle() fail!"); + return; + } + /* -------------------------------------------------------------------------- */ + UIView::OnClickListener *clickListener = static_cast(SystemPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = x; + buttonconfig.y = y; + buttonconfig.w = w; + buttonconfig.h = h; + + int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext); + + for(int i=0;i*(ViewMapper[i].func))(interface); + bool jug = (this->*(ViewMapper_t[i].func))(interface); if (jug == false) { return false; @@ -356,7 +456,8 @@ namespace OHOS void SystemView::OnStart() { View::OnStart(); - InitIView(); + //InitIView(); + initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin"); } void SystemView::OnSetUpView() @@ -367,12 +468,20 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); return; } + SystemScrollView[SYSTEMVIEW]->Add(SystemLabel); - SystemScrollView[SYSTEMVIEW]->Add(AboutTheWatchButton); - SystemScrollView[SYSTEMVIEW]->Add(SuperviseButton); - SystemScrollView[SYSTEMVIEW]->Add(SystemLanguageButton); - SystemScrollView[SYSTEMVIEW]->Add(FactoryResetButton); - SystemScrollView[SYSTEMVIEW]->Add(SystemUpgradeButtonExt); + + int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext); + + for(int i=0;iAdd(button[i]); + } + // SystemScrollView[SYSTEMVIEW]->Add(SuperviseButton); + // SystemScrollView[SYSTEMVIEW]->Add(SystemLanguageButton); + // SystemScrollView[SYSTEMVIEW]->Add(FactoryResetButton); + // SystemScrollView[SYSTEMVIEW]->Add(SystemUpgradeButtonExt); + RootView::GetInstance()->Add(SystemScrollView[SYSTEMVIEW]); Draw(); }