From: luozheng <1732036298@qq.com> Date: Fri, 22 Mar 2024 11:08:55 +0000 (+0800) Subject: 添加绑定和解绑弹窗视图 X-Git-Tag: release_V1.2.70_20241020_135402~1250^2~15 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=2ad4d52c3b3224724408a5b453692f1c12bff0b2;p=mirrors%2FFD230.git 添加绑定和解绑弹窗视图 --- diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index 48203abb1..89e8204a6 100755 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -67,6 +67,11 @@ typedef enum { TOPIC_EVENT_CAT1_POWER_ON, TOPIC_EVENT_CAT1_POWER_OFF, #endif + +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION + TOPIC_EVENT_DEVICE_BIND, + TOPIC_EVENT_DEVICE_UNBIND, +#endif TOPIC_END_NUM = 20000, } TopicNum; diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index c833df4eb..24fd03f92 100755 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -142,6 +142,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/vendor_app/baidu/baidu_app.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp ) else() set(SOURCES @@ -150,6 +151,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp ) endif() diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h index f81e0b878..2e9846b90 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h @@ -23,6 +23,7 @@ #include "components/ui_view_group.h" #include "alarm_notification.h" #include "makephone_notification.h" +#include "pairing_notification.h" #define UN_OPACITY 255 #define HAlf_SCREEN 2 diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h new file mode 100644 index 000000000..9fb75fc50 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h @@ -0,0 +1,38 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-22 09:48:07 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-03-22 16:09:57 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h + */ +#ifndef PAIRING_NOTIFICATION_H +#define PAIRING_NOTIFICATION_H + +#include "BaseView.h" + +namespace OHOS +{ + UIViewGroup *CreateDeviceBindingView(void); + UIViewGroup *CreateDeviceUnBindingView(void); + + void FreeDeviceBindingView(void); + void FreeDeviceUnBindingView(void); + + class PairingViewEventListener : public OHOS::UIView::OnClickListener + { + public: + static PairingViewEventListener &GetInstance(void); + const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); + void FreeImagePathsArray(const char **imagePaths, const int numImages); + bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; + + private: + PairingViewEventListener(); + ~PairingViewEventListener(); + PairingViewEventListener(const PairingViewEventListener &) = delete; + const PairingViewEventListener &operator=(const PairingViewEventListener &) = delete; + }; + +} + +#endif diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 642c0a77c..c130e5ecc 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -36,6 +36,7 @@ #include "testchanging.h" #include "testcat1.h" #include "testhrsenson.h" +#include "power_display_service.h" namespace OHOS { #ifdef __cplusplus @@ -75,6 +76,10 @@ const PriorityMapper g_pri_mapper[] = { {TOPIC_EVENT_GRAYCARD_UPDATA, PRIORITY_TWO}, {TOPIC_EVENT_LEAKLIGHT_UPDATA, PRIORITY_TWO}, #endif +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 + {TOPIC_EVENT_DEVICE_BIND, PRIORITY_TWO}, + {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, +#endif }; static bool CheckPriority(const Topic topic) @@ -128,6 +133,10 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_ON); MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_OFF); #endif +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 + MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND); + MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBIND); +#endif } static OHOS::UIViewGroup* showAlarmNotify(void) @@ -150,6 +159,18 @@ static OHOS::UIViewGroup* CalldialNotify(void) return OHOS::CreateCalldialView(); } +/*显示绑定通知*/ +static OHOS::UIViewGroup* showDeviceBindingNotify(void) +{ + return OHOS::CreateDeviceBindingView(); +} + +/*显示解绑通知*/ +static OHOS::UIViewGroup* showDeviceUnBindingNotify(void) +{ + return OHOS::CreateDeviceUnBindingView(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -169,8 +190,14 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req) { unused(req); - unused(topic); + //unused(topic); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug !"); + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } DialModelCharge::GetInstance()->UpdateChargeStuaut(1); testCHANINGView *t=testCHANINGView::GetInstance(); @@ -378,6 +405,7 @@ void MsgCenterNotifyStopSPO2MonitoringProc(const Topic topic, Request* req) #endif + #ifdef SUPPORT_CAT1_MODEM void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) { @@ -542,6 +570,39 @@ void MsgCenterNotifyCat1PowerOnProc(const Topic topic, Request* req) unused(req); } #endif + + +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 +//设备绑定通知 +void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req) +{ + unused(req); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyBindProc Bind!"); + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showDeviceBindingNotify, (uint16_t)topic, true); +} + +//设备解绑通知 +void MsgCenterNotifyDeviceUnBindProc(const Topic topic, Request* req) +{ + unused(req); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyUnBindProc Unbind !"); + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true); + +} +#endif + /* 订阅事件通知逻辑可定制 */ static msg_center_notify_table_t g_msg_center_notify_table[] = { {TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc}, @@ -576,6 +637,10 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = { {TOPIC_EVENT_CAT1_POWER_ON, MsgCenterNotifyCat1PowerOnProc}, {TOPIC_EVENT_CAT1_POWER_OFF, MsgCenterNotifyCat1PowerOffProc}, #endif +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION + {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc}, + {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, +#endif }; static msg_center_notify_table_t *MsgCenterGetNotifyTblCb(uint8_t idx) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp index ae651d813..19f86f4c6 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-07 18:27:45 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-03-22 17:48:52 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp + */ /* * Copyright (c) CompanyNameMagicTag. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,5 +36,9 @@ void NotificationManager::FreeNotifyViews() #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION //Do Free notification view #endif +#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 + FreeDeviceBindingView(); + FreeDeviceUnBindingView(); +#endif } } 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 new file mode 100644 index 000000000..08086cabf --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp @@ -0,0 +1,416 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-22 10:04:36 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-03-22 19:02:16 + * @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" +namespace OHOS +{ + UIViewGroup *DeviceBindingView{nullptr}; + UILabelExt *DeviceBindingViewTitleLabel{nullptr}; // 标题 :设备绑定 + UILabelExt *DeviceBindingName{nullptr}; // 绑定的设备名称 + UILabelExt *DeviceBindingViewLabel{nullptr}; // 标签内容:“想要进行连接是否同意” + UIButton *DeviceBindingButtonOK{nullptr}; // 设备绑定确认 + UIButton *DeviceBindingButtonCancel{nullptr}; // 设备绑定取消 + + UIViewGroup *DeviceUnBindingView{nullptr}; + UILabelExt *DeviceUnBindingViewTitleLabel{nullptr}; // 标题 :设备解绑 + UILabelExt *DeviceUnBindingName{nullptr}; // 解绑的设备名称 + UILabelExt *DeviceUnBindingViewLabel{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 = 110; + 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 char **UnBindPathsArray{nullptr}; + ImageAnimatorInfo UnBindImageInfo[UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + + PairingViewEventListener::PairingViewEventListener() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::PairingViewEventListener"); + } + + PairingViewEventListener::~PairingViewEventListener() + { + WEARABLE_LOGE(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_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::OnClick"); + UNUSED(event); + if (&view == DeviceBindingButtonCancel) // 设备绑定取消按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel OnClick"); + // 终止当前的绑定流程并关闭相关的通知界面。 + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonOK OnClick"); + /* + * 可能会执行的绑定流程: + * 1.启动绑定过程. + * 2.更新设备绑定状态. + * 3.发送绑定请求到设备或服务器等. + */ + + // 关闭通知界面 + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel OnClick"); + // 不想执行解绑动作,并关闭解绑的通知界面。 + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonOK OnClick"); + /* + * 可能会执行的解绑流程: + * 1.通知设备或服务器执行解绑操作. + * 2.从绑定设备列表移除设备. + * 3.更新UI状态. + */ + + // 关闭通知界面 + NotificationManager::GetInstance()->StopNotify(); + } + return true; + } + + const char **PairingViewEventListener::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) + { + const char **imagePaths = new const char *[numImages]; + char buffer[256]; + for (int i = 0; i < numImages; i++) + { + snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); + imagePaths[i] = strdup(buffer); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]); + } + return imagePaths; + } + + void PairingViewEventListener::FreeImagePathsArray(const char **imagePaths, const int numImages) + { + for (int i = 0; i < numImages; i++) + { + delete imagePaths[i]; + imagePaths[i] = nullptr; + } + } + + 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, 0x2d); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4fc34c, UIButton::PRESSED); + button->SetImageSrc(imageSrc, imageSrc); + return button; + } + + /* + * @brief 创建设备绑定视图 + */ + UIViewGroup *CreateDeviceBindingView(void) + { + WEARABLE_LOGE(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); + /* ----------------------- DeviceBindingViewTitleLabel ---------------------- */ + DeviceBindingViewTitleLabel = new UILabelExt(); + if (DeviceBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingViewTitleLabel new fail!!"); + return nullptr; + } + DeviceBindingViewTitleLabel->SetPosition(173, 52, 120, 35); + DeviceBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingViewTitleLabel->SetText("设备绑定"); + DeviceBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + DeviceBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- DeviceBindingName --------------------------- */ + DeviceBindingName = new UILabelExt(); + if (DeviceBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingName new fail!!"); + return nullptr; + } + DeviceBindingName->SetPosition(33, 180, 400, 40); + DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingName->SetText("Iphone 14 Pro\n"); + DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingName->SetRollSpeed(60); + DeviceBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------- DeviceBindingViewLabel ------------------------- */ + DeviceBindingViewLabel = new UILabelExt(); + if (DeviceBindingViewLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceBindingView] DeviceBindingViewLabel new fail!!"); + return nullptr; + } + DeviceBindingViewLabel->SetPosition(33, 240, 400, 40); + DeviceBindingViewLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceBindingViewLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceBindingViewLabel->SetText("想要进行连接是否同意"); + DeviceBindingViewLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceBindingViewLabel->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + DeviceBindingViewLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceBindingViewLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + DeviceBindingButtonCancel = CreateButton(111, 320, 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, 320, 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()); + DeviceBindingButtonCancel->SetOnClickListener(listener); + DeviceBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceBindingView->Add(DeviceBindingViewTitleLabel); + DeviceBindingView->Add(DeviceBindingName); + DeviceBindingView->Add(DeviceBindingViewLabel); + DeviceBindingView->Add(DeviceBindingButtonCancel); + DeviceBindingView->Add(DeviceBindingButtonOK); + } + return DeviceBindingView; + } + + /* + * @brief 创建设备解绑视图 + */ + UIViewGroup *CreateDeviceUnBindingView(void) + { + WEARABLE_LOGE(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); + /* ----------------------- DeviceUnBindingAnimatorView ---------------------- */ + UnBindPathsArray = PairingViewEventListener::GetInstance().CreateImagePathsArray("/user/res/remind/unbind/", "bin", 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].imagePath = (UnBindPathsArray[i]); + UnBindImageInfo[i].imageType = IMG_SRC_FILE_PATH; + 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->Start(); + } + /* ----------------------- DeviceUnBindingViewTitleLabel ---------------------- */ + DeviceUnBindingViewTitleLabel = new UILabelExt(); + if (DeviceUnBindingViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewTitleLabel new fail!!"); + return nullptr; + } + DeviceUnBindingViewTitleLabel->SetPosition(173, 52, 120, 35); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnBindingViewTitleLabel->SetText("设备解绑"); + DeviceUnBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + DeviceUnBindingViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- DeviceUnBindingName --------------------------- */ + DeviceUnBindingName = new UILabelExt(); + if (DeviceUnBindingName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName new fail!!"); + return nullptr; + } + DeviceUnBindingName->SetPosition(33, 200, 400, 40); + DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnBindingName->SetText("小米5\n"); + DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + DeviceUnBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingName->SetRollSpeed(60); + DeviceUnBindingName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------- DeviceUnBindingViewLabel ------------------------- */ + DeviceUnBindingViewLabel = new UILabelExt(); + if (DeviceUnBindingViewLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewLabel new fail!!"); + return nullptr; + } + DeviceUnBindingViewLabel->SetPosition(33, 250, 400, 40); + DeviceUnBindingViewLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnBindingViewLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnBindingViewLabel->SetText("想要进行解绑是否同意"); + DeviceUnBindingViewLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnBindingViewLabel->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + DeviceUnBindingViewLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnBindingViewLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + DeviceUnBindingButtonCancel = CreateButton(111, 320, 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, 320, 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()); + DeviceUnBindingButtonCancel->SetOnClickListener(listener); + DeviceUnBindingButtonOK->SetOnClickListener(listener); + /* ----------------------------------- Add ---------------------------------- */ + DeviceUnBindingView->Add(DeviceUnBindingViewTitleLabel); + DeviceUnBindingView->Add(DeviceUnBindingAnimatorView); + DeviceUnBindingView->Add(DeviceUnBindingName); + DeviceUnBindingView->Add(DeviceUnBindingViewLabel); + DeviceUnBindingView->Add(DeviceUnBindingButtonCancel); + DeviceUnBindingView->Add(DeviceUnBindingButtonOK); + } + return DeviceUnBindingView; + } + + /* + * @brief 销毁设备绑定视图 + */ + void FreeDeviceBindingView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView]"); + if (DeviceBindingView != nullptr) + { + DeviceBindingView->RemoveAll(); + + delete DeviceBindingViewTitleLabel; + DeviceBindingViewTitleLabel = nullptr; + + delete DeviceBindingName; + DeviceBindingName = nullptr; + + delete DeviceBindingViewLabel; + DeviceBindingViewLabel = nullptr; + + delete DeviceBindingButtonCancel; + DeviceBindingButtonCancel = nullptr; + + delete DeviceBindingButtonOK; + DeviceBindingButtonOK = nullptr; + + RootView::GetInstance()->Remove(DeviceBindingView); + + delete DeviceBindingView; + DeviceBindingView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceBindingView] success"); + } + } + + /* + * @brief 销毁设备解绑视图 + */ + void FreeDeviceUnBindingView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]"); + if (DeviceUnBindingView != nullptr) + { + DeviceUnBindingView->RemoveAll(); + + delete DeviceUnBindingViewTitleLabel; + DeviceUnBindingViewTitleLabel = nullptr; + + PairingViewEventListener::GetInstance().FreeImagePathsArray(UnBindPathsArray, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + + delete DeviceUnBindingAnimatorView; + DeviceUnBindingAnimatorView = nullptr; + + delete DeviceUnBindingName; + DeviceUnBindingName = nullptr; + + delete DeviceUnBindingViewLabel; + DeviceUnBindingViewLabel = nullptr; + + delete DeviceUnBindingButtonCancel; + DeviceUnBindingButtonCancel = nullptr; + + delete DeviceUnBindingButtonOK; + DeviceUnBindingButtonOK = nullptr; + + RootView::GetInstance()->Remove(DeviceUnBindingView); + + delete DeviceUnBindingView; + DeviceUnBindingView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView] success"); + } + } + +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index a98ae4a44..70f33da11 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -127,6 +127,7 @@ target = { 'ENCODER_SUPPORT', 'SUPPORT_SPO2_NOTIFICATION', 'SUPPORT_SPO2_NOTIFICATION_TEST', + 'SUPPORT_DEVICE_PAIRING_NOTIFICATION', #'CONFIG_ADC_SUPPORT_AUTO_SCAN','CONFIG_ADC_SUPPORT_LONG_SAMPLE', 'MIPI_ULPS_SUPPORT', 'ENABLE_FONT_VECTOR_GLOBAL', diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/1.bin new file mode 100644 index 000000000..9f1299c0c Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/1.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/10.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/10.bin new file mode 100644 index 000000000..aba8a23f2 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/10.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/11.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/11.bin new file mode 100644 index 000000000..92f55d3a9 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/11.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/12.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/12.bin new file mode 100644 index 000000000..e4587ab2d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/12.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/13.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/13.bin new file mode 100644 index 000000000..32b37ce63 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/13.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/14.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/14.bin new file mode 100644 index 000000000..32b37ce63 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/14.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/15.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/15.bin new file mode 100644 index 000000000..9fbaf9541 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/15.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/16.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/16.bin new file mode 100644 index 000000000..249e1fcf0 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/16.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/17.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/17.bin new file mode 100644 index 000000000..f7f1529e1 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/17.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/18.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/18.bin new file mode 100644 index 000000000..0fa409149 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/18.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/19.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/19.bin new file mode 100644 index 000000000..c34db509d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/19.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/2.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/2.bin new file mode 100644 index 000000000..4cf0213ff Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/2.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/20.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/20.bin new file mode 100644 index 000000000..a1033ceca Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/20.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/21.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/21.bin new file mode 100644 index 000000000..0e8dfeaa3 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/21.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/22.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/22.bin new file mode 100644 index 000000000..98457b13c Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/22.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/23.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/23.bin new file mode 100644 index 000000000..be9f6a22b Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/23.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/24.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/24.bin new file mode 100644 index 000000000..522fa4bd3 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/24.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/25.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/25.bin new file mode 100644 index 000000000..221652125 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/25.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/3.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/3.bin new file mode 100644 index 000000000..141c7a37e Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/3.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/4.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/4.bin new file mode 100644 index 000000000..e7b15cf92 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/4.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/5.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/5.bin new file mode 100644 index 000000000..245679761 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/5.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/6.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/6.bin new file mode 100644 index 000000000..582c8bdee Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/6.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/7.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/7.bin new file mode 100644 index 000000000..8774b852a Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/7.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/8.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/8.bin new file mode 100644 index 000000000..8c16538f0 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/8.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/9.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/9.bin new file mode 100644 index 000000000..2d39bfd09 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/remind/unbind/9.bin differ