From 2d8d2ed51c8615cb2ac461fc2906f814543f57f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Mon, 3 Jun 2024 13:25:41 +0000 Subject: [PATCH] Merge #217 into sdk602patch0521 from refs/changes/217/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 优化久坐提醒:根据久坐间隔时间和是否在设置的提醒时间段内判断是否弹出久坐视图。协议需要对接 * refs/changes/217/head: (1 commits squashed) - 优化久坐提醒:根据久坐间隔时间和是否在设置的提醒时间段内判断是否弹出久坐视图。协议需要对接 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/217 --- .../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