From d1ff3bf17e63d3df001ce4f8bbee788aa1cf0842 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 8 Oct 2024 15:32:22 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3#17,=E6=89=8B=E8=A1=A8?= =?utf8?q?=EF=BC=8C=E5=85=85=E7=94=B5=E6=97=B6=E4=B8=8B=E6=8B=89=E7=8A=B6?= =?utf8?q?=E6=80=81=E6=A0=8F=E7=94=B5=E9=87=8F=E5=9B=BE=E6=A0=87=E4=B8=8D?= =?utf8?q?=E6=98=BE=E7=A4=BA=E5=85=85=E7=94=B5=E7=8A=B6=E6=80=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/main/include/PullUpDownView.h | 5 +- .../nativeui/main/src/PullUpDownView.cpp | 59 ++++++++++++++++++- .../msg_center/src/msg_center_customer.cpp | 7 +++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h index 89f76263f..dd1cc95df 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 15:26:49 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-29 09:44:02 + * @LastEditTime: 2024-10-08 11:12:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h */ @@ -89,6 +89,7 @@ namespace OHOS UIBoxProgress *GetProgress(); UILabel *GetDateAndWeekLabel(void); void UpdateSignalStrengthStatusAndBatteryPosition(); + void UpdateBatteryProcess(); private: void InitBaseData(); @@ -111,6 +112,8 @@ namespace OHOS UIImageView *batteryimage{nullptr}; // 电池图片 UIBoxProgress *progress{nullptr}; // 电池进度条 UILabel *showDateAndWeekLabel{nullptr}; // 显示日期和星期 + UIImageView *chargeBatteryicon{nullptr}; //充电图标 + bool isChargeBatteryIconVisible{false}; // 充电图标是否可见 /* ---------------------------------- 3.滑动列表 ---------------------------------- */ public: AppGroupView *DropDownCardPage1Init(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index b94743226..b2eeced91 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-26 18:14:24 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-05 10:40:04 + * @LastEditTime: 2024-10-08 15:14:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp */ @@ -483,6 +483,19 @@ namespace OHOS progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); group1->Add(progress); /* -------------------------------------------------------------------------- */ + chargeBatteryicon = new UIImageView(); + if (!chargeBatteryicon) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon creation failed"); + return; + } + chargeBatteryicon->SetPosition(progress->GetX() + 6, batteryimage->GetY() + 2, 17, 26); + chargeBatteryicon->SetSrc("/user/res/Battery/Icon.bin"); + chargeBatteryicon->SetAutoEnable(false); + chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN); + chargeBatteryicon->SetVisible(false); + group1->Add(chargeBatteryicon); + /* -------------------------------------------------------------------------- */ group[DROPDOWNVIEW]->Add(group1); /* --------------------------------- 显示日期和星期 -------------------------------- */ showDateAndWeekLabel = new UILabel(); @@ -504,6 +517,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ MainPresenterSample::GetInstance()->UpdataBaseData(); /* -------------------------------------------------------------------------- */ + UpdateBatteryProcess(); } void PullUpDownView::ClearAll_2(void) { @@ -548,6 +562,11 @@ namespace OHOS delete progress; progress = nullptr; } + if (chargeBatteryicon != nullptr) + { + delete chargeBatteryicon; + chargeBatteryicon = nullptr; + } delete group1; group1 = nullptr; } @@ -660,7 +679,7 @@ namespace OHOS } } /*4g开关的状态刷新*/ - if(DropDownCardPage1::GetInstance()) + if (DropDownCardPage1::GetInstance()) { DropDownCardPage1::GetInstance()->Refresh4GState(); } @@ -718,7 +737,7 @@ namespace OHOS void PullUpDownView::UpdateXPosition(void) { // 判断相关组件是否有效 - if (MobileData && HD && Singal_4 && NoSignal && batteryimage && progress) + if (MobileData && HD && Singal_4 && NoSignal && batteryimage && progress && chargeBatteryicon) { // 获取各个组件的可见状态 bool mobileDataVisible = MobileData->IsVisible(); // 移动数据 @@ -800,6 +819,7 @@ namespace OHOS MobileData->SetX(showSignalStrength[0]->GetX()); } } + chargeBatteryicon->SetPosition(progress->GetX() + 6, batteryimage->GetY() + 2); // 使相关组件无效化以触发重绘 MobileData->Invalidate(); HD->Invalidate(); @@ -807,6 +827,7 @@ namespace OHOS NoSignal->Invalidate(); batteryimage->Invalidate(); progress->Invalidate(); + chargeBatteryicon->Invalidate(); } } @@ -824,6 +845,38 @@ namespace OHOS UpdateBlueToothStatus(bluetoothstatus); } + // 更新是否是充电状态 + void PullUpDownView::UpdateBatteryProcess() + { + if (!chargeBatteryicon || !progress) + { + return; + } + + bool isCharging = get_charge_stat(); // 获取充电状态 + + if (isCharging) + { + if (!isChargeBatteryIconVisible) + { + chargeBatteryicon->SetVisible(true); + isChargeBatteryIconVisible = true; + } + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 充电状态为绿色 + return; + } + else + { + if (isChargeBatteryIconVisible) + { + chargeBatteryicon->SetVisible(false); + isChargeBatteryIconVisible = false; + } + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full); // 充电状态为绿色 + return; + } + } + UILabel *PullUpDownView::GetDateAndWeekLabel(void) { return showDateAndWeekLabel; 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 de9b71212..9bafa671b 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 @@ -67,6 +67,7 @@ #include "heart_blood/health_service/health_service.h" #include "vibrator_service.h" #include "respiratorytraining/include/RespiratoryTrainingModel.h" +#include "main/include/PullUpDownView.h" #define DIALDATASET 1 //#include "Systemupgrade.h" @@ -496,6 +497,9 @@ void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req) DialModelCharge::GetInstance()->UpdatechargeStatus(1); #endif SaveEleModel::GetInstance()->SetChargeStatus(true); + if(PullUpDownView::GetInstance()){ + PullUpDownView::GetInstance()->UpdateBatteryProcess(); + } /* ---------------------------------- 充电弹窗 ---------------------------------- */ testCHANINGView *t=testCHANINGView::GetInstance(); if(t!=NULL) @@ -523,6 +527,9 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req) DialModelCharge::GetInstance()->UpdatechargeStatus(0); #endif SaveEleModel::GetInstance()->SetChargeStatus(false); + if(PullUpDownView::GetInstance()){ + PullUpDownView::GetInstance()->UpdateBatteryProcess(); + } /* ---------------------------------- 充电弹窗 ---------------------------------- */ testCHANINGView *t=testCHANINGView::GetInstance(); if(t!=NULL) -- 2.17.1