实现消息弹窗 347/3 347/head 348/target/1 349/target/1
authorCaisking <3449750381@qq.com>
Fri, 21 Jun 2024 10:21:36 +0000 (18:21 +0800)
committerCaisking <3449750381@qq.com>
Fri, 21 Jun 2024 10:21:36 +0000 (18:21 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp

index c027afd..50bee17 100644 (file)
@@ -322,8 +322,8 @@ namespace OHOS
         // 达到最高心率进行心率提醒弹窗
         if (sportdata->heart >= ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX))
         {
-            uapi_set_screen_on_api(); // 亮屏检测
-            custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO);
+            uapi_set_screen_on_api();                             // 亮屏检测
+            custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
             TraingCardView::GetInstance()->SetPopupViewStatus(HeartPopup, true);
         }
         // sportdata->duration = cyweeInfo->duration;
index ca2750e..394ef20 100644 (file)
@@ -5040,7 +5040,6 @@ uint8_t jscheck_ancs(uint8_t *data)
         return 2;\r
     }\r
 \r
-\r
     int uid_t = 0;\r
     int appid_t = 0;\r
     int hasCode_t = 0;\r
@@ -5075,7 +5074,6 @@ uint8_t jscheck_ancs(uint8_t *data)
             title_c->valuestring[len++] = '.';\r
             title_c->valuestring[len++] = 0;\r
         }\r
-        \r
         memcpy(titleBuf,(uint8_t *)title_c->valuestring,len);\r
     }\r
     cJSON* msg = cJSON_GetObjectItem(root, "msg");\r
@@ -5134,6 +5132,7 @@ void ancsDataShowCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,
         value[17] = 1;\r
         value[18] = Calculate_CRC(value,18);\r
         sendBleData(value,19);\r
+        CustomEventPublish(TOPIC_EVENT_MESSAGENOTE,&data,1);\r
     }else{\r
         value[17] = 0;\r
         value[18] = Calculate_CRC(value,18);\r
index 6e09357..be46f56 100644 (file)
@@ -627,6 +627,22 @@ void MsgCenterNotifyStopSPO2MonitoringProc(const Topic topic, Request* req)
     }
 }
 
+//消息通知
+void MsgCenterNotifyMessageProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(req);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !");
+    //亮屏显示新信息弹窗
+    const power_display_svr_api_t *display_api = power_display_svr_get_api();
+    if (display_api->get_screen_state() != SCREEN_ON)
+    {   
+        display_api->turn_on_screen();  
+    }  
+    display_api->set_screen_set_keepon_timeout(1000*5);
+    NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+    NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true);
+}
 
 #endif
 
@@ -918,15 +934,7 @@ void MsgCenterNotifyDrinkReminderProc(const Topic topic, Request* req)
     NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
     NotificationManager::GetInstance()->ShowNotify(showDrinkReminderNotify, (uint16_t)topic, true);
 }
-//消息通知
-void MsgCenterNotifyMessageProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !");
-    NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
-    NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true);
-}
+
 void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
 {
     unused(topic);
@@ -980,7 +988,6 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
         return;
     }
       
-            
     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);
     if(cywee_Inactivity_Info->sedentary_status==9)
@@ -988,8 +995,6 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
         set_stand_falg();
     }
 
-                
-    
     static int interval = 0;//久坐间隔时间
     switch (cywee_Inactivity_Info->output_number)
     {
index b2ff7d1..1072298 100644 (file)
@@ -10,6 +10,9 @@
 #include "message/include/MessageModel.h"
 #include "message_notification.h"
 #include "string"
+#include "vibrator_service.h"
+extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType);
+
 namespace OHOS
 {
 
@@ -143,7 +146,8 @@ namespace OHOS
         messageLabel->SetText(messageStr.c_str());
         messageLabel->SetTextColor(Color::Gray());
         messageLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
+        messageLabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);             // 换行裁剪
+        messageLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 居中显示
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLabel is ok");
 
         /*加载清除按键*/
@@ -165,7 +169,8 @@ namespace OHOS
         MessageGroupView->Add(deleteButton);
 
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create MessageGroupView succeed!!");
-
+        // 震动提醒
+        custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO);
         return MessageGroupView;
     }
     /*释放消息弹窗视图*/