From 8c1c67417df7aefc5f7ebd2e7c0849ed7a67aa2a Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Wed, 17 Sep 2025 14:06:27 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E9=9B=B7=E9=B8=9FLCD=E4=BA=A7?= =?utf8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/AppViewIDs.h | 1 + .../include/lcdtest/LcdTestPresenter.h | 22 +++ .../nativeui/include/lcdtest/LcdTestView.h | 36 +++++ .../nativeui/lcdtest/src/LcdTestPresenter.cpp | 31 +++++ .../nativeui/lcdtest/src/LcdTestView.cpp | 123 ++++++++++++++++ .../rebootdevice/src/RebootPresenter.cpp | 2 +- .../include/ThunderBirdGuideView.h | 2 + .../thunderbird/include/ThunderBirdMainView.h | 4 - .../include/ThunderBirdShutdownTestView.h | 45 ------ .../thunderbird/src/ThunderBirdGuideView.cpp | 25 ++-- .../src/ThunderBirdLullabyView.cpp | 1 + .../thunderbird/src/ThunderBirdMainView.cpp | 36 +---- .../thunderbird/src/ThunderBirdModel.cpp | 9 ++ .../thunderbird/src/ThunderBirdPresenter.cpp | 53 ++++--- .../src/ThunderBirdShutdownTestView.cpp | 131 ------------------ 15 files changed, 282 insertions(+), 239 deletions(-) create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp delete mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h delete mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp diff --git a/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h index 067b5d932..25768eb3b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h @@ -60,6 +60,7 @@ typedef enum : uint16_t { VIEW_TRAINING, VIEW_EMPTY, VIEW_THUNDER_BIRD, + VIEW_LCD_TEST, #ifdef SUPPORT_ALIPAY_SEC VIEW_MAIN_ALIPAY, #endif diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h new file mode 100644 index 000000000..85770b920 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h @@ -0,0 +1,22 @@ +#ifndef LCD_TEST_PRESENTER_H +#define LCD_TEST_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "drag_event.h" + +namespace OHOS { +class LcdTestView; +class LcdTestPresenter : public Presenter { +public: + LcdTestPresenter(); + ~LcdTestPresenter() override; + static LcdTestPresenter* GetInstance(); + +private: + static LcdTestPresenter* self_; +}; +} // namespace OHOS +#endif + + diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h new file mode 100644 index 000000000..58a74bc24 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h @@ -0,0 +1,36 @@ +#ifndef LCD_TEST_VIEW_H +#define LCD_TEST_VIEW_H + +#include "lcdtest/LcdTestPresenter.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "cmsis_os2.h" + +namespace OHOS { +class LcdTestView : public View { +public: + LcdTestView(); + ~LcdTestView() override; + static LcdTestView* GetInstance(); + + void OnStart() override; + UIViewGroup* InitShowUpView(); + void StartAnimation(); + void SetLCDColor(int color); + +private: + void ClearAll(); + +private: + UIViewGroup* group{nullptr}; + UIImageView* overlay{nullptr}; + osTimerId_t timer_{NULL}; + uint8_t colorIndex_{0}; + static LcdTestView* self_; +}; +} // namespace OHOS +#endif + + + diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp new file mode 100644 index 000000000..b2e8099b7 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp @@ -0,0 +1,31 @@ +#include "lcdtest/LcdTestPresenter.h" +#include "lcdtest/LcdTestView.h" +#include "NativeAbility.h" +#include "AppViewIDs.h" +#include "NativeRegisterManager.h" +#include "wearable_log.h" +#include "drag_event.h" + +namespace OHOS { +REGIST_SLICE(VIEW_LCD_TEST, LcdTestView, LcdTestPresenter); + +LcdTestPresenter* LcdTestPresenter::self_{nullptr}; + +LcdTestPresenter::LcdTestPresenter() +{ + self_ = this; +} + +LcdTestPresenter::~LcdTestPresenter() +{ + self_ = nullptr; +} + +LcdTestPresenter* LcdTestPresenter::GetInstance() +{ + return self_; +} + +} // namespace OHOS + + diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp new file mode 100644 index 000000000..3435de636 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp @@ -0,0 +1,123 @@ +#include "lcdtest/LcdTestView.h" +#include "UiConfig.h" +#include "components/root_view.h" +#include "common/screen.h" +#include "wearable_log.h" + +namespace OHOS { +static void LcdTestTick(void* arg) +{ + LcdTestView* v = reinterpret_cast(arg); + if (v != nullptr) { + v->SetLCDColor(-1); + } +} + +LcdTestView* LcdTestView::self_{nullptr}; + +LcdTestView::LcdTestView() +{ + self_ = this; +} + +LcdTestView::~LcdTestView() +{ + ClearAll(); + self_ = nullptr; +} + +LcdTestView* LcdTestView::GetInstance() +{ + return self_; +} + +void LcdTestView::ClearAll() +{ + if (timer_ != NULL) { + osTimerStop(timer_); + osTimerDelete(timer_); + timer_ = NULL; + } + if (overlay != nullptr) { + if (group != nullptr) { + group->Remove(overlay); + } + delete overlay; + overlay = nullptr; + } + if (group != nullptr) { + group->RemoveAll(); + delete group; + group = nullptr; + } +} + +UIViewGroup* LcdTestView::InitShowUpView() +{ + if (group != nullptr) { + return group; + } + group = new UIViewGroup(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LcdTestView group new fail"); + return nullptr; + } + group->SetPosition(0, 0); + group->SetWidth(HORIZONTAL_RESOLUTION); + group->SetHeight(VERTICAL_RESOLUTION); + group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + + overlay = new UIImageView(); + if (overlay != nullptr) { + overlay->SetPosition(0, 0, group->GetWidth(), group->GetHeight()); + overlay->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + overlay->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + overlay->SetVisible(true); + group->Add(overlay); + } + return group; +} + +void LcdTestView::StartAnimation() +{ + if (timer_ == NULL) { + timer_ = osTimerNew((osTimerFunc_t)LcdTestTick, osTimerPeriodic, this, NULL); + } + colorIndex_ = 0; + if (timer_ != NULL) { + osTimerStart(timer_, 1000); + } +} + +void LcdTestView::SetLCDColor(int color) +{ + if (group == nullptr) { + return; + } + if (color < 0) { + color = colorIndex_++; + } + switch (color % 6) { + case 0: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); break; + case 1: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); break; + case 2: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Yellow().full); break; + case 3: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); break; + case 4: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full); break; + case 5: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); break; + default: break; + } + RootView::GetInstance()->Invalidate(); +} + +void LcdTestView::OnStart() +{ + UIViewGroup* v = InitShowUpView(); + if (v != nullptr) { + AddViewToRootContainer(v); + StartAnimation(); + } +} +} // namespace OHOS + + diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp index bdd3ef7a4..223e102dd 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/rebootdevice/src/RebootPresenter.cpp @@ -13,7 +13,7 @@ namespace OHOS { -//REGIST_SLICE(VIEW_REBOOT, RebootView, RebootPresenter); +REGIST_SLICE(VIEW_REBOOT, RebootView, RebootPresenter); static RebootPresenter *g_pRebootPresenter = nullptr; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h index 6ff4bb5f6..e705b46c7 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h @@ -6,6 +6,7 @@ #include "components/ui_label_ext.h" #include "components/ui_image_view.h" #include "components/ui_label_button.h" +#include "components/ui_qrcode.h" namespace OHOS { @@ -29,6 +30,7 @@ namespace OHOS UIViewGroup *group{nullptr}; UILabelExt *TextLabel{nullptr}; UILabelExt *TextLabel_Y{nullptr}; + UIQrcode *qrcode_{nullptr}; UILabelButton *RemindButton{nullptr}; UILabelExt *RemindLabel{nullptr}; UIImageView *RemindGround{nullptr}; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h index 80b4db9b3..51b2039e5 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h @@ -22,7 +22,6 @@ #include "thunderbird/include/ThunderBirdReminderView.h" #include "thunderbird/include/ThunderBirdAdjustView.h" #include "thunderbird/include/ThunderBirdShutdownView.h" -#include "thunderbird/include/ThunderBirdShutdownTestView.h" namespace OHOS { static constexpr const char *DROPDOWN_NOSIGNAL_IMAGE = "/user/res/DROPDOWN_NOSIGNAL.bin"; @@ -37,7 +36,6 @@ namespace OHOS THUNDERBIRD_REMINDERVIEW, THUNDERBIRD_ADJUSTVIEW, THUNDERBIRD_SHUTDOWNVIEW, - THUNDERBIRD_SHUTDOWNTESTVIEW, MAXVIEW } BPVIEWID; @@ -59,7 +57,6 @@ namespace OHOS bool ChangeThunderBirdReminderView(int16_t); bool ChangeThunderBirdAdjustView(int16_t); bool ChangeThunderBirdShutdownView(int16_t); - bool ChangeThunderBirdShutdownTestView(int16_t); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView, int16_t subView = -1); int16_t GetPrevViewId() const { return prevView_; } @@ -141,7 +138,6 @@ namespace OHOS ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr}; ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr}; ThunderBirdShutdownView *g_pThunderBirdShutdownView{nullptr}; - ThunderBirdShutdownTestView *g_pThunderBirdShutdownTestView{nullptr}; #define SCREEN_WIDTH 360 #define SCREEN_HEIGHT 360 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h deleted file mode 100644 index d040aeb3c..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdShutdownTestView.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef THUNDERBIRD_SHUTDOWN_TEST_VIEW_H -#define THUNDERBIRD_SHUTDOWN_TEST_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_image_animator.h" - -namespace OHOS -{ - static constexpr int16_t TB_SHUTDOWN_ANIM_X_TEST = 0; - static constexpr int16_t TB_SHUTDOWN_ANIM_Y_TEST = 0; - static constexpr int16_t TB_SHUTDOWN_ANIM_W_TEST = 360; - static constexpr int16_t TB_SHUTDOWN_ANIM_H_TEST = 360; - static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES_TEST = 86; - static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL_TEST = 41; - static constexpr const char *TB_SHUTDOWN_ANIM_PATH_TEST = "/user/res/emoticon/naughty"; - class ThunderBirdShutdownTestView : public UIImageAnimatorView::AnimatorStopListener - { - public: - ThunderBirdShutdownTestView(); - virtual ~ThunderBirdShutdownTestView(); - - static ThunderBirdShutdownTestView *GetInstance(); - - UIViewGroup *Init(); - UIImageAnimatorView *GetAnimator(); - - void StartAnimation(); - - private: - void OnAnimatorStop(UIView &view) override; - void ClearAll(); - bool EnsureAnimator(); - - private: - UIViewGroup *group{nullptr}; - UIImageAnimatorView *animator{nullptr}; - ImageAnimatorInfo imageInfos[TB_SHUTDOWN_ANIM_FRAMES_TEST]; - UIImageView *iconView{nullptr}; - const char **pathsArray{nullptr}; - }; -} - -#endif - - diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp index 4e9919224..2c6155089 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp @@ -33,6 +33,7 @@ namespace OHOS if (RemindButton != nullptr) { delete RemindButton; RemindButton = nullptr; } if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; } + if (qrcode_ != nullptr) { delete qrcode_; qrcode_ = nullptr; } if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } if (RemindGround != nullptr) { delete RemindGround; RemindGround = nullptr; } if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } @@ -74,6 +75,18 @@ namespace OHOS TextLabel->SetVisible(false); group->Add(TextLabel); } + qrcode_ = new UIQrcode(); + if (qrcode_) + { + qrcode_->SetPosition(133, 169, 104, 104); + qrcode_->SetQrcodeInfo("https://example.com/device/bind?deviceId=DEVICE_001"); + qrcode_->SetStyle(STYLE_PADDING_LEFT, 4); + qrcode_->SetStyle(STYLE_PADDING_RIGHT, 4); + qrcode_->SetStyle(STYLE_PADDING_TOP, 4); + qrcode_->SetStyle(STYLE_PADDING_BOTTOM, 4); + qrcode_->SetVisible(false); + group->Add(qrcode_); + } RemindButton = new UILabelButton(); if (RemindButton) @@ -129,6 +142,7 @@ namespace OHOS if (group == nullptr) { return; } if (TextLabel) { TextLabel->SetVisible(false);TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);} if (TextLabel_Y) { TextLabel_Y->SetVisible(false); } + if (qrcode_) { qrcode_->SetVisible(false); } if (RemindButton) { RemindButton->SetVisible(false); } if (RemindLabel) { RemindLabel->SetVisible(false); } if (RemindIcon) { RemindIcon->SetVisible(false); } @@ -211,18 +225,14 @@ namespace OHOS TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);//自动换行 TextLabel->SetVisible(true); } - if(RemindIcon2) + if (qrcode_) { - RemindIcon2->SetPosition(133, 169, 104, 104); - RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - RemindIcon2->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - //RemindIcon->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); + qrcode_->SetVisible(true); } if(RemindIcon) { RemindIcon->SetPosition(158, 296, 30, 30); - RemindIcon->SetSrc("/user/res/volumeup.bin"); + RemindIcon->SetSrc("/user/res/volume_up.bin"); RemindIcon->SetVisible(true); } if (RemindButton) @@ -234,7 +244,6 @@ namespace OHOS RemindButton->SetVisible(true); } - // 黑色背景与二维码需要补充 break; } default: diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp index 6b855ff08..245270604 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp @@ -186,6 +186,7 @@ namespace OHOS { TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel_Y->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); TextLabel_Y->SetVisible(false); group->Add(TextLabel_Y); } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 8b9b425ae..cfa4cebd9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -17,7 +17,6 @@ //#include "MainPresenterSample.h" #include "thunderbird/include/ThunderBirdMainView.h" #include "thunderbird/include/ThunderBirdShutdownView.h" -#include "thunderbird/include/ThunderBirdShutdownTestView.h" #include "wearable_log.h" @@ -74,7 +73,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ThunderBirdMainView"); g_pThunderBirdMainView = this; - //ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮 + ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮 ThunderBirdModel::GetInstance()->StartTimer(); } @@ -89,7 +88,7 @@ namespace OHOS ScrollView_ = nullptr; } g_pThunderBirdMainView = nullptr; - //ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 + ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 ThunderBirdModel::GetInstance()->StopTimer(); } @@ -136,11 +135,6 @@ namespace OHOS delete g_pThunderBirdShutdownView; g_pThunderBirdShutdownView = nullptr; } - if (g_pThunderBirdShutdownTestView) - { - delete g_pThunderBirdShutdownTestView; - g_pThunderBirdShutdownTestView = nullptr; - } if (g_pThunderBirdShutdownView) { delete g_pThunderBirdShutdownView; @@ -282,22 +276,22 @@ namespace OHOS ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, 0); // 文字显示图层 //绑定设备提示 > 配置更新成功>OTA升级>其他(按触发时间先后提示) /*************************用户是否绑定*************************/ - // ln_http_server_send_task(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定 + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定 // if(uapi_ln_get_user_bind_status() == 0)//未绑定 // { // ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1); // } // if(uapi_ln_get_user_bind_status() == 1)//已绑定 // { - // ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2); + // //ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);进入对话界面 // } // /*************************更新角色配置*************************/ - // ln_http_server_send_task(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置 + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置 // /*************************OTA升级*************************/ - // ln_http_server_send_task(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级 + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级 // if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级 // { // ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); @@ -316,6 +310,7 @@ namespace OHOS // RootView::GetInstance()->SetOnKeyActListener(keyactListener); } } + bool ThunderBirdMainView::SwitchVideo(const char *uri) // 切换表情接口 { @@ -500,22 +495,6 @@ namespace OHOS } return true; } - bool ThunderBirdMainView::ChangeThunderBirdShutdownTestView(int16_t thisView) // 切换关机测试界面接口 - { - if (group[thisView] == nullptr) - { - g_pThunderBirdShutdownTestView = new ThunderBirdShutdownTestView(); - if (g_pThunderBirdShutdownTestView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new fail %d", thisView); - return false; - } - group[thisView] = g_pThunderBirdShutdownTestView->Init(); - ScrollView_->Add(group[thisView]); - g_pThunderBirdShutdownTestView->StartAnimation(); - } - return true; - } /** * 视图映射结构体 - 将视图ID映射到对应的视图切换函数 @@ -534,7 +513,6 @@ namespace OHOS {THUNDERBIRD_REMINDERVIEW, &ThunderBirdMainView::ChangeThunderBirdReminderView}, {THUNDERBIRD_ADJUSTVIEW, &ThunderBirdMainView::ChangeThunderBirdAdjustView}, {THUNDERBIRD_SHUTDOWNVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownView}, - {THUNDERBIRD_SHUTDOWNTESTVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownTestView}, }; bool ThunderBirdMainView::ClickFunc(int16_t interface) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index ef1b33c17..c71b9d858 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -25,6 +25,13 @@ #include namespace OHOS { + enum OTA_STATUS + { + OTA_STATUS_LOW_BATTERY = 0, + OTA_STATUS_DOW, + OTA_STATUS_UPDATING, + OTA_STATUS_SUCCESS, + }; ThunderBirdModel::ThunderBirdModel() {} ThunderBirdModel::~ThunderBirdModel() {} @@ -66,6 +73,8 @@ namespace OHOS } } + + /* ---------------------- 状态栏时间刷新定时器 ---------------------- */ static osTimerId_t g_timer = nullptr; /*定时器到期时的处理*/ diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index 10304d95e..fcdd1593b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -23,6 +23,7 @@ #include "samgr_lite.h" #include "service_id_define.h" #include "dock/input_device.h" +#include "custom_runtime.h" namespace OHOS { static int i=0;//版本临时变量 @@ -104,6 +105,11 @@ namespace OHOS uint16_t keyID = event.GetKeyId(); uint16_t keyState = event.GetState(); + // 刷新息屏计时:任意按键按下时重置屏幕熄灭倒计时 + if (keyState == InputDevice::STATE_PRESS) { + uapi_set_screen_on_api(); + } + // 长按关机键 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == InputDevice::STATE_LONG_PRESS) @@ -111,33 +117,38 @@ namespace OHOS NativeAbility::GetInstance().SwitchSlice(VIEW_REBOOT); return true; } + + // 长按 FUNC:进入 LCD 产测 slice + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC) && + keyState == InputDevice::STATE_LONG_PRESS && + uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().SwitchSlice(VIEW_LCD_TEST); + return true; + } /*************************power键*************************/ if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView); - i++; - if(i == 1) - { - ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/blue.bin"); - } - else if(i == 2) - { - ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/curly_hair.bin"); - } - else if(i == 3) - { - ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/SidePartingShort/purple.bin"); - } - else if(i == 4) - { - ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Bangs/gold.bin"); - } - else if(i == 5) - { - ThunderBirdMainView::GetInstance()->SwitchVideo("/user/video/Angry.mp4"); - } + // i++; + // if(i == 1) + // { + // ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/blue.bin"); + // } + // else if(i == 2) + // { + // ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/curly_hair.bin"); + // } + // else if(i == 3) + // { + // ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/SidePartingShort/purple.bin"); + // } + // else if(i == 4) + // { + // ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Bangs/gold.bin"); + // } return true; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp deleted file mode 100644 index 7a1d8ea52..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdShutdownTestView.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "thunderbird/include/ThunderBirdShutdownTestView.h" -//#include "uicomponents/UIComponents.h" -#include "wearable_log.h" -#include "custom_utils.h" -#include "thunderbird/include/ThunderBirdMainView.h" -#include "UiConfig.h" - -namespace OHOS -{ - static ThunderBirdShutdownTestView *g_tbShutdownTestView{nullptr}; - static const char *TB_NAUGHTY_PATHS[TB_SHUTDOWN_ANIM_FRAMES_TEST] = { - - }; - ThunderBirdShutdownTestView::ThunderBirdShutdownTestView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::ThunderBirdShutdownTestView"); - if (ThunderBirdMainView::GetInstance()) - { - // ThunderBirdMainView::GetInstance()->CloseVideo(); - ThunderBirdMainView::GetInstance()->videoPlay_->StopVideoPlay(); - } - g_tbShutdownTestView = this; - } - - ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView"); - ClearAll(); - g_tbShutdownTestView = nullptr; - } - ThunderBirdShutdownTestView *ThunderBirdShutdownTestView::GetInstance() - { - return g_tbShutdownTestView; - } - - void ThunderBirdShutdownTestView::ClearAll() - { - if (group != nullptr) - { - group->RemoveAll(); - if (animator != nullptr) - { - delete animator; - animator = nullptr; - } - //FreeImagePathsArray(pathsArray, TB_SHUTDOWN_ANIM_FRAMES_TEST); - delete group; - group = nullptr; - } - } - - bool ThunderBirdShutdownTestView::EnsureAnimator() - { - if (animator == nullptr) - { - pathsArray = TB_NAUGHTY_PATHS; - animator = new UIImageAnimatorView(); - if (animator == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new UIImageAnimatorView fail"); - return false; - } - animator->SetAutoEnable(false); - for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES_TEST; i++) - { - imageInfos[i].imagePath = (pathsArray[i]); - imageInfos[i].imageType = IMG_SRC_FILE_PATH; - imageInfos[i].pos.x = TB_SHUTDOWN_ANIM_X_TEST; - imageInfos[i].pos.y = TB_SHUTDOWN_ANIM_Y_TEST; - imageInfos[i].width = TB_SHUTDOWN_ANIM_W_TEST; - imageInfos[i].height = TB_SHUTDOWN_ANIM_H_TEST; - } - animator->SetPosition(TB_SHUTDOWN_ANIM_X_TEST, TB_SHUTDOWN_ANIM_Y_TEST, TB_SHUTDOWN_ANIM_W_TEST, TB_SHUTDOWN_ANIM_H_TEST); - animator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - animator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - animator->SetImageAnimatorSrc(imageInfos, TB_SHUTDOWN_ANIM_FRAMES_TEST, TB_SHUTDOWN_ANIM_INTERVAL_TEST); - animator->SetRepeat(true); - animator->SetRepeatTimes(1); - animator->SetResizeMode(UIImageView::COVER); - //animator->SetAnimatorStopListener(this); - } - return true; - } - - UIViewGroup *ThunderBirdShutdownTestView::Init() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::Init"); - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView group new fail"); - return nullptr; - } - group->SetPosition(0, 0, 360, 360); - if (!EnsureAnimator()) - { - return nullptr; - } - group->Add(animator); - iconView = new UIImageView(); - iconView->SetPosition(0, 0, 360, 360); - iconView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - iconView->SetStyle(STYLE_BACKGROUND_OPA, 0x66); - iconView->SetVisible(false); - group->Add(iconView); - return group; - } - - UIImageAnimatorView *ThunderBirdShutdownTestView::GetAnimator() - { - return animator; - } - - void ThunderBirdShutdownTestView::StartAnimation() - { - if (!EnsureAnimator()) - { - return; - } - animator->Start(); - } - - void ThunderBirdShutdownTestView::OnAnimatorStop(UIView &view) - { - UNUSED(view); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::OnAnimatorStop"); - // No shutdown side effects in test view - } -} - - -- 2.17.1