From: luozheng <1732036298@qq.com> Date: Mon, 8 Jun 2026 04:19:16 +0000 (+0800) Subject: 充电弹窗界面优化 X-Git-Url: http://git.snicker.com.cn/css/html/static/gitweb.css?a=commitdiff_plain;h=f5954df11d9915ec5eefbc2c4931962f40eb5d58;p=mirrors%2FFD230.git 充电弹窗界面优化 --- diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp index 9b765ba39..5e4c21ee5 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp @@ -272,6 +272,7 @@ static OHOS::UIViewGroup* showlowpowerNotify(void) return OHOS::lowPowerShow(); } +//显示充电提醒弹窗 static OHOS::UIViewGroup* ShowChargeingNotify(void) { return OHOS::ShowChargeingView(); diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp index 64a41836c..72cc8c7aa 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp @@ -137,16 +137,13 @@ namespace OHOS { if (UIViewGroup_charge != nullptr) { - if (Chargeing_timer) { osTimerStop(Chargeing_timer); osTimerDelete(Chargeing_timer); Chargeing_timer = NULL; } - UIViewGroup_charge->RemoveAll(); - if (batteryprogress) { delete batteryprogress; @@ -182,14 +179,13 @@ namespace OHOS } } + // 显示充电提醒弹窗 UIViewGroup *ShowChargeingView(void) { - if (UIViewGroup_charge == nullptr) { UIViewGroup_charge = new UIViewGroup(); UIViewGroup_charge->SetPosition(0, 0, 466, 466); - // UIViewGroup_charge->SetStyle(STYLE_BACKGROUND_OPA, 0); } UIViewGroup_charge->SetViewId(CHARGE_GROUP); UIViewGroup_charge->SetTouchable(true); @@ -201,35 +197,25 @@ namespace OHOS #ifdef SUPPORT_BATTERY_SERVICE power = battery_get_voltage(&voltage); #endif - char buf[16] = {0}; sprintf(buf, "%d%c", power, '%'); - // printf("power:%s\r\n",buf); - time_t currtime; struct tm *timeinfo; time(&currtime); timeinfo = localtime(&currtime); - char time_buf[16] = {0}; sprintf_s(time_buf, 16, "%02d:%02d", timeinfo->tm_hour, timeinfo->tm_min); - if (batteryprogress == nullptr) { batteryprogress = new UICircleProgress(); } batteryprogress->SetPosition(123, 123,224,222); - batteryprogress->SetViewId("circleProgress1"); batteryprogress->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property - // Set BackgroundStyle batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x05); batteryprogress->SetBackgroundStyle(STYLE_BORDER_OPA, 0x07); batteryprogress->SetBackgroundStyle(STYLE_LINE_OPA, 0x07); batteryprogress->SetBackgroundStyle(STYLE_LINE_WIDTH, 22); - // Set ForegroundStyle batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); batteryprogress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); batteryprogress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4FC34C); @@ -240,53 +226,48 @@ namespace OHOS batteryprogress->SetValue(power); batteryprogress->SetVisible(true); // batteryprogress->SetCapType(CAP_ROUND); 不使用圆形边缘 - + /* -------------------------------------------------------------------------- */ if (image_lightning == nullptr) { image_lightning = new UIImageView(); } image_lightning->SetPosition(207, 176); image_lightning->Resize(70, 60); - image_lightning->SetViewId("image2"); image_lightning->SetStyle(STYLE_BORDER_COLOR, 0xff191919); char *image2imagesPath = "/user/res/solar-energy_1.bin"; image_lightning->SetSrc(image2imagesPath); image_lightning->SetVisible(true); - + /* -------------------------------------------------------------------------- */ if (image_circle == nullptr) { image_circle = new UIImageView(); } image_circle->SetPosition(126, 125); image_circle->Resize(194, 194); - image_circle->SetViewId("image1"); char *image1imagesPath = "/user/res/Ellipse_37.bin"; image_circle->SetSrc(image1imagesPath); image_circle->SetVisible(true); - + /* -------------------------------------------------------------------------- */ if (UILabel_power == nullptr) { UILabel_power = new UILabelExt(); } UILabel_power->SetPosition(133, 252); UILabel_power->Resize(200, 60); - UILabel_power->SetViewId("label5"); UILabel_power->SetStyle(STYLE_TEXT_FONT, 40); - UILabel_power->SetText(buf); UILabel_power->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); UILabel_power->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); UILabel_power->SetRollSpeed(0); UILabel_power->SetFont(GILROY_BOLD_FONT, 40); UILabel_power->SetVisible(true); - + /* -------------------------------------------------------------------------- */ if (UILabel_Chargeing == nullptr) { UILabel_Chargeing = new UILabelExt(); } UILabel_Chargeing->SetPosition(133, 356); UILabel_Chargeing->Resize(200, 60); - UILabel_Chargeing->SetViewId("label4"); UILabel_Chargeing->SetStyle(STYLE_TEXT_FONT, 30); // UILabel_Chargeing->SetText("正在充电"); // UILabel_Chargeing->SetTextId(STR_CHARGE); @@ -296,7 +277,7 @@ namespace OHOS UILabel_Chargeing->SetRollSpeed(0); UILabel_Chargeing->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); UILabel_Chargeing->SetVisible(true); - + /* -------------------------------------------------------------------------- */ if (UILabel_time == nullptr) { UILabel_time = new UILabelExt(); @@ -312,7 +293,13 @@ namespace OHOS UILabel_time->SetRollSpeed(0); UILabel_time->SetFont(GILROY_BOLD_FONT, 40); UILabel_time->SetVisible(true); - + /* -------------------------------------------------------------------------- */ + if (Chargeing_timer) + { + osTimerStop(Chargeing_timer); + osTimerDelete(Chargeing_timer); + Chargeing_timer = NULL; + } osStatus_t retTimer; Chargeing_timer = osTimerNew((osTimerFunc_t)Chargeing_Timer_CallBack, osTimerPeriodic, NULL, NULL); retTimer = osTimerStart(Chargeing_timer, 1000 * 1); @@ -323,16 +310,12 @@ namespace OHOS osTimerDelete(Chargeing_timer); Chargeing_timer = NULL; } - UIViewGroup_charge->Add(image_lightning); UIViewGroup_charge->Add(image_circle); - UIViewGroup_charge->Add(batteryprogress); - UIViewGroup_charge->Add(UILabel_time); UIViewGroup_charge->Add(UILabel_power); UIViewGroup_charge->Add(UILabel_Chargeing); - g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener(); RootView::GetInstance()->SetOnKeyActListener(lowppowrViewEventListener::GetInstance()); NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeChargePower);