增加早起弹窗
authorCaisking <3449750381@qq.com>
Tue, 2 Jul 2024 09:39:03 +0000 (17:39 +0800)
committerCaisking <3449750381@qq.com>
Tue, 2 Jul 2024 09:39:03 +0000 (17:39 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp
code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp

index 7d03c8b..9e3af5b 100644 (file)
@@ -269,6 +269,9 @@ extern "C"
                 printf("起床啦!\r\n");\r
                 do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL);\r
                 // 早安提醒\r
+                AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4);\r
+                // 设置状态为睡眠\r
+                OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WALK);\r
             }\r
         }\r
 \r
index f898b36..0dac41b 100644 (file)
@@ -1,4 +1,10 @@
 /*** 
+ * @Date: 2024-07-02 10:15:59
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-02 17:27:39
+ * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h
+ */
+/***
  * @Date: 2024-07-02 10:15:59
  * @LastEditors: Caisking 3449750381@qq.com
  * @LastEditTime: 2024-07-02 11:27:01
@@ -18,6 +24,7 @@ namespace OHOS
 {
     UIViewGroup *CreateSleepNotifyView(void);
     void FreeSleepView(void);
+    void SetAlarmClockView();
 
     class SleepViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener
     {
index e13c539..e5faea3 100644 (file)
@@ -12,6 +12,7 @@
 #include "string"
 #include "vibrator_service.h"
 #include "UiConfig.h"
+#include "ConfigModel.h"
 extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType);
 
 namespace OHOS
@@ -24,9 +25,22 @@ namespace OHOS
     UILabelExt *sleepnotifylabel{nullptr};  // 详细label
     UILabelButtonExt *sleepbutton{nullptr}; // 删除按键
 
-    static std::string titleStr, timeStr, sleepStr;
+    UILabelExt *alarmtitle{nullptr}; // 标题
+    UIImageView *backimage{nullptr};
+    UIImageView *sunnyicon{nullptr};
+    UIImageView *alarmicon{nullptr};
+    UILabelExt *nowlabel{nullptr};
+    UILabelExt *walklabel{nullptr};         // 早安时间
+    UILabelButtonExt *closebutton{nullptr}; // 关闭按键
+    UILabelButtonExt *nopbutton{nullptr};   // 小睡按键
+
+    static std::string titleStr;
+    static constexpr const char *PNG_SLEEP_SUUNY_IMAGE = "/user/res/Sleep/sunny.bin";
+    static constexpr const char *PNG_SLEEP_ALARM_IMAGE = "/user/res/Sleep/alarmicon.bin";
+    static constexpr const char *PNG_SLEEP_BACK_IMAGE = "/user/res/Sleep/goodmorning.bin";
 
 #define DELETEBUTTON "delete_button"
+#define NOPBUTTON "nop_button"
 
     SleepViewEventListener::SleepViewEventListener()
     {
@@ -51,7 +65,6 @@ namespace OHOS
         {
             NotificationManager::GetInstance()->StopNotify();
         }
-
         return true;
     }
     bool SleepViewEventListener::OnDrag(UIView &view, const DragEvent &event)
@@ -108,7 +121,10 @@ namespace OHOS
             break;
         case SLEEPSTATE::WALK:
             titleStr = SleepModel::GetInstance().get_walk_notifiy();
+            textId = STR_MORNNING;
             ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰
+            SetAlarmClockView();                               // 设置为早安视图
+            return SleepGroupView;
             break;
         default:
             break;
@@ -170,10 +186,43 @@ namespace OHOS
         SleepGroupView->Add(sleepbutton);
 
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
-        // 震动提醒
-        custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO);
+        custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
         return SleepGroupView;
     }
+    void SetAlarmClockView()
+    {
+        /*初始化图片*/
+        InitImageView(backimage, 0, 0, 466, 466, "image", PNG_SLEEP_BACK_IMAGE);
+        InitImageView(sunnyicon, 153, 95, 160, 160, "image", PNG_SLEEP_SUUNY_IMAGE);
+        InitImageView(alarmicon, 149, 260, 29, 29, "image", PNG_SLEEP_ALARM_IMAGE);
+        /*初始化固定label*/
+        InitLabelExt(alarmtitle, 83, 50, 300, 35, "labletitle", STR_MORNNING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabelExt(nowlabel, 110, 243, 200, 60, "labletitle", STR_NOW, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        /*获取起床时间labe*/
+        std::string walkStr = SleepModel::GetInstance().get_walk_notifiy();
+        InitLabel(walklabel, 190, 245, 200, 60, "labletitle", walkStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30);
+        /*设置按键*/
+        InitButtonExt(nopbutton, 58, 320, 170, 90, NOPBUTTON, STR_NAP, 30);
+        nopbutton->SetOnTouchListener(static_cast<UIView::OnTouchListener *>(&SleepViewEventListener::GetInstance()));
+        nopbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
+        nopbutton->SetStyle(STYLE_BORDER_RADIUS, 100);
+
+        InitButtonExt(closebutton, 238, 320, 170, 90, DELETEBUTTON, STR_CLOSE, 30);
+        closebutton->SetOnTouchListener(static_cast<UIView::OnTouchListener *>(&SleepViewEventListener::GetInstance()));
+        closebutton->SetStyle(STYLE_BORDER_RADIUS, 100);
+
+        /* -------------------------------------------------------------------------- */
+        SleepGroupView->Add(backimage);
+        SleepGroupView->Add(sunnyicon);
+        SleepGroupView->Add(alarmicon);
+        SleepGroupView->Add(nowlabel);
+        SleepGroupView->Add(walklabel);
+        SleepGroupView->Add(nopbutton);
+        SleepGroupView->Add(closebutton);
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
+        custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
+    }
     /*释放消息弹窗视图*/
     void FreeSleepView(void)
     {