* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-22 10:04:36
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-02 14:52:10
+ * @LastEditTime: 2024-09-02 15:37:52
* @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp
*/
#include "notification_manager.h"
static constexpr const char *BIND_IMAGE_SRC = "/user/res/remind/bind/";
UIViewGroup *DeviceUnBindingView{nullptr};
+ UIScrollView *DeviceUnBindingScrollView{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_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;
/*获取设备名称*/
char *PairingViewEventListener::GetDeviceName(void)
{
- return DeviceName; // 先用固定字符串测试
+ return DeviceName;
}
/*
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("Iphone 14 Pro MAX 想要与你进行连接绑定Iphone 14 Pro MAX 想要与你进行连接绑定Iphone 14 Pro MAX 想要与你进行连接绑定Iphone 14 Pro MAX 想要与你进行连接绑定");
// DeviceBindingName->SetText(devanme);
- DeviceBindingName->SetTextId(STR_DEVICE_BINDING_NOTE); // XX想要与你进行连接绑定
UpdateLabel(DeviceBindingName, devanme, STR_DEVICE_BINDING_NOTE);
}
else
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(800); // 800: compensation distance
+ DeviceUnBindingScrollView->SetDragACCLevel(5); // 5: drag acceleration
+ DeviceUnBindingScrollView->SetMaxScrollDistance(1000);
+ DeviceUnBindingScrollView->SetDirection(UIScrollView::VERTICAL);
/* ----------------------- DeviceUnBindingAnimatorView ---------------------- */
UnBindPathsArray = CreateImageInfoArray(UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
if (DeviceUnBindingAnimatorView == nullptr)
DeviceUnBindingAnimatorView->Start();
}
/* ----------------------- DeviceUnBindingViewTitleLabel ---------------------- */
- DeviceUnBindingViewTitleLabel = new UILabelExt();
if (DeviceUnBindingViewTitleLabel == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingViewTitleLabel new fail!!");
- return nullptr;
+ 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->SetPosition(83, 50, 300, 35);
DeviceUnBindingViewTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
DeviceUnBindingViewTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- DeviceUnBindingViewTitleLabel->SetText("设备解绑");
- DeviceUnBindingViewTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ // 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 --------------------------- */
- DeviceUnBindingName = new UILabelExt();
if (DeviceUnBindingName == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName new fail!!");
- return nullptr;
+ 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->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_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s", devanme);
if (strlen(devanme))
{
- DeviceUnBindingName->SetText(devanme);
+ // DeviceUnBindingName->SetText(devanme);
+ UpdateLabel(DeviceUnBindingName, devanme, STR_EQUIPMENT_UNTYING_NOTE);
}
else
{
- DeviceUnBindingName->SetText(" ");
+ // DeviceUnBindingName->SetText(" ");
+ UpdateLabel(DeviceUnBindingName, " ", STR_EQUIPMENT_UNTYING_NOTE);
}
// DeviceUnBindingName->SetText("小米5\n");
- DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ DeviceUnBindingName->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
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");
+ 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, 320, 100, 100, "/user/res/SYSTEM_CheckOn.bin");
+ DeviceUnBindingButtonOK = CreateButton(256, y, 100, 100, "/user/res/SYSTEM_CheckOn.bin");
if (DeviceUnBindingButtonOK == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingButtonOK new fail!!");
}
/* ------------------------- button OnClickListener ------------------------- */
UIView::OnClickListener *listener = static_cast<UIView::OnClickListener *>(&PairingViewEventListener::GetInstance());
+ if (nullptr == listener)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] PairingViewEventListener::GetInstance fail!!");
+ return nullptr;
+ }
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);
+ DeviceUnBindingScrollView->Add(DeviceUnBindingViewTitleLabel);
+ DeviceUnBindingScrollView->Add(DeviceUnBindingAnimatorView);
+ DeviceUnBindingScrollView->Add(DeviceUnBindingName);
+ DeviceUnBindingScrollView->Add(DeviceUnBindingButtonCancel);
+ DeviceUnBindingScrollView->Add(DeviceUnBindingButtonOK);
+ DeviceUnBindingView->Add(DeviceUnBindingScrollView);
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!");
+
+ /* -------------------------------------------------------------------------- */
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+ {
+ ui_api_vibrate_once_func(); // 震动一次
+ }
+
+ ScreenTurnOn(40 * 1000); // 亮屏操作 40秒关闭
+ /* -------------------------------------------------------------------------- */
+
NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceUnBindingView);
return DeviceUnBindingView;
}
*/
void FreeDeviceUnBindingView(void)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]");
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView]");
if (DeviceUnBindingView != nullptr)
{
DeviceUnBindingView->RemoveAll();
-
- delete DeviceUnBindingViewTitleLabel;
- DeviceUnBindingViewTitleLabel = nullptr;
-
- DeviceUnBindingAnimatorView->Stop();
- delete DeviceUnBindingAnimatorView;
- DeviceUnBindingAnimatorView = nullptr;
- FreeImageInfoArray(UnBindPathsArray, UNBIND_IMAGE_SRC, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-
- delete DeviceUnBindingName;
- DeviceUnBindingName = nullptr;
-
- delete DeviceUnBindingViewLabel;
- DeviceUnBindingViewLabel = nullptr;
-
- delete DeviceUnBindingButtonCancel;
- DeviceUnBindingButtonCancel = nullptr;
-
- delete DeviceUnBindingButtonOK;
- DeviceUnBindingButtonOK = nullptr;
-
+ 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;
+ }
+ delete DeviceUnBindingScrollView;
+ DeviceUnBindingScrollView = nullptr;
+ }
RootView::GetInstance()->Remove(DeviceUnBindingView);
-
delete DeviceUnBindingView;
DeviceUnBindingView = nullptr;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FreeDeviceUnBindingView] success");