From 095b16ab12ed496033b2f4750fbdbf601ddfb12f Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 14 Jan 2025 18:11:18 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E7=94=B5=E8=AF=9D=E7=95=8C?= =?utf8?q?=E9=9D=A2=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/makephone/src/CallingView.cpp | 3 + .../nativeui/phone/include/PhoneCallView.h | 19 +-- .../nativeui/phone/src/PhoneCallView.cpp | 122 ++++-------------- 3 files changed, 31 insertions(+), 113 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp index 471bfc290..435584715 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp @@ -83,6 +83,9 @@ CallingView::~CallingView() imagedial = nullptr; + delete imageheadset; + imageheadset = nullptr; + delete imageperson; imageperson = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h index 59b844848..8878f6d40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallView.h @@ -45,7 +45,6 @@ namespace OHOS // 定义包含按钮初始化参数的结构体 struct ButtonInitParams { - UIButton *button; const char *buttonNumber; int leftPos; int topPos; @@ -74,7 +73,7 @@ namespace OHOS void Init(); void DeInit(); void container_child_init(); - void initButton(const ButtonInitParams ¶ms); + UIButton* initButton(const ButtonInitParams ¶ms); void UpdateLabel(const std::string &text); void container_child_SetVisible(bool); void start_call_roll_timer(); @@ -92,21 +91,7 @@ namespace OHOS UILabel *label_ = nullptr; UILabel *label_4G = nullptr; UILabel *label_BT = nullptr; - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - UIButton *button3_ = nullptr; - UIButton *button4_ = nullptr; - UIButton *button5_ = nullptr; - UIButton *button6_ = nullptr; - UIButton *button7_ = nullptr; - UIButton *button8_ = nullptr; - UIButton *button9_ = nullptr; - UIButton *button0_ = nullptr; - UIButton *buttoncall_ = nullptr; - UIButton *buttondel_ = nullptr; - UIButton *button_4G =NULL; - UIButton *button_BT =NULL; - + UIButton *button_[12] = {nullptr}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index d98534d7d..b6e1da1e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -32,13 +32,9 @@ namespace OHOS return g_pPhoneCallView; } - void PhoneCallView ::initButton(const ButtonInitParams ¶ms) + UIButton* PhoneCallView ::initButton(const ButtonInitParams ¶ms) { - UIButton *button = params.button; - if (button == nullptr) - { - button = new UIButton(); - } + UIButton *button = new UIButton(); const char *buttonNumber = params.buttonNumber; int leftPos = params.leftPos; @@ -69,6 +65,7 @@ namespace OHOS container_->Add(button); button->SetVisible(true); + return button; } @@ -81,12 +78,6 @@ namespace OHOS void PhoneCallView::Init() { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } // Add Label to App if (label_ == nullptr) { @@ -110,23 +101,22 @@ namespace OHOS container_->Add(label_); label_->SetVisible(true); ButtonInitParams buttonParams[] = { - {button1_, BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, - {button2_, BUTTON2, 181, 104, 104, 70, button2Path, button2Path}, - {button3_, BUTTON3, 293, 104, 104, 70, button3Path, button3Path}, - {button4_, BUTTON4, 69, 182, 104, 70, button4Path, button4Path}, - {button5_, BUTTON5, 182, 182, 104, 70, button5Path, button5Path}, - {button6_, BUTTON6, 293, 182, 104, 70, button6Path, button6Path}, - {button7_, BUTTON7, 69, 260, 104, 70, button7Path, button7Path}, - {button8_, BUTTON8, 181, 260, 104, 70, button8Path, button8Path}, - {button9_, BUTTON9, 293, 260, 104, 70, button9Path, button9Path}, - {button0_, BUTTON0, 181, 338, 104, 70, button0Path, button0Path}, - {buttoncall_, BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath}, - {buttondel_, BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath}, + { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, + {BUTTON2, 181, 104, 104, 70, button2Path, button2Path}, + { BUTTON3, 293, 104, 104, 70, button3Path, button3Path}, + { BUTTON4, 69, 182, 104, 70, button4Path, button4Path}, + { BUTTON5, 182, 182, 104, 70, button5Path, button5Path}, + { BUTTON6, 293, 182, 104, 70, button6Path, button6Path}, + { BUTTON7, 69, 260, 104, 70, button7Path, button7Path}, + { BUTTON8, 181, 260, 104, 70, button8Path, button8Path}, + { BUTTON9, 293, 260, 104, 70, button9Path, button9Path}, + { BUTTON0, 181, 338, 104, 70, button0Path, button0Path}, + { BUTTONCALL, 69, 338, 104, 70, buttonCallPath, buttonCallPath}, + { BUTTONDEL, 293, 338, 104, 70, buttonDelPath, buttonDelPath}, }; - for (const auto ¶ms : buttonParams) - { - initButton(params); + for(int i = 0;i<12;i++){ + button_[i] = initButton(buttonParams[i]); } } static int8_t roll_falg=0;//0.1s一次变换 @@ -213,89 +203,29 @@ namespace OHOS { container_->RemoveAll(); } - if(container_child!=NULL) + if(container_child!=nullptr) { container_child->RemoveAll(); } - if(button_4G!=NULL) - { - delete button_4G; - button_4G = nullptr; - } - if(button_BT!=NULL) + if(label_!=nullptr) { - delete button_BT; - button_BT = nullptr; + delete label_; + label_ = nullptr; } - if(label_4G!=NULL) + if(label_4G!=nullptr) { delete label_4G; label_4G = nullptr; } - if(label_BT!=NULL) + if(label_BT!=nullptr) { delete label_BT; label_BT = nullptr; } - if (button1_ != nullptr) - { - delete button1_; - button1_ = nullptr; - } - if (button2_ != nullptr) - { - delete button2_; - button2_ = nullptr; - } - if (button3_ != nullptr) - { - delete button3_; - button3_ = nullptr; - } - if (button4_ != nullptr) - { - delete button4_; - button4_ = nullptr; - } - if (button5_ != nullptr) - { - delete button5_; - button5_ = nullptr; - } - if (button6_ != nullptr) - { - delete button6_; - button6_ = nullptr; - } - if (button7_ != nullptr) - { - delete button7_; - button7_ = nullptr; - } - if (button8_ != nullptr) - { - delete button8_; - button8_ = nullptr; - } - if (button9_ != nullptr) - { - delete button9_; - button9_ = nullptr; - } - if (button0_ != nullptr) - { - delete button0_; - button0_ = nullptr; - } - if (buttoncall_ != nullptr) - { - delete buttoncall_; - buttoncall_ = nullptr; - } - if (buttondel_ != nullptr) + for(int i = 0;i<12;i++) { - delete buttondel_; - buttondel_ = nullptr; + delete button_[i]; + button_[i] = nullptr; } if(call_roll_timer) { -- 2.17.1