From: hcj <1224667075@qq.com> Date: Fri, 4 Oct 2024 11:16:03 +0000 (+0800) Subject: 目标达成弹窗添加 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=9b16cda374999c7a13b95d6bd72a0213aea485de;p=mirrors%2FFD230.git 目标达成弹窗添加 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h index 4e6422fb4..7e02201e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h @@ -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(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index 2ec118812..aa370e352 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp index 6ec2dcb24..2c63936af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp @@ -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(); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index e2ecded8c..5684d04cc 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -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) { diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index 8f9242b6b..575b60d1e 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -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 } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index a0b4730e1..2a8ad5193 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -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];//目标里程 uint8_t target_stand = data[3];//目标站立 uint8_t target_fattime = data[4];//目标燃脂 + + uint8_t ring = data[5];//铃声 uint8_t vibratior = data[6];//振动 uint8_t notify = data[7];//通知 @@ -1620,13 +1622,17 @@ static void SetOtherTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota set_goal_discount(target_km); set_goal_standupcount(target_stand); set_goal_durationcount(target_fattime); - set_goal_caloriescount(target_kcal); - set_SilentMode(ring); - set_vibrationremiander(vibratior); + // set_SilentMode(ring); + // set_vibrationremiander(vibratior); + // set_notify_switch(notify); + if(ring && vibratior && notify) + set_goal_other_notification(1); + else + set_goal_other_notification(0); + - set_notify_switch(notify); sendBuf[17] = 1; sendBuf[18] = Calculate_CRC(sendBuf,18); sendBleData(sendBuf,19); @@ -2418,16 +2424,18 @@ void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota uint32_t targetStep; memcpy(&targetStep,data,4); - uint8_t ringOn=data[5]; - uint8_t vibration=data[6]; - uint8_t notify=data[7]; - printf("设置步数:%d\r\n",targetStep); - - set_goal_stepcount(targetStep); - set_vibrationremiander(vibration); + uint8_t ringOn=data[4]; + uint8_t vibration=data[5]; + uint8_t notify=data[6]; + + printf("设置步数:%d %d %d %d \r\n",targetStep,ringOn,vibration,notify); - set_SilentMode(ringOn); + + if(ringOn &&vibration && notify) + set_goal_step_notification(1); + else + set_goal_step_notification(0); sendBuf[17] = 1; @@ -5124,13 +5132,19 @@ static void GetTargetStepCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to { uint32_t targetStep = get_goal_stepcount();//目标步数 4字节 printf("目标步数:%d\r\n",targetStep); - uint8_t ringOn = get_SilentMode();//铃声提醒 - uint8_t vibration = get_vibrationremiander();//振动提醒 - uint8_t notify = 1;//通知提醒 + + uint8_t ringOn = get_step_goal_notify_switch();//铃声提醒 + uint8_t vibration = get_step_goal_notify_switch();//振动提醒 + uint8_t notify = get_step_goal_notify_switch();//通知提醒 + + printf("提醒开关:%d %d %d \r\n",ringOn,vibration,notify); + memcpy(&value[17],&targetStep,4);//目标步数 + value[21] = ringOn;//铃声提醒 value[22] = vibration;//振动提醒 value[23] = notify;//通知提醒 + value[24] = Calculate_CRC(value,24); sendBleData(value,25); }else @@ -5170,13 +5184,16 @@ static void GetTargetOtherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *t targetKm = get_goal_discount(); targetstand =get_goal_standupcount(); targetfat = get_goal_durationcount(); - ringTime = get_SilentMode(); - vibration = get_vibrationremiander(); - notify = get_notify_switch(); + + ringTime = get_other_goal_notify_switch (); + vibration = get_other_goal_notify_switch(); + notify = get_other_goal_notify_switch(); + memcpy(&value[17],&targetKcal,2);//目标卡路里 value[19] = targetKm;// value[20] = targetstand;// value[21] = targetfat;// + value[22] = ringTime;// value[23] = vibration;// value[24] = notify;//通知提醒 diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index 09e6ed17d..3e03268e5 100644 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -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, diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index 9533787c2..1eb9bb098 100644 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -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 diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index 7d580d33b..8d1e0e970 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -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 index 000000000..e96dd068f --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/goal_notification.h @@ -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 diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h index e2997786c..bb6edec3b 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h @@ -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" 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 fd723197d..392688321 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 @@ -58,8 +58,11 @@ #endif #include #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(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 index 000000000..7f8d745f8 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp @@ -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(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); + } + +} diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index db1c87a3f..9cd1bdfc0 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -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 diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index e4520d8e3..c1890e998 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -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;