${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/ClassicBlueToothModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp
#录音
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/record/src/RecordDeleteView.cpp
VIEW_ALARM_POP_UP, // 闹铃界面
VIEW_BLUETOOTH_EARPHONE, // 连接蓝牙耳机界面
VIEW_CLASSIC_BLUETOOTH, // 经典蓝牙
+ VIEW_BLUETOOTH_SERVICE_OPTIONS,// 蓝牙服务选项
VIEW_CALLER_LOG, // 通话记录界面
VIEW_INCOMING_CALL, // 来电界面
VIEW_COMPASS, // 指南针界面
void InitMediaVolumeSlice(void);
void InitDisplayBrightnessSlice(void);
void InitClassicBluetoothSlice(void);
+ void InitBluetoothServiceOptionsSlice(void);
void InitFindPhoneSlice(void);
void InitLanguageSwitchSlice(void);
void InitMainStopWatchSlice(void);
static constexpr const char *PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE = APP_LIST_PATH "/lighting.bin"; // 亮度调节
static constexpr const char *PNG_APPLIST_SAVEELE_IMAGE = APP_LIST_PATH "/save.bin"; // 省电模式
static constexpr const char *PNG_APPLIST_MESSAGE_IMAGE = APP_LIST_PATH "/message.bin"; // 消息通知
+ static constexpr const char *PNG_APPLIST_BLUETOOTH_IMAGE = APP_LIST_PATH "/Bluetooth.bin"; // 蓝牙
/* ---------------------------------- 快速训练 ---------------------------------- */
static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin";
static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin";
#include "classicbluetooth/include/ClassicBlueToothPresenter.h"
#include "classicbluetooth/include/ClassicBlueToothView.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsPresenter.h"
#include "record/include/RecordingPresenter.h"
#include "record/include/RecordingView.h"
{VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice}, // 系统音量
{VIEW_CALL_VOLUME, &NativeLauncher::InitCallVolumeSlice}, // 系统音量
{VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice}, // 经典蓝牙slice
+ {VIEW_BLUETOOTH_SERVICE_OPTIONS, &NativeLauncher::InitBluetoothServiceOptionsSlice}, // 蓝牙服务slice
{VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址
{VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话
{VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话
// }
// NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALUPDATE, dialupdate);
// }
+ //传统蓝牙
void NativeLauncher::InitClassicBluetoothSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitClassicBluetoothSlice");
NativeAbility::GetInstance().AddSliceProxy(VIEW_CLASSIC_BLUETOOTH, classicbluetooth);
}
+ // 蓝牙服务选项
+ void NativeLauncher::InitBluetoothServiceOptionsSlice(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitClassicBluetoothSlice");
+ SliceProxy *bluetoothserviceoptions = new AbilitySliceProxy<BluetoothServiceOptionsView, BluetoothServiceOptionsPresenter>;
+ if (bluetoothserviceoptions == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothserviceoptions");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_BLUETOOTH_SERVICE_OPTIONS, bluetoothserviceoptions);
+ }
+
void NativeLauncher::InitRecordingSlice(void) // 录音
{
SliceProxy *record = new AbilitySliceProxy<RecordingView, RecordingPresenter>;
{VIEW_SET_DESKTOP, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, "主题样式", nullptr},
{VIEW_SET_CARD, PNG_APPLIST_CARDSET_IMAGE, PNG_APPLIST_CARDSET_IMAGE, "卡片管理", nullptr},
{VIEW_SET_DIAL, PNG_APPLIST_CHANGEDIAL_IMAGE, PNG_APPLIST_CHANGEDIAL_IMAGE, "切换表盘", nullptr},
+ {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, "蓝牙", nullptr},
{VIEW_DNOTDISTURB, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DISTURB_IMAGE, "勿扰模式", nullptr},
{VIEW_FLASHLIGHT, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_FLASHLIGHT_IMAGE, "手电筒", nullptr},
{VIEW_BRIGHTNESSLEVEL, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, "亮度调节", nullptr},
#define BLUETOOTH_PRESENTER_H\r
\r
#include "Presenter.h"\r
+#include "View.h"\r
#include "MainBluetoothView.h"\r
#include "components/ui_view.h"\r
#include "components/ui_image_view.h"\r
#include "UiViewId.h"\r
#include "cmsis_os.h"\r
\r
-#include "KeyInputListener.h"\r
#include "common/key_code.h"\r
namespace OHOS {\r
enum BluetoothPresenterNum : uint8_t {\r
#include "MainBluetoothView.h"\r
#include "UiConfig.h"\r
#include "bluetooth/include/BluetoothModel.h"\r
+#include "custom_utils.h"\r
+#include "common/key_code.h"\r
\r
namespace OHOS {\r
static BluetoothPresenter *g_pBluetoothPresenter = nullptr;\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnKeyAct");\r
uint16 keyID = event.GetKeyId();\r
+ uint16 keyState = event.GetState();\r
// 如果是power键就返回上一级\r
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER))\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)\r
{\r
- uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
- NativeAbility::GetInstance().ChangeSlice(preSlice);\r
+ NativeAbility::GetInstance().Back();\r
}\r
return true;\r
}\r
BaseView::RootView(Color::Black().full);\r
\r
// 增加按键监听\r
- //RootView::OnKeyActListener *keyactListener =(RootView::OnKeyActListener *)OHOS::BluetoothPresenter::GetInstance();\r
- //RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+ RootView::OnKeyActListener *keyactListener =(RootView::OnKeyActListener *)OHOS::BluetoothPresenter::GetInstance();\r
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
\r
BluetoothModel *bluetoothModel = BluetoothModel::GetInstance();\r
if (bluetoothModel == nullptr) {\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeSettingView");\r
BluetoothModel::GetInstance()->SetTagConnectView(false);\r
BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false);\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_CLASSIC_BLUETOOTH);\r
+ //NativeAbility::GetInstance().ChangeSlice(VIEW_CLASSIC_BLUETOOTH);\r
+ NativeAbility::GetInstance().Back();\r
}\r
\r
void MainBluetoothView::DropEarPhoneView()\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-02-20 10:27:30
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-25 14:18:02
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/BluetoothServiceOptionsPresenter.h
+ */
+#ifndef BLUETOOTH_SERVICE_OPTIONS_PRESENTER_H
+#define BLUETOOTH_SERVICE_OPTIONS_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+
+namespace OHOS
+{
+ class BluetoothServiceOptionsView;
+ class BluetoothServiceOptionsPresenter : public Presenter<BluetoothServiceOptionsView>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener,
+ public RootView::OnKeyActListener
+ {
+ public:
+ BluetoothServiceOptionsPresenter();
+ virtual ~BluetoothServiceOptionsPresenter();
+
+ virtual void OnStart() override;
+ virtual void OnPause() override;
+ virtual void OnResume() override;
+ virtual void OnStop() override;
+
+ static BluetoothServiceOptionsPresenter *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 OnKeyAct(UIView &view, const KeyEvent &event) override;
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-25 11:49:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-25 15:14:34
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/BluetoothServiceOptionsView.h
+ */
+
+#ifndef BLUETOOTH_SERVICE_OPTIONS_VIEW_H
+#define BLUETOOTH_SERVICE_OPTIONS_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/root_view.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+namespace OHOS
+{
+ // 返回setting视图界面
+ class BluetoothServiceOptionsPresenter;
+ class BluetoothServiceOptionsView : public View<BluetoothServiceOptionsPresenter>
+ {
+ public:
+ struct LabelConfig
+ {
+ int16_t left;
+ int16_t top;
+ int16_t width;
+ int16_t height;
+ int16_t fontSize; // 字体大小
+ int16_t lineHeigh; // 行高
+ const char *text; // 文本
+ uint8_t lineBreakMode; // 断行模式。
+ };
+ BluetoothServiceOptionsView();
+ virtual ~BluetoothServiceOptionsView();
+ static BluetoothServiceOptionsView *GetInstance(void);
+ void BluetoothServiceOptionsViewInit(void);
+ void ClearAll(void);
+ UIToggleButton *GetHFP_ToggleButton(void);
+ UIToggleButton *GetA2DP_ToggleButton(void);
+
+ public:
+ virtual void OnStart() override;
+ virtual void OnSetUpView() override;
+ virtual void OnTearDownView() override;
+ virtual void OnStop() override;
+
+ private:
+ bool SetUpBlueToothScrollView(void);
+ UILabelExt *SetBluetoothServiceOptionsViewLabel(LabelConfig &labelconfig);
+ bool SetUpBlueToothLabel(void);
+ bool SetUpBlueToothToggleButton(void);
+ bool SetUpBlueToothImageView(void);
+ UIScrollView *BlueToothScrollView = nullptr;
+ UILabelExt *Title = nullptr;
+ UILabelExt *HFP_Label{nullptr};
+ UILabelExt *A2DP_Label{nullptr};
+ UIImageView *HFP_Image{nullptr};
+ UIImageView *A2DP_Image{nullptr};
+ UIToggleButton *HFP_ToggleButton{nullptr}; // HFP
+ UIToggleButton *A2DP_ToggleButton{nullptr}; // A2DP
+ bool initViewStatus{false};
+ };
+}
+#endif
{\r
public:\r
static ClassicBlueToothModel *GetInstance(void);\r
- void MarkTradionalBlueToothToggleButtonStatus(bool value);\r
- bool TradionalBlueToothToggleButtonStatusInit();\r
\r
private:\r
ClassicBlueToothModel();\r
- ClassicBlueToothModel(const ClassicBlueToothModel &);\r
- ClassicBlueToothModel &operator=(const ClassicBlueToothModel &);\r
+ ClassicBlueToothModel(const ClassicBlueToothModel &) = delete;\r
+ ClassicBlueToothModel &operator=(const ClassicBlueToothModel &) = delete;\r
virtual ~ClassicBlueToothModel();\r
-\r
- private:\r
- // 用来记录蓝牙开关状态,默认关闭状态\r
- bool ClassicBlueToothState{false}; \r
};\r
} // namespace OHOS\r
#endif
\ No newline at end of file
#ifndef CLASSIC_BLUETOOTH_PRESENTER_H\r
#define CLASSIC_BLUETOOTH_PRESENTER_H\r
#include "Presenter.h"\r
-#include "ClassicBlueToothView.h"\r
-#include "wearable_log.h"\r
+#include "View.h"\r
+#include "classicbluetooth/include/ClassicBlueToothView.h"\r
\r
-#include "KeyInputListener.h"\r
-#include "common/key_code.h"\r
namespace OHOS\r
{\r
class ClassicBlueToothView;\r
virtual void OnStop() override;\r
\r
static ClassicBlueToothPresenter *GetInstance();\r
- void SetBluetoothDeviceSwitchState(bool value);\r
+\r
private:\r
// 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
bool OnClick(UIView &view, const ClickEvent &event) override;\r
#include "View.h"\r
#include "components/root_view.h"\r
#include "components/ui_scroll_view.h"\r
-#include "components/ui_label.h"\r
#include "components/ui_label_ext.h"\r
-#include "components/ui_button.h"\r
+#include "components/ui_label_button_ext.h"\r
#include "components/ui_image_view.h"\r
#include "components/ui_toggle_button.h"\r
#include "wearable_log.h"\r
namespace OHOS\r
{\r
- static const char *BLUETOOTHEARPHONEBUTTON = "BlueToothEarPhoneButton"; // 蓝牙耳机按钮ID\r
+ static constexpr const char *BLUETOOTHEARPHONEBUTTON = "BlueToothEarPhoneButton"; // 蓝牙耳机按钮ID\r
+ static constexpr const char *TRADIONALBLUETOOTHBUTTON = "TradionalBluetoothButton"; // 传统蓝牙服按钮ID\r
+ static constexpr const char *BLUETOOTHSERVICEOPTIONSBUTTON = "BluetoothServiceOptionsButton"; // 蓝牙服务选项按钮ID\r
// 返回setting视图界面\r
class ClassicBlueToothPresenter;\r
class ClassicBlueToothView : public View<ClassicBlueToothPresenter>\r
static ClassicBlueToothView *GetInstance(void);\r
void ClassicBlueToothViewInit(void);\r
void ClearAll(void);\r
- bool GetClassicBlueToothState(void);\r
- void SetClassicBlueToothState(bool state);\r
+ UIToggleButton * GetTradionalBlueToothToggleButton(void);\r
\r
public:\r
virtual void OnStart() override;\r
\r
private:\r
bool SetUpBlueToothScrollView(void);\r
- UILabel *SetClassicBlueToothViewLabel(LabelConfig &labelconfig);\r
+ UILabelExt *SetClassicBlueToothViewLabel(LabelConfig &labelconfig);\r
bool SetUpBlueToothLabel(void);\r
- bool SetUpBlueToothEarPhoneButton(void);\r
+ bool SetUpBlueToothButton(void);\r
bool SetUpBlueToothToggleButton(void);\r
- bool SetUpImageView(void);\r
UIScrollView *BlueToothScrollView = nullptr;\r
- UILabel *Title = nullptr;\r
- UILabel *BlueToothEarPhoneLabel = nullptr;\r
- UILabel *TradionalBlueToothLabel = nullptr;\r
- UILabel *AttentionLabel = nullptr;\r
- UIImageView *image[2]{nullptr};\r
- UIButton *BlueToothEarPhoneButton = nullptr;\r
+ UILabelExt *Title = nullptr;\r
+ UILabelButtonExt *BlueToothEarPhoneButton = nullptr; // 蓝牙耳机按钮\r
+ UILabelButtonExt *TradionalBlueToothButton = nullptr; // 传统蓝牙按钮\r
+ UILabelButtonExt *BluetoothServiceOptionsButton = nullptr; // 蓝牙服务选项按钮\r
+ UILabelExt *BlueToothEarPhoneLabel = nullptr; // 蓝牙耳机\r
+ UILabelExt *TradionalBlueToothLabel = nullptr; // 传统蓝牙\r
+ UILabelExt *BluetoothServiceOptionsLabel = nullptr; // 蓝牙服务选项\r
+ UILabelExt *AttentionLabel = nullptr;\r
UIToggleButton *TradionalBlueToothToggleButton = nullptr;\r
bool initViewStatus{false};\r
};\r
--- /dev/null
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include <ohos_types.h>
+#include "wearable_log.h"
+#include "config/include/ConfigModel.h"
+#include "iostream"
+#include "map"
+#include "classicbluetooth/include/BluetoothServiceOptionsPresenter.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
+
+namespace OHOS
+{
+ // 当前Presenter属性实例化的内存指针
+ static BluetoothServiceOptionsPresenter *g_pBluetoothServiceOptionsPresenter = nullptr;
+
+ BluetoothServiceOptionsPresenter::BluetoothServiceOptionsPresenter()
+ {
+ g_pBluetoothServiceOptionsPresenter = this;
+ }
+
+ BluetoothServiceOptionsPresenter::~BluetoothServiceOptionsPresenter()
+ {
+ g_pBluetoothServiceOptionsPresenter = nullptr;
+ }
+
+ BluetoothServiceOptionsPresenter *BluetoothServiceOptionsPresenter::GetInstance()
+ {
+ return g_pBluetoothServiceOptionsPresenter;
+ }
+
+ void BluetoothServiceOptionsPresenter::OnStart()
+ {
+ Presenter<BluetoothServiceOptionsView>::OnStart();
+ }
+
+ void BluetoothServiceOptionsPresenter::OnPause(void)
+ {
+
+ Presenter<BluetoothServiceOptionsView>::OnPause();
+ }
+
+ void BluetoothServiceOptionsPresenter::OnResume(void)
+ {
+
+ Presenter<BluetoothServiceOptionsView>::OnResume();
+ }
+
+ void BluetoothServiceOptionsPresenter::OnStop(void)
+ {
+ Presenter<BluetoothServiceOptionsView>::OnStop();
+ }
+
+ bool BluetoothServiceOptionsPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnClick");
+ BluetoothServiceOptionsView *classicBlueToothView = BluetoothServiceOptionsView::GetInstance();
+ if (classicBlueToothView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::GetInstance");
+ return false;
+ }
+
+ std::map<UIView *, std::string> buttonMap = {
+ {classicBlueToothView->GetHFP_ToggleButton(), "HFP"},
+ {
+ classicBlueToothView->GetA2DP_ToggleButton(),
+ "A2DP",
+ }};
+
+ auto it = buttonMap.find(&view);
+ if (it != buttonMap.end())
+ {
+ UIToggleButton *toggleButton = dynamic_cast<UIToggleButton *>(&view);
+ if (toggleButton != nullptr)
+ {
+ if (toggleButton->GetState() == true)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
+ if (it->second == "HFP")
+ {
+ ConfigModel::GetInstance()->SetHFPState(true);
+ }
+ else if (it->second == "A2DP")
+ {
+ ConfigModel::GetInstance()->SetA2DPState(true);
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
+ if (it->second == "HFP")
+ {
+ ConfigModel::GetInstance()->SetHFPState(false);
+ }
+ else if (it->second == "A2DP")
+ {
+ ConfigModel::GetInstance()->SetA2DPState(false);
+ }
+ }
+ }
+
+ return true;
+ }
+ }
+
+ bool BluetoothServiceOptionsPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ UNUSED(event);
+ return true;
+ }
+
+ bool BluetoothServiceOptionsPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::OnDragEnd");
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+
+ return true;
+ }
+
+ bool BluetoothServiceOptionsPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::OnKeyAct");
+ uint16 keyID = event.GetKeyId();
+ uint16 keyState = event.GetState();
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+ {
+ NativeAbility::GetInstance().Back();
+ }
+ return true;
+ }
+}
--- /dev/null
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsPresenter.h"
+#include "config/include/ConfigModel.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr};
+
+ BluetoothServiceOptionsView::BluetoothServiceOptionsView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BluetoothServiceOptionsView");
+ g_pBluetoothServiceOptionsView = this;
+ }
+
+ BluetoothServiceOptionsView::~BluetoothServiceOptionsView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "~BluetoothServiceOptionsView::BluetoothServiceOptionsView");
+ ClearAll();
+ g_pBluetoothServiceOptionsView = nullptr;
+ }
+
+ BluetoothServiceOptionsView *BluetoothServiceOptionsView::GetInstance()
+ {
+ return g_pBluetoothServiceOptionsView;
+ }
+
+ void BluetoothServiceOptionsView::ClearAll()
+ {
+ 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;
+ }
+ }
+
+ bool BluetoothServiceOptionsView::SetUpBlueToothScrollView(void)
+ {
+ BlueToothScrollView = new UIScrollView();
+ if (BlueToothScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BlueToothScrollView new fail!");
+ return false;
+ }
+ BlueToothScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ BlueToothScrollView->SetScrollBlankSize(35);
+ BlueToothScrollView->SetReboundSize(50);
+ BlueToothScrollView->SetDirection(1);
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(BluetoothServiceOptionsPresenter::GetInstance());
+ if (draglistener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::draglistener can not be nullptr!");
+ return false;
+ }
+ BlueToothScrollView->SetOnDragListener(draglistener);
+ BlueToothScrollView->SetTouchable(true);
+ BlueToothScrollView->SetDraggable(true);
+
+ return true;
+ }
+
+ // 标签配置
+ UILabelExt *BluetoothServiceOptionsView::SetBluetoothServiceOptionsViewLabel(LabelConfig &labelconfig)
+ {
+ UILabelExt *label = new UILabelExt();
+ if (label == nullptr)
+ {
+ return nullptr;
+ }
+ 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->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+ return label;
+ }
+
+ // 标签初始化
+ bool BluetoothServiceOptionsView::SetUpBlueToothLabel(void)
+ {
+ LabelConfig labelconfig = {
+ .left = 93,
+ .top = 52,
+ .width = 280,
+ .height = 40,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .text = "蓝牙服务选项",
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ Title = SetBluetoothServiceOptionsViewLabel(labelconfig);
+ if (nullptr == Title)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::Title is nullptr!");
+ return false;
+ }
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ /* -------------------------------------------------------------------------- */
+ labelconfig = {
+ .left = 90,
+ .top = 153,
+ .width = 180,
+ .height = 40,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .text = "通话蓝牙",
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ HFP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig);
+ if (nullptr == HFP_Label)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::HFP_Label is nullptr!");
+ return false;
+ }
+ labelconfig.top = 273;
+ labelconfig.text = "媒体蓝牙";
+ A2DP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig);
+ if (nullptr == A2DP_Label)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::A2DP_Label is nullptr!");
+ return false;
+ }
+
+ return true;
+ }
+
+ // ToggleButton初始化
+ bool BluetoothServiceOptionsView::SetUpBlueToothToggleButton()
+ {
+ HFP_ToggleButton = new UIToggleButton();
+ if (nullptr == HFP_ToggleButton)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BluetoothServiceOptionsView::BlueToothEarPhoneButton new fail!");
+ return false;
+ }
+ HFP_ToggleButton->SetPosition(298, 145, 100, 50);
+ HFP_ToggleButton->SetState(ConfigModel::GetInstance()->GetHFPState());
+ HFP_ToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ HFP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+ /* -------------------------------------------------------------------------- */
+ A2DP_ToggleButton = new UIToggleButton();
+ if (A2DP_ToggleButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::A2DP_ToggleButton is nullptr!");
+ return false;
+ }
+ A2DP_ToggleButton->SetPosition(298, 265, 100, 50);
+ A2DP_ToggleButton->SetState(ConfigModel::GetInstance()->GetA2DPState());
+ A2DP_ToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0xffffffff);
+ A2DP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+ /* -------------------------------------------------------------------------- */
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(BluetoothServiceOptionsPresenter::GetInstance());
+ HFP_ToggleButton->SetOnClickListener(clickListener);
+ A2DP_ToggleButton->SetOnClickListener(clickListener);
+
+ return true;
+ }
+
+ // 图片初始化
+ bool BluetoothServiceOptionsView::SetUpBlueToothImageView(void)
+ {
+ HFP_Image = new UIImageView();
+ if (nullptr == HFP_Image)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BluetoothServiceOptionsView::HFP_Image new fail!");
+ return false;
+ }
+ HFP_Image->SetPosition(43, 120, 380, 100);
+ HFP_Image->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ HFP_Image->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ HFP_Image->SetStyle(STYLE_BORDER_RADIUS, 100);
+ /* -------------------------------------------------------------------------- */
+ A2DP_Image = new UIImageView();
+ if (nullptr == A2DP_Image)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BluetoothServiceOptionsView::A2DP_Image new fail!");
+ return false;
+ }
+ A2DP_Image->SetPosition(43, 240, 380, 100);
+ A2DP_Image->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ A2DP_Image->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ A2DP_Image->SetStyle(STYLE_BORDER_RADIUS, 100);
+ return true;
+ }
+
+ UIToggleButton *BluetoothServiceOptionsView::GetHFP_ToggleButton(void)
+ {
+ return HFP_ToggleButton;
+ }
+ UIToggleButton *BluetoothServiceOptionsView::GetA2DP_ToggleButton(void)
+ {
+ return A2DP_ToggleButton;
+ }
+
+ /// @brief 蓝牙界面初始化
+ /// @param void
+ void BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit(void)
+ {
+ if (!SetUpBlueToothScrollView())
+ {
+ return;
+ }
+
+ if (!SetUpBlueToothImageView())
+ {
+ return;
+ }
+
+ if (!SetUpBlueToothLabel())
+ {
+ return;
+ }
+
+ if (!SetUpBlueToothToggleButton())
+ {
+ return;
+ }
+
+ initViewStatus = true;
+ }
+
+ void BluetoothServiceOptionsView::OnStart()
+ {
+ View<BluetoothServiceOptionsPresenter>::OnStart();
+ BluetoothServiceOptionsViewInit();
+
+ // 增加按键监听
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BluetoothServiceOptionsPresenter::GetInstance();
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ }
+
+ void BluetoothServiceOptionsView::OnSetUpView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnSetUpView");
+ View<BluetoothServiceOptionsPresenter>::OnSetUpView();
+ BlueToothScrollView->Add(Title);
+ BlueToothScrollView->Add(HFP_Image);
+ BlueToothScrollView->Add(A2DP_Image);
+ BlueToothScrollView->Add(HFP_Label);
+ BlueToothScrollView->Add(A2DP_Label);
+ BlueToothScrollView->Add(HFP_ToggleButton);
+ BlueToothScrollView->Add(A2DP_ToggleButton);
+ RootView::GetInstance()->Add(BlueToothScrollView);
+ Draw();
+ }
+
+ void BluetoothServiceOptionsView::OnTearDownView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnTearDownView");
+ View<BluetoothServiceOptionsPresenter>::OnTearDownView();
+ return;
+ }
+
+ void BluetoothServiceOptionsView::OnStop()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnStop");
+ View<BluetoothServiceOptionsPresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ return;
+ }
+
+}
#include "classicbluetooth/include/ClassicBlueToothModel.h"\r
-#include "classicbluetooth/include/ClassicBlueToothPresenter.h"\r
-\r
namespace OHOS\r
{\r
- ClassicBlueToothModel::ClassicBlueToothModel()\r
- {\r
- ConfigModel *p_ConfigModel = ConfigModel::GetInstance();\r
- ClassicBlueToothState = p_ConfigModel->GetClassicBlueToothState();\r
- }\r
+ ClassicBlueToothModel::ClassicBlueToothModel() {}\r
\r
ClassicBlueToothModel::~ClassicBlueToothModel() {}\r
\r
return &instance;\r
}\r
\r
- /// @brief 标记蓝牙开关的状态\r
- /// @param value true 开启状态 false 关闭状态\r
- void ClassicBlueToothModel::MarkTradionalBlueToothToggleButtonStatus(bool value)\r
- {\r
- ClassicBlueToothState = value;\r
- }\r
-\r
- /// @brief 根据标记蓝牙开关的状态来确定蓝牙切换按钮是"开"还是"关状态\r
- /// @return true 初始化成功 false 初始化失败\r
- bool ClassicBlueToothModel::TradionalBlueToothToggleButtonStatusInit(void)\r
- {\r
- ClassicBlueToothPresenter *Classicbluetoothpresenter = ClassicBlueToothPresenter::GetInstance();\r
- if (Classicbluetoothpresenter == nullptr)\r
- {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TradionalBlueToothToggleButtonStatusInit ClassicBlueToothPresenter GetInstance fail");\r
- return false;\r
- }\r
- Classicbluetoothpresenter->SetBluetoothDeviceSwitchState(ClassicBlueToothState); // 蓝牙开关状态\r
- return true;\r
- }\r
} // namespace OHOS\r
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-25 11:50:57\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-25 15:54:05\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp\r
+ */\r
+#include "classicbluetooth/include/ClassicBlueToothPresenter.h"\r
+#include "classicbluetooth/include/ClassicBlueToothView.h"\r
#include "AppViewIDs.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
#include "NativeAbility.h"\r
-#include "graphic_math.h"\r
-#include "classicbluetooth/include/ClassicBlueToothPresenter.h"\r
-#include "classicbluetooth/include/ClassicBlueToothModel.h"\r
#include "custom_utils.h"\r
+#include "common/key_code.h"\r
+#include <ohos_types.h>\r
+#include "wearable_log.h"\r
+#include "config/include/ConfigModel.h"\r
namespace OHOS\r
{\r
// 当前Presenter属性实例化的内存指针\r
Presenter<ClassicBlueToothView>::OnStop();\r
}\r
\r
- /// @brief 设置蓝牙设备的开关状态\r
- /// @param value true 开启蓝牙 false 关闭蓝牙\r
- void ClassicBlueToothPresenter::SetBluetoothDeviceSwitchState(bool value)\r
- {\r
- ClassicBlueToothView *classicBlueToothView = ClassicBlueToothView::GetInstance();\r
- if (classicBlueToothView == nullptr)\r
- {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetBluetoothDeviceSwitchState ClassicBlueToothView GetInstance fail");\r
- return;\r
- }\r
- if (value != false)\r
- {\r
- classicBlueToothView->SetClassicBlueToothState(true);\r
- ClassicBlueToothModel::GetInstance()->MarkTradionalBlueToothToggleButtonStatus(false); // 将Model层保存的状态清除\r
- }\r
- }\r
-\r
bool ClassicBlueToothPresenter::OnClick(UIView &view, const ClickEvent &event)\r
{\r
UNUSED(event);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnClick");\r
ClassicBlueToothView *classicBlueToothView = ClassicBlueToothView::GetInstance();\r
if (classicBlueToothView == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::GetInstance");\r
return false;\r
}\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::OnClick");\r
+\r
if (strcmp(view.GetViewId(), BLUETOOTHEARPHONEBUTTON) == 0)\r
{\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_BLUETOOTH_EARPHONE);\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE);\r
+ }\r
+ else if (strcmp(view.GetViewId(), BLUETOOTHSERVICEOPTIONSBUTTON) == 0)\r
+ {\r
+ if (classicBlueToothView->GetTradionalBlueToothToggleButton()->GetState() == true)\r
+ {\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_SERVICE_OPTIONS);\r
+ }\r
}\r
\r
return true;\r
\r
bool ClassicBlueToothPresenter::OnDrag(UIView &view, const DragEvent &event)\r
{\r
+ UNUSED(view);\r
+ UNUSED(event);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDrag");\r
return true;\r
}\r
\r
bool ClassicBlueToothPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
{\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDragEnd");\r
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
{\r
- uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); // 上一个SliceId\r
- uint16_t currentSlice = NativeAbility::GetInstance().GetCurSliceId(); // 当前SliceId\r
-\r
- if (preSlice == VIEW_MAIN)\r
- {\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);\r
- }\r
- else\r
- {\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
- }\r
+ NativeAbility::GetInstance().Back();\r
}\r
\r
return true;\r
\r
extern "C"\r
{\r
- void closeBle(void);//主动关闭蓝牙\r
- void openBle(void);//主动开启蓝牙\r
- bool get_ble_status(void);//获取蓝牙是否关闭还是开启 1就是开启 0关闭 一开机默认是开启蓝牙\r
+ void closeBle(void); // 主动关闭蓝牙\r
+ void openBle(void); // 主动开启蓝牙\r
+ bool get_ble_status(void); // 获取蓝牙是否关闭还是开启 1就是开启 0关闭 一开机默认是开启蓝牙\r
void getDeviceState(void);\r
}\r
bool ClassicBlueToothPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
{\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnChange");\r
switch (state)\r
{\r
case UICheckBox::SELECTED:\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BlueTooth Capability Is Enabled");\r
\r
- ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_CLASSIC_BT_SERVICE_ON,true);\r
+ start_custom_ble_service(); // 主动开启蓝牙\r
\r
- start_custom_ble_service();//主动开启蓝牙\r
+ ConfigModel::GetInstance()->SetClassicBlueToothState(true);\r
break;\r
case UICheckBox::UNSELECTED:\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BlueTooth Capability Is Disabled");\r
- ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_CLASSIC_BT_SERVICE_ON,false);\r
\r
stop_custom_ble_service();\r
+\r
+ ConfigModel::GetInstance()->SetClassicBlueToothState(false);\r
break;\r
default:\r
break;\r
// 如果是power键,且是亮屏状态,按键释放就返回上一级\r
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)\r
{\r
- uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
- if (preSlice == VIEW_SETTING || VIEW_BLUETOOTH_EARPHONE)\r
- {\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
- }\r
- else\r
- {\r
- NativeAbility::GetInstance().ChangeSlice(preSlice);\r
- }\r
+ NativeAbility::GetInstance().Back();\r
}\r
return true;\r
}\r
#include "classicbluetooth/include/ClassicBlueToothView.h"\r
#include "classicbluetooth/include/ClassicBlueToothPresenter.h"\r
-#include "classicbluetooth/include/ClassicBlueToothModel.h"\r
-\r
+#include "config/include/ConfigModel.h"\r
+#include "UiConfig.h"\r
namespace OHOS\r
{\r
static ClassicBlueToothView *g_pClassicBlueToothView{nullptr};\r
{\r
BlueToothScrollView->RemoveAll();\r
\r
- bool state = GetClassicBlueToothState();\r
- if (state == true)\r
- {\r
- ClassicBlueToothModel::GetInstance()->MarkTradionalBlueToothToggleButtonStatus(true);\r
- // ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_CLASSIC_BT_SERVICE_ON,true);\r
- // ConfigModel::GetInstance()->WriteJsonData_Bool(ConfigModel::GetInstance()->GetcJSON(), "ClassicBlueToothState", true);\r
- }\r
- else\r
- {\r
- ClassicBlueToothModel::GetInstance()->MarkTradionalBlueToothToggleButtonStatus(false);\r
- // ConfigModel::GetInstance()->WriteJsonData_Bool(ConfigModel::GetInstance()->GetcJSON(), "ClassicBlueToothState", false);\r
- }\r
-\r
delete Title;\r
Title = nullptr;\r
\r
+ delete BlueToothEarPhoneButton;\r
+ BlueToothEarPhoneButton = nullptr;\r
+\r
+ delete TradionalBlueToothButton;\r
+ TradionalBlueToothButton = nullptr;\r
+\r
+ delete BluetoothServiceOptionsButton;\r
+ BluetoothServiceOptionsButton = nullptr;\r
+\r
delete BlueToothEarPhoneLabel;\r
BlueToothEarPhoneLabel = nullptr;\r
\r
delete AttentionLabel;\r
AttentionLabel = nullptr;\r
\r
- for (int i = 0; i < 2; i++)\r
- {\r
- delete image[i];\r
- image[i] = nullptr;\r
- }\r
-\r
- delete BlueToothEarPhoneButton;\r
- BlueToothEarPhoneButton = nullptr;\r
-\r
delete TradionalBlueToothToggleButton;\r
TradionalBlueToothToggleButton = nullptr;\r
\r
}\r
\r
// 标签配置\r
- UILabel *ClassicBlueToothView::SetClassicBlueToothViewLabel(LabelConfig &labelconfig)\r
+ UILabelExt *ClassicBlueToothView::SetClassicBlueToothViewLabel(LabelConfig &labelconfig)\r
{\r
- UILabel *label = new UILabel();\r
+ UILabelExt *label = new UILabelExt();\r
if (label == nullptr)\r
{\r
return nullptr;\r
label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高\r
label->SetText(labelconfig.text); // 内容\r
label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。\r
- label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
return label;\r
}\r
bool ClassicBlueToothView::SetUpBlueToothLabel(void)\r
{\r
LabelConfig labelconfig = {\r
- .left = 203,\r
+ .left = 93,\r
.top = 52,\r
- .width = 65,\r
- .height = 35,\r
+ .width = 280,\r
+ .height = 40,\r
.fontSize = 30,\r
.lineHeigh = 35,\r
.text = "蓝牙",\r
- .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,\r
};\r
Title = SetClassicBlueToothViewLabel(labelconfig);\r
if (nullptr == Title)\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::Title is nullptr!");\r
return false;\r
}\r
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ /* -------------------------------------------------------------------------- */\r
labelconfig = {\r
.left = 90,\r
.top = 153,\r
- .width = 120,\r
- .height = 35,\r
+ .width = 180,\r
+ .height = 40,\r
.fontSize = 30,\r
.lineHeigh = 35,\r
.text = "蓝牙耳机",\r
- .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,\r
};\r
BlueToothEarPhoneLabel = SetClassicBlueToothViewLabel(labelconfig);\r
if (nullptr == BlueToothEarPhoneLabel)\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::BlueToothEarPhoneLabel is nullptr!");\r
return false;\r
}\r
+ /* -------------------------------------------------------------------------- */\r
labelconfig.top = 273;\r
labelconfig.text = "传统蓝牙";\r
TradionalBlueToothLabel = SetClassicBlueToothViewLabel(labelconfig);\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::TradionalBlueToothLabel is nullptr!");\r
return false;\r
}\r
-\r
+ /* -------------------------------------------------------------------------- */\r
+ labelconfig.top = 393;\r
+ labelconfig.text = "蓝牙服务选项";\r
+ BluetoothServiceOptionsLabel = SetClassicBlueToothViewLabel(labelconfig);\r
+ if (nullptr == BluetoothServiceOptionsLabel)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::BluetoothServiceOptionsLabel is nullptr!");\r
+ return false;\r
+ }\r
+ /* -------------------------------------------------------------------------- */\r
labelconfig = {\r
.left = 53,\r
- .top = 379,\r
+ .top = 499,\r
.width = 360,\r
.height = 180,\r
.fontSize = 20,\r
return true;\r
}\r
\r
- // 蓝牙耳机按钮\r
- bool ClassicBlueToothView::SetUpBlueToothEarPhoneButton(void)\r
+ // 按钮初始化\r
+ bool ClassicBlueToothView::SetUpBlueToothButton(void)\r
{\r
- BlueToothEarPhoneButton = new UIButton();\r
+ BlueToothEarPhoneButton = new UILabelButtonExt();\r
if (BlueToothEarPhoneButton == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BlueToothEarPhoneButton new fail!");\r
BlueToothEarPhoneButton->SetPosition(43, 120, 380, 100);\r
BlueToothEarPhoneButton->SetViewId(BLUETOOTHEARPHONEBUTTON);\r
BlueToothEarPhoneButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4fc34c, UIButton::PRESSED);\r
- BlueToothEarPhoneButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED);\r
- BlueToothEarPhoneButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);\r
-\r
+ BlueToothEarPhoneButton->SetImagePosition(326, 37);\r
+ BlueToothEarPhoneButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE);\r
+ BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);\r
+ /* -------------------------------------------------------------------------- */\r
+ TradionalBlueToothButton = new UILabelButtonExt();\r
+ if (TradionalBlueToothButton == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::TradionalBlueToothButton new fail!");\r
+ return false;\r
+ }\r
+ TradionalBlueToothButton->SetPosition(43, 240,380,100); \r
+ TradionalBlueToothButton->SetViewId(TRADIONALBLUETOOTHBUTTON);\r
+ TradionalBlueToothButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ TradionalBlueToothButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16);\r
+ TradionalBlueToothButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);\r
+ /* -------------------------------------------------------------------------- */\r
+ BluetoothServiceOptionsButton = new UILabelButtonExt();\r
+ if (BluetoothServiceOptionsButton == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BluetoothServiceOptionsButton new fail!");\r
+ return false;\r
+ }\r
+ BluetoothServiceOptionsButton->SetPosition(43, 360, 380, 100);\r
+ BluetoothServiceOptionsButton->SetViewId(BLUETOOTHSERVICEOPTIONSBUTTON);\r
+ BluetoothServiceOptionsButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ BluetoothServiceOptionsButton->SetImagePosition(326, 37);\r
+ BluetoothServiceOptionsButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE);\r
+ BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);\r
+ /* -------------------------------------------------------------------------- */\r
UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(ClassicBlueToothPresenter::GetInstance());\r
BlueToothEarPhoneButton->SetOnClickListener(clickListener);\r
+ BluetoothServiceOptionsButton->SetOnClickListener(clickListener);\r
\r
return true;\r
}\r
\r
- // 手表蓝牙开关按钮\r
+ // 传统蓝牙开关按钮\r
bool ClassicBlueToothView::SetUpBlueToothToggleButton()\r
{\r
TradionalBlueToothToggleButton = new UIToggleButton();\r
return false;\r
}\r
TradionalBlueToothToggleButton->SetPosition(298, 265, 100, 50);\r
+ TradionalBlueToothToggleButton->SetState(ConfigModel::GetInstance()->GetClassicBlueToothState());\r
TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
- TradionalBlueToothToggleButton->SetImages("/user/res/TOGGLEBUTTON_ON.bin", "/user/res/TOGGLEBUTTON_OFF.bin");\r
+ TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);\r
UICheckBox::OnChangeListener *changeListener = static_cast<UICheckBox::OnChangeListener *>(ClassicBlueToothPresenter::GetInstance());\r
TradionalBlueToothToggleButton->SetOnChangeListener(changeListener);\r
return true;\r
}\r
\r
- bool ClassicBlueToothView::SetUpImageView(void)\r
+ UIToggleButton * ClassicBlueToothView::GetTradionalBlueToothToggleButton(void)\r
{\r
- image[0] = new UIImageView();\r
- if (nullptr == image[0])\r
- {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::image[0] new fail!");\r
- return false;\r
- }\r
- image[0]->SetPosition(369, 157, 14, 26);\r
- image[0]->SetSrc("/user/res/SETTING_NEXT.bin");\r
-\r
- image[1] = new UIImageView();\r
- if (nullptr == image[1])\r
- {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::image[1] new fail!");\r
- return false;\r
- }\r
- image[1]->SetPosition(43, 240, 380, 100);\r
- image[1]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- image[1]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- image[1]->SetStyle(STYLE_BORDER_RADIUS, 100);\r
- return true;\r
- }\r
-\r
- /// @brief 获取蓝牙切换按钮的状态\r
- /// @param void\r
- /// @return true 表示开启状态 false 表示开启状态\r
- bool ClassicBlueToothView::GetClassicBlueToothState(void)\r
- {\r
- return TradionalBlueToothToggleButton->GetState();\r
- }\r
-\r
- /// @brief 设置蓝牙切换按钮的状态\r
- /// @param state true 开启 false 关闭\r
- void ClassicBlueToothView::SetClassicBlueToothState(bool state)\r
- {\r
- if (TradionalBlueToothToggleButton == nullptr)\r
- {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TradionalBlueToothToggleButton is nullptr!");\r
- return;\r
- }\r
- TradionalBlueToothToggleButton->SetState(state);\r
+ return TradionalBlueToothToggleButton;\r
}\r
\r
/// @brief 蓝牙界面初始化\r
return;\r
}\r
\r
- if (!SetUpBlueToothLabel())\r
+ if (!SetUpBlueToothButton())\r
{\r
return;\r
}\r
\r
- if (!SetUpBlueToothEarPhoneButton())\r
+ if (!SetUpBlueToothLabel())\r
{\r
return;\r
}\r
return;\r
}\r
\r
- if (!SetUpImageView())\r
- {\r
- return;\r
- }\r
- ClassicBlueToothModel::GetInstance()->TradionalBlueToothToggleButtonStatusInit();\r
initViewStatus = true;\r
}\r
\r
View<ClassicBlueToothPresenter>::OnSetUpView();\r
BlueToothScrollView->Add(Title);\r
BlueToothScrollView->Add(BlueToothEarPhoneButton);\r
- BlueToothScrollView->Add(image[0]);\r
- BlueToothScrollView->Add(image[1]);\r
+ BlueToothScrollView->Add(TradionalBlueToothButton);\r
+ BlueToothScrollView->Add(BluetoothServiceOptionsButton);\r
BlueToothScrollView->Add(BlueToothEarPhoneLabel);\r
BlueToothScrollView->Add(TradionalBlueToothLabel);\r
+ BlueToothScrollView->Add(BluetoothServiceOptionsLabel);\r
BlueToothScrollView->Add(AttentionLabel);\r
BlueToothScrollView->Add(TradionalBlueToothToggleButton);\r
RootView::GetInstance()->Add(BlueToothScrollView);\r
CONFIGMODEL_ITEM_CALL_VOLUME,//通话音量
CONFIGMODEL_ITEM_VOLTE_CALL,//VoLTE通话
CONFIGMODEL_ITEM_MOTIONRECOGNITION,//运动识别
+ CONFIGMODEL_ITEM_HFP, //通话蓝牙开关
+ CONFIGMODEL_ITEM_A2DP,//媒体蓝牙开关
CONFIGMODEL_ITEM_MAX,
} ;
/* --------------------------------自定义封装 set与get方法 ------------------------------- */
- bool GetClassicBlueToothState(void);
void SetLanguage(int languageid);
int GetLanguage();
void SetSilentMode(bool state);
bool GetSilentMode(void);
+
+ /* ------------------------------- 蓝牙相关set与get ------------------------------ */
+ void SetClassicBlueToothState(bool value);
+ bool GetClassicBlueToothState(void);
+
+ void SetHFPState(bool value);
+ bool GetHFPState(void);
+
+ void SetA2DPState(bool value);
+ bool GetA2DPState(void);
+
/* ---------------------------------- 运动识别相关set与get ---------------------------------- */
void SetMotionRecognition(bool state);
bool GetMotionRecognition(void);
{ConfigDataType::DATATYPE_INT, "CallVolume", "100" },// CONFIGMODEL_ITEM_CALL_VOLUME //
{ConfigDataType::DATATYPE_BOOL, "VoLTECall", "false" },// CONFIGMODEL_ITEM_VOLTE_CALL
{ConfigDataType::DATATYPE_BOOL, "MotionRecognition", "false" },// CONFIGMODEL_ITEM_MOTIONRECOGNITION
+ {ConfigDataType::DATATYPE_BOOL, "HFP", "false" },// CONFIGMODEL_ITEM_HFP
+ {ConfigDataType::DATATYPE_BOOL, "A2DP", "false" },// CONFIGMODEL_ITEM_A2DP
};
ConfigModel(); // 私有构造函数,确保无法在外部实例化
ConfigModel(const ConfigModel &) = delete; // 禁止拷贝构造
return get_configData_int(CONFIGMODEL_ITEM_SCREEN_OFF_TIMEOUT_VALUE);
}
+ /// @brief 设置蓝牙开关状态
+ void ConfigModel::SetClassicBlueToothState(bool value)
+ {
+ set_condigData_Bool(CONFIGMODEL_ITEM_CLASSIC_BT_SERVICE_ON,value);
+ }
+
/// @brief 获取蓝牙开关状态
bool ConfigModel::GetClassicBlueToothState(void)
{
return get_configData_bool(CONFIGMODEL_ITEM_CLASSIC_BT_SERVICE_ON);
}
+ // 设置HFP开启状态
+ void ConfigModel::SetHFPState(bool value)
+ {
+ set_condigData_Bool(CONFIGMODEL_ITEM_HFP,value);
+ }
+
+ //获取HFP开启状态
+ bool ConfigModel::GetHFPState(void)
+ {
+ return get_configData_bool(CONFIGMODEL_ITEM_HFP);
+ }
+
+ //设置A2DP开启状态
+ void ConfigModel::SetA2DPState(bool value)
+ {
+ set_condigData_Bool(CONFIGMODEL_ITEM_A2DP,value);
+ }
+
+ //获取A2DP开启状态
+ bool ConfigModel::GetA2DPState(void)
+ {
+ return get_configData_bool(CONFIGMODEL_ITEM_A2DP);
+ }
+
/* -------------------------------------------------------------------------- */
void ConfigModel::SetLanguage(int language)
{