From: luozheng <1732036298@qq.com> Date: Tue, 23 Jul 2024 03:14:18 +0000 (+0800) Subject: 传统蓝牙Slice优化修改 X-Git-Tag: release_V1.2.70_20241020_135402~769 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4db8c951b8f339e97f966f495ce50abad555db63;p=mirrors%2FFD230.git 传统蓝牙Slice优化修改 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp index 4792a68c6..3c6aa8cac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp @@ -342,7 +342,8 @@ void MainBluetoothView::ChangeSettingView() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeSettingView"); BluetoothModel::GetInstance()->SetTagConnectView(false); BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + // NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + NativeAbility::GetInstance().Back(); } void MainBluetoothView::DropEarPhoneView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h index 06f9536a4..0404af427 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-25 11:50:51 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-23 10:15:46 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h + */ #ifndef CLASSIC_BLUETOOTH_PRESENTER_H #define CLASSIC_BLUETOOTH_PRESENTER_H #include "Presenter.h" @@ -16,21 +23,21 @@ namespace OHOS public: ClassicBlueToothPresenter(); virtual ~ClassicBlueToothPresenter(); + static ClassicBlueToothPresenter *GetInstance(); virtual void OnStart() override; virtual void OnPause() override; virtual void OnResume() override; virtual void OnStop() override; - static ClassicBlueToothPresenter *GetInstance(); - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnChange(UICheckBox::UICheckBoxState state) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; + + bool X_DRAG_FLAG{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp index 694965bc6..7461ab113 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp @@ -4,7 +4,9 @@ #include "UiConfig.h" #include "wearable_log.h" #include "PhoneService.h" +#include "phoneservice/include/PhoneService.h" #include "BluetoothModel.h" +#include "ui_resource_string.h" namespace OHOS { static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr}; @@ -31,31 +33,48 @@ namespace OHOS { if (initViewStatus == true) { - BlueToothScrollView->RemoveAll(); - - delete Title; - Title = nullptr; - - delete HFP_Image; - HFP_Image = nullptr; - - delete A2DP_Image; - A2DP_Image = nullptr; - - delete HFP_Label; - HFP_Label = nullptr; - - delete A2DP_Label; - A2DP_Label = nullptr; - - delete HFP_ToggleButton; - HFP_ToggleButton = nullptr; - - delete A2DP_ToggleButton; - A2DP_ToggleButton = nullptr; - - delete BlueToothScrollView; - BlueToothScrollView = nullptr; + if (BlueToothScrollView != nullptr) + { + BlueToothScrollView->RemoveAll(); + + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (HFP_Image != nullptr) + { + delete HFP_Image; + HFP_Image = nullptr; + } + if (A2DP_Image != nullptr) + { + delete A2DP_Image; + A2DP_Image = nullptr; + } + if (HFP_Label != nullptr) + { + delete HFP_Label; + HFP_Label = nullptr; + } + if (A2DP_Label != nullptr) + { + delete A2DP_Label; + A2DP_Label = nullptr; + } + if (HFP_ToggleButton != nullptr) + { + delete HFP_ToggleButton; + HFP_ToggleButton = nullptr; + } + if (A2DP_ToggleButton != nullptr) + { + delete A2DP_ToggleButton; + A2DP_ToggleButton = nullptr; + } + delete BlueToothScrollView; + BlueToothScrollView = nullptr; + } } } @@ -95,9 +114,8 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 - //label->SetText(labelconfig.text); // 内容 - label->SetTextId(labelconfig.textId); - label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); return label; } @@ -107,14 +125,13 @@ namespace OHOS { LabelConfig labelconfig = { .left = 93, - .top = 52, + .top = 50, .width = 280, .height = 40, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙服务选项", - .textId = STR_BLUETOOTH_SERVICE_OPTIONS, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH_SERVICE_OPTIONS, /*蓝牙服务选项*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Title = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == Title) @@ -131,9 +148,8 @@ namespace OHOS .height = 40, .fontSize = 30, .lineHeigh = 35, - //.text = "通话蓝牙", - .textId = STR_HFP, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_HFP, /*通话蓝牙*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; HFP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == HFP_Label) @@ -142,8 +158,7 @@ namespace OHOS return false; } labelconfig.top = 273; - //labelconfig.text = "媒体蓝牙"; - labelconfig.textId = STR_A2DP; + labelconfig.textId = STR_A2DP; /*媒体蓝牙*/ A2DP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == A2DP_Label) { @@ -164,7 +179,7 @@ namespace OHOS return false; } HFP_ToggleButton->SetPosition(298, 145, 100, 50); - HFP_ToggleButton->SetState(uapi_hfp_connect_state());//ConfigModel::GetInstance()->GetHFPState()); + HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState()); HFP_ToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); HFP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); /* -------------------------------------------------------------------------- */ @@ -180,6 +195,11 @@ namespace OHOS A2DP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); /* -------------------------------------------------------------------------- */ UIView::OnClickListener *clickListener = static_cast(BluetoothServiceOptionsPresenter::GetInstance()); + if (nullptr == clickListener) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::GetInstance fail!!"); + return false; + } HFP_ToggleButton->SetOnClickListener(clickListener); A2DP_ToggleButton->SetOnClickListener(clickListener); @@ -226,33 +246,23 @@ namespace OHOS /// @param void void BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit(void) { - if (!SetUpBlueToothScrollView()) - { - return; - } - - if (!SetUpBlueToothImageView()) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit"); + if (!SetUpBlueToothScrollView() || !SetUpBlueToothImageView() || !SetUpBlueToothLabel() || !SetUpBlueToothToggleButton()) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit fail!!"); return; } - - if (!SetUpBlueToothLabel()) - { - return; - } - - if (!SetUpBlueToothToggleButton()) - { - return; - } - - initViewStatus = true; } void BluetoothServiceOptionsView::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnStart"); View::OnStart(); - BluetoothServiceOptionsViewInit(); + if (!initViewStatus) + { + BluetoothServiceOptionsViewInit(); + initViewStatus = true; + } // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BluetoothServiceOptionsPresenter::GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp index e91a7ede4..b63e96800 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-25 11:50:57 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-03 15:18:50 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-23 10:18:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp */ #include "classicbluetooth/include/ClassicBlueToothPresenter.h" @@ -14,6 +14,7 @@ #include #include "wearable_log.h" #include "ConfigModel.h" +#include namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -36,23 +37,25 @@ namespace OHOS void ClassicBlueToothPresenter::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnStart"); Presenter::OnStart(); } void ClassicBlueToothPresenter::OnPause(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnPause"); Presenter::OnPause(); } void ClassicBlueToothPresenter::OnResume(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnResume"); Presenter::OnResume(); } void ClassicBlueToothPresenter::OnStop(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnStop"); Presenter::OnStop(); } @@ -85,8 +88,11 @@ namespace OHOS bool ClassicBlueToothPresenter::OnDrag(UIView &view, const DragEvent &event) { UNUSED(view); - UNUSED(event); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + X_DRAG_FLAG = true; + } return true; } @@ -94,9 +100,10 @@ namespace OHOS { UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDragEnd"); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { NativeAbility::GetInstance().Back(); + X_DRAG_FLAG = false; } return true; @@ -128,7 +135,7 @@ namespace OHOS bool ClassicBlueToothPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnKeyAct"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnKeyAct"); uint16 keyID = event.GetKeyId(); uint16 keyState = event.GetState(); // 如果是power键,且是亮屏状态,按键释放就返回上一级 diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp index 520695e45..789145744 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp @@ -16,7 +16,6 @@ namespace OHOS ClassicBlueToothView::~ClassicBlueToothView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "~ClassicBlueToothView::ClassicBlueToothView"); - ClearAll(); g_pClassicBlueToothView = nullptr; } @@ -29,34 +28,52 @@ namespace OHOS { if (initViewStatus == true) { - BlueToothScrollView->RemoveAll(); - - delete Title; - Title = nullptr; - - delete BlueToothEarPhoneButton; - BlueToothEarPhoneButton = nullptr; - - delete TradionalBlueToothButton; - TradionalBlueToothButton = nullptr; - - delete BluetoothServiceOptionsButton; - BluetoothServiceOptionsButton = nullptr; - - delete BlueToothEarPhoneLabel; - BlueToothEarPhoneLabel = nullptr; - - delete TradionalBlueToothLabel; - TradionalBlueToothLabel = nullptr; - - delete AttentionLabel; - AttentionLabel = nullptr; - - delete TradionalBlueToothToggleButton; - TradionalBlueToothToggleButton = nullptr; - - delete BlueToothScrollView; - BlueToothScrollView = nullptr; + if (BlueToothScrollView) + { + BlueToothScrollView->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (BlueToothEarPhoneButton != nullptr) + { + delete BlueToothEarPhoneButton; + BlueToothEarPhoneButton = nullptr; + } + if (TradionalBlueToothButton != nullptr) + { + delete TradionalBlueToothButton; + TradionalBlueToothButton = nullptr; + } + if (BluetoothServiceOptionsButton != nullptr) + { + delete BluetoothServiceOptionsButton; + BluetoothServiceOptionsButton = nullptr; + } + if (BlueToothEarPhoneLabel != nullptr) + { + delete BlueToothEarPhoneLabel; + BlueToothEarPhoneLabel = nullptr; + } + if (TradionalBlueToothLabel != nullptr) + { + delete TradionalBlueToothLabel; + TradionalBlueToothLabel = nullptr; + } + if (AttentionLabel != nullptr) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + if (TradionalBlueToothToggleButton != nullptr) + { + delete TradionalBlueToothToggleButton; + TradionalBlueToothToggleButton = nullptr; + } + delete BlueToothScrollView; + BlueToothScrollView = nullptr; + } } } @@ -69,9 +86,10 @@ namespace OHOS return false; } BlueToothScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - BlueToothScrollView->SetScrollBlankSize(35); + BlueToothScrollView->SetScrollBlankSize(50); BlueToothScrollView->SetReboundSize(50); BlueToothScrollView->SetDirection(1); + BlueToothScrollView->RequestFocus(); UIView::OnDragListener *draglistener = static_cast(ClassicBlueToothPresenter::GetInstance()); if (draglistener == nullptr) { @@ -96,7 +114,6 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 - // label->SetText(labelconfig.text); // 内容 label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); @@ -108,14 +125,13 @@ namespace OHOS { LabelConfig labelconfig = { .left = 93, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙", - .textId = STR_BLUETOOTH, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH, /*蓝牙*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Title = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == Title) @@ -132,9 +148,8 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙耳机", - .textId = STR_BLUETOOTH_HEADPHONES, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH_HEADPHONES, /*蓝牙耳机*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; BlueToothEarPhoneLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BlueToothEarPhoneLabel) @@ -144,8 +159,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 273; - // labelconfig.text = "传统蓝牙"; - labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; + labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; /*传统蓝牙*/ TradionalBlueToothLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == TradionalBlueToothLabel) { @@ -154,8 +168,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 393; - // labelconfig.text = "蓝牙服务选项"; - labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; + labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; /*蓝牙服务选项*/ BluetoothServiceOptionsLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BluetoothServiceOptionsLabel) { @@ -172,10 +185,10 @@ namespace OHOS AttentionLabel->SetPosition(53, 499, 360, 180); // 位置大小 AttentionLabel->SetStyle(STYLE_TEXT_FONT, 20); // 字体大小 AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 - //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用\n\n(该功能主要用于电话拨打/通知、音乐控制/传输等)", - //SetLabelId(AttentionLabel, STR_AUTO_OFF_BLUETOOTH_NOTE); + //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用(该功能主要用于电话拨打/通知、音乐控制/传输等)", AttentionLabel->SetTextId(STR_AUTO_OFF_BLUETOOTH_NOTE); AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); // 断行模式。 AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); /* -------------------------------------------------------------------------- */ @@ -197,7 +210,7 @@ namespace OHOS 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, 0xff191919, UIButton::PRESSED); + BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ TradionalBlueToothButton = new UILabelButtonExt(); if (TradionalBlueToothButton == nullptr) @@ -222,11 +235,10 @@ namespace OHOS 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, 0xff191919, UIButton::PRESSED); + BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ - UIView::OnClickListener *clickListener = static_cast(ClassicBlueToothPresenter::GetInstance()); - BlueToothEarPhoneButton->SetOnClickListener(clickListener); - BluetoothServiceOptionsButton->SetOnClickListener(clickListener); + BlueToothEarPhoneButton->SetOnClickListener(presenter_); + BluetoothServiceOptionsButton->SetOnClickListener(presenter_); return true; } @@ -244,8 +256,7 @@ namespace OHOS TradionalBlueToothToggleButton->SetState(ConfigModel::GetInstance()->GetClassicBlueToothState()); TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); - UICheckBox::OnChangeListener *changeListener = static_cast(ClassicBlueToothPresenter::GetInstance()); - TradionalBlueToothToggleButton->SetOnChangeListener(changeListener); + TradionalBlueToothToggleButton->SetOnChangeListener(presenter_); return true; } @@ -258,37 +269,25 @@ namespace OHOS /// @param void void ClassicBlueToothView::ClassicBlueToothViewInit(void) { - if (!SetUpBlueToothScrollView()) - { - return; - } - - if (!SetUpBlueToothButton()) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::ClassicBlueToothViewInit"); + if (!SetUpBlueToothScrollView() || !SetUpBlueToothButton() || !SetUpBlueToothLabel() || !SetUpBlueToothToggleButton()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::ClassicBlueToothViewInit fail!!"); return; } - - if (!SetUpBlueToothLabel()) - { - return; - } - - if (!SetUpBlueToothToggleButton()) - { - return; - } - - initViewStatus = true; } void ClassicBlueToothView::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::OnStart"); View::OnStart(); - ClassicBlueToothViewInit(); + if (!initViewStatus) + { + ClassicBlueToothViewInit(); + initViewStatus = true; + } - // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ClassicBlueToothPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); // 增加按键监听 } void ClassicBlueToothView::OnSetUpView() @@ -305,6 +304,7 @@ namespace OHOS BlueToothScrollView->Add(AttentionLabel); BlueToothScrollView->Add(TradionalBlueToothToggleButton); RootView::GetInstance()->Add(BlueToothScrollView); + container_ = BlueToothScrollView; Draw(); } @@ -321,6 +321,7 @@ namespace OHOS View::OnStop(); RootView::GetInstance()->RemoveAll(); RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); return; }