From: luozheng <1732036298@qq.com> Date: Mon, 25 Mar 2024 09:19:08 +0000 (+0800) Subject: 添加“设备解除绑定请求”的弹窗 X-Git-Tag: release_V1.2.70_20241020_135402~1250^2~11 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=161f23b54f5c4b5f91de9708eaa0749f0133d39d;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 89e8204a6..13594c30c 100755 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -71,6 +71,7 @@ typedef enum { #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION TOPIC_EVENT_DEVICE_BIND, TOPIC_EVENT_DEVICE_UNBIND, + TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, #endif TOPIC_END_NUM = 20000, } TopicNum; 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 index 9fb75fc50..b1e980a78 100644 --- 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 @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-22 09:48:07 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-22 16:09:57 + * @LastEditTime: 2024-03-25 10:14:52 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h */ #ifndef PAIRING_NOTIFICATION_H @@ -14,10 +14,11 @@ namespace OHOS { UIViewGroup *CreateDeviceBindingView(void); UIViewGroup *CreateDeviceUnBindingView(void); - + UIViewGroup * CreateDeviceUnbindingRequestGroupView(void); + void FreeDeviceBindingView(void); void FreeDeviceUnBindingView(void); - + void FreeDeviceUnbindingRequestGroupView(void); class PairingViewEventListener : public OHOS::UIView::OnClickListener { public: 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 bd758a761..53a01373d 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 @@ -80,6 +80,7 @@ const PriorityMapper g_pri_mapper[] = { #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 {TOPIC_EVENT_DEVICE_BIND, PRIORITY_TWO}, {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO}, + {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO}, #endif }; @@ -137,6 +138,7 @@ void MsgCenterSubscribe() #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND); MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBIND); + MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_UNBINDING_REQUEST); #endif } @@ -172,6 +174,12 @@ static OHOS::UIViewGroup* showDeviceUnBindingNotify(void) return OHOS::CreateDeviceUnBindingView(); } +/*显示解除绑定请求(与新设备连接)通知*/ +static OHOS::UIViewGroup* showDeviceUnbindingRequestNotify(void) +{ + return OHOS::CreateDeviceUnbindingRequestGroupView(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -602,6 +610,20 @@ void MsgCenterNotifyDeviceUnBindProc(const Topic topic, Request* req) NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); NotificationManager::GetInstance()->ShowNotify(showDeviceUnBindingNotify, (uint16_t)topic, true); +} + +void MsgCenterNotifyDeviceUnBindingRequestProc(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(showDeviceUnbindingRequestNotify, (uint16_t)topic, true); + } #endif @@ -642,6 +664,7 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = { #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION {TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc}, {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, + {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, #endif }; 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 19f86f4c6..6021262f4 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 @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-07 18:27:45 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-22 17:48:52 + * @LastEditTime: 2024-03-25 10:21:16 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp */ /* @@ -39,6 +39,7 @@ void NotificationManager::FreeNotifyViews() #ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION //如果支持设备配对通知 FreeDeviceBindingView(); FreeDeviceUnBindingView(); + FreeDeviceUnbindingRequestGroupView(); #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 index 08086cabf..5ca4bd98c 100644 --- 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 @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-22 10:04:36 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-22 19:02:16 + * @LastEditTime: 2024-03-25 17:00:39 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp */ #include "notification_manager.h" @@ -10,6 +10,9 @@ #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" + namespace OHOS { UIViewGroup *DeviceBindingView{nullptr}; @@ -36,6 +39,14 @@ namespace OHOS const char **UnBindPathsArray{nullptr}; ImageAnimatorInfo UnBindImageInfo[UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; + UIViewGroup *DeviceUnbindingRequestGroupView{nullptr}; + UIScrollView *DeviceUnbindingRequestScrollView{nullptr}; // 设备解除绑定请求(与新设备连接)视图 + UILabelExt *DeviceUnbindingRequestViewTitleLabel{nullptr}; // 标题 :注意 + UIImageView *DeviceUnbindingRequestViewImageView{nullptr}; // + UILabelExt *DeviceUnbindingRequestViewLabel[2]{nullptr}; // + UIButton *DeviceUnbindingRequestButtonOK{nullptr}; // 设备解除绑定请求(与新设备连接)确认 + UIButton *DeviceUnbindingRequestButtonCancel{nullptr}; // 设备解除绑定请求(与新设备连接)取消 + PairingViewEventListener::PairingViewEventListener() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener::PairingViewEventListener"); @@ -95,6 +106,16 @@ namespace OHOS // 关闭通知界面 NotificationManager::GetInstance()->StopNotify(); } + else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK OnClick"); + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DeviceUnbindingRequestButtonCancel) //设备解除绑定请求(与新设备连接)取消 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonCancel OnClick"); + NotificationManager::GetInstance()->StopNotify(); + } return true; } @@ -110,7 +131,11 @@ namespace OHOS } return imagePaths; } - + /* + * @brief: 释放图片路径数组指针 + * @param {char} imagePaths 图片路径数组 + * @param {int} numImages 图片数量 + */ void PairingViewEventListener::FreeImagePathsArray(const char **imagePaths, const int numImages) { for (int i = 0; i < numImages; i++) @@ -135,6 +160,12 @@ namespace OHOS return button; } + /*获取设备名称*/ + static const char *GetDeviceName(void) + { + return "Iphone 13 pro"; //先用固定字符串测试 + } + /* * @brief 创建设备绑定视图 */ @@ -342,6 +373,135 @@ namespace OHOS return DeviceUnBindingView; } + /* + * @brief 创建解除绑定请求(与新设备连接)视图 + */ + UIViewGroup *CreateDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGE(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); + /* -------------------- 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->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DeviceUnbindingRequestScrollView->SetScrollBlankSize(20); + DeviceUnbindingRequestScrollView->SetReboundSize(50); + DeviceUnbindingRequestScrollView->SetDirection(1); + /* ------------------ DeviceUnbindingRequestViewTitleLabel ------------------ */ + DeviceUnbindingRequestViewTitleLabel = new UILabelExt(); + if (DeviceUnbindingRequestViewTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnbindingRequestGroupView] DeviceUnbindingRequestViewTitleLabel is nullptr"); + return nullptr; + } + DeviceUnbindingRequestViewTitleLabel->SetPosition(203, 52, 200, 60); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + DeviceUnbindingRequestViewTitleLabel->SetText("注意"); + DeviceUnbindingRequestViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + DeviceUnbindingRequestViewTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------- DeviceUnbindingRequestViewImageView ------------------ */ + 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/FastTrainingAttentionVector.bin"; + DeviceUnbindingRequestViewImageView->SetSrc(imageimagesPath); + + /* --------------------- 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(33, 220, 400, 90); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 40); + char str[512]; + memcpy(str, 0, 512); + sprintf(str, "当前设备已经与 %s 绑定", GetDeviceName()); + DeviceUnbindingRequestViewLabel[0]->SetText(str); + 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] ------------------- */ + 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]->GetHeight(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %d %d %d", DeviceUnbindingRequestViewLabel[0]->GetY(), DeviceUnbindingRequestViewLabel[0]->GetHeight(), y); + DeviceUnbindingRequestViewLabel[1]->SetPosition(33, y, 400, 300); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_TEXT_FONT, 30); + DeviceUnbindingRequestViewLabel[1]->SetStyle(STYLE_LINE_HEIGHT, 40); + memcpy(str, 0, 512); + sprintf(str, "继续连接操作会解除与%s的绑定并将手表恢复出厂设置(会清空手表数据)\n\n是否继续此操作\n", GetDeviceName()); + // str = "继续连接操作会解除与 " + GetDeviceName() + " 的绑定并将手表恢复出厂设置(会清空手表数据)\n\n是否继续此操作\n"; + DeviceUnbindingRequestViewLabel[1]->SetText(str); + DeviceUnbindingRequestViewLabel[1]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + DeviceUnbindingRequestViewLabel[1]->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + DeviceUnbindingRequestViewLabel[1]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceUnbindingRequestViewLabel[1]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + /* ------------------------------ DeviceBindingButtonCancel ------------------------------ */ + y = DeviceUnbindingRequestViewLabel[1]->GetY() + DeviceUnbindingRequestViewLabel[1]->GetHeight(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %d %d %d", DeviceUnbindingRequestViewLabel[1]->GetY(), DeviceUnbindingRequestViewLabel[1]->GetHeight(), y); + 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()); + DeviceUnbindingRequestButtonCancel->SetOnClickListener(listener); + DeviceUnbindingRequestButtonOK->SetOnClickListener(listener); + + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewTitleLabel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewImageView); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[0]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestViewLabel[1]); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonCancel); + DeviceUnbindingRequestScrollView->Add(DeviceUnbindingRequestButtonOK); + DeviceUnbindingRequestGroupView->Add(DeviceUnbindingRequestScrollView); + } + + return DeviceUnbindingRequestGroupView; + } + /* * @brief 销毁设备绑定视图 */ @@ -413,4 +573,44 @@ namespace OHOS } } + /* + * @brief 销毁解除绑定请求(与新设备连接)视图 + */ + void FreeDeviceUnbindingRequestGroupView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView]"); + if (DeviceUnbindingRequestGroupView != nullptr) + { + DeviceUnbindingRequestGroupView->Remove(DeviceUnbindingRequestScrollView); + + DeviceUnbindingRequestScrollView->RemoveAll(); + + delete DeviceUnbindingRequestViewTitleLabel; + DeviceUnbindingRequestViewTitleLabel = nullptr; + + delete DeviceUnbindingRequestViewImageView; + DeviceUnbindingRequestViewImageView = nullptr; + + delete DeviceUnbindingRequestViewLabel[0]; + DeviceUnbindingRequestViewLabel[0] = nullptr; + + delete DeviceUnbindingRequestViewLabel[1]; + DeviceUnbindingRequestViewLabel[1] = nullptr; + + delete DeviceUnbindingRequestButtonOK; + DeviceUnbindingRequestButtonOK = nullptr; + + delete DeviceUnbindingRequestButtonCancel; + DeviceUnbindingRequestButtonCancel = nullptr; + + delete DeviceUnbindingRequestScrollView; + DeviceUnbindingRequestScrollView = nullptr; + + RootView::GetInstance()->Remove(DeviceUnbindingRequestGroupView); + + delete DeviceUnbindingRequestGroupView; + DeviceUnbindingRequestGroupView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnbindingRequestGroupView] success"); + } + } } \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/FastTrainingAttentionVector.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/FastTrainingAttentionVector.bin new file mode 100644 index 000000000..b8120b857 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/FastTrainingAttentionVector.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/recording/test.txt b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/recording/test.txt deleted file mode 100644 index 56529f294..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/recording/test.txt +++ /dev/null @@ -1 +0,0 @@ -recording test \ No newline at end of file