From efa706ae3d0cf3fff13110c943a5c64680095730 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 14 Nov 2025 11:08:45 +0800 Subject: [PATCH] =?utf8?q?fd272,=E5=8E=BB=E6=8E=89=E8=93=9D=E7=89=99?= =?utf8?q?=E7=95=8C=E9=9D=A2=E4=B8=AD=E8=93=9D=E7=89=99=E8=80=B3=E6=9C=BA?= =?utf8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/ClassicBlueToothView.h | 3 - .../src/ClassicBlueToothPresenter.cpp | 5 -- .../src/ClassicBlueToothView.cpp | 57 +++++-------------- 3 files changed, 14 insertions(+), 51 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h index 2d878fda8..ea6dae96d 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h @@ -19,7 +19,6 @@ #include "wearable_log.h" namespace OHOS { - static constexpr const char *BLUETOOTHEARPHONEBUTTON = "BlueToothEarPhoneButton"; // 蓝牙耳机按钮ID static constexpr const char *TRADIONALBLUETOOTHBUTTON = "TradionalBluetoothButton"; // 传统蓝牙服按钮ID static constexpr const char *BLUETOOTHSERVICEOPTIONSBUTTON = "BluetoothServiceOptionsButton"; // 蓝牙服务选项按钮ID // 返回setting视图界面 @@ -57,10 +56,8 @@ namespace OHOS bool SetUpBlueToothToggleButton(void); UIScrollView *BlueToothScrollView = nullptr; UILabelExt *Title = nullptr; - UILabelButtonExt *BlueToothEarPhoneButton = nullptr; // 蓝牙耳机按钮 UILabelButtonExt *TradionalBlueToothButton = nullptr; // 传统蓝牙按钮 UILabelButtonExt *BluetoothServiceOptionsButton = nullptr; // 蓝牙服务选项按钮 - UILabelExt *BlueToothEarPhoneLabel = nullptr; // 蓝牙耳机 UILabelExt *TradionalBlueToothLabel = nullptr; // 传统蓝牙 UILabelExt *BluetoothServiceOptionsLabel = nullptr; // 蓝牙服务选项 UILabelExt *AttentionLabel = nullptr; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp index 60a882383..e5b6e55d4 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp @@ -69,11 +69,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::GetInstance"); return false; } - - if (strcmp(view.GetViewId(), BLUETOOTHEARPHONEBUTTON) == 0) - { - NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); - } else if (strcmp(view.GetViewId(), BLUETOOTHSERVICEOPTIONSBUTTON) == 0) { if (classicBlueToothView->GetTradionalBlueToothToggleButton()->GetState() == true) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp index 0ecb24876..d0345aaf5 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp @@ -38,11 +38,6 @@ namespace OHOS delete Title; Title = nullptr; } - if (BlueToothEarPhoneButton != nullptr) - { - delete BlueToothEarPhoneButton; - BlueToothEarPhoneButton = nullptr; - } if (TradionalBlueToothButton != nullptr) { delete TradionalBlueToothButton; @@ -53,11 +48,6 @@ namespace OHOS delete BluetoothServiceOptionsButton; BluetoothServiceOptionsButton = nullptr; } - if (BlueToothEarPhoneLabel != nullptr) - { - delete BlueToothEarPhoneLabel; - BlueToothEarPhoneLabel = nullptr; - } if (TradionalBlueToothLabel != nullptr) { delete TradionalBlueToothLabel; @@ -155,18 +145,9 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - .textId = STR_BLUETOOTH_HEADPHONES, /*蓝牙耳机*/ + .textId = STR_TRADITIONAL_BLUETOOTH, .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; - BlueToothEarPhoneLabel = SetClassicBlueToothViewLabel(labelconfig); - if (nullptr == BlueToothEarPhoneLabel) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::BlueToothEarPhoneLabel is nullptr!"); - return false; - } - /* -------------------------------------------------------------------------- */ - labelconfig.top = 273; - labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; /*传统蓝牙*/ TradionalBlueToothLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == TradionalBlueToothLabel) { @@ -174,7 +155,7 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - labelconfig.top = 393; + labelconfig.top = 273; labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; /*蓝牙服务选项*/ BluetoothServiceOptionsLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BluetoothServiceOptionsLabel) @@ -189,12 +170,17 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::AttentionLabel is nullptr!"); return false; } - AttentionLabel->SetPosition(53, 499, 360, 180); // 位置大小 + int y = 0; + if (BluetoothServiceOptionsButton) + { + y = BluetoothServiceOptionsButton->GetY() + BluetoothServiceOptionsButton->GetHeight() + 39; + } + AttentionLabel->SetPosition(53, y, 360, 180); // 位置大小 AttentionLabel->SetStyle(STYLE_TEXT_FONT, 20); // 字体大小 AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用(该功能主要用于电话拨打/通知、音乐控制/传输等)", // AttentionLabel->SetTextId(STR_AUTO_OFF_BLUETOOTH_NOTE); - //TODO:多国语言 + // TODO:多国语言 AttentionLabel->SetTextId(STR_AUTO_OFF_BLUETOOTH_NOTE2); AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -208,18 +194,6 @@ namespace OHOS // 按钮初始化 bool ClassicBlueToothView::SetUpBlueToothButton(void) { - BlueToothEarPhoneButton = new UILabelButtonExt(); - if (BlueToothEarPhoneButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BlueToothEarPhoneButton new fail!"); - return false; - } - BlueToothEarPhoneButton->SetPosition(43, 120, 380, 100); - BlueToothEarPhoneButton->SetViewId(BLUETOOTHEARPHONEBUTTON); - BlueToothEarPhoneButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - BlueToothEarPhoneButton->SetImagePosition(326, 37); - BlueToothEarPhoneButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); - BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ TradionalBlueToothButton = new UILabelButtonExt(); if (TradionalBlueToothButton == nullptr) @@ -227,7 +201,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::TradionalBlueToothButton new fail!"); return false; } - TradionalBlueToothButton->SetPosition(43, 240, 380, 100); + TradionalBlueToothButton->SetPosition(43, 120, 380, 100); TradionalBlueToothButton->SetViewId(TRADIONALBLUETOOTHBUTTON); TradionalBlueToothButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); TradionalBlueToothButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); @@ -239,14 +213,13 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BluetoothServiceOptionsButton new fail!"); return false; } - BluetoothServiceOptionsButton->SetPosition(43, 360, 380, 100); + BluetoothServiceOptionsButton->SetPosition(43, 240, 380, 100); BluetoothServiceOptionsButton->SetViewId(BLUETOOTHSERVICEOPTIONSBUTTON); BluetoothServiceOptionsButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); BluetoothServiceOptionsButton->SetImagePosition(326, 37); BluetoothServiceOptionsButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ - BlueToothEarPhoneButton->SetOnClickListener(presenter_); BluetoothServiceOptionsButton->SetOnClickListener(presenter_); return true; @@ -258,10 +231,10 @@ namespace OHOS TradionalBlueToothToggleButton = new UIToggleButton(); if (nullptr == TradionalBlueToothToggleButton) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BlueToothEarPhoneButton new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::TradionalBlueToothToggleButton new fail!"); return false; } - TradionalBlueToothToggleButton->SetPosition(298, 265, 100, 50); + TradionalBlueToothToggleButton->SetPosition(298, 145, 100, 50); TradionalBlueToothToggleButton->SetState(ConfigModel::GetInstance()->GetClassicBlueToothState()); TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); @@ -293,16 +266,14 @@ namespace OHOS ClassicBlueToothViewInit(); initViewStatus = true; } - if(BlueToothScrollView == nullptr) + if (BlueToothScrollView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BlueToothScrollView is nullptr!"); return; } BlueToothScrollView->Add(Title); - BlueToothScrollView->Add(BlueToothEarPhoneButton); BlueToothScrollView->Add(TradionalBlueToothButton); BlueToothScrollView->Add(BluetoothServiceOptionsButton); - BlueToothScrollView->Add(BlueToothEarPhoneLabel); BlueToothScrollView->Add(TradionalBlueToothLabel); BlueToothScrollView->Add(BluetoothServiceOptionsLabel); BlueToothScrollView->Add(AttentionLabel); -- 2.17.1