From 8d07d3f00a14afb5952eab0a178d2a1f882c337c Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 16 Aug 2025 14:33:40 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=85=B3=E6=9C=BA=E5=8A=A8?= =?utf8?q?=E7=94=BB=E5=BC=B9=E7=AA=97=E5=BE=85=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../msg_center/src/msg_center_customer.cpp | 20 +- .../src/notify/pairing_notification.cpp | 126 +- .../src/notify/pairing_notification.cpp | 1027 ----------------- 3 files changed, 80 insertions(+), 1093 deletions(-) delete mode 100644 code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp index 153186fe6..60f5754a9 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp @@ -101,7 +101,7 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_GOAL_SHOW_VIEW,PRIORITY_TWO}, // 训练目标弹窗 {TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO}, // 喝水提醒弹窗 {TOPIC_EVENT_SLEEPNOTE,PRIORITY_TWO}, // 睡眠提醒弹窗 - + {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,PRIORITY_ONE}, // 关机动画弹窗 }; @@ -152,6 +152,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_GOAL_SHOW_VIEW); MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER); MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE); + MsgCenterSubscribeTopic(TOPIC_EVENT_SHUTDOWN_ANIMATIOR); } @@ -249,7 +250,11 @@ static OHOS::UIViewGroup* showSleepNotify(void) { return OHOS::CreateSleepNotifyView(); } - +//关机动画 +static OHOS::UIViewGroup* showShutdownAnimatorNotify(void) +{ + return OHOS::showShutDownAnimation(); +} void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -748,6 +753,16 @@ void MsgCenterNotifySleepProc(const Topic topic, Request* req) } } +//关机动画 +void MsgCenterNotifyShutDownAnimatorProc(const Topic topic, Request* req) +{ + unused(topic); + uint8_t* data=(uint8_t*)req->data; + set_shutDownAnimation_falg(data[0]); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyShutDownAnimatorProc,shutdown_flag = %d",*data); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + NotificationManager::GetInstance()->ShowNotify(showShutdownAnimatorNotify, (uint16_t)topic, true); +} #endif @@ -777,6 +792,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_GOAL_SHOW_VIEW,MsgCenterNotifyGoalShowViewProc}, {TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc}, {TOPIC_EVENT_SLEEPNOTE,MsgCenterNotifySleepProc}, + {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,MsgCenterNotifyShutDownAnimatorProc}, }; static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx) diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp index 6f7638043..6651b7f96 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/pairing_notification.cpp @@ -27,10 +27,13 @@ #include "ConfigModel.h" #include #include "pairing_notification.h" +#include +#include "uiservice/include/ui_service.h" +#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" // #include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" // #include -// #include "rebootandshutdown/include/ShutDownImageAnimatorView.h" + namespace OHOS { UIViewGroup *DeviceBindingView{nullptr}; @@ -77,11 +80,11 @@ namespace OHOS UIButton *DeviceUnbindingRequestButtonOK{nullptr}; // 设备解除绑定请求(与新设备连接)确认 UIButton *DeviceUnbindingRequestButtonCancel{nullptr}; // 设备解除绑定请求(与新设备连接)取消 - // ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 - // UIViewGroup *ShutDownImageAnimatorGroupView{nullptr}; + ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 + UIViewGroup *ShutDownImageAnimatorGroupView{nullptr}; - // ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; // 关机动画 - // UIViewGroup *shutDownImageAnimatorGroupView{nullptr}; + ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; // 关机动画 + UIViewGroup *shutDownImageAnimatorGroupView{nullptr}; PairingViewEventListener::PairingViewEventListener() { @@ -152,28 +155,28 @@ namespace OHOS else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认 { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK OnClick"); - // if (p_ShutDownImageAnimatorView == nullptr) - // { - // p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); - // if (p_ShutDownImageAnimatorView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_ShutDownImageAnimatorView new fail!!"); - // return false; - // } - // ShutDownImageAnimatorGroupView = p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit(); - // if (ShutDownImageAnimatorGroupView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorGroupView new fail!!"); - // return false; - // } - // DeviceUnbindingRequestGroupView->SetVisible(false); - // /* -------------------------------------------------------------------------- */ - // RootView::GetInstance()->ClearOnKeyActListener(); - // RootView::GetInstance()->SetOnKeyActListener(this); - // /* -------------------------------------------------------------------------- */ - // RootView::GetInstance()->Add(ShutDownImageAnimatorGroupView); - // } - // ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(3); + if (p_ShutDownImageAnimatorView == nullptr) + { + p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (p_ShutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_ShutDownImageAnimatorView new fail!!"); + return false; + } + ShutDownImageAnimatorGroupView = p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit(); + if (ShutDownImageAnimatorGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorGroupView new fail!!"); + return false; + } + DeviceUnbindingRequestGroupView->SetVisible(false); + /* -------------------------------------------------------------------------- */ + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->SetOnKeyActListener(this); + /* -------------------------------------------------------------------------- */ + RootView::GetInstance()->Add(ShutDownImageAnimatorGroupView); + } + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(3); } else if (&view == DeviceUnbindingRequestButtonCancel) // 设备解除绑定请求(与新设备连接)取消 { @@ -345,12 +348,10 @@ namespace OHOS if (strlen(devanme)) { - // DeviceBindingName->SetText(devanme); UpdateLabel(DeviceBindingName, devanme, STR_DEVICE_BINDING_NOTE); } else { - // DeviceBindingName->SetText(" "); UpdateLabel(DeviceBindingName, " ", STR_DEVICE_BINDING_NOTE); } DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); @@ -393,10 +394,10 @@ namespace OHOS // 震动一次 if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { - // custom_VibratorFunc_int(0); + custom_VibratorFunc_int(0); } - // ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 @@ -509,15 +510,12 @@ namespace OHOS if (strlen(devanme)) { - // DeviceUnBindingName->SetText(devanme); UpdateLabel(DeviceUnBindingName, devanme, STR_EQUIPMENT_UNTYING_NOTE); } else { - // DeviceUnBindingName->SetText(" "); UpdateLabel(DeviceUnBindingName, " ", STR_EQUIPMENT_UNTYING_NOTE); } - // DeviceUnBindingName->SetText("小米5\n"); DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DeviceUnBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -558,11 +556,11 @@ namespace OHOS /* -------------------------------------------------------------------------- */ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { - // custom_VibratorFunc_int(0); // 震动一次 + custom_VibratorFunc_int(0); // 震动一次 } - // ScreenTurnOff(); //先设置为0 - // ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 + ScreenTurnOff(); //先设置为0 + ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 /* -------------------------------------------------------------------------- */ @@ -908,12 +906,12 @@ namespace OHOS DeviceUnbindingRequestGroupView = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView] success"); } - // if (p_ShutDownImageAnimatorView != nullptr) - // { - // RootView::GetInstance()->Remove(ShutDownImageAnimatorGroupView); - // delete p_ShutDownImageAnimatorView; - // p_ShutDownImageAnimatorView; - // } + if (p_ShutDownImageAnimatorView != nullptr) + { + RootView::GetInstance()->Remove(ShutDownImageAnimatorGroupView); + delete p_ShutDownImageAnimatorView; + p_ShutDownImageAnimatorView; + } } /* -------------------------------------------------------------------------- */ @@ -1005,25 +1003,25 @@ namespace OHOS /* * @brief 显示关机动画 */ - // UIViewGroup *showShutDownAnimation(void) - // { - // if (shutDownImageAnimatorView == nullptr) - // { - // shutDownImageAnimatorView = new ShutDownImageAnimatorView(); - // if (shutDownImageAnimatorView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail!!"); - // return nullptr; - // } - // shutDownImageAnimatorGroupView = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); - // if (shutDownImageAnimatorGroupView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorGroupView new fail!!"); - // return nullptr; - // } - // shutDownImageAnimatorView->ShutDownImageAnimator_Start(shutDownAnimation_falg); - // RootView::GetInstance()->ClearOnKeyActListener(); - // } - // return shutDownImageAnimatorGroupView; - // } + UIViewGroup *showShutDownAnimation(void) + { + if (shutDownImageAnimatorView == nullptr) + { + shutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (shutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail!!"); + return nullptr; + } + shutDownImageAnimatorGroupView = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); + if (shutDownImageAnimatorGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorGroupView new fail!!"); + return nullptr; + } + shutDownImageAnimatorView->ShutDownImageAnimator_Start(shutDownAnimation_falg); + RootView::GetInstance()->ClearOnKeyActListener(); + } + return shutDownImageAnimatorGroupView; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp deleted file mode 100644 index 863284d5e..000000000 --- a/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-03-22 10:04:36 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2025-01-15 11:34:47 - * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp - */ -#include "notification_manager.h" -#include "wearable_log.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_animator.h" -#include "components/ui_button.h" -#include "components/ui_image_view.h" -#include "components/ui_scroll_view.h" -#ifdef SUPPORT_BLE_SERVICE -#include "bleEvent.h" -#endif - -#include -#include -#include -#include -#include "iostream" -#include -#include -#include "uicomponents/UIComponents.h" -#include "ConfigModel.h" -#include -#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" -#include -#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" -namespace OHOS -{ - UIViewGroup *DeviceBindingView{nullptr}; - UIScrollView *DeviceBindingScrollView{nullptr}; - UILabelExt *DeviceBindingViewTitleLabel{nullptr}; // 标题 :设备绑定 - UILabelExt *DeviceBindingName{nullptr}; // 绑定的设备名称 - UIButton *DeviceBindingButtonOK{nullptr}; // 设备绑定确认 - UIButton *DeviceBindingButtonCancel{nullptr}; // 设备绑定取消 - - UIImageAnimatorView *DeviceBindingAnimatorView{nullptr}; // 设备绑定动画 - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_X = 183; - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_Y = 125; - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_W = 100; - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_H = 66; - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 70; - static constexpr int BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 绑定动画帧数 - const ImageInfo **BindPathsArray{nullptr}; - ImageAnimatorInfo BindImageInfo[BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - static constexpr const char *BIND_IMAGE_SRC = "/user/res/remind/bind/"; - - UIViewGroup *DeviceUnBindingView{nullptr}; - UIScrollView *DeviceUnBindingScrollView{nullptr}; - UILabelExt *DeviceUnBindingViewTitleLabel{nullptr}; // 标题 :设备解绑 - UILabelExt *DeviceUnBindingName{nullptr}; // 解绑的设备名称 - UIButton *DeviceUnBindingButtonOK{nullptr}; // 设备解绑定确认 - UIButton *DeviceUnBindingButtonCancel{nullptr}; // 设备解绑取消 - - UIImageAnimatorView *DeviceUnBindingAnimatorView{nullptr}; // 设备解绑动画 - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_X = 193; - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_Y = 118; - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_W = 80; - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_H = 80; - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE = 100; - static constexpr int UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 25; // 解绑动画帧数 - const ImageInfo **UnBindPathsArray{nullptr}; - ImageAnimatorInfo UnBindImageInfo[UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - static constexpr const char *UNBIND_IMAGE_SRC = "/user/res/remind/unbind/"; - - UIViewGroup *DeviceUnbindingRequestGroupView{nullptr}; - UIScrollView *DeviceUnbindingRequestScrollView{nullptr}; // 设备解除绑定请求(与新设备连接)视图 - UILabelExt *DeviceUnbindingRequestViewTitleLabel{nullptr}; // 标题 :注意 - UIImageView *DeviceUnbindingRequestViewImageView{nullptr}; // - UILabelExt *DeviceUnbindingRequestViewLabel[3]{nullptr}; // - UIButton *DeviceUnbindingRequestButtonOK{nullptr}; // 设备解除绑定请求(与新设备连接)确认 - UIButton *DeviceUnbindingRequestButtonCancel{nullptr}; // 设备解除绑定请求(与新设备连接)取消 - - ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 - UIViewGroup *ShutDownImageAnimatorGroupView{nullptr}; - - ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; // 关机动画 - UIViewGroup *shutDownImageAnimatorGroupView{nullptr}; - - PairingViewEventListener::PairingViewEventListener() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::PairingViewEventListener"); - } - - PairingViewEventListener::~PairingViewEventListener() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::~PairingViewEventListener"); - } - - PairingViewEventListener &PairingViewEventListener::GetInstance(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::GetInstance"); - static PairingViewEventListener instance; - return instance; - } - - bool PairingViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::OnClick"); - UNUSED(event); - if (&view == DeviceBindingButtonCancel) // 设备绑定取消按钮 - { - PairingViewEventListener::GetInstance().Pairing_StopTimer(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); -// 终止当前的绑定流程并关闭相关的通知界面。 -#ifdef SUPPORT_BLE_SERVICE - comfirmPaire(0); -#endif - NotificationManager::GetInstance()->StopNotify(); - } - else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮 - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonOK OnClick"); - /* - * 可能会执行的绑定流程: - * 1.启动绑定过程. - * 2.更新设备绑定状态. - * 3.发送绑定请求到设备或服务器等. - */ - PairingViewEventListener::GetInstance().Pairing_StopTimer(); -// 关闭通知界面 -#ifdef SUPPORT_BLE_SERVICE - comfirmPaire(1); -#endif - NotificationManager::GetInstance()->StopNotify(); - } - else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮 - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel OnClick"); -// 不想执行解绑动作,并关闭解绑的通知界面。 -#ifdef SUPPORT_BLE_SERVICE - cleanUnbindInfor(0); -#endif - NotificationManager::GetInstance()->StopNotify(); - } - else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮 - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonOK OnClick"); - // 切换到再次确认解绑弹窗 - if (DeviceUnbindingRequestGroupView == nullptr) - { - RootView::GetInstance()->Add(CreateDeviceUnbindingRequestGroupView()); - } - DeviceUnBindingViewIsVisible(false); - } - else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认 - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK OnClick"); - if (p_ShutDownImageAnimatorView == nullptr) - { - p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); - if (p_ShutDownImageAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_ShutDownImageAnimatorView new fail!!"); - return false; - } - ShutDownImageAnimatorGroupView = p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit(); - if (ShutDownImageAnimatorGroupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorGroupView new fail!!"); - return false; - } - DeviceUnbindingRequestGroupView->SetVisible(false); - /* -------------------------------------------------------------------------- */ - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->SetOnKeyActListener(this); - /* -------------------------------------------------------------------------- */ - RootView::GetInstance()->Add(ShutDownImageAnimatorGroupView); - } - ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(3); - } - else if (&view == DeviceUnbindingRequestButtonCancel) // 设备解除绑定请求(与新设备连接)取消 - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonCancel OnClick"); - DeviceUnBindingViewIsVisible(true); - } - return true; - } - - bool PairingViewEventListener::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 - { - //消耗按键事件 - return true; - } - - static UIButton *CreateButton(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const char *imageSrc) - { - UIButton *button = new UIButton(); - if (button == nullptr) - { - return nullptr; - } - button->SetPosition(x, y, w, h); - button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - button->SetStyle(STYLE_BACKGROUND_OPA, 0x19); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); - button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); - button->SetImageSrc(imageSrc, imageSrc); - return button; - } - - void PairingViewEventListener::SetDeviceName(char *Name) - { - // printf("Name:%s\r\n",Name); - memset(DeviceName, 0, sizeof(DeviceName)); - if (Name == NULL) - { - strcpy(DeviceName, "phone"); - return; - } - int len = strlen(Name); - if (len > sizeof(DeviceName)) - len = sizeof(DeviceName); - Name[len] = '\0'; - - memcpy(DeviceName, Name, len); - } - - void PairingViewEventListener::DeviceUnBindingViewIsVisible(bool state) - { - if (DeviceUnBindingView && DeviceUnbindingRequestGroupView) - { - DeviceUnBindingView->SetVisible(state); - DeviceUnbindingRequestGroupView->SetVisible(!state); - } - } - - /*获取设备名称*/ - char *PairingViewEventListener::GetDeviceName(void) - { - return DeviceName; - } - - /* - * @brief 创建设备绑定视图 - */ - UIViewGroup *CreateDeviceBindingView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView]"); - /* ---------------------------- DeviceBindingView --------------------------- */ - if (DeviceBindingView == nullptr) - { - DeviceBindingView = new UIViewGroup(); - if (nullptr == DeviceBindingView) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingView new fail!!"); - return nullptr; - } - DeviceBindingView->SetPosition(0, 0, 466, 466); - DeviceBindingView->SetDraggable(true); - DeviceBindingView->SetTouchable(true); - /* ------------------------- DeviceBindingScrollView ------------------------ */ - if (DeviceBindingScrollView == nullptr) - { - DeviceBindingScrollView = new UIScrollView(); - if (DeviceBindingScrollView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceBindingScrollView new fail"); - return nullptr; - } - } - DeviceBindingScrollView->SetPosition(0, 0, 466, 466); - DeviceBindingScrollView->SetThrowDrag(true); - DeviceBindingScrollView->SetDraggable(true); - DeviceBindingScrollView->SetTouchable(true); - DeviceBindingScrollView->SetReboundSize(30); - DeviceBindingScrollView->SetScrollBlankSize(30); - DeviceBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance - DeviceBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration - DeviceBindingScrollView->SetMaxScrollDistance(1000); - DeviceBindingScrollView->SetDirection(UIScrollView::VERTICAL); - DeviceBindingScrollView->RequestFocus(); - DeviceBindingScrollView->SetRotateFactor(1.0); - /* ----------------------- DeviceBindingViewTitleLabel ---------------------- */ - if (DeviceBindingViewTitleLabel == nullptr) - { - DeviceBindingViewTitleLabel = new UILabelExt(); - if (DeviceBindingViewTitleLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingViewTitleLabel new fail!!"); - return nullptr; - } - } - DeviceBindingViewTitleLabel->SetPosition(83, 50, 300, 35); - DeviceBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); - DeviceBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - - // DeviceBindingViewTitleLabel->SetText("设备绑定"); - DeviceBindingViewTitleLabel->SetTextId(STR_DEVICE_BINDING); - DeviceBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); - DeviceBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - DeviceBindingViewTitleLabel->SetRollSpeed(23); - /* ----------------------- DeviceBindingAnimatorView ---------------------- */ - BindPathsArray = CreateImageInfoArray(BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - if (DeviceBindingAnimatorView == nullptr) - { - DeviceBindingAnimatorView = new UIImageAnimatorView(); - if (DeviceBindingAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceBindingAnimatorView new fail"); - return nullptr; - } - for (uint8_t i = 0; i < BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) - { - BindImageInfo[i].imageInfo = (BindPathsArray[i]); - BindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; - BindImageInfo[i].pos.x = BIND_IMAGE_ANIMATOR_VIEW_X; - BindImageInfo[i].pos.y = BIND_IMAGE_ANIMATOR_VIEW_Y; - BindImageInfo[i].width = BIND_IMAGE_ANIMATOR_VIEW_W; - BindImageInfo[i].height = BIND_IMAGE_ANIMATOR_VIEW_H; - } - DeviceBindingAnimatorView->SetPosition(BIND_IMAGE_ANIMATOR_VIEW_X, BIND_IMAGE_ANIMATOR_VIEW_Y, BIND_IMAGE_ANIMATOR_VIEW_W, BIND_IMAGE_ANIMATOR_VIEW_H); - DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - DeviceBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - DeviceBindingAnimatorView->SetImageAnimatorSrc(BindImageInfo, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, BIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); - DeviceBindingAnimatorView->SetRepeat(true); - DeviceBindingAnimatorView->SetAutoEnable(false); - DeviceBindingAnimatorView->SetResizeMode(UIImageAnimatorView::CENTER); - DeviceBindingAnimatorView->Start(); - DeviceBindingAnimatorView->SetSizeFixed(true); - } - /* ---------------------------- DeviceBindingName --------------------------- */ - if (DeviceBindingName == nullptr) - { - DeviceBindingName = new UILabelExt(); - if (DeviceBindingName == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingName new fail!!"); - return nullptr; - } - } - - char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); - DeviceBindingName->SetPosition(53, 230, 360, 70); - DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30); - DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceBindingName->SetTextId(STR_DEVICE_BINDING_NOTE); // XX想要与你进行连接绑定 - - if (strlen(devanme)) - { - // DeviceBindingName->SetText(devanme); - UpdateLabel(DeviceBindingName, devanme, STR_DEVICE_BINDING_NOTE); - } - else - { - // DeviceBindingName->SetText(" "); - UpdateLabel(DeviceBindingName, " ", STR_DEVICE_BINDING_NOTE); - } - DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - DeviceBindingName->SetRollSpeed(23); - /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ - int y = DeviceBindingName->GetY() + DeviceBindingName->GetTextHeight() + 20; - DeviceBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); - if (DeviceBindingButtonCancel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonCancel new fail!!"); - return nullptr; - } - /* -------------------------------- DeviceBindingButtonOK -------------------------------- */ - DeviceBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); - if (DeviceBindingButtonOK == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingButtonOK new fail!!"); - return nullptr; - } - - UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); - if (listener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] PairingViewEventListener::GetInstance fail!!"); - return nullptr; - } - DeviceBindingButtonCancel->SetOnClickListener(listener); - DeviceBindingButtonOK->SetOnClickListener(listener); - /* ----------------------------------- Add ---------------------------------- */ - DeviceBindingScrollView->Add(DeviceBindingViewTitleLabel); - DeviceBindingScrollView->Add(DeviceBindingAnimatorView); - DeviceBindingScrollView->Add(DeviceBindingName); - DeviceBindingScrollView->Add(DeviceBindingButtonCancel); - DeviceBindingScrollView->Add(DeviceBindingButtonOK); - DeviceBindingView->Add(DeviceBindingScrollView); - } - - // 震动一次 - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) - { - custom_VibratorFunc_int(0); - } - - ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 - - PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 - - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceBindingView); - return DeviceBindingView; - } - - /* - * @brief 创建设备解绑视图 - */ - UIViewGroup *CreateDeviceUnBindingView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); - /* ---------------------------- DeviceUnBindingView --------------------------- */ - if (DeviceUnBindingView == nullptr) - { - DeviceUnBindingView = new UIViewGroup(); - if (nullptr == DeviceUnBindingView) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new fail!!"); - return nullptr; - } - DeviceUnBindingView->SetPosition(0, 0, 466, 466); - DeviceUnBindingView->SetDraggable(true); - DeviceUnBindingView->SetTouchable(true); - /* ------------------------- DeviceUnBindingScrollView ------------------------ */ - if (DeviceUnBindingScrollView == nullptr) - { - DeviceUnBindingScrollView = new UIScrollView(); - if (DeviceUnBindingScrollView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeviceUnBindingScrollView new fail"); - return nullptr; - } - } - DeviceUnBindingScrollView->SetPosition(0, 0, 466, 466); - DeviceUnBindingScrollView->SetThrowDrag(true); - DeviceUnBindingScrollView->SetDraggable(true); - DeviceUnBindingScrollView->SetTouchable(true); - DeviceUnBindingScrollView->SetReboundSize(30); - DeviceUnBindingScrollView->SetScrollBlankSize(30); - DeviceUnBindingScrollView->SetSwipeACCLevel(200); // 800: compensation distance - DeviceUnBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration - DeviceUnBindingScrollView->SetMaxScrollDistance(1000); - DeviceUnBindingScrollView->SetDirection(UIScrollView::VERTICAL); - DeviceUnBindingScrollView->RequestFocus(); - DeviceUnBindingScrollView->SetRotateFactor(1.0); - /* ----------------------- DeviceUnBindingAnimatorView ---------------------- */ - UnBindPathsArray = CreateImageInfoArray(UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - if (DeviceUnBindingAnimatorView == nullptr) - { - DeviceUnBindingAnimatorView = new UIImageAnimatorView(); - if (DeviceUnBindingAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]DeviceUnBindingAnimatorView new fail"); - return nullptr; - } - for (uint8_t i = 0; i < UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) - { - UnBindImageInfo[i].imageInfo = (UnBindPathsArray[i]); - UnBindImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; - UnBindImageInfo[i].pos.x = UNBIND_IMAGE_ANIMATOR_VIEW_X; - UnBindImageInfo[i].pos.y = UNBIND_IMAGE_ANIMATOR_VIEW_Y; - UnBindImageInfo[i].width = UNBIND_IMAGE_ANIMATOR_VIEW_W; - UnBindImageInfo[i].height = UNBIND_IMAGE_ANIMATOR_VIEW_H; - } - DeviceUnBindingAnimatorView->SetPosition(UNBIND_IMAGE_ANIMATOR_VIEW_X, UNBIND_IMAGE_ANIMATOR_VIEW_Y, UNBIND_IMAGE_ANIMATOR_VIEW_W, UNBIND_IMAGE_ANIMATOR_VIEW_H); - DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - DeviceUnBindingAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - DeviceUnBindingAnimatorView->SetImageAnimatorSrc(UnBindImageInfo, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, UNBIND_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE); - DeviceUnBindingAnimatorView->SetRepeat(true); - DeviceUnBindingAnimatorView->SetSizeFixed(true); - DeviceUnBindingAnimatorView->Start(); - } - /* ----------------------- DeviceUnBindingViewTitleLabel ---------------------- */ - if (DeviceUnBindingViewTitleLabel == nullptr) - { - DeviceUnBindingViewTitleLabel = new UILabelExt(); - if (DeviceUnBindingViewTitleLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewTitleLabel new fail!!"); - return nullptr; - } - } - DeviceUnBindingViewTitleLabel->SetPosition(83, 50, 300, 35); - DeviceUnBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // DeviceUnBindingViewTitleLabel->SetText("设备解绑"); - DeviceUnBindingViewTitleLabel->SetTextId(STR_EQUIPMENT_UNTYING); - DeviceUnBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); - DeviceUnBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - /* ---------------------------- DeviceUnBindingName --------------------------- */ - if (DeviceUnBindingName == nullptr) - { - DeviceUnBindingName = new UILabelExt(); - if (DeviceUnBindingName == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName new fail!!"); - return nullptr; - } - } - DeviceUnBindingName->SetPosition(53, 230, 360, 70); - DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceUnBindingName->SetTextId(STR_EQUIPMENT_UNTYING_NOTE); // XX想要与你进行解绑 - - char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s", devanme); - - if (strlen(devanme)) - { - // DeviceUnBindingName->SetText(devanme); - UpdateLabel(DeviceUnBindingName, devanme, STR_EQUIPMENT_UNTYING_NOTE); - } - else - { - // DeviceUnBindingName->SetText(" "); - UpdateLabel(DeviceUnBindingName, " ", STR_EQUIPMENT_UNTYING_NOTE); - } - // DeviceUnBindingName->SetText("小米5\n"); - DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ - int y = DeviceUnBindingName->GetY() + DeviceUnBindingName->GetTextHeight() + 20; - DeviceUnBindingButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); - if (DeviceUnBindingButtonCancel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonCancel new fail!!"); - return nullptr; - } - /* -------------------------------- DeviceUnBindingButtonOK -------------------------------- */ - DeviceUnBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); - if (DeviceUnBindingButtonOK == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonOK new fail!!"); - return nullptr; - } - /* ------------------------- button OnClickListener ------------------------- */ - UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); - if (nullptr == listener) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); - return nullptr; - } - DeviceUnBindingButtonCancel->SetOnClickListener(listener); - DeviceUnBindingButtonOK->SetOnClickListener(listener); - /* ----------------------------------- Add ---------------------------------- */ - DeviceUnBindingScrollView->Add(DeviceUnBindingViewTitleLabel); - DeviceUnBindingScrollView->Add(DeviceUnBindingAnimatorView); - DeviceUnBindingScrollView->Add(DeviceUnBindingName); - DeviceUnBindingScrollView->Add(DeviceUnBindingButtonCancel); - DeviceUnBindingScrollView->Add(DeviceUnBindingButtonOK); - DeviceUnBindingView->Add(DeviceUnBindingScrollView); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!"); - - /* -------------------------------------------------------------------------- */ - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) - { - custom_VibratorFunc_int(0); // 震动一次 - } - - // ScreenTurnOff(); //先设置为0 - ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭 - - PairingViewEventListener::GetInstance().Pairing_StartTimer(); // 开启一个40s后弹窗自动销毁定时器 - /* -------------------------------------------------------------------------- */ - - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceUnBindingView); - return DeviceUnBindingView; - } - - /* - * @brief 创建解除绑定请求(与新设备连接)视图 - */ - UIViewGroup *CreateDeviceUnbindingRequestGroupView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]"); - - if (nullptr == DeviceUnbindingRequestGroupView) - { - /* --------------------- DeviceUnbindingRequestGroupView -------------------- */ - DeviceUnbindingRequestGroupView = new UIViewGroup(); - if (DeviceUnbindingRequestGroupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestGroupView is nullptr"); - return nullptr; - } - DeviceUnbindingRequestGroupView->SetPosition(0, 0, 466, 466); - DeviceUnbindingRequestGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0); - DeviceUnbindingRequestGroupView->SetVisible(false); - /* -------------------- DeviceUnbindingRequestScrollView -------------------- */ - DeviceUnbindingRequestScrollView = new UIScrollView(); - if (DeviceUnbindingRequestScrollView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestScrollView is nullptr"); - return nullptr; - } - DeviceUnbindingRequestScrollView->SetPosition(0, 0, 466, 466); - DeviceUnbindingRequestScrollView->SetThrowDrag(true); - DeviceUnbindingRequestScrollView->SetDraggable(true); - DeviceUnbindingRequestScrollView->SetTouchable(true); - DeviceUnbindingRequestScrollView->SetReboundSize(30); - DeviceUnbindingRequestScrollView->SetScrollBlankSize(30); - DeviceUnbindingRequestScrollView->SetSwipeACCLevel(200); // 800: compensation distance - DeviceUnbindingRequestScrollView->SetDragACCLevel(5); // 5: drag acceleration - DeviceUnbindingRequestScrollView->SetMaxScrollDistance(1000); - DeviceUnbindingRequestScrollView->SetDirection(UIScrollView::VERTICAL); - DeviceUnbindingRequestScrollView->RequestFocus(); - DeviceUnbindingRequestScrollView->SetRotateFactor(1.0); - /* ------------------ DeviceUnbindingRequestViewTitleLabel ------------------ */ - if (DeviceUnbindingRequestViewTitleLabel == nullptr) - { - DeviceUnbindingRequestViewTitleLabel = new UILabelExt(); - if (DeviceUnbindingRequestViewTitleLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewTitleLabel is nullptr"); - return nullptr; - } - } - DeviceUnbindingRequestViewTitleLabel->SetPosition(83, 50, 300, 35); - DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // DeviceUnbindingRequestViewTitleLabel->SetText("注意"); - DeviceUnbindingRequestViewTitleLabel->SetTextId(STR_LOOK_OUT); - DeviceUnbindingRequestViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); - DeviceUnbindingRequestViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnbindingRequestViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - /* ------------------- DeviceUnbindingRequestViewImageView ------------------ */ - if (DeviceUnbindingRequestViewImageView == nullptr) - { - DeviceUnbindingRequestViewImageView = new UIImageView(); - if (DeviceUnbindingRequestViewImageView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewImageView is nullptr"); - return nullptr; - } - } - DeviceUnbindingRequestViewImageView->SetPosition(193, 121, 80, 80); - const char *imageimagesPath = "/user/res/Attention.bin"; - DeviceUnbindingRequestViewImageView->SetSrc(imageimagesPath); - - /* --------------------- DeviceUnbindingRequestViewLabel[0] -------------------- */ - if (nullptr == DeviceUnbindingRequestViewLabel[0]) - { - DeviceUnbindingRequestViewLabel[0] = new UILabelExt(); - if (DeviceUnbindingRequestViewLabel[0] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[0] is nullptr"); - return nullptr; - } - } - DeviceUnbindingRequestViewLabel[0]->SetPosition(53, 242, 360, 70); - DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceUnbindingRequestViewLabel[0]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE1); - - char *devanme = PairingViewEventListener::GetInstance().GetDeviceName(); - if (strlen(devanme)) - { - UpdateLabel(DeviceUnbindingRequestViewLabel[0], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE1); - } - else - { - UpdateLabel(DeviceUnbindingRequestViewLabel[0], " ", STR_NEWDEVICE_BIND_REMIND_NOTE1); - } - - DeviceUnbindingRequestViewLabel[0]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - DeviceUnbindingRequestViewLabel[0]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnbindingRequestViewLabel[0]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - /* ------------------- DeviceUnbindingRequestViewLabel[1] ------------------- */ - if (DeviceUnbindingRequestViewLabel[1] == nullptr) - { - DeviceUnbindingRequestViewLabel[1] = new UILabelExt(); - if (DeviceUnbindingRequestViewLabel[1] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[1] is nullptr"); - return nullptr; - } - } - int y = DeviceUnbindingRequestViewLabel[0]->GetY() + DeviceUnbindingRequestViewLabel[0]->GetTextHeight() + 50; - DeviceUnbindingRequestViewLabel[1]->SetPosition(53, y, 360, 280); - DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceUnbindingRequestViewLabel[1]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE2); - if (strlen(devanme)) - { - UpdateLabel(DeviceUnbindingRequestViewLabel[1], devanme, STR_NEWDEVICE_BIND_REMIND_NOTE2); - } - else - { - UpdateLabel(DeviceUnbindingRequestViewLabel[1], " ", STR_NEWDEVICE_BIND_REMIND_NOTE2); - } - DeviceUnbindingRequestViewLabel[1]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - DeviceUnbindingRequestViewLabel[1]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnbindingRequestViewLabel[1]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - /* ------------------- DeviceUnbindingRequestViewLabel[2] ------------------- */ - if (DeviceUnbindingRequestViewLabel[2] == nullptr) - { - DeviceUnbindingRequestViewLabel[2] = new UILabelExt(); - if (DeviceUnbindingRequestViewLabel[2] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewLabel[2] is nullptr"); - return nullptr; - } - } - y = DeviceUnbindingRequestViewLabel[1]->GetY() + DeviceUnbindingRequestViewLabel[1]->GetTextHeight() + 50; - DeviceUnbindingRequestViewLabel[2]->SetPosition(53, y, 360, 35); - DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_TEXT_FONT, 30); - DeviceUnbindingRequestViewLabel[2]->SetStyle(STYLE_LINE_HEIGHT, 35); - DeviceUnbindingRequestViewLabel[2]->SetTextId(STR_NEWDEVICE_BIND_REMIND_NOTE3); - DeviceUnbindingRequestViewLabel[2]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - DeviceUnbindingRequestViewLabel[2]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - DeviceUnbindingRequestViewLabel[2]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ - y = DeviceUnbindingRequestViewLabel[2]->GetY() + DeviceUnbindingRequestViewLabel[2]->GetTextHeight() + 50; - DeviceUnbindingRequestButtonCancel = CreateButton(111, y, 100, 100, "/user/res/SYSTEM_CheckOff.bin"); - if (DeviceUnbindingRequestButtonCancel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonCancel new fail!!"); - return nullptr; - } - - /* -------------------------------- DeviceUnbindingRequestButtonOK -------------------------------- */ - DeviceUnbindingRequestButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin"); - if (DeviceUnbindingRequestButtonOK == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnbindingRequestButtonOK new fail!!"); - return nullptr; - } - /* ------------------------- button OnClickListener ------------------------- */ - UIView::OnClickListener *listener = static_cast(&PairingViewEventListener::GetInstance()); - if (listener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!"); - return nullptr; - } - DeviceUnbindingRequestButtonCancel->SetOnClickListener(listener); - DeviceUnbindingRequestButtonOK->SetOnClickListener(listener); - /* -------------------------------------------------------------------------- */ - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewTitleLabel); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewImageView); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[0]); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[1]); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[2]); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonCancel); - DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonOK); - DeviceUnbindingRequestGroupView->Add(DeviceUnbindingRequestScrollView); - } - return DeviceUnbindingRequestGroupView; - } - - /* - * @brief 销毁设备绑定视图 - */ - void FreeDeviceBindingView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView]"); - if (DeviceBindingView != nullptr) - { - PairingViewEventListener::GetInstance().Pairing_StopTimer(); - DeviceBindingView->RemoveAll(); - if (DeviceBindingScrollView != nullptr) - { - DeviceBindingScrollView->RemoveAll(); - if (DeviceBindingViewTitleLabel) - { - delete DeviceBindingViewTitleLabel; - DeviceBindingViewTitleLabel = nullptr; - } - if (DeviceBindingName) - { - delete DeviceBindingName; - DeviceBindingName = nullptr; - } - if (DeviceBindingAnimatorView) - { - DeviceBindingAnimatorView->Stop(); - delete DeviceBindingAnimatorView; - DeviceBindingAnimatorView = nullptr; - FreeImageInfoArray(BindPathsArray, BIND_IMAGE_SRC, BIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - } - if (DeviceBindingButtonCancel) - { - delete DeviceBindingButtonCancel; - DeviceBindingButtonCancel = nullptr; - } - if (DeviceBindingButtonOK) - { - delete DeviceBindingButtonOK; - DeviceBindingButtonOK = nullptr; - } - DeviceBindingScrollView->ClearFocus(); - delete DeviceBindingScrollView; - DeviceBindingScrollView = nullptr; - } - RootView::GetInstance()->Remove(DeviceBindingView); - delete DeviceBindingView; - DeviceBindingView = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView] success"); - ScreenTurnOff(); - } - } - - /* - * @brief 销毁设备解绑视图 - */ - void FreeDeviceUnBindingView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]"); - if (DeviceUnBindingView != nullptr) - { - PairingViewEventListener::GetInstance().Pairing_StopTimer(); - DeviceUnBindingView->RemoveAll(); - if (DeviceUnBindingScrollView != nullptr) - { - DeviceUnBindingScrollView->RemoveAll(); - if (DeviceUnBindingViewTitleLabel) - { - delete DeviceUnBindingViewTitleLabel; - DeviceUnBindingViewTitleLabel = nullptr; - } - if (DeviceUnBindingAnimatorView) - { - DeviceUnBindingAnimatorView->Stop(); - delete DeviceUnBindingAnimatorView; - DeviceUnBindingAnimatorView = nullptr; - FreeImageInfoArray(UnBindPathsArray, UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - } - if (DeviceUnBindingName) - { - delete DeviceUnBindingName; - DeviceUnBindingName = nullptr; - } - if (DeviceUnBindingButtonCancel) - { - delete DeviceUnBindingButtonCancel; - DeviceUnBindingButtonCancel = nullptr; - } - if (DeviceUnBindingButtonOK) - { - delete DeviceUnBindingButtonOK; - DeviceUnBindingButtonOK = nullptr; - } - DeviceUnBindingScrollView->ClearFocus(); - delete DeviceUnBindingScrollView; - DeviceUnBindingScrollView = nullptr; - } - RootView::GetInstance()->Remove(DeviceUnBindingView); - delete DeviceUnBindingView; - DeviceUnBindingView = nullptr; - FreeDeviceUnbindingRequestGroupView(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView] success"); - ScreenTurnOff(); - } - } - - /* - * @brief 销毁解除绑定请求(与新设备连接)视图 - */ - void FreeDeviceUnbindingRequestGroupView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView]"); - if (DeviceUnbindingRequestGroupView != nullptr) - { - DeviceUnbindingRequestGroupView->RemoveAll(); - if (nullptr != DeviceUnbindingRequestScrollView) - { - DeviceUnbindingRequestScrollView->RemoveAll(); - if (DeviceUnbindingRequestViewTitleLabel) - { - delete DeviceUnbindingRequestViewTitleLabel; - DeviceUnbindingRequestViewTitleLabel = nullptr; - } - if (DeviceUnbindingRequestViewImageView) - { - delete DeviceUnbindingRequestViewImageView; - DeviceUnbindingRequestViewImageView = nullptr; - } - for (int i = 0; i < (sizeof(DeviceUnbindingRequestViewLabel) / sizeof(DeviceUnbindingRequestViewLabel[0])); i++) - { - if (DeviceUnbindingRequestViewLabel[i]) - { - delete DeviceUnbindingRequestViewLabel[i]; - DeviceUnbindingRequestViewLabel[i] = nullptr; - } - } - if (DeviceUnbindingRequestButtonOK) - { - delete DeviceUnbindingRequestButtonOK; - DeviceUnbindingRequestButtonOK = nullptr; - } - if (DeviceUnbindingRequestButtonCancel) - { - delete DeviceUnbindingRequestButtonCancel; - DeviceUnbindingRequestButtonCancel = nullptr; - } - DeviceUnbindingRequestScrollView->ClearFocus(); - delete DeviceUnbindingRequestScrollView; - DeviceUnbindingRequestScrollView = nullptr; - } - RootView::GetInstance()->Remove(DeviceUnbindingRequestGroupView); - delete DeviceUnbindingRequestGroupView; - DeviceUnbindingRequestGroupView = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView] success"); - } - if (p_ShutDownImageAnimatorView != nullptr) - { - RootView::GetInstance()->Remove(ShutDownImageAnimatorGroupView); - delete p_ShutDownImageAnimatorView; - p_ShutDownImageAnimatorView; - } - } - - /* -------------------------------------------------------------------------- */ - - // 声明定时器变量 - static osTimerId_t g_timer = NULL; - - /*定时器到期时的处理*/ - static void Pairing_TimerCallbackProc(int data) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Pairing_TimerCallbackProc"); - NotificationManager::GetInstance()->StopNotify(); - } - - /* - * @brief 回调函数 - */ - static void Pairing_TimerCallback(int data) - { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(Pairing_TimerCallbackProc, data)); - } - - /* - * @brief 开启定时器函数 - * @param interval 时间间隔,单位ms - */ - void PairingViewEventListener::Pairing_StartTimer(uint32_t interval) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StartTimer"); - /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ - if (g_timer != NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer already exists!!"); - return; - } - - /* --------------------------------- 2.创建定时器 -------------------------------- */ - g_timer = osTimerNew((osTimerFunc_t)Pairing_TimerCallback, osTimerOnce, NULL, NULL); - // 检查定时器创建是否成功 - if (g_timer == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer create failed!!"); - return; - } - - /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ - int tick = osMs2Tick(interval); - - /* --------------------------------- 4.启动定时器 -------------------------------- */ - osStatus_t ret = osTimerStart(g_timer, tick); - /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */ - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CountDown_StartTimer] osTimerDelete failed, ret = %lx!!", ret); - if (g_timer != NULL) - { - ret = osTimerDelete(g_timer); - } - g_timer = NULL; - return; - } - return; - } - - /* - * @brief 停止定时器 - */ - void PairingViewEventListener::Pairing_StopTimer(void) - { - // 检查定时器是否存在 - if (g_timer != NULL) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::Pairing_StopTimer"); - osTimerStop(g_timer); - // 删除定时器并置为 NULL - osStatus_t ret = osTimerDelete(g_timer); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); - } - g_timer = NULL; - } - } - static uint8_t shutDownAnimation_falg = -1; //关机动画标志位 - void set_shutDownAnimation_falg(uint8_t falg) - { - shutDownAnimation_falg = falg; - } - /* - * @brief 显示关机动画 - */ - UIViewGroup *showShutDownAnimation(void) - { - if (shutDownImageAnimatorView == nullptr) - { - shutDownImageAnimatorView = new ShutDownImageAnimatorView(); - if (shutDownImageAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail!!"); - return nullptr; - } - shutDownImageAnimatorGroupView = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); - if (shutDownImageAnimatorGroupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorGroupView new fail!!"); - return nullptr; - } - shutDownImageAnimatorView->ShutDownImageAnimator_Start(shutDownAnimation_falg); - RootView::GetInstance()->ClearOnKeyActListener(); - } - return shutDownImageAnimatorGroupView; - } -} \ No newline at end of file -- 2.17.1