From 3293734fea01a8ca137e34040de53d174a791b21 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 2 Jul 2024 17:39:03 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=97=A9=E8=B5=B7=E5=BC=B9?= =?utf8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/AlarmClockTimerConfig.cpp | 3 + .../include/notify/sleep_notification.h | 7 +++ .../src/notify/sleep_notification.cpp | 57 +++++++++++++++++-- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 7d03c8b7a..9e3af5bac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -269,6 +269,9 @@ extern "C" printf("起床啦!\r\n"); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL); // 早安提醒 + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为睡眠 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WALK); } } diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h index f898b36af..0dac41be3 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h @@ -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 { diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp index e13c539eb..e5faea3d0 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp @@ -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(&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(&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) { -- 2.17.1