From: luozheng <1732036298@qq.com> Date: Mon, 29 Jul 2024 06:51:36 +0000 (+0800) Subject: 久坐提醒适配间隔提醒 X-Git-Tag: release_V1.2.70_20241020_135402~725^2~14 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=eb47378c397666917b5ace203989145889809bc1;p=mirrors%2FFD230.git 久坐提醒适配间隔提醒 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index ccd497237..e01a5c5c8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -102,15 +102,20 @@ extern "C" { sedentary_switch = get_sedentary_switch_from_config_model(); sedentary_time = get_sedentary_time_from_config_model(); - sedentary_start_hour = (sedentary_time & 0XFF000000) >> 24; - sedentary_start_min = (sedentary_time & 0X00FF0000) >> 16; - sedentary_stop_hour = (sedentary_time & 0X0000FF00) >> 8; - sedentary_stop_min = sedentary_time & 0X000000FF; + // sedentary_start_hour = (sedentary_time & 0XFF000000) >> 24; + // sedentary_start_min = (sedentary_time & 0X00FF0000) >> 16; + // sedentary_stop_hour = (sedentary_time & 0X0000FF00) >> 8; + // sedentary_stop_min = sedentary_time & 0X000000FF; + sedentary_stop_min = (sedentary_time & 0XFF000000) >> 24; + sedentary_stop_hour = (sedentary_time & 0X00FF0000) >> 16; + sedentary_start_min = (sedentary_time & 0X0000FF00) >> 8; + sedentary_start_hour = sedentary_time & 0X000000FF; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "set_sedentary_data:%d:%d~%d:%d", sedentary_start_hour, sedentary_start_min, sedentary_stop_hour, sedentary_stop_min); } void set_drinkreminder_data(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "set_drinkreminder_data"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "set_drinkreminder_data"); drinkreminder_switch = OHOS::ConfigModel::GetInstance()->GetDrinkSwitch(); drinkreminder_freq = OHOS::ConfigModel::GetInstance()->GetDrinkFreq(); drinkreminder_goal = OHOS::ConfigModel::GetInstance()->GetDrinkGoal(); @@ -459,7 +464,7 @@ extern "C" if (uapi_dev_runtime_get_drinkremind_status() == 0) { uapi_dev_runtime_set_drinkremind_status(1); - drinkremind_expectedTime = start_time_seconds + interval_time_seconds; + drinkremind_expectedTime = current_seconds + interval_time_seconds; if (drinkremind_expectedTime >= hour_24_seconds) { drinkremind_expectedTime = drinkremind_expectedTime - hour_24_seconds; 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 c924afd53..37721a2d2 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -511,6 +511,9 @@ void set_sedent_param( msg_sedent_set_param_info_t * data) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,data->sedent_time ); p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,data->frequenc); + printf("开关:%d\r\n",data->sedent_on); + printf("久坐提醒时间段:%d\r\n",data->sedent_time); + printf("久坐提醒时间间隔(单位小时):%d\r\n",data->frequenc); set_sedentary_data(); clean_sedentary_flag(); 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 769a51daa..b8e680b83 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 @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-12 11:44:04 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-29 11:15:23 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/service/msg_center/include/notify/sedentaryReminder_notification.h + */ #ifndef SEDENTARYREMINDER_NOTIFICATION #define SEDENTARYREMINDER_NOTIFICATION /*久坐提醒*/ @@ -8,14 +15,14 @@ namespace OHOS UIViewGroup *CreateSedentaryReminderView(void); void FreeSedentaryReminderView(void); - class SedentaryReminderViewEventListener : public UIView::OnTouchListener,public UIView::OnDragListener + class SedentaryReminderViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener { public: static SedentaryReminderViewEventListener &GetInstance(); bool OnRelease(UIView &view, const ReleaseEvent &event) override; - bool OnDrag(UIView& view, const DragEvent& event) override; - bool OnDragEnd(UIView& view, const DragEvent& event) override; - bool IsReminderTime(); + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + void SetSedentaryReminderNoteIntervalTime(int interval); int GetIntervalTime(); private: 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 22c993415..661893a95 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 @@ -1068,8 +1068,8 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) //NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); //根据久坐间隔时间和是否在设置的提醒时间段内判断是否弹出久坐视图 interval++; - if(( interval % SedentaryReminderViewEventListener::GetInstance().GetIntervalTime() == 0) && - (SedentaryReminderViewEventListener::GetInstance().IsReminderTime() == true)) { + if( interval % SedentaryReminderViewEventListener::GetInstance().GetIntervalTime() == 0){ + SedentaryReminderViewEventListener::GetInstance().SetSedentaryReminderNoteIntervalTime(interval); NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); } } 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 08a052c96..4138c091e 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 @@ -6,7 +6,7 @@ #ifdef FD230 #include "ui_resource_string.h" #endif -#include +#include "uicomponents/UIComponents.h" #include #include #include @@ -19,7 +19,7 @@ namespace OHOS UIViewGroup *SedentaryReminderGroupView{nullptr}; UILabelExt *SedentaryReminderTitleLabel{nullptr}; // 标题: 久坐提醒 UIImageView *SedentaryReminderImage{nullptr}; - UILabel *SedentaryReminderNoteLabel{nullptr}; // 久坐提醒note + UILabelExt *SedentaryReminderNoteLabel{nullptr}; // 久坐提醒note UILabelExt *SedentaryReminderLabel{nullptr}; UIButton *SedentaryReminderButton{nullptr}; @@ -84,38 +84,41 @@ namespace OHOS return true; } - // 是否是久坐提醒时间段内 - bool SedentaryReminderViewEventListener::IsReminderTime() + static std::string UpdateNoteLabelText(UILabelExt *&label, const std::string &newText, int id) { - // 获取当前时间 - time_t now = time(0); - tm *ltm = localtime(&now); - int currentHour = ltm->tm_hour; - int currentMinute = ltm->tm_min; - - // 获取提醒时间段 - int ReminderTime = ConfigModel::GetInstance()->GetSedentaryReminderTime(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ReminderTime = %d ",ReminderTime); - - // 解析开始时间 - int startHour = (ReminderTime >> 24) & 0xFF; // 前8位是小时 - int startMinute = (ReminderTime >> 16) & 0xFF; // 后8位是分钟 + if (label == nullptr) + { + return nullptr; + } + /*取Id对应的字符串*/ + UILabelExt *labelext = new UILabelExt(); + labelext->SetTextId(id); + std::string text = labelext->GetText(); - // 解析结束时间 - int endHour = (ReminderTime >> 8) & 0xFF; // 中间8位是小时 - int endMinute = ReminderTime & 0xFF; // 后8位是分钟 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateLabel:%s->%s\r\n", text.c_str(), newText.c_str()); - // 判断当前时间是否在提醒时间段内 - if (currentHour > startHour || (currentHour == startHour && currentMinute >= startMinute)) + // 找到标志"XX"在字符串中的位置 + size_t pos = text.find("XX"); + if (pos != std::string::npos) { - if (currentHour < endHour || (currentHour == endHour && currentMinute < endMinute)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "It's time to remind the user to move!"); - return true; - } + // 替换标志"XX"为更新字符串 + text.replace(pos, 2, newText); // 2 是标志"XX"的长度 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "newText:%s\r\n", text.c_str()); + label->SetText(text.c_str()); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "找不到变量标志位XX,请注意是否已经被修改!"); } - return false; + delete labelext; + return text; + } + + /*设置喝水提醒note上的提醒时间*/ + void SedentaryReminderViewEventListener::SetSedentaryReminderNoteIntervalTime(int interval) + { + UpdateNoteLabelText(SedentaryReminderNoteLabel,std::to_string(interval),STR_SEDENTARY_REMINDER_NOTE); } // 获取久坐提醒时间间隔 @@ -128,7 +131,7 @@ namespace OHOS /*创建久坐提醒视图*/ UIViewGroup *CreateSedentaryReminderView(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateSedentaryReminderView(void)"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreateSedentaryReminderView(void)"); if (SedentaryReminderGroupView == nullptr) { SedentaryReminderGroupView = new UIViewGroup(); @@ -163,7 +166,8 @@ namespace OHOS #else SedentaryReminderTitleLabel->SetText("久坐提醒"); #endif - SedentaryReminderTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + SedentaryReminderTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + SedentaryReminderTitleLabel->SetRollSpeed(70); SedentaryReminderTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); SedentaryReminderTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* --------------------------- SedentaryReminderImage --------------------------- */ @@ -176,7 +180,7 @@ namespace OHOS SedentaryReminderImage->SetPosition(193, 130, 80, 80); SedentaryReminderImage->SetSrc("/user/res/SedentaryReminder/SedentaryReminder.bin"); /* ------------------------- SedentaryReminderNoteLabel ------------------------- */ - SedentaryReminderNoteLabel = new UILabel(); + SedentaryReminderNoteLabel = new UILabelExt(); if (SedentaryReminderNoteLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateSedentaryReminderView] SedentaryReminderNoteLabel new fail!!"); @@ -186,7 +190,8 @@ namespace OHOS SedentaryReminderNoteLabel->SetStyle(STYLE_TEXT_FONT, 30); SedentaryReminderNoteLabel->SetStyle(STYLE_LINE_HEIGHT, 35); #ifdef FD230 - SetLabelId(SedentaryReminderNoteLabel, STR_SEDENTARY_REMINDER_NOTE); + // SetLabelId(SedentaryReminderNoteLabel, STR_SEDENTARY_REMINDER_NOTE); + SedentaryReminderNoteLabel->SetTextId(STR_SEDENTARY_REMINDER_NOTE); #endif // UpdateLabel(SedentaryReminderNoteLabel,"1",STR_SEDENTARY_REMINDER_NOTE); SedentaryReminderNoteLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); @@ -236,7 +241,7 @@ namespace OHOS SedentaryReminderGroupView->Add(SedentaryReminderButton); SedentaryReminderGroupView->Add(SedentaryReminderLabel); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SedentaryReminderView succeed!!"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SedentaryReminderView succeed!!"); } return SedentaryReminderGroupView; @@ -245,7 +250,7 @@ namespace OHOS /*释放久坐提醒视图*/ void FreeSedentaryReminderView(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeSedentaryReminderView(void)"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FreeSedentaryReminderView(void)"); if (SedentaryReminderGroupView != nullptr) { SedentaryReminderGroupView->RemoveAll(); diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index 80ae16795..52826f60a 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -318,7 +318,7 @@ namespace OHOS {ConfigDataType::DATATYPE_BOOL, "dnotdisturb", "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭 {ConfigDataType::DATATYPE_INT, "system_volume", "100" },// CONFIGMODEL_ITEM_SYSTEM_VOLUME // {ConfigDataType::DATATYPE_INT, "call_volume", "100" },// CONFIGMODEL_ITEM_CALL_VOLUME // - {ConfigDataType::DATATYPE_BOOL, "VoLTECall", "false" },// CONFIGMODEL_ITEM_VOLTE_CALL + {ConfigDataType::DATATYPE_BOOL, "voltecall", "false" },// CONFIGMODEL_ITEM_VOLTE_CALL {ConfigDataType::DATATYPE_BOOL, "motion_recognition", "false" },// CONFIGMODEL_ITEM_MOTIONRECOGNITION {ConfigDataType::DATATYPE_BOOL, "hfp", "false" },// CONFIGMODEL_ITEM_HFP {ConfigDataType::DATATYPE_BOOL, "a2dp", "false" },// CONFIGMODEL_ITEM_A2DP @@ -351,7 +351,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "sleep_remide", "0" }, // CONFIGMODEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 {ConfigDataType::DATATYPE_INT, "sedentary_switch", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 {ConfigDataType::DATATYPE_INT, "sedentary_interval", "1" }, // CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔 - {ConfigDataType::DATATYPE_INT, "sedentary_reminderTime", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 前16位是开始时间 前8 为小时 后8为分钟 后16位为结束时间规则同前 例: 1600 0B00 11点开始到 22点结束 + {ConfigDataType::DATATYPE_INT, "sedentary_remindertime", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 前16位是开始时间 前8 为小时 后8为分钟 后16位为结束时间规则同前 例: 1600 0B00 11点开始到 22点结束 {ConfigDataType::DATATYPE_STRING, "password", "000000" }, //CONFIGMODEL_ITEM_PASSWORD //手表密码 CONFIGMODEL_ITEM_SWITCH {ConfigDataType::DATATYPE_INT, "passwordswich", "0" },//CONFIGMODEL_ITEM_PASSWORD_SWITCH 手表密码开关 0关 1开 {ConfigDataType::DATATYPE_INT, "message_index", "0" },//CONFIGMODEL_ITEM_MESSAGE_INDEX//消息文件序号