From: luozheng <1732036298@qq.com> Date: Tue, 4 Jun 2024 06:50:03 +0000 (+0800) Subject: 1.喝水提醒弹窗增加右滑退出功能 X-Git-Tag: release_V1.2.70_20241020_135402~1046^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5f8a90a88d752161b7469ad192516c91e7145228;p=mirrors%2FFD230.git 1.喝水提醒弹窗增加右滑退出功能 2.修改ConfigModel.h文件中有关喝水提醒的枚举变量单词的拼写错误,增加其对应的set和get函数 --- diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h index fdb019543..62d495012 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/drinkReminder_notification.h @@ -7,17 +7,21 @@ namespace OHOS UIViewGroup *CreateDrinkReminderView(void); void FreeDrinkReminderView(void); - class DrinkReminderViewEventListener : public UIView::OnTouchListener + class DrinkReminderViewEventListener : public UIView::OnTouchListener,public UIView::OnDragListener { public: static DrinkReminderViewEventListener &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; private: DrinkReminderViewEventListener(); ~DrinkReminderViewEventListener(); DrinkReminderViewEventListener(const DrinkReminderViewEventListener &) = delete; const DrinkReminderViewEventListener &operator=(const DrinkReminderViewEventListener &) = delete; + bool X_DRAG_FLAG{false}; + }; } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp index 644f62599..f9a68766e 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp @@ -18,6 +18,10 @@ namespace OHOS UILabelExt *DrinkReminderLabel{nullptr}; UIButton *DrinkReminderButton{nullptr}; + static constexpr const int X_DRAG_OFFSET = 20; + static constexpr const int DOUBLES = 2; + + static constexpr const char *DRINKREMINDERGROUPVIEWID = "DrinkReminderGroupview"; static constexpr const char *DRINKREMINDERBUTTONVIEWID = "DrinkReminderButton"; DrinkReminderViewEventListener::DrinkReminderViewEventListener() @@ -49,6 +53,32 @@ namespace OHOS return true; } + bool DrinkReminderViewEventListener::OnDrag(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DrinkReminderViewEventListener::OnDrag"); + UNUSED(view); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + DrinkReminderViewEventListener::X_DRAG_FLAG = true; + } + return true; + } + + bool DrinkReminderViewEventListener::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DrinkReminderViewEventListener::OnDragEnd"); + std::string viewId = view.GetViewId(); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && DrinkReminderViewEventListener::X_DRAG_FLAG) + { + if (viewId == DRINKREMINDERGROUPVIEWID) + { + NotificationManager::GetInstance()->StopNotify(); + } + DrinkReminderViewEventListener::X_DRAG_FLAG = false; + } + return true; + } + /*创建喝水提醒视图*/ UIViewGroup *CreateDrinkReminderView(void) { @@ -62,8 +92,16 @@ namespace OHOS return nullptr; } DrinkReminderGroupView->SetPosition(0, 0, 466, 466); + DrinkReminderGroupView->SetViewId(DRINKREMINDERGROUPVIEWID); DrinkReminderGroupView->SetTouchable(true); DrinkReminderGroupView->SetDraggable(true); + UIView::OnDragListener *dragListener = static_cast(&DrinkReminderViewEventListener::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] dragListener new fail!!"); + return nullptr; + } + DrinkReminderGroupView->SetOnDragListener(dragListener); /* ------------------------- DrinkReminderTitleLabel ------------------------ */ DrinkReminderTitleLabel = new UILabelExt(); if (DrinkReminderTitleLabel == nullptr) @@ -74,11 +112,11 @@ namespace OHOS DrinkReminderTitleLabel->SetPosition(83, 52, 300, 35); DrinkReminderTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); DrinkReminderTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 DrinkReminderTitleLabel->SetTextId(STR_DRINK_WATER_REMINDER); - #else +#else DrinkReminderTitleLabel->SetText("喝水提醒"); - #endif +#endif DrinkReminderTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); DrinkReminderTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DrinkReminderTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -101,9 +139,9 @@ namespace OHOS DrinkReminderNoteLabel->SetPosition(53, 248, 360, 70); DrinkReminderNoteLabel->SetStyle(STYLE_TEXT_FONT, 30); DrinkReminderNoteLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 SetLabelId(DrinkReminderNoteLabel, STR_DRINK_WATER_REMINDER_NOTE); - #endif +#endif DrinkReminderNoteLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); DrinkReminderNoteLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DrinkReminderNoteLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -119,8 +157,13 @@ namespace OHOS const char *buttonImgSrc = "/user/res/466x100button.bin"; DrinkReminderButton->SetImageSrc(buttonImgSrc, buttonImgSrc); DrinkReminderButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); - UIView::OnTouchListener *listener = static_cast(&DrinkReminderViewEventListener::GetInstance()); - DrinkReminderButton->SetOnTouchListener(listener); + UIView::OnTouchListener *TouchListener = static_cast(&DrinkReminderViewEventListener::GetInstance()); + if (TouchListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDrinkReminderView] TouchListener new fail!!"); + return nullptr; + } + DrinkReminderButton->SetOnTouchListener(TouchListener); /* --------------------------- DrinkReminderLabel --------------------------- */ DrinkReminderLabel = new UILabelExt(); if (DrinkReminderLabel == nullptr) @@ -131,11 +174,11 @@ namespace OHOS DrinkReminderLabel->SetPosition(133, 399, 200, 35); DrinkReminderLabel->SetStyle(STYLE_TEXT_FONT, 30); DrinkReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - #ifdef FD230 +#ifdef FD230 DrinkReminderLabel->SetTextId(STR_KONW); - #else +#else DrinkReminderLabel->SetText("知道了"); - #endif +#endif DrinkReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); DrinkReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DrinkReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index b90757576..66515336c 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -90,9 +90,9 @@ namespace OHOS CONFIFMOFEL_ITEM_SLEEP_GET_UP,//起床时间 CONFIFMOFEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 //久坐提醒相关 - CONFIFMOFEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 - CONFIFMOFEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔(单位小时) - CONFIFMOFEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 + CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 + CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔(单位小时) + CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 CONFIFMOFEL_ITEM_SIM_ICCID,//SIM卡的ICCID CONFIFMOFEL_ITEM_TELECOM_DMP_TIMESEC,//注册时间戳 @@ -199,6 +199,21 @@ namespace OHOS void SetA2DPState(bool value); bool GetA2DPState(void); + /* ------------------------------ 喝水提醒相关set与get ----------------------------- */ + void SetDrinkSwitch(const int value); + int GetDrinkSwitch(); + + void SetDrinkGoal(const int value); + int GetDrinkGoal(); + + void SetDrinkStart(const int value); + int GetDrinkStart(); + + void SetDrinkEnd(const int value); + int GetDrinkEnd(); + + void SetDrinkFreq(const int value); + int GetDrinkFreq(); /* ------------------------------ 久坐提醒相关set与get ----------------------------- */ void SetSedentarySwitch(const bool value); bool GetSedentarySwitch(); @@ -271,9 +286,9 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "sleep_bedtime", "0" }, //CONFIFMOFEL_ITEM_SLEEP_BEDTIME,//就寝时间 {ConfigDataType::DATATYPE_INT, "sleep_getup", "0" }, // CONFIFMOFEL_ITEM_SLEEP_GET_UP,//起床时间 {ConfigDataType::DATATYPE_INT, "sleep_remide", "0" }, // CONFIFMOFEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 - {ConfigDataType::DATATYPE_BOOL, "sedentary_switch", "false" }, // CONFIFMOFEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 - {ConfigDataType::DATATYPE_INT, "sedentary_interval", "1" }, // CONFIFMOFEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔 - {ConfigDataType::DATATYPE_STRING, "sedentary_reminderTime ", "10:00-22:00" }, // CONFIFMOFEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 + {ConfigDataType::DATATYPE_BOOL, "sedentary_switch", "false" }, // CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 + {ConfigDataType::DATATYPE_INT, "sedentary_interval", "1" }, // CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔 + {ConfigDataType::DATATYPE_STRING, "sedentary_reminderTime ", "10:00-22:00" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 {ConfigDataType::DATATYPE_STRING, "sim_iccid", "" },//CONFIFMOFEL_ITEM_SIM_ICCID cat1的iccid {ConfigDataType::DATATYPE_STRING, "telecom_regist_timesec", "" },//CONFIFMOFEL_ITEM_TELECOM_DMP_TIMESEC }; diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 1e4ec44e0..8cbb2a9f8 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -564,40 +564,95 @@ namespace OHOS return get_configData_bool(CONFIGMODEL_ITEM_A2DP); } + //设置喝水提醒开关 + void ConfigModel::SetDrinkSwitch(const int value) + { + set_condigData_Int(CONFIFMOFEL_ITEM_DRINK,value); + } + //获取喝水提醒开关 + int ConfigModel::GetDrinkSwitch() + { + return get_configData_int(CONFIFMOFEL_ITEM_DRINK); + } + + //设置喝水目标,单位ml + void ConfigModel::SetDrinkGoal(const int value) + { + set_condigData_Int(CONFIFMOFEL_ITEM_DRINK_GOAL,value); + } + //获取喝水目标,单位ml + int ConfigModel::GetDrinkGoal() + { + return get_configData_int(CONFIFMOFEL_ITEM_DRINK_GOAL); + } + + //设置喝水提醒开始时间,32位数字,前16位代表小时,后16位代表分钟 + void ConfigModel::SetDrinkStart(const int value) + { + set_condigData_Int(CONFIFMOFEL_ITEM_DRINK_START,value); + } + //获取喝水提醒开始时间,32位数字,前16位代表小时,后16位代表分钟 + int ConfigModel::GetDrinkStart() + { + return get_configData_int(CONFIFMOFEL_ITEM_DRINK_START); + } + + //设置喝水提醒结束时间,32位数字,前16位代表小时,后16位代表分钟 + void ConfigModel::SetDrinkEnd(const int value) + { + set_condigData_Int(CONFIFMOFEL_ITEM_DRINK_END,value); + } + //获取喝水提醒结束时间,32位数字,前16位代表小时,后16位代表分钟 + int ConfigModel::GetDrinkEnd() + { + return get_configData_int(CONFIFMOFEL_ITEM_DRINK_END); + } + + //设置喝水提醒的提醒频率,0代表每30分钟提醒一次,1:1小时,2:2小时 等等依次类推 + void ConfigModel::SetDrinkFreq(const int value) + { + set_condigData_Int(CONFIGMODEL_ITEM_DRINK_FREQ,value); + } + //获取喝水提醒的提醒频率,0代表每30分钟提醒一次,1:1小时,2:2小时 等等依次类推 + int ConfigModel::GetDrinkFreq() + { + return get_configData_int(CONFIGMODEL_ITEM_DRINK_FREQ); + } + // 设置久坐提醒开关 void ConfigModel::SetSedentarySwitch(const bool value) { - set_condigData_Bool(CONFIFMOFEL_ITEM_SEDENTARY_SWITCH,value); + set_condigData_Bool(CONFIGMODEL_ITEM_SEDENTARY_SWITCH,value); } // 获取久坐提醒开关 bool ConfigModel::GetSedentarySwitch() { - return get_configData_bool(CONFIFMOFEL_ITEM_SEDENTARY_SWITCH); + return get_configData_bool(CONFIGMODEL_ITEM_SEDENTARY_SWITCH); } // 设置久坐提醒时间间隔 void ConfigModel::SetSedentaryInterval(const int value) { - set_condigData_Int(CONFIFMOFEL_ITEM_SEDENTARY_INTERVAL,value); + set_condigData_Int(CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,value); } // 获取久坐提醒时间间隔 int ConfigModel::GetSedentaryInterval() { - return get_configData_int(CONFIFMOFEL_ITEM_SEDENTARY_INTERVAL); + return get_configData_int(CONFIGMODEL_ITEM_SEDENTARY_INTERVAL); } // 设置久坐提醒时间段 void ConfigModel::SetSedentaryReminderTime(const std::string& value) { - set_condigData_String(CONFIFMOFEL_ITEM_SEDENTARY_REMINDERTIME,value.c_str()); + set_condigData_String(CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,value.c_str()); } // 获取久坐提醒时间段 std::string ConfigModel::GetSedentaryReminderTime() { - return get_configData_string(CONFIFMOFEL_ITEM_SEDENTARY_REMINDERTIME); + return get_configData_string(CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME); } /* -------------------------------------------------------------------------- */