UILabel *GetDateAndWeekLabel(void);
void UpdateSignalStrengthStatusAndBatteryPosition();
void UpdateBatteryProcess();
+ UILabel *GetBatteryPercentLabel(void);
private:
void InitBaseData();
UIViewGroup *group1{nullptr};
UIImageView *batteryimage{nullptr}; // 电池图片
UIBoxProgress *progress{nullptr}; // 电池进度条
+ UILabel *batteryPercentLabel{nullptr}; // 电量百分比文本
UILabel *showDateAndWeekLabel{nullptr}; // 显示日期和星期
UIImageView *chargeBatteryicon{nullptr}; //充电图标
bool isChargeBatteryIconVisible{false}; // 充电图标是否可见
#endif
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
std::string dateAndweek = std::string(dateStr) + " " + std::string(weekStr);
- if (PullUpDownView::GetInstance() != nullptr)
- {
- PullUpDownView::GetInstance()->GetProgress()->SetValue(value);
- PullUpDownView::GetInstance()->GetDateAndWeekLabel()->SetText(dateAndweek.c_str());
+ if (PullUpDownView::GetInstance() != nullptr)
+ {
+ PullUpDownView::GetInstance()->GetProgress()->SetValue(value);
+ PullUpDownView::GetInstance()->GetDateAndWeekLabel()->SetText(dateAndweek.c_str());
+ UILabel *batLabel = PullUpDownView::GetInstance()->GetBatteryPercentLabel();
+ if (batLabel != nullptr)
+ {
+ std::string percentStr = std::to_string(static_cast<int>(value)) + "%";
+ batLabel->SetText(percentStr.c_str());
+ }
}
// 释放动态分配的内存
group1->SetStyle(STYLE_BACKGROUND_OPA, 0);
group[DROPDOWNVIEW]->Add(group1);
/* ----------------------------------- 电池 ----------------------------------- */
+ const int BATTERY_LEFT_OFFSET = 30; /* 电池图标整体左移 */
+ int batteryAreaWidth = 48; /* 图标+间距+电量文本 */
batteryimage = new UIImageView();
if (batteryimage == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail");
return;
}
- batteryimage->SetPosition((group1->GetWidth() - 48) / 2, (group1->GetHeight() - 30) / 2, 48, 30);
+ batteryimage->SetPosition((group1->GetWidth() - batteryAreaWidth) / 2 - BATTERY_LEFT_OFFSET, (group1->GetHeight() - 30) / 2, 48, 30);
std::string batteryimagesPath = "/user/res/Battery/Battery_White.bin";
batteryimage->SetSrc(batteryimagesPath.c_str());
group1->Add(batteryimage);
chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN);
chargeBatteryicon->SetVisible(false);
group1->Add(chargeBatteryicon);
+ /* ----------------------------------- 电量百分比文本 ----------------------------------- */
+ batteryPercentLabel = new UILabel();
+ if (batteryPercentLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryPercentLabel new fail");
+ return;
+ }
+ batteryPercentLabel->SetPosition(batteryimage->GetX() + 48 + 8, (group1->GetHeight() - 28) / 2, 50, 28);
+ batteryPercentLabel->SetStyle(STYLE_TEXT_FONT, 24);
+ batteryPercentLabel->SetStyle(STYLE_LINE_HEIGHT, 28);
+ batteryPercentLabel->SetTextColor(Color::White());
+ batteryPercentLabel->SetText("0%");
+ batteryPercentLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ batteryPercentLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+ batteryPercentLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 26);
+ group1->Add(batteryPercentLabel);
/* --------------------------------- 显示日期和星期 -------------------------------- */
showDateAndWeekLabel = new UILabel();
if (showDateAndWeekLabel == nullptr)
delete chargeBatteryicon;
chargeBatteryicon = nullptr;
}
+ if (batteryPercentLabel != nullptr)
+ {
+ delete batteryPercentLabel;
+ batteryPercentLabel = nullptr;
+ }
delete group1;
group1 = nullptr;
}
{
return showDateAndWeekLabel;
}
+
+ UILabel *PullUpDownView::GetBatteryPercentLabel(void)
+ {
+ return batteryPercentLabel;
+ }
/* -------------------------------------------------------------------------- */
AppGroupView *PullUpDownView::DropDownCardPage1Init(void)
{