优化久坐提醒:根据久坐间隔时间和是否在设置的提醒时间段内判断是否弹出久坐视图。协议需要对接 217/1 217/head
authorluozheng <1732036298@qq.com>
Mon, 3 Jun 2024 10:28:54 +0000 (18:28 +0800)
committerluozheng <1732036298@qq.com>
Mon, 3 Jun 2024 10:28:54 +0000 (18:28 +0800)
code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/sedentaryReminder_notification.cpp

index e808751..490f7de 100644 (file)
@@ -14,6 +14,7 @@ namespace OHOS
         static SedentaryReminderViewEventListener &GetInstance();
         bool OnRelease(UIView &view, const ReleaseEvent &event) override;
         bool IsReminderTime();
+        int GetIntervalTime();
     private:
         SedentaryReminderViewEventListener();
         ~SedentaryReminderViewEventListener();
index 079acbc..0b69e0e 100644 (file)
@@ -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)
index 99fe159..c6b65ac 100644 (file)
@@ -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);