From ddce364e4b01b901077f34cf06ec66729c56ab84 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 3 Jun 2024 18:28:54 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E4=B9=85=E5=9D=90=E6=8F=90?= =?utf8?q?=E9=86=92=EF=BC=9A=E6=A0=B9=E6=8D=AE=E4=B9=85=E5=9D=90=E9=97=B4?= =?utf8?q?=E9=9A=94=E6=97=B6=E9=97=B4=E5=92=8C=E6=98=AF=E5=90=A6=E5=9C=A8?= =?utf8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E6=8F=90=E9=86=92=E6=97=B6=E9=97=B4?= =?utf8?q?=E6=AE=B5=E5=86=85=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=BC=B9?= =?utf8?q?=E5=87=BA=E4=B9=85=E5=9D=90=E8=A7=86=E5=9B=BE=E3=80=82=E5=8D=8F?= =?utf8?q?=E8=AE=AE=E9=9C=80=E8=A6=81=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../notify/sedentaryReminder_notification.h | 1 + .../msg_center/src/msg_center_customer.cpp | 14 +++++++---- .../notify/sedentaryReminder_notification.cpp | 23 ++++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h index e808751b2..490f7de34 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h @@ -14,6 +14,7 @@ namespace OHOS static SedentaryReminderViewEventListener &GetInstance(); bool OnRelease(UIView &view, const ReleaseEvent &event) override; bool IsReminderTime(); + int GetIntervalTime(); private: SedentaryReminderViewEventListener(); ~SedentaryReminderViewEventListener(); diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 079acbc5a..0b69e0ed6 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -906,16 +906,19 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->sedentary_status = %d, stand_freq = %d", cywee_Inactivity_Info->sedentary_status, cywee_Inactivity_Info->stand_freq); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "cywee_Inactivity_Info->output_number = %d", cywee_Inactivity_Info->output_number); + static int interval = 0;//久坐间隔时间 switch (cywee_Inactivity_Info->output_number) { case INACTIVITY_MODE_SEDENTARY_OUTPUT: if(cywee_Inactivity_Info->sedentary_status == 1) { - NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); - // if(SedentaryReminderViewEventListener::GetInstance().IsReminderTime() == true) - // { - // NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); - // } + //NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); + //根据久坐间隔时间和是否在设置的提醒时间段内判断是否弹出久坐视图 + interval++; + if(( interval % SedentaryReminderViewEventListener::GetInstance().GetIntervalTime() == 0) && + (SedentaryReminderViewEventListener::GetInstance().IsReminderTime() == true)) { + NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); + } } break; default: @@ -923,6 +926,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) } free(cywee_Inactivity_Info); + cywee_Inactivity_Info = NULL; } //APP运动相关 void MsgCenterNotifybleAPPtraining(const Topic topic, Request* req) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sedentaryReminder_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sedentaryReminder_notification.cpp index 99fe15985..c6b65ac96 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/sedentaryReminder_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sedentaryReminder_notification.cpp @@ -72,6 +72,13 @@ namespace OHOS return false; } + // 获取久坐提醒时间间隔 + int SedentaryReminderViewEventListener::GetIntervalTime() + { + interval = ConfigModel::GetInstance()->GetSedentaryInterval(); + return interval; + } + /*创建久坐提醒视图*/ UIViewGroup *CreateSedentaryReminderView(void) { @@ -97,11 +104,11 @@ namespace OHOS SedentaryReminderTitleLabel->SetPosition(83, 52, 300, 35); SedentaryReminderTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); SedentaryReminderTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 SedentaryReminderTitleLabel->SetTextId(STR_SEDENTARY_REMINDER); - #else +#else SedentaryReminderTitleLabel->SetText("久坐提醒"); - #endif +#endif SedentaryReminderTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); SedentaryReminderTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); SedentaryReminderTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -124,9 +131,9 @@ namespace OHOS SedentaryReminderNoteLabel->SetPosition(53, 248, 360, 70); SedentaryReminderNoteLabel->SetStyle(STYLE_TEXT_FONT, 30); SedentaryReminderNoteLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 SetLabelId(SedentaryReminderNoteLabel, STR_SEDENTARY_REMINDER_NOTE); - #endif +#endif // UpdateLabel(SedentaryReminderNoteLabel,"1",STR_SEDENTARY_REMINDER_NOTE); SedentaryReminderNoteLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); SedentaryReminderNoteLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -155,11 +162,11 @@ namespace OHOS SedentaryReminderLabel->SetPosition(133, 399, 200, 35); SedentaryReminderLabel->SetStyle(STYLE_TEXT_FONT, 30); SedentaryReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 SedentaryReminderLabel->SetTextId(STR_KONW); - #else +#else SedentaryReminderLabel->SetText("知道了"); - #endif +#endif SedentaryReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); SedentaryReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); SedentaryReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); -- 2.17.1