From: Caisking <3449750381@qq.com> Date: Thu, 22 Feb 2024 09:06:54 +0000 (+0800) Subject: 更正进度条不同步bug X-Git-Tag: release_V1.2.70_20241020_135402~1298^2~17 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=d7034a6482f584a7b18e36ac7493efe2441959af;p=mirrors%2FFD230.git 更正进度条不同步bug --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialBoxProgressView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialBoxProgressView.h index ad1f1d59b..e4aca93ac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialBoxProgressView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialBoxProgressView.h @@ -13,9 +13,14 @@ class DialBoxProgressView : public UIBoxProgress, public DialView { public: DialBoxProgressView(); virtual ~DialBoxProgressView(); + static DialBoxProgressView* GetInstance() + { + static DialBoxProgressView instance; + return &instance; + } void HandleFloatData(float data) override; private: - int32_t value_ = 50; + int32_t value_ = -1; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index af86ed727..9a8298811 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -23,6 +23,7 @@ #include "ModelDialDataFactory.h" #include "PresenterTask.h" #include "DialModelTime.h" +#include "DialModelPower.h" #if USE_OFFLINE_DIAL #include "DialViewGroup.h" #endif @@ -32,7 +33,7 @@ namespace OHOS { map g_jumpView = { - {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置 + {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置 {DROPDOWN_CLICK_BLUETOOTH, VIEW_CLASSIC_BLUETOOTH}, // 蓝牙 }; @@ -139,7 +140,7 @@ namespace OHOS SendMsgToUIService(SCREEN_OFF_ENABLE_TO_UI, 0, &enable, sizeof(int32_t)); } } - #endif +#endif if (g_jumpView.count(curViewId) != 0) { NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); @@ -290,6 +291,7 @@ namespace OHOS { #if USE_OFFLINE_DIAL DialModelTime::GetInstance()->UpdateTime(); + DialModelPower::GetInstance()->UpdatePower(); dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData(); #else dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateTime(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp index 8084dfb75..6a5088f56 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp @@ -3,29 +3,41 @@ */ #include "DialBoxProgressView.h" +#include "wearable_log.h" +#include "battery_hal.h" +extern uint8_t battery_get_voltage(float *voltage); -namespace OHOS { -DialBoxProgressView::DialBoxProgressView(void) +namespace OHOS { -} - -DialBoxProgressView::~DialBoxProgressView(void) -{ -} + DialBoxProgressView::DialBoxProgressView(void) + { + } -void DialBoxProgressView::HandleFloatData(float data) -{ - float ratio = data; - if (ratio > 1.0f) { - ratio = 1.0f; - } else if (ratio < 0.0f) { - ratio = 0.0f; + DialBoxProgressView::~DialBoxProgressView(void) + { } - int32_t value = ratio * (GetRangeMax() - GetRangeMin()); - if (value_ == value) { - return; + + void DialBoxProgressView::HandleFloatData(float data) + { + float ratio = data; + if (ratio > 1.0f) + { + ratio = 1.0f; + } + else if (ratio < 0.0f) + { + ratio = 0.0f; + } + int32_t value = ratio * (GetRangeMax() - GetRangeMin()); + if (value_ == value) + { + return; + } + // 获取电池电压值 + float voltage = 0.0F; + value = battery_get_voltage(&voltage); + value_ = value; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"battery_get_value:%d", value_); + SetValue(value_); } - value_ = value; - SetValue(value_); } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp index 55d6a942a..1e5f086db 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp @@ -7,6 +7,7 @@ #include "RegisterDialModel.h" #include "DialModelPower.h" +#include "DialBoxProgressView.h" #include #include "battery_hal.h" extern uint8_t battery_get_voltage(float *voltage); @@ -17,12 +18,11 @@ namespace OHOS { bool DialModelPower::GetDialFloatData(DialDataType &type, float &out) { - if (power_ == 0) - { - UpdatePower(); - } (void)type; - out = power_; + // 获取电池电压值 + float voltage = 0.0F; + power_ = battery_get_voltage(&voltage); + out = static_cast(power_); return true; } void DialModelPower::UpdatePower() @@ -30,9 +30,12 @@ namespace OHOS // 获取电池电压值 float voltage = 0.0F; power_ = battery_get_voltage(&voltage); +#if 1 if (onChangeListener_ != nullptr) { onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_POWER, power_); } +#endif } + } diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h new file mode 100644 index 000000000..7cbcade6c --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h @@ -0,0 +1,9 @@ +#ifndef CHARGE_NOTIFICATION_H +#define CHARGE_NOTIFICATION_H + +namespace OHOS +{ + UIViewGroup *ChargingStatuShow(void); + UIView *view_ = nullptr; +}; +#endif /* CHARGE_NOTIFICATION_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp new file mode 100644 index 000000000..661f390d3 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp @@ -0,0 +1,35 @@ +#include "notification_manager.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "AlarmPopUpPresenter.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +namespace OHOS +{ + UIImageView *imageCharge = nullptr; + + // 展示充电图标 + UIViewGroup *ChargingStatuShow() + { + // Add ImageView to App + if (imageCharge == nullptr) + { + imageCharge = new UIImageView(); + } + imageCharge->SetPosition(186, 55); // widget's left position and top position + imageCharge->Resize(100, 100); // widget's width and height + imageCharge->SetViewId("image1"); // Set style + + // Set additional property + char *image1imagesPath = "/user/res/Battery/Charge_Icon.bin"; + imageCharge->SetSrc(image1imagesPath); + + // Add to rootView + RootView::GetInstance()->Add(imageCharge); + + if (view_->GetHorCurrentPage() == WATCH_FACE) + { + imageCharge->SetVisible(true); + } + } +}