增加喝水提醒ui还未对接协议
authorluozheng <1732036298@qq.com>
Fri, 17 May 2024 10:18:49 +0000 (18:18 +0800)
committerluozheng <1732036298@qq.com>
Fri, 17 May 2024 10:18:49 +0000 (18:18 +0800)
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c
code/sdk/application/wearable/service/msg_center/CMakeLists.txt
code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/drinkReminder/DrinkReminder.bin [new file with mode: 0644]

index 434fced..b1d6e56 100755 (executable)
@@ -84,6 +84,7 @@ typedef enum {
     TOPIC_EVENT_CANCEL_CMAERA,
     TOPIC_EVENT_FIND_WATCH, //查找手表
     TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找
+    TOPIC_EVENT_DRINKREMINDER,//喝水提醒
     TOPIC_END_NUM = 20000,
 } TopicNum;
 
index 2c88897..db59f3d 100755 (executable)
@@ -61,6 +61,7 @@ static const TopicToCore topicToCoreArray[] = {
     {TOPIC_EVENT_CANCEL_CMAERA,A_CORE_MASK, 1},
     {TOPIC_EVENT_FIND_WATCH,A_CORE_MASK, 1},//查找手表
     {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1},
+    {TOPIC_EVENT_DRINKREMINDER,A_CORE_MASK, 1},
 #ifdef SUPPORT_CAT1_MODEM
     {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1},
     {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1},
index 68ee1a1..65d88b4 100755 (executable)
@@ -125,6 +125,7 @@ set(PRIVATE_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/bluetooth/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include
     ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../CustomUIComponentTool/uicomponents/
     ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include
     ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits
     ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits
@@ -154,6 +155,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/vendor_app/baidu/baidu_app.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/drinkReminder_notification.cpp
 )
 else()
 set(SOURCES
@@ -165,6 +167,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/drinkReminder_notification.cpp
 )
 endif()
 
diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h
new file mode 100644 (file)
index 0000000..fdb0195
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef DRINKREMINDER_NOTIFICATION
+#define DRINKREMINDER_NOTIFICATION
+
+#include "BaseView.h"
+namespace OHOS
+{
+    UIViewGroup *CreateDrinkReminderView(void);
+    void FreeDrinkReminderView(void);
+
+    class DrinkReminderViewEventListener : public UIView::OnTouchListener
+    {
+    public:
+        static DrinkReminderViewEventListener &GetInstance();
+        bool OnRelease(UIView &view, const ReleaseEvent &event) override;
+
+    private:
+        DrinkReminderViewEventListener();
+        ~DrinkReminderViewEventListener();
+        DrinkReminderViewEventListener(const DrinkReminderViewEventListener &) = delete;
+        const DrinkReminderViewEventListener &operator=(const DrinkReminderViewEventListener &) = delete;
+    };
+
+}
+
+#endif
\ No newline at end of file
index 70ef95a..2aa2ddd 100755 (executable)
@@ -26,6 +26,7 @@
 #include "charge_notification.h"
 #include "pairing_notification.h"
 #include "findwatch_notification.h"
+#include "drinkReminder_notification.h"
 
 #define UN_OPACITY 255
 #define HAlf_SCREEN  2
index cb4a651..31b13a5 100644 (file)
@@ -96,6 +96,7 @@ const PriorityMapper g_pri_mapper[] = {
 #endif
     {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO},
     {TOPIC_EVENT_CANCEL_FIND_WATCH,PRIORITY_TWO},
+    {TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO},
 };
 
 static bool CheckPriority(const Topic topic)
@@ -163,6 +164,7 @@ void MsgCenterSubscribe()
 #endif 
     MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH);
     MsgCenterSubscribeTopic(TOPIC_EVENT_CANCEL_FIND_WATCH);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER);
 }
 
 static OHOS::UIViewGroup* showAlarmNotify(void)
@@ -214,6 +216,12 @@ static OHOS::UIViewGroup* showFindWatchNotify(void)
     return OHOS::CreateFindWatchView();
 }
 
+/*显示喝水提醒视图*/
+static OHOS::UIViewGroup* showDrinkReminderNotify(void)
+{
+    return OHOS::CreateDrinkReminderView();
+}
+
 void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -231,6 +239,7 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
 }
 #ifdef FD230
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
+/*充电器已插上*/
 void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -253,6 +262,7 @@ void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
    
 }
 
+/*充电器已拔掉*/
 void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -268,6 +278,7 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
     }
 }
 
+/*低电量提醒*/
 void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
 {
     //unused(req);
@@ -806,6 +817,16 @@ void MsgCenterNotifyCanCelFindWatchProc(const Topic topic, Request* req)
     }
     FindWatchViewEventListener::GetInstance().SetFindWatchNotifyFlag(false);
 }
+
+//喝水提醒通知
+void MsgCenterNotifyDrinkReminderProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(req);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDrinkReminderProc !");
+    NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+    NotificationManager::GetInstance()->ShowNotify(showDrinkReminderNotify, (uint16_t)topic, true);
+}
 void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
 {
     unused(topic);
@@ -853,8 +874,6 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = {
     {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc},
     {TOPIC_EVENT_HFP_WATCH_ACTIVE,   MsgCenterNotifyHfpWatchProc},
     {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
-    {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
-    {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc},
  #ifdef CYWEE_SPORT   
     {TOPIC_EVENT_ACTIVITY_UPDATE,       MsgCenterNotifyActivityProc},
     {TOPIC_EVENT_INACTIVITY_UPDATE,       MsgCenterNotifyInactivityProc},
@@ -892,6 +911,7 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = {
 #endif
     {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
     {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc},
+    {TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc},
 };
 
 static msg_center_notify_table_t *MsgCenterGetNotifyTblCb(uint8_t idx)
diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp
new file mode 100644 (file)
index 0000000..26ace86
--- /dev/null
@@ -0,0 +1,175 @@
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include <UIComponents.h>
+
+namespace OHOS
+{
+
+    UIViewGroup *DrinkReminderGroupView{nullptr};
+    UILabelExt *DrinkReminderTitleLabel{nullptr}; // 标题: 喝水提醒
+    UIImageView *DrinkReminderImage{nullptr};
+    UILabel *DrinkReminderNoteLabel{nullptr}; // 喝水提醒note
+    UILabelExt *DrinkReminderLabel{nullptr};
+    UIButton *DrinkReminderButton{nullptr};
+
+    static constexpr const char *DRINKREMINDERBUTTONVIEWID = "DrinkReminderButton";
+
+    DrinkReminderViewEventListener::DrinkReminderViewEventListener()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DrinkReminderViewEventListener::DrinkReminderViewEventListener");
+    }
+
+    DrinkReminderViewEventListener::~DrinkReminderViewEventListener()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DrinkReminderViewEventListener::~DrinkReminderViewEventListener");
+    }
+
+    DrinkReminderViewEventListener &DrinkReminderViewEventListener::GetInstance()
+    {
+        static DrinkReminderViewEventListener instance;
+        return instance;
+    }
+
+    bool DrinkReminderViewEventListener::OnRelease(UIView &view, const ReleaseEvent &event)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DrinkReminderViewEventListener::OnRelease");
+        UNUSED(event);
+        std::string viewId = view.GetViewId();
+        if (viewId == DRINKREMINDERBUTTONVIEWID)
+        {
+            NotificationManager::GetInstance()->StopNotify();
+        }
+
+        return true;
+    }
+
+    /*创建喝水提醒视图*/
+    UIViewGroup *CreateDrinkReminderView(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateDrinkReminderView(void)");
+        if (DrinkReminderGroupView == nullptr)
+        {
+            DrinkReminderGroupView = new UIViewGroup();
+            if (DrinkReminderGroupView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderGroupView new fail!!");
+                return nullptr;
+            }
+            DrinkReminderGroupView->SetPosition(0, 0, 466, 466);
+            DrinkReminderGroupView->SetTouchable(true);
+            DrinkReminderGroupView->SetDraggable(true);
+            /* ------------------------- DrinkReminderTitleLabel ------------------------ */
+            DrinkReminderTitleLabel = new UILabelExt();
+            if (DrinkReminderTitleLabel == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderTitleLabel new fail!!");
+                return nullptr;
+            }
+            DrinkReminderTitleLabel->SetPosition(83, 52, 300, 35);
+            DrinkReminderTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+            DrinkReminderTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+            // DrinkReminderTitleLabel->SetText("喝水提醒");
+            DrinkReminderTitleLabel->SetTextId(STR_DRINK_WATER_REMINDER);
+            DrinkReminderTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            DrinkReminderTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            DrinkReminderTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* --------------------------- DrinkReminderImage --------------------------- */
+            DrinkReminderImage = new UIImageView();
+            if (DrinkReminderImage == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderImage new fail!!");
+                return nullptr;
+            }
+            DrinkReminderImage->SetPosition(193, 130, 80, 80);
+            DrinkReminderImage->SetSrc("/user/res/drinkReminder/DrinkReminder.bin");
+            /* ------------------------- DrinkReminderNoteLabel ------------------------- */
+            DrinkReminderNoteLabel = new UILabel();
+            if (DrinkReminderNoteLabel == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderNoteLabel new fail!!");
+                return nullptr;
+            }
+            DrinkReminderNoteLabel->SetPosition(53, 248, 360, 70);
+            DrinkReminderNoteLabel->SetStyle(STYLE_TEXT_FONT, 30);
+            DrinkReminderNoteLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+            SetLabelId(DrinkReminderNoteLabel, STR_DRINK_WATER_REMINDER_NOTE);
+            DrinkReminderNoteLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+            DrinkReminderNoteLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            DrinkReminderNoteLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* --------------------------- DrinkReminderButton -------------------------- */
+            DrinkReminderButton = new UIButton();
+            if (DrinkReminderButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderButton new fail!!");
+                return nullptr;
+            }
+            DrinkReminderButton->SetPosition(0, 366, 466, 100);
+            DrinkReminderButton->SetViewId(DRINKREMINDERBUTTONVIEWID);
+            const char *buttonImgSrc = "/user/res/466x100button.bin";
+            DrinkReminderButton->SetImageSrc(buttonImgSrc, buttonImgSrc);
+            DrinkReminderButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED);
+            UIView::OnTouchListener *listener = static_cast<UIView::OnTouchListener *>(&DrinkReminderViewEventListener::GetInstance());
+            DrinkReminderButton->SetOnTouchListener(listener);
+            /* --------------------------- DrinkReminderLabel --------------------------- */
+            DrinkReminderLabel = new UILabelExt();
+            if (DrinkReminderLabel == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] DrinkReminderLabel new fail!!");
+                return nullptr;
+            }
+            DrinkReminderLabel->SetPosition(133, 399, 200, 35);
+            DrinkReminderLabel->SetStyle(STYLE_TEXT_FONT, 30);
+            DrinkReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+            // DrinkReminderLabel->SetText("知道了");
+            DrinkReminderLabel->SetTextId(STR_KONW);
+            DrinkReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            DrinkReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            DrinkReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* ----------------------------------- Add ---------------------------------- */
+            DrinkReminderGroupView->Add(DrinkReminderTitleLabel);
+            DrinkReminderGroupView->Add(DrinkReminderImage);
+            DrinkReminderGroupView->Add(DrinkReminderNoteLabel);
+            DrinkReminderGroupView->Add(DrinkReminderButton);
+            DrinkReminderGroupView->Add(DrinkReminderLabel);
+
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create DrinkReminderView succeed!!");
+        }
+
+        return DrinkReminderGroupView;
+    }
+
+    /*释放喝水提醒视图*/
+    void FreeDrinkReminderView(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDrinkReminderView(void)");
+        if (DrinkReminderGroupView != nullptr)
+        {
+            DrinkReminderGroupView->RemoveAll();
+
+            delete DrinkReminderTitleLabel;
+            DrinkReminderTitleLabel = nullptr;
+
+            delete DrinkReminderImage;
+            DrinkReminderImage = nullptr;
+
+            delete DrinkReminderNoteLabel;
+            DrinkReminderNoteLabel = nullptr;
+
+            delete DrinkReminderButton;
+            DrinkReminderButton = nullptr;
+
+            delete DrinkReminderLabel;
+            DrinkReminderLabel = nullptr;
+
+            RootView::GetInstance()->Remove(DrinkReminderGroupView);
+            delete DrinkReminderGroupView;
+            DrinkReminderGroupView = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Free DrinkReminderView succeed!!");
+        }
+        return;
+    }
+}
\ No newline at end of file
index 7c20796..3eb3796 100755 (executable)
@@ -35,6 +35,7 @@ void NotificationManager::FreeNotifyViews()
     FreeCalldialView();
     FreeFindWatchView();
     FreelowPower();
+    FreeDrinkReminderView();
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     //Do Free notification view
 #endif
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/drinkReminder/DrinkReminder.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/drinkReminder/DrinkReminder.bin
new file mode 100644 (file)
index 0000000..1d16cb5
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6119a47af2d1547b3a4c4723bc19442c9c63c6125ec1ce762a972ff43156b7bf
+size 4504