#include "power_display_service.h"
#include "cat1_server.h"
#include "testchanging.h"
+#include "message_notification.h"
#include "testcat1.h"
#include "testold.h"
#include "testhrsenson.h"
{TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE},
{TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE},
{TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
-
#ifdef SUPPORT_CAT1_MODEM
{TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE},
{TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE},
{TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO},
{TOPIC_EVENT_CANCEL_FIND_WATCH,PRIORITY_TWO},
{TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO},
+ {TOPIC_EVENT_MESSAGENOTE,PRIORITY_TWO},
};
static bool CheckPriority(const Topic topic)
MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH);
MsgCenterSubscribeTopic(TOPIC_EVENT_CANCEL_FIND_WATCH);
MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_MESSAGENOTE);
}
static OHOS::UIViewGroup* ShowAlarmNotify(void)
return OHOS::transmittingShow();
}
+/*显示消息提醒*/
+static OHOS::UIViewGroup* showMessageNotify(void)
+{
+ return OHOS::CreateMessageView();
+}
+
void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
{
unused(req);
NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
NotificationManager::GetInstance()->ShowNotify(showDrinkReminderNotify, (uint16_t)topic, true);
}
+//消息通知
+void MsgCenterNotifyMessageProc(const Topic topic, Request* req)
+{
+ unused(topic);
+ unused(req);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !");
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true);
+}
void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
{
unused(topic);
{TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
{TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc},
{TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc},
+ {TOPIC_EVENT_MESSAGENOTE,MsgCenterNotifyMessageProc},
};
static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx)
--- /dev/null
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "components/ui_button.h"
+#include <iostream>
+#include "ui_service.h"
+#include <graphic_service.h>
+#include "bleEvent.h"
+#include "components/ui_label_ext.h"
+#include "uicomponents/UIComponents.h"
+#include "message/include/MessageModel.h"
+#include "message_notification.h"
+#include "string"
+namespace OHOS
+{
+
+ UIViewGroup *MessageGroupView{nullptr};
+
+ UILabel *titleLabel{nullptr}; // 标题
+ UILabel *timeLabel{nullptr}; // 时间
+ UILabel *messageLabel{nullptr}; // 详细label
+ UILabelButtonExt *deleteButton{nullptr}; // 删除按键
+
+ static std::string titleStr, timeStr, messageStr;
+
+#define DELETEBUTTON "delete_button"
+
+ MessageViewEventListener::MessageViewEventListener()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageViewEventListener::MessageViewEventListener");
+ }
+
+ MessageViewEventListener::~MessageViewEventListener()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageViewEventListener::~MessageViewEventListener");
+ }
+
+ MessageViewEventListener &MessageViewEventListener::GetInstance()
+ {
+ static MessageViewEventListener instance;
+ return instance;
+ }
+ bool MessageViewEventListener::OnRelease(UIView &view, const ReleaseEvent &event)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageViewEventListener::OnRelease");
+ UNUSED(event);
+ if (strcmp(view.GetViewId(), DELETEBUTTON) == 0)
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+
+ return true;
+ }
+ bool MessageViewEventListener::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageViewEventListener::OnDrag");
+ UNUSED(view);
+ return true;
+ }
+
+ bool MessageViewEventListener::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageViewEventListener::OnDragEnd");
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ return true;
+ }
+
+ /*创建信息弹窗*/
+ UIViewGroup *CreateMessageView(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateMessageView");
+ MessageGroupView = new UIViewGroup();
+ if (MessageGroupView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateMessageView] MessageGroupView new fail!!");
+ return nullptr;
+ }
+ MessageGroupView->SetPosition(0, 0, 466, 466);
+ MessageGroupView->SetViewId("messagenotify");
+ MessageGroupView->SetTouchable(true);
+ MessageGroupView->SetDraggable(true);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(&MessageViewEventListener::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateMessageView] dragListener new fail!!");
+ return nullptr;
+ }
+ MessageGroupView->SetOnDragListener(dragListener);
+ /*获取最新message*/
+ MessageData *data = MessageModel::GetInstance().GetNewestData();
+ if (data != nullptr)
+ {
+ titleStr = data->labelTitle;
+ timeStr = data->labelTime;
+ messageStr = data->labelDetails;
+ }
+ /*初始化label*/
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitView");
+ /* -------------------------------------------------------------------------- */
+ titleLabel = new UILabel();
+ if (titleLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel:: new UILabel fail");
+ return nullptr; // 内存分配失败,返回
+ }
+ titleLabel->SetPosition(83, 60, 300, 35);
+ titleLabel->SetText(titleStr.c_str());
+ titleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ titleLabel->SetVisible(true);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel is ok!");
+ /* -------------------------------------------------------------------------- */
+ timeLabel = new UILabel();
+ if (timeLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel:: new UILabel fail");
+ return nullptr; // 内存分配失败,返回
+ }
+ timeLabel->SetPosition(73, 104, 320, 33);
+ timeLabel->SetViewId("timeLabel");
+ timeLabel->SetText(timeStr.c_str());
+ timeLabel->SetTextColor(Color::Gray());
+ timeLabel->SetStyle(STYLE_TEXT_FONT, 28);
+ timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
+ timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ timeLabel->SetVisible(true);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel is ok!");
+ /* -------------------------------------------------------------------------- */
+ /*初始化消息内容*/
+ messageLabel = new UILabel();
+ if (messageLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLabel:: new UILabel fail");
+ return nullptr; // 内存分配失败,返回
+ }
+ messageLabel->SetPosition(53, 170, 360, 144);
+ messageLabel->SetViewId("messageLabel");
+ messageLabel->SetText(messageStr.c_str());
+ messageLabel->SetTextColor(Color::Gray());
+ messageLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLabel is ok");
+
+ /*加载清除按键*/
+ InitButtonExt(deleteButton, 0, 366, 466, 100, DELETEBUTTON, STR_CLOSE, 30);
+ const char *buttonImgSrc = "/user/res/466x100button.bin";
+ deleteButton->SetImageSrc(buttonImgSrc, buttonImgSrc);
+ UIView::OnTouchListener *TouchListener = static_cast<UIView::OnTouchListener *>(&MessageViewEventListener::GetInstance());
+ if (TouchListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateMessageView] TouchListener new fail!!");
+ return nullptr;
+ }
+ deleteButton->SetOnTouchListener(TouchListener);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "deleteButton");
+ /* -------------------------------------------------------------------------- */
+ MessageGroupView->Add(titleLabel);
+ MessageGroupView->Add(timeLabel);
+ MessageGroupView->Add(messageLabel);
+ MessageGroupView->Add(deleteButton);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create MessageGroupView succeed!!");
+
+ return MessageGroupView;
+ }
+ /*释放消息弹窗视图*/
+ void FreeMessageView(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeMessageView(void)");
+ if (MessageGroupView != nullptr)
+ {
+ MessageGroupView->RemoveAll();
+
+ delete titleLabel;
+ titleLabel = nullptr;
+
+ delete timeLabel;
+ timeLabel = nullptr;
+
+ delete messageLabel;
+ messageLabel = nullptr;
+
+ delete deleteButton;
+ deleteButton = nullptr;
+
+ RootView::GetInstance()->Remove(MessageGroupView);
+ delete MessageGroupView;
+ MessageGroupView = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Free MessageView succeed!!");
+ }
+ return;
+ }
+}
\ No newline at end of file