目标达成弹窗添加
authorhcj <1224667075@qq.com>
Fri, 4 Oct 2024 11:16:03 +0000 (19:16 +0800)
committerhcj <1224667075@qq.com>
Fri, 4 Oct 2024 11:16:03 +0000 (19:16 +0800)
15 files changed:
code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h
code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp
code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c
code/sdk/application/wearable/service/msg_center/CMakeLists.txt
code/sdk/application/wearable/service/msg_center/include/notify/goal_notification.h [new file with mode: 0644]
code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp [new file with mode: 0644]
code/sdk/drivers/peripheral/config/include/ConfigModel.h
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index 4e6422f..7e02201 100644 (file)
@@ -20,6 +20,14 @@ namespace OHOS
     public:
         static GoalModel &GetInstance(void);
 
+        bool is_goal_DISTANCE_done();
+
+        bool is_goal_fatburning_done();
+
+        bool is_goal_stand_done();
+
+        bool is_goal_calories_done();
+
         uint8_t getstepvalue();
 
         char* getstepGoal();
index 2ec1188..aa370e3 100644 (file)
@@ -103,7 +103,60 @@ namespace OHOS
       return fatburninggoalstr;
    }
 
+
+   bool GoalModel::is_goal_DISTANCE_done()
+   {
+       float distancedata_now = (float)get_distance_data() / 1000.0;
+       int distancedata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE);
+
+      if(distancedata_now>=distancedata_goal)
+      return true;
+      else
+      return false;
+
+   }
+
+   bool GoalModel::is_goal_fatburning_done()
+   {
+       int fatburningdata_now = get_fat_time_data()/60;
+
+       int fatburningdata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION);
+
+      if(fatburningdata_now>=fatburningdata_goal)
+       return true;
+      else
+      return false;
+
+   }
+
+   bool GoalModel::is_goal_stand_done()
+   {
+      int standdata_now = get_now_stand_count();
+
+      int standdata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES);
+
+      if(standdata_now>=standdata_goal)
+       return true;
+      else
+      return false;
+
+   }
+
+   bool GoalModel::is_goal_calories_done()
+   {
+      int calories_now =  get_calories_data();
+
+      int calories_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES);
+
+      if(calories_now>=calories_goal)
+       return true;
+      else
+      return false;
+
+   }
+
    char fatburningnewstr[20];
+
    char *GoalModel::getfatburningnew()
    {
       int fatburningdata = get_fat_time_data()/60;
index 6ec2dcb..2c63936 100644 (file)
@@ -4,12 +4,9 @@
 #include "common/image_cache_manager.h"
 #include "gfx_utils/mem_api.h"
 #include "uicomponents/UIComponents.h"
-/*
-当至天气界面时,主动获取最新天气数据。
-(此操作静默将进行,获取到则立刻更新显示,获取不到则重试
-重试3次无果结束更新)
-在加载该视图时,需要加载:1时间,2天气图片,3温度,4天气描述,5,地点,6,温度范围
-*/
+
+
+#include "goal_notification.h"
 
 namespace OHOS
 {
@@ -43,6 +40,7 @@ namespace OHOS
         ClearAll();
         g_pgoalView = nullptr;
     }
+  
 
     void GoalView::GoalViewrefresh()
     {
@@ -53,6 +51,8 @@ namespace OHOS
         if(circleProgress1_)
         circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue());
 
+       
+
         Invalidate();
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalViewrefresh Invalidat ");
         RootView::GetInstance()->Invalidate();
index e2ecded..5684d04 100644 (file)
@@ -47,6 +47,8 @@
 #include "SleepModel.h"
 #include "BluetoothModel.h"
 #include "MusicPlayerModel.h"
+#include "goal_notification.h"
+
 
 //#include "AlarmClockModel.h"
 #ifdef __cplusplus
@@ -1966,6 +1968,22 @@ bool get_notify_switch(void)
     OHOS::ConfigModel *p_ConfigModel  =   OHOS::ConfigModel::GetInstance();
     return p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_NOTIFY);
 }
+
+uint8_t get_other_goal_notify_switch(void)
+{
+    OHOS::ConfigModel *p_ConfigModel  =   OHOS::ConfigModel::GetInstance();
+    return p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER);
+}
+
+
+uint8_t get_step_goal_notify_switch(void)
+{
+    OHOS::ConfigModel *p_ConfigModel  =   OHOS::ConfigModel::GetInstance();
+    return p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEP);
+}
+
+
+
 void set_goal_discount(uint32_t dis)
 {
     OHOS::ConfigModel *p_ConfigModel  =   OHOS::ConfigModel::GetInstance();
@@ -2027,6 +2045,36 @@ void set_traning_updata_auto(uint8_t traingauto)
     return;
 }
 
+void set_goal_other_notification(uint8_t data)
+{
+    OHOS::ConfigModel *p_ConfigModel  =  OHOS::ConfigModel::GetInstance();
+    p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER,data);
+    if(data==1)
+    {
+        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_CALOREIE);
+        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_STAND);
+        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_FAT);
+        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_DISTANCE);
+
+    }
+    return;
+}
+
+void set_goal_step_notification(uint8_t data)
+{
+    OHOS::ConfigModel *p_ConfigModel  =  OHOS::ConfigModel::GetInstance();
+    p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEP,data);
+    if(data==1)
+    {
+        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_STEP);
+    }
+    return;
+}
+
+
+
+
+
 /*设置获取实时数据频率*/
 void set_traning_updata_freq(uint8_t freq)
 {
index 8f9242b..575b60d 100644 (file)
@@ -392,6 +392,14 @@ bool get_training_spead_path(char *path ,uint32_t time,uint32_t max_len);
 
 bool get_training_heart_path(char *path ,uint32_t time,uint32_t max_len);
 
+void set_goal_other_notification(uint8_t data);
+
+uint8_t get_other_goal_notify_switch(void);
+
+uint8_t get_step_goal_notify_switch(void);
+
+void set_goal_step_notification(uint8_t data);
+
 #ifdef __cplusplus
 #if __cplusplus
 }
index a0b4730..2a8ad51 100644 (file)
@@ -1612,6 +1612,8 @@ static void SetOtherTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota
         uint8_t target_km = data[2];//目标里程\r
         uint8_t target_stand = data[3];//目标站立\r
         uint8_t target_fattime = data[4];//目标燃脂\r
+\r
+\r
         uint8_t ring = data[5];//铃声\r
         uint8_t vibratior = data[6];//振动\r
         uint8_t notify = data[7];//通知\r
@@ -1620,13 +1622,17 @@ static void SetOtherTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota
         set_goal_discount(target_km);\r
         set_goal_standupcount(target_stand);\r
         set_goal_durationcount(target_fattime);\r
-\r
         set_goal_caloriescount(target_kcal);\r
 \r
-        set_SilentMode(ring);\r
-        set_vibrationremiander(vibratior);\r
+        // set_SilentMode(ring);\r
+        // set_vibrationremiander(vibratior);\r
+        // set_notify_switch(notify);\r
+        if(ring && vibratior && notify)\r
+        set_goal_other_notification(1);\r
+        else\r
+        set_goal_other_notification(0);\r
+\r
 \r
-        set_notify_switch(notify);\r
         sendBuf[17] = 1;\r
         sendBuf[18] = Calculate_CRC(sendBuf,18);\r
         sendBleData(sendBuf,19);\r
@@ -2418,16 +2424,18 @@ void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota
         \r
         uint32_t targetStep;\r
         memcpy(&targetStep,data,4);\r
-        uint8_t ringOn=data[5];\r
-        uint8_t vibration=data[6];\r
-        uint8_t notify=data[7];\r
-        printf("设置步数:%d\r\n",targetStep);\r
-        \r
-        set_goal_stepcount(targetStep);\r
 \r
-        set_vibrationremiander(vibration);\r
+        uint8_t ringOn=data[4];\r
+        uint8_t vibration=data[5];\r
+        uint8_t notify=data[6];\r
+\r
+        printf("设置步数:%d %d %d %d \r\n",targetStep,ringOn,vibration,notify);\r
 \r
-        set_SilentMode(ringOn);\r
+\r
+        if(ringOn &&vibration &&  notify)\r
+        set_goal_step_notification(1);\r
+        else\r
+        set_goal_step_notification(0);\r
 \r
 \r
         sendBuf[17] = 1;\r
@@ -5124,13 +5132,19 @@ static void GetTargetStepCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to
     {\r
         uint32_t targetStep = get_goal_stepcount();//目标步数 4字节\r
         printf("目标步数:%d\r\n",targetStep);\r
-        uint8_t ringOn = get_SilentMode();//铃声提醒\r
-        uint8_t vibration = get_vibrationremiander();//振动提醒\r
-        uint8_t notify = 1;//通知提醒\r
+\r
+        uint8_t ringOn = get_step_goal_notify_switch();//铃声提醒\r
+        uint8_t vibration = get_step_goal_notify_switch();//振动提醒\r
+        uint8_t notify = get_step_goal_notify_switch();//通知提醒\r
+\r
+        printf("提醒开关:%d %d %d \r\n",ringOn,vibration,notify);\r
+\r
         memcpy(&value[17],&targetStep,4);//目标步数\r
+\r
         value[21] = ringOn;//铃声提醒\r
         value[22] = vibration;//振动提醒\r
         value[23] = notify;//通知提醒\r
+\r
         value[24] = Calculate_CRC(value,24);\r
         sendBleData(value,25);\r
     }else\r
@@ -5170,13 +5184,16 @@ static void GetTargetOtherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *t
         targetKm = get_goal_discount();\r
         targetstand =get_goal_standupcount();\r
         targetfat = get_goal_durationcount();\r
-        ringTime = get_SilentMode();\r
-        vibration = get_vibrationremiander();\r
-        notify = get_notify_switch();\r
+\r
+        ringTime = get_other_goal_notify_switch ();\r
+        vibration = get_other_goal_notify_switch();\r
+        notify = get_other_goal_notify_switch();\r
+        \r
         memcpy(&value[17],&targetKcal,2);//目标卡路里\r
         value[19] = targetKm;//\r
         value[20] = targetstand;//\r
         value[21] = targetfat;//\r
+\r
         value[22] = ringTime;//\r
         value[23] = vibration;//\r
         value[24] = notify;//通知提醒\r
index 09e6ed1..3e03268 100644 (file)
@@ -56,6 +56,7 @@ typedef enum {
     TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,
     TOPIC_EVENT_BLE_TRAINING,
     TOPIC_EVENT_BLE_TRANSMIT,
+    TOPIC_EVENT_GOAL_SHOW_VIEW,
 #endif
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     TOPIC_EVENT_CHARGE_PLUG,
index 9533787..1eb9bb0 100644 (file)
@@ -36,6 +36,7 @@ static const TopicToCore topicToCoreArray[] = {
     {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE, A_CORE_MASK, 1},
     {TOPIC_EVENT_BLE_TRAINING,A_CORE_MASK,1},
     {TOPIC_EVENT_BLE_TRANSMIT,A_CORE_MASK,1},
+    {TOPIC_EVENT_GOAL_SHOW_VIEW,A_CORE_MASK,1},
     
 #endif
 #ifdef SUPPORT_SPO2_NOTIFICATION
index 7d580d3..8d1e0e9 100644 (file)
@@ -223,6 +223,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/message_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sleep_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/motion_recognition_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/goal_notification.cpp
 )
 else()
 set(SOURCES
@@ -239,6 +240,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/transmitting.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/message_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sleep_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/goal_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/motion_recognition_notification.cpp
 )
 endif()
diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/goal_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/goal_notification.h
new file mode 100644 (file)
index 0000000..e96dd06
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef GOAL_NOTIFICATION_H
+#define GOAL_NOTIFICATION_H
+// #include "components/ui_image_animator.h" 
+#include "bletest.h"
+#include "components/ui_view_group.h"
+
+namespace OHOS
+{
+
+    typedef enum GOAL_type {
+    GOAL_STEP=1,
+
+    GOAL_CALOREIE,
+    GOAL_STAND,
+    GOAL_FAT,
+    GOAL_DISTANCE,
+
+
+    GOAL_free,
+    } transmitting_type;
+
+
+    UIViewGroup *GoalviewShow(void);
+    void set_goal_flag_view(uint8_t falg);
+
+    uint8_t get_Is_shouw_falg(uint8_t type);
+    
+    uint8_t set_Is_shouw_falg(uint8_t flag,uint8_t type);
+
+   
+    class GoalViewEventListener : public OHOS::UIView::OnClickListener,
+                              public OHOS::UIView::OnLongPressListener,
+                              public OHOS::UIView::OnTouchListener,
+                              public OHOS::UIView::OnDragListener 
+    {
+public:
+    GoalViewEventListener();
+       virtual ~GoalViewEventListener();
+       static GoalViewEventListener *GetInstance(void);
+
+    bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override;
+    bool OnDrag(UIView& view, const DragEvent& event) override
+    {
+        return true;
+    }
+    bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override
+    {
+        return true;
+    }
+    virtual bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override
+    {
+        return true;
+    }
+    virtual bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override
+    {
+        return true;
+    }
+    virtual bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override
+    {
+        return true;
+    }
+
+    virtual bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override
+    {
+        return true;
+    }
+};
+};
+#endif /* CHARGE_NOTIFICATION_H */
\ No newline at end of file
index e299778..bb6edec 100644 (file)
@@ -24,6 +24,8 @@
 #include "components/ui_view_group.h"
 #include "alarm_notification.h"
 #include "makephone_notification.h"
+#include "goal_notification.h"
+
 #include "dial_sos_c.h"
 #include "charge_notification.h"
 #include "transmitting.h"
index fd72319..3926883 100644 (file)
 #endif
 #include <cywee_hal.h>
 #include "cywee_service.h"
+
 #include "goalview.h"
 #include "goalother.h"
+#include "goalmodel.h"
+
 #include "ConfigModelC.h"
 #include "heart_blood/health_service/health_service.h"
 #include "vibrator_service.h"
@@ -85,6 +88,7 @@ const PriorityMapper PRI_MAPPER[] = {
     {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,PRIORITY_TWO},
     {TOPIC_EVENT_BLE_TRAINING,PRIORITY_TWO},
     {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE},
+    {TOPIC_EVENT_GOAL_SHOW_VIEW,PRIORITY_TWO},
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO},
     {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO},
@@ -165,7 +169,7 @@ void MsgCenterSubscribe()
     MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE);
     MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
     MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRANSMIT);
-    
+    MsgCenterSubscribeTopic(TOPIC_EVENT_GOAL_SHOW_VIEW);
 
 #endif
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
@@ -202,6 +206,12 @@ void MsgCenterSubscribe()
     MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE);
 }
 
+static OHOS::UIViewGroup* ShowGoalNotify(void)
+{
+    return OHOS::GoalviewShow();
+}
+
+
 static OHOS::UIViewGroup* ShowAlarmNotify(void)
 {
     return OHOS::CreateAlarmView();
@@ -348,6 +358,36 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
    fat_history_save();
 }
 
+
+void MsgCenterNotifygoalnotificationviewProc(const Topic topic, Request* req)
+{
+    unused(req);
+    if (CheckPriority(topic)) {
+
+        uint8_t* data=(uint8_t*)req->data;
+       
+        if(get_Is_shouw_falg(data[0]))
+        {   
+            set_goal_flag_view(data[0]);
+            set_Is_shouw_falg(0,data[0]);
+
+             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();
+            }
+
+            NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+            NotificationManager::GetInstance()->ShowNotify(ShowGoalNotify, static_cast<uint16_t>(topic), true);
+        }
+
+       
+    }
+  
+}
+
+  static uint8_t goal_type=0;
 void MsgCenterNotifystepProc(const Topic topic, Request* req)
 {
     unused(req);
@@ -360,6 +400,52 @@ void MsgCenterNotifystepProc(const Topic topic, Request* req)
     {
         OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
     }
+
+     if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
+    {
+        goal_type=GOAL_STEP;
+        if(get_Is_shouw_falg(goal_type))
+        {   
+            CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+        }
+    }
+
+    if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
+    {
+        goal_type=GOAL_DISTANCE;
+        if(get_Is_shouw_falg(goal_type))
+        {   
+            CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+        }
+    }
+
+    if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
+    {
+        goal_type=GOAL_FAT;
+        if(get_Is_shouw_falg(goal_type))
+        {   
+            CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+        }
+    }
+
+    if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
+    {
+        goal_type=GOAL_STAND;
+        if(get_Is_shouw_falg(goal_type))
+        {   
+            CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+        }
+    }
+
+    if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
+    {
+        goal_type=GOAL_CALOREIE;
+        if(get_Is_shouw_falg(goal_type))
+        {   
+            CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+        }
+    }
+
 #endif
     // The alarm notification is not displayed if the incoming call notification is already being processed
    // cywee_save_data();
@@ -1506,6 +1592,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
     {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,       MsgCenterNotifyInactivityAccumulateTimeProc},
     {TOPIC_EVENT_BLE_TRAINING,       MsgCenterNotifybleAPPtraining},
     {TOPIC_EVENT_BLE_TRANSMIT,       MsgCenterNotifybleTransmit},
+    {TOPIC_EVENT_GOAL_SHOW_VIEW,    MsgCenterNotifygoalnotificationviewProc},
     
 #endif  
 #ifdef FD230
diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp
new file mode 100644 (file)
index 0000000..7f8d745
--- /dev/null
@@ -0,0 +1,296 @@
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "AlarmPopUpPresenter.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button_ext.h"  
+#include "battery_service.h"
+#include "NativeAbility.h"
+#include "custom_utils.h"
+#include "components/ui_slider.h"
+// #include "UiConfig.h"
+#include "bleEvent.h"
+#include "power_display_service.h"
+#include "uicomponents/UIComponents.h"
+#include "ConfigModel.h"
+
+#include "upg.h"
+namespace OHOS
+{
+
+    #define BUTTONWINOK "buttom_win"
+
+    static UIScrollView *getView{nullptr};
+
+        /*达成训练目标弹窗*/
+    static   UILabelExt *labeltitle = nullptr;
+
+    static   UILabelExt *labelgettag = nullptr;
+    static UILabelExt *labeltag = nullptr;
+    static   UILabelExt *labelpre = nullptr;
+    static   UILabelButtonExt *buttonok_ = nullptr;
+    static   UIImageAnimatorView *imageAnimator{nullptr};
+    static const ImageInfo **winimageInfos;
+    static ImageAnimatorInfo *winimageAnimatorInfo{nullptr};
+    static std::string winbasePath = "/user/res/Training/training_GIF/win/";
+
+    void Freegoalview(void)
+    {
+       if (getView != nullptr) 
+       {
+        getView->RemoveAll();
+
+        if(labeltag)
+        {
+            delete labeltag;
+            labeltag = nullptr;
+        }
+
+        if(labeltitle)
+        {
+            delete labeltitle;
+            labeltitle = nullptr;
+        }
+         if(labelpre)
+        {
+            delete labelpre;
+            labelpre = nullptr;
+        }
+         if(buttonok_)
+        {
+            delete buttonok_;
+            buttonok_ = nullptr;
+        }
+        if(imageAnimator)
+        {
+          
+            delete imageAnimator;
+            imageAnimator = nullptr;
+        }
+
+
+        RootView::GetInstance()->Remove(getView);
+
+        delete getView;
+        getView = nullptr;
+        }
+    }
+    static uint8_t flag_goal=0;
+
+    static uint8_t GOAL_CALOREIE_falg=1;
+
+    static uint8_t GOAL_FAT_falg=1;
+
+    static uint8_t GOAL_STAND_falg=1;
+
+    static uint8_t GOAL_DISTANCE_falg=1;
+
+    static uint8_t GOAL_STEP_falg=1;
+
+    uint8_t get_Is_shouw_falg(uint8_t type)
+    {
+        switch (type) {
+        case GOAL_CALOREIE:
+            return GOAL_CALOREIE_falg;
+
+        case GOAL_FAT:
+            return GOAL_FAT_falg;
+
+        case GOAL_STAND:
+            return GOAL_STAND_falg;
+   
+        case GOAL_DISTANCE:
+            return GOAL_DISTANCE_falg;
+     
+        case GOAL_STEP:
+             return GOAL_STEP_falg;
+     
+    default:
+      return 0;
+        }
+    }
+
+    uint8_t set_Is_shouw_falg(uint8_t flag,uint8_t type)
+    {
+        switch (type) {
+        case GOAL_CALOREIE:
+            GOAL_CALOREIE_falg=flag;
+            break;
+
+        case GOAL_FAT:
+            GOAL_FAT_falg=flag;
+            break;
+
+        case GOAL_STAND:
+            GOAL_STAND_falg=flag;
+            break;
+   
+        case GOAL_DISTANCE:
+            GOAL_DISTANCE_falg=flag;
+            break;
+     
+        case GOAL_STEP:
+            GOAL_STEP_falg=flag;
+            break;
+     
+        default:
+        return 0;
+        }
+        return 1;
+    }
+
+    void set_goal_flag_view(uint8_t falg)
+    {
+        flag_goal=falg;
+    }
+
+    static void InitImageAnimator() {
+
+    int tag = 0;
+    uint8_t tagType =flag_goal;
+    std::string tagString;
+
+    switch (tagType) {
+        case GOAL_CALOREIE:
+            tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES);
+            tagString=std::to_string(tag)+"kcal";
+            break;
+        case GOAL_FAT:
+            tag =  ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION);
+            tagString=std::to_string(tag)+"minute";
+            break;
+        case GOAL_STAND:
+             tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES);
+            tagString=std::to_string(tag)+"times";
+            break;
+        case GOAL_DISTANCE:
+             tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE);
+            tagString=std::to_string(tag)+"km";
+            break;
+        case GOAL_STEP:
+            tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT);;
+            tagString=std::to_string(tag);
+            break;
+    default:
+        break;
+    }
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                    "tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType,
+                    tagString.c_str());
+    InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(),
+                DEFAULT_VECTOR_FONT_FILENAME, 80);
+    labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+    getView->Add(labeltag);
+
+    // 初始化图片数组以及动画
+    winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94);
+    InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos,
+                            94, 173, 100, 120, 120, "imageAnimator1", 10);
+    imageAnimator->Start();
+    getView->Add(imageAnimator);
+    }
+
+    UIViewGroup *GoalviewShow()
+    {
+        if (getView == nullptr) {
+            getView = new UIScrollView();
+             getView->SetPosition(0, 0);
+            getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            getView->SetScrollBlankSize(20);
+            getView->SetReboundSize(50);
+            getView->SetDirection(1);
+
+            UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(GoalViewEventListener::GetInstance());
+            getView->SetOnClickListener(button1Click);
+            getView->SetTouchable(true);
+
+            // 初始化Lable
+            InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED,
+                            DEFAULT_VECTOR_FONT_FILENAME, 35);
+            getView->Add(labeltitle);
+            InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL,
+                            DEFAULT_VECTOR_FONT_FILENAME, 30);
+            getView->Add(labelgettag);
+            InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%",
+                        DEFAULT_VECTOR_FONT_FILENAME, 30);
+            getView->Add(labelpre);
+
+            // 初始化按键
+            InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30);
+            buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+            getView->Add(buttonok_);
+
+            RootView::GetInstance()->Add(getView);
+
+            getView->SetDraggable(false);
+            getView->SetTouchable(true);
+            NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(Freegoalview);
+
+            InitImageAnimator();
+        }
+        else
+        {
+            uint8_t tagType =flag_goal;
+            std::string tagString;
+            uint8_t tag=0;
+            switch (tagType) {
+                case GOAL_CALOREIE:
+                    tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES);
+                    tagString=std::to_string(tag)+"kcal";
+                    break;
+                case GOAL_FAT:
+                    tag =  ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION);
+                    tagString=std::to_string(tag)+"minute";
+                    break;
+                case GOAL_STAND:
+                    tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES);
+                    tagString=std::to_string(tag)+"times";
+                    break;
+                case GOAL_DISTANCE:
+                    tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE);
+                    tagString=std::to_string(tag)+"km";
+                    break;
+                case GOAL_STEP:
+                    tag = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT);;
+                    tagString=std::to_string(tag);
+                    break;
+            default:
+                break;
+            }
+            labeltag->SetText(tagString.c_str());
+            getView->Invalidate();
+
+        }
+        return getView;
+
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end");
+    }
+    
+
+    GoalViewEventListener::GoalViewEventListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this);
+    }
+
+    GoalViewEventListener::~GoalViewEventListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener");
+    }
+
+    GoalViewEventListener *GoalViewEventListener::GetInstance(void)
+    {
+        static GoalViewEventListener lowppowrViewEventListene_t;
+        return &lowppowrViewEventListene_t;
+    }
+
+    bool GoalViewEventListener::OnClick(UIView& view, const ClickEvent& event)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick");
+        NotificationManager::GetInstance()->StopNotify();
+        return true;
+        UNUSED(event);
+    }
+
+}
index db1c87a..9cd1bdf 100644 (file)
@@ -69,6 +69,10 @@ namespace OHOS
             CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES,    //运动目标站立次数
             CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION,    //运动目标时长
             CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离
+            //目标达成提醒开关
+            CONFIGMODEL_ITEM_SPORTS_GOAL_STEP,  //步数目标
+            CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER,    //其他目标
+
             CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式
             CONFIGMODEL_ITEM_MESSAGE_UNREAD,//未读状态
             CONFIGMODEL_ITEM_VOLTE_CALL,//VoLTE通话
@@ -327,6 +331,8 @@ namespace OHOS
             {ConfigDataType::DATATYPE_INT,     "goal_standup_times",         "10"    },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES,    //运动目标站立次数 10
             {ConfigDataType::DATATYPE_INT,     "goal_duration",             "30"    },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION,    //运动目标时长   30(分钟)
             {ConfigDataType::DATATYPE_INT,     "goal_distance",             "8"   },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离   8.0(km)
+            {ConfigDataType::DATATYPE_INT,     "goal_step_notification",             "1"   },//CONFIGMODEL_ITEM_SPORTS_GOAL_STEP,  //步数目标
+            {ConfigDataType::DATATYPE_INT,     "goal_other_notification",             "1"   },//CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER,    //其他目标
             {ConfigDataType::DATATYPE_BOOL,    "dnotdisturb",              "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭
             {ConfigDataType::DATATYPE_BOOL,    "unread",              "false"},//CONFIGMODEL_ITEM_MESSAGE_UNREAD//未读状态默认未读
             {ConfigDataType::DATATYPE_BOOL,    "voltecall",                "true" },// CONFIGMODEL_ITEM_VOLTE_CALL #默认是开启VOLTE
index e4520d8..c1890e9 100644 (file)
@@ -1116,6 +1116,8 @@ static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
     case 16:
         ble_test_ANCS_notify(type_2);
         break;
+     case 17:
+        CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&type_2,1);
 
     default:
         break;