UILabel *bpmLabel = nullptr;
std::string bpmStr = rec.bpm > 0 ? (std::to_string(rec.bpm) + " 次/分") : "-- 次/分";
- InitUILabel(bpmLabel, ECG_HISTORY_CARD_MARGIN + 40 + 38 + 8 + 8 + 120, y + 36 + 5 + 4, 119, 35, "ecg_list_bpm",
+ InitUILabel(bpmLabel, ECG_HISTORY_CARD_MARGIN + 40 + 38 + 8 + 8 + 120, y + 36 + 5 + 2, 119, 35, "ecg_list_bpm",
bpmStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 28);
bpmLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
namespace OHOS {
-static constexpr int kHealthMeasureMinBatteryPercent = 80;
+static constexpr int kHealthMeasureMinBatteryPercent = 20;
-/** 电量低于 10% 时不允许开始测量/校准 */
+/** 电量低于 kHealthMeasureMinBatteryPercent 时不允许开始测量/校准 */
bool IsBatteryTooLowForMeasure();
-/** å¤\8dç\94¨ç³»ç»\9fä½\8eç\94µé\87\8få\85\85ç\94µæ\8f\90é\86\92å¼¹çª\97ï¼\88charge_notification::lowPowerShowï¼\89 */
+/** å¤\8dç\94¨ç³»ç»\9fä½\8eç\94µé\87\8få\85\85ç\94µæ\8f\90é\86\92å¼¹çª\97ï¼\8cæ\96\87æ¡\88é\98\88å\80¼ä¸\8e kHealthMeasureMinBatteryPercent ä¸\80è\87´ */
void ShowHealthMeasureLowBatteryNotify();
} // namespace OHOS
#include "uicomponents/UIComponents.h"
#include "charge_notification.h"
+#include <string>
+
// #include "ui_resource_string.h"
namespace OHOS
}
static uint8_t battery_falg = 0;
+ static int lowpower_charge_remind_percent = 0;
+
+ void set_lowpower_charge_remind_percent(int percent)
+ {
+ lowpower_charge_remind_percent = percent > 0 ? percent : 0;
+ }
+
+ void reset_lowpower_charge_remind_percent(void)
+ {
+ lowpower_charge_remind_percent = 0;
+ }
+
+ static void apply_lowpower_charge_remind_text(UILabelExt *label)
+ {
+ if (label == nullptr) {
+ return;
+ }
+ if (lowpower_charge_remind_percent <= 0) {
+ label->SetTextId(STR_LOW_POWER_NOTIF_1);
+ return;
+ }
+ label->SetTextId(STR_LOW_POWER_NOTIF_1);
+ std::string result = UpdateLabel(label, lowpower_charge_remind_percent, STR_LOW_POWER_NOTIF_1);
+ const std::string percentStr = std::to_string(lowpower_charge_remind_percent);
+ if (result.find(percentStr) == std::string::npos) {
+ char buf[80] = {0};
+ (void)snprintf(buf, sizeof(buf) - 1, "当前电量低于%d%%请及时充电", lowpower_charge_remind_percent);
+ label->SetText(buf);
+ }
+ }
+
void set_lowpower_falg(uint8_t falg)
{
battery_falg = falg;
delete UIViewGroup_lowpower;
UIViewGroup_lowpower = nullptr;
}
+ reset_lowpower_charge_remind_percent();
}
void low_power_TimerCallBack(int data)
{
alarm_UILabel->SetPosition(110, 252);
alarm_UILabel->Resize(245, 70);
- // alarm_UILabel->SetText("当前电量低于10%请及时充电");
- alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_1);
+ apply_lowpower_charge_remind_text(alarm_UILabel);
alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);