From: luozheng <1732036298@qq.com> Date: Fri, 26 Apr 2024 07:37:44 +0000 (+0800) Subject: 优化下拉控制中心,添加信号强度和4G图标显示 X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~70 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=f87c2da5918c880b9956b4c7086797118bd948f0;p=mirrors%2FFD230.git 优化下拉控制中心,添加信号强度和4G图标显示 --- diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_image.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_image.h index ab08e2c52..c19b9b08a 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_image.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_image.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-16 14:43:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-27 10:02:08 + * @LastEditTime: 2024-04-26 14:53:43 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_image.h */ #ifndef UI_RESOURCE_IMAGE_H @@ -66,20 +66,22 @@ namespace OHOS static const int CLOCK_MINUTE = 0x300016; static const int CLOCK_SECOND = 0x300017; /* -------------------------------------------------------------------------- */ - static const int DROPDOWN_BLUETOOTHCONNECTED = 0x400001; // 蓝牙连接中 - static const int DROPDOWN_BLUETOOTHDISCONNECTED = 0x400002; // 蓝牙未连接 - static const int DROPDOWN_DNOTDISTURB = 0x400003; // 勿扰模式 - static const int DROPDOWN_EARPHONESCONNECTED = 0x400004; // 耳机连接中 - static const int DROPDOWN_EARPHONESDISCONNECTED = 0x400005; // 耳机未连接 - static const int DROPDOWN_FINDPHONE = 0x400006; // 找手机 - static const int DROPDOWN_ICONELLIPSEBLACK = 0x400007; // 图标椭圆黑色 - static const int DROPDOWN_ICONELLIPSEPURPLE = 0x400008; // 图标椭圆紫色 - static const int DROPDOWN_LIGHTING = 0x400009; // 亮屏 - static const int DROPDOWN_LINE = 0x40000a; // 线 - static const int DROPDOWN_PHONECONNECTED = 0x40000b; // 手机连接中 - static const int DROPDOWN_PHONEDISCONNECTED = 0x40000c; // 手机未连接 - static const int DROPDOWN_SAVEPOWER = 0x40000d; // 省电模式 - static const int DROPDOWN_SETTING = 0x40000e; // 设置 + static const int DROPDOWN_BLUETOOTH = 0x400001; // 蓝牙 + static const int DROPDOWN_BLUETOOTHCONNECTED = 0x400002; // 蓝牙连接中 + static const int DROPDOWN_BLUETOOTHDISCONNECTED = 0x400003; // 蓝牙未连接 + static const int DROPDOWN_DNOTDISTURB = 0x400004; // 勿扰模式 + static const int DROPDOWN_EARPHONESCONNECTED = 0x400005; // 耳机连接中 + static const int DROPDOWN_EARPHONESDISCONNECTED = 0x400006; // 耳机未连接 + static const int DROPDOWN_FINDPHONE = 0x400007; // 找手机 + static const int DROPDOWN_ICONELLIPSEBLACK = 0x400008; // 图标椭圆黑色 + static const int DROPDOWN_ICONELLIPSEPURPLE = 0x400009; // 图标椭圆紫色 + static const int DROPDOWN_LIGHTING = 0x40000a; // 亮屏 + static const int DROPDOWN_LINE = 0x40000b; // 线 + static const int DROPDOWN_NOSIGNAL = 0x40000c; // 无信号 + static const int DROPDOWN_PHONECONNECTED = 0x40000d; // 手机连接中 + static const int DROPDOWN_PHONEDISCONNECTED = 0x40000e; // 手机未连接 + static const int DROPDOWN_SAVEPOWER = 0x40000f; // 省电模式 + static const int DROPDOWN_SETTING = 0x400010; // 设置 /* -------------------------------------------------------------------------- */ static const int COMPASS_COMPASS0 = 0x500001; // 背景 static const int COMPASS_COMPASS1 = 0x500002; // 标记点图片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp index 8148416ad..c91d3375f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 11:58:37 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 11:09:23 + * @LastEditTime: 2024-04-25 16:39:57 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp */ #include "AppViewIDs.h" @@ -79,14 +79,11 @@ namespace OHOS if (&view == p_DnotDisturbView->GetButtonOn())//开启勿扰模式 { DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(true); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } else if (&view == p_DnotDisturbView->GetButtonOff()) { - //DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } @@ -100,8 +97,7 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h index 451746afd..caf82a29b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-01 15:10:34 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-10 15:48:47 + * @LastEditTime: 2024-04-26 11:45:11 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h */ @@ -42,6 +42,9 @@ namespace OHOS static constexpr const char *DROPDOWN_CLICK_SAVEELE = "dropdownclicksaveele"; // 省电 static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; // 找手机 + static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = "connectedstatusbackgroundbutton"; // 连接状态按钮 + + constexpr uint16_t VERTICAL_STATUS = 1; constexpr uint16_t HORIZONTAL_STATUS = 0; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h index 513f24afd..0fe914566 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h @@ -1,10 +1,10 @@ -/*** - * @Date: 2024-04-16 19:15:33 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-04-16 19:56:24 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-17 15:26:49 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-26 15:17:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h */ - /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: WeekStep @@ -31,6 +31,13 @@ extern uint8_t battery_get_voltage(float *voltage); namespace OHOS { + static constexpr int16_t SETTING_INDEX = 0; + static constexpr int16_t LIGHTING_INDEX = 1; + static constexpr int16_t DNOTDISTURB_INDEX = 2; + static constexpr int16_t SAVEPOWER_INDEX = 3; + static constexpr int16_t FINDPHONE_INDEX = 4; + static constexpr int16_t MAX_INDEX = 5; + class PullUpDownView : public UICardPage { public: @@ -43,26 +50,41 @@ namespace OHOS void UpdateDnotDisturbStatus(int status); bool InitBaseData(); // 初始化基础数据组件 void RefreshData(); // 刷新数据 - + UILabel *GetTimeLabel(); UILabel *GetDateLabel(); UILabel *GetWeekLabel(); UIBoxProgress *GetProgress(); + void ClearAll(); + bool InitSingalComponentsView(); + void ClearAllSingalComponentsView(); + void SetSingalComponentsVisible(int SignalStrength); + int GetSignalStrength(void); + + void ClearAllConnectedStatusComponentsView(); + bool GetPhoneConnectedStatus(void); + bool GetEarPhoneConnectedStatus(void); + bool GetBluetoothConnectedStatus(void); + private: - UIImageView *dropSetting{nullptr}; // 设置 - UIImageView *dropLighting{nullptr}; // 亮屏 - UIImageView *dropDnotDisturb{nullptr}; // 勿扰模式 - UIImageView *dropSavePower{nullptr}; // 省电 - UIImageView *drofindPhone{nullptr}; // 找手机 - UIImageView *dropIconBackground[5]{nullptr}; // 放置各个icon的背景 - UIImageView *showPhoneConnectedStatus{nullptr}; // 显示手机连接状态 - UIImageView *showEarPhoneConnectedStatus{nullptr}; // 显示耳机连接状态 - UIImageView *showBluetoothConnectedStatus{nullptr}; // 显示蓝牙连接状态 - UIImageView *dropLine{nullptr}; // 线 - UILabel *showTimeLabel{nullptr}; // 显示时间 - UILabel *showDateLabel{nullptr}; // 显示日期 - UILabel *showWeekLabel{nullptr}; // 显示星期 + UIImageView *dropSetting{nullptr}; // 设置 + UIImageView *dropLighting{nullptr}; // 蓝牙 + UIImageView *dropDnotDisturb{nullptr}; // 勿扰模式 + UIImageView *dropSavePower{nullptr}; // 省电 + UIImageView *drofindPhone{nullptr}; // 找手机 + UIImageView *dropIconBackground[MAX_INDEX]{nullptr}; // 放置各个icon的背景 + UIButton *connectedStatusBackgroundButton{nullptr}; // 放置连接状态icon的背景按钮 + UIImageView *showPhoneConnectedStatus{nullptr}; // 显示手机连接状态 + UIImageView *showEarPhoneConnectedStatus{nullptr}; // 显示耳机连接状态 + UIImageView *showBluetoothConnectedStatus{nullptr}; // 显示蓝牙连接状态 + UIImageView *dropLine{nullptr}; // 线 + UILabel *showTimeLabel{nullptr}; // 显示时间 + UILabel *showDateLabel{nullptr}; // 显示日期 + UILabel *showWeekLabel{nullptr}; // 显示星期 + UIImageView *showSignalStrength[4]{nullptr}; // 信号强度 + UILabel *Singal_4{nullptr}; // 4G图标 + UIImageView *NoSignal{nullptr}; // 无信号 UIImageView *batteryimage = nullptr; UIBoxProgress *progress = nullptr; 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 b2993d481..b8b0c2d80 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -38,7 +38,7 @@ namespace OHOS map g_jumpView = { {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置 - {DROPDOWN_CLICK_LIGHTING, VIEW_FLASHLIGHT}, // 手电筒 + {DROPDOWN_CLICK_LIGHTING, VIEW_CLASSIC_BLUETOOTH},// 蓝牙 {DROPDOWN_CLICK_DNOTDISTURB, VIEW_DNOTDISTURB}, // 勿扰 {DROPDOWN_CLICK_SAVEELE, VIEW_SAVEELE}, // 省电模式 {DROPDOWN_CLICK_FINDMYPHONE, VIEW_FIND_PHONE}, // 查找手机 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index 7400fced9..48f673674 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -19,13 +19,6 @@ namespace OHOS { - static constexpr int16_t SETTING_INDEX = 0; - static constexpr int16_t LIGHTING_INDEX = 1; - static constexpr int16_t DNOTDISTURB_INDEX = 2; - static constexpr int16_t SAVEPOWER_INDEX = 3; - static constexpr int16_t FINDPHONE_INDEX = 4; - static constexpr int16_t MAX_INDEX = 5; - /* ---------------------------------- 坐标位置 ---------------------------------- */ // 设置 constexpr int16_t SETTING_IMG_X = 30; @@ -72,16 +65,22 @@ namespace OHOS constexpr int16_t WEEK_LABEL_Y = 300; // 手机连接状态 - constexpr int16_t PHONECONNECTSTATUS_BUTTON_X = 155; - constexpr int16_t PHONECONNECTSTATUS_BUTTON_Y = 369; + constexpr int16_t PHONECONNECTSTATUS_BUTTON_X = 123; + constexpr int16_t PHONECONNECTSTATUS_BUTTON_Y = 350; + constexpr int16_t PHONECONNECTSTATUS_BUTTON_W = 60; + constexpr int16_t PHONECONNECTSTATUS_BUTTON_H = 60; // 耳机连接状态 - constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_X = 217; - constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_Y = 369; + constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_X = 203; + constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_Y = 350; + constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_W = 60; + constexpr int16_t EARPHONESCONNECTSTATUS_BUTTON_H = 60; // 蓝牙连接状态 - constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_X = 279; - constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_Y = 369; + constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_X = 283; + constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_Y = 350; + constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_W = 60; + constexpr int16_t BLUETOOTHCONNECTSTATUS_BUTTON_H = 60; /* -------------------------------------------------------------------------- */ std::string getWeekString(int wday) { @@ -99,58 +98,70 @@ namespace OHOS PullUpDownView::~PullUpDownView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::~PullUpDownView"); + ClearAll(); + g_pPullUpDownView = nullptr; + } + + PullUpDownView *PullUpDownView::GetInstance(void) + { + return g_pPullUpDownView; + } + + void PullUpDownView::ClearAll() + { RemoveAll(); + for (int i = 0; i < MAX_INDEX; i++) { delete dropIconBackground[i]; dropIconBackground[i] = nullptr; } + delete dropSetting; dropSetting = nullptr; + delete dropLighting; dropLighting = nullptr; + delete dropDnotDisturb; dropDnotDisturb = nullptr; + delete dropLine; dropLine = nullptr; + delete dropSavePower; dropSavePower = nullptr; + delete drofindPhone; drofindPhone = nullptr; + delete showTimeLabel; showTimeLabel = nullptr; + delete showDateLabel; showDateLabel = nullptr; + delete showWeekLabel; showWeekLabel = nullptr; - delete showPhoneConnectedStatus; - showPhoneConnectedStatus = nullptr; - delete showEarPhoneConnectedStatus; - showEarPhoneConnectedStatus = nullptr; - delete showBluetoothConnectedStatus; - showBluetoothConnectedStatus = nullptr; + /* -------------------------------------------------------------------------- */ + ClearAllSingalComponentsView(); + ClearAllConnectedStatusComponentsView(); /* -------------------------------------------------------------------------- */ delete progress; progress = nullptr; + if (progresscallback_ != nullptr) { delete progresscallback_; progresscallback_ = nullptr; } + if (progressanimator_ != nullptr) { progressanimator_->Stop(); delete progressanimator_; progressanimator_ = nullptr; } - /* -------------------------------------------------------------------------- */ - g_pPullUpDownView = nullptr; - } - - PullUpDownView *PullUpDownView::GetInstance(void) - { - static PullUpDownView instance; - return &instance; } /// @brief 初始化icon图标背景 @@ -205,7 +216,7 @@ namespace OHOS dropSetting->SetViewId(DROPDOWN_CLICK_SETTING); // 进入设置界面 dropSetting->SetTouchable(true); dropSetting->SetOnClickListener(clickListener); - /* ----------------------------------- 亮屏 ----------------------------------- */ + /* ----------------------------------- 蓝牙 ----------------------------------- */ dropLighting = new UIImageView(); if (dropLighting == nullptr) { @@ -215,7 +226,7 @@ namespace OHOS dropLighting->SetPosition(LIGHTING_IMG_X, LIGHTING_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H); dropLighting->SetAutoEnable(false); dropLighting->SetResizeMode(UIImageView::CENTER); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_LIGHTING); + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_BLUETOOTH); dropLighting->SetViewId(DROPDOWN_CLICK_LIGHTING); // 进入亮屏界面 dropLighting->SetTouchable(true); dropLighting->SetOnClickListener(clickListener); @@ -280,11 +291,43 @@ namespace OHOS Add(dropLine); } + // 获取手机连接状态 + bool PullUpDownView::GetPhoneConnectedStatus(void) + { + return true; + } + + // 获取蓝牙耳机连接状态 + bool PullUpDownView::GetEarPhoneConnectedStatus(void) + { + return true; + } + + // 获取蓝牙连接状态 + bool PullUpDownView::GetBluetoothConnectedStatus(void) + { + return true; + } + /// @brief 连接状态 /// @param void void PullUpDownView::InitTimeDateWeekLabelAndConnectedStatusImage(void) { - bool ConnectedStatus = false; + if (connectedStatusBackgroundButton == nullptr) + { + connectedStatusBackgroundButton = new UIButton(); + } + connectedStatusBackgroundButton->SetPosition(113, 348, 240, 64); + connectedStatusBackgroundButton->SetViewId(CONNECTEDSTATUSBACKGROUNDBUTTON); + connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // connectedStatusBackgroundButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + // connectedStatusBackgroundButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + // connectedStatusBackgroundButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); + // connectedStatusBackgroundButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + // connectedStatusBackgroundButton->SetOnClickListener(clickListener); + Add(connectedStatusBackgroundButton); /* -------------------------------- 显示手机连接状态 -------------------------------- */ showPhoneConnectedStatus = new UIImageView(); if (showPhoneConnectedStatus == nullptr) @@ -292,8 +335,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showPhoneConnectedStatus new fail"); return; } - showPhoneConnectedStatus->SetPosition(PHONECONNECTSTATUS_BUTTON_X, PHONECONNECTSTATUS_BUTTON_Y); - if (ConnectedStatus) // 获取手机连接状态 + showPhoneConnectedStatus->SetPosition(PHONECONNECTSTATUS_BUTTON_X, PHONECONNECTSTATUS_BUTTON_Y, PHONECONNECTSTATUS_BUTTON_W, PHONECONNECTSTATUS_BUTTON_H); + showPhoneConnectedStatus->SetAutoEnable(false); + showPhoneConnectedStatus->SetResizeMode(UIImageView::CENTER); + showPhoneConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30); + if (GetPhoneConnectedStatus()) // 获取手机连接状态 { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONECONNECTED); } @@ -301,6 +347,7 @@ namespace OHOS { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showPhoneConnectedStatus, DROPDOWN_PHONEDISCONNECTED); } + /* -------------------------------- 显示耳机连接状态 -------------------------------- */ showEarPhoneConnectedStatus = new UIImageView(); if (showEarPhoneConnectedStatus == nullptr) @@ -308,8 +355,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus new fail"); return; } - showEarPhoneConnectedStatus->SetPosition(EARPHONESCONNECTSTATUS_BUTTON_X, EARPHONESCONNECTSTATUS_BUTTON_Y); - if (ConnectedStatus) // 获取耳机连接状态 + showEarPhoneConnectedStatus->SetPosition(EARPHONESCONNECTSTATUS_BUTTON_X, EARPHONESCONNECTSTATUS_BUTTON_Y, EARPHONESCONNECTSTATUS_BUTTON_W, EARPHONESCONNECTSTATUS_BUTTON_H); + showEarPhoneConnectedStatus->SetAutoEnable(false); + showEarPhoneConnectedStatus->SetResizeMode(UIImageView::CENTER); + showEarPhoneConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30); + if (GetEarPhoneConnectedStatus()) // 获取耳机连接状态 { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESCONNECTED); } @@ -317,6 +367,7 @@ namespace OHOS { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showEarPhoneConnectedStatus, DROPDOWN_EARPHONESDISCONNECTED); } + /* -------------------------------- 显示蓝牙连接状态 -------------------------------- */ showBluetoothConnectedStatus = new UIImageView(); if (showBluetoothConnectedStatus == nullptr) @@ -324,13 +375,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showBluetoothConnectedStatus new fail"); return; } - showBluetoothConnectedStatus->SetPosition(BLUETOOTHCONNECTSTATUS_BUTTON_X, BLUETOOTHCONNECTSTATUS_BUTTON_Y); - if (BluetoothModel::GetInstance() == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showBluetoothConnectedStatus model nullptr"); - return; - } - if (SettingModel::GetInstance().GetBlueToothConnectStatus()) // 获取蓝牙连接状态 + showBluetoothConnectedStatus->SetPosition(BLUETOOTHCONNECTSTATUS_BUTTON_X, BLUETOOTHCONNECTSTATUS_BUTTON_Y, BLUETOOTHCONNECTSTATUS_BUTTON_W, BLUETOOTHCONNECTSTATUS_BUTTON_H); + showBluetoothConnectedStatus->SetAutoEnable(false); + showBluetoothConnectedStatus->SetResizeMode(UIImageView::CENTER); + showBluetoothConnectedStatus->SetStyle(STYLE_BORDER_RADIUS, 30); + if (GetBluetoothConnectedStatus()) // 获取蓝牙连接状态 { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHCONNECTED); } @@ -338,15 +387,39 @@ namespace OHOS { ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, showBluetoothConnectedStatus, DROPDOWN_BLUETOOTHDISCONNECTED); } + /* -------------------------------------------------------------------------- */ Add(showPhoneConnectedStatus); Add(showEarPhoneConnectedStatus); Add(showBluetoothConnectedStatus); } + + // 清除所有与连接状态相关的视图组件 + void PullUpDownView::ClearAllConnectedStatusComponentsView() + { + delete connectedStatusBackgroundButton; + connectedStatusBackgroundButton = nullptr; + + delete showPhoneConnectedStatus; + showPhoneConnectedStatus = nullptr; + + delete showEarPhoneConnectedStatus; + showEarPhoneConnectedStatus = nullptr; + + delete showBluetoothConnectedStatus; + showBluetoothConnectedStatus = nullptr; + } + /*** - * @brief 初始化时间,日期,星期,电池 + * @brief 初始化时间,日期,星期,电池,信号强度 */ bool PullUpDownView::InitBaseData() { + + if (!InitSingalComponentsView()) + { + return false; + } + /* ---------------------------------- 时间显示 ---------------------------------- */ showTimeLabel = new UILabel(); if (showTimeLabel == nullptr) @@ -387,24 +460,38 @@ namespace OHOS showWeekLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); showWeekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); /* ----------------------------------- 电池 ----------------------------------- */ + batteryimage = new UIImageView(); if (batteryimage == nullptr) { - batteryimage = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail"); + return false; + } + if (GetSignalStrength() == 0) + { + batteryimage->SetPosition(200, 180, 48, 30); + } + else + { + batteryimage->SetPosition(258, 180, 48, 30); } - batteryimage->SetPosition(210, 180); // widget's left position and top position - batteryimage->Resize(48, 30); // widget's width and height - batteryimage->SetViewId("imagebattery"); // Set style std::string batteryimagesPath = "/user/res/Battery/Battery-E.bin"; batteryimage->SetSrc(batteryimagesPath.c_str()); Add(batteryimage); /* -------------------------------------------------------------------------- */ + progress = new UIBoxProgress(); if (progress == nullptr) { - progress = new UIBoxProgress(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail"); + return false; + } + if (GetSignalStrength() == 0) + { + batteryimage->SetPosition(206, 180, 48, 30); + } + else + { + progress->SetPosition(264, 186, 31, 19); } - progress->SetPosition(216, 186); // widget's left position and top position - progress->Resize(31, 19); // widget's width and height - progress->SetViewId("progress1"); // Set style progress->SetValidHeight(19); progress->SetValidWidth(31); @@ -425,6 +512,135 @@ namespace OHOS return true; } + // 初始化信号强度相关组件 + bool PullUpDownView::InitSingalComponentsView() + { + + /* -------------------------------------------------------------------------- */ + NoSignal = new UIImageView(); + if (NoSignal == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal new fail"); + return false; + } + NoSignal->SetPosition(160, 176, 36, 38); + NoSignal->SetAutoEnable(false); + NoSignal->SetResizeMode(UIImageView::CENTER); + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, NoSignal, DROPDOWN_NOSIGNAL); + NoSignal->SetVisible(false); + Add(NoSignal); + /* -------------------------------------------------------------------------- */ + // 定义一个结构体,用于存储 ImageView 的信息 + struct ImageViewInfo + { + int posX; + int posY; + int width; + int height; + }; + // 待添加的 ImageView 信息列表 + std::vector imageViewList = { + {160, 204, 6, 6}, + {170, 196, 6, 14}, + {180, 188, 6, 22}, + {190, 180, 6, 30}, + }; + + // 循环添加 ImageView 到相应的容器中 + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] == nullptr) + { + showSignalStrength[i] = new UIImageView(); + if (showSignalStrength[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d] new fail", i); + return false; + } + } + showSignalStrength[i]->SetPosition(imageViewList[i].posX, imageViewList[i].posY, imageViewList[i].width, imageViewList[i].height); + if (i < GetSignalStrength()) + { + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + } + else + { + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff383838); + } + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + showSignalStrength[i]->SetStyle(STYLE_BORDER_RADIUS, 10); + Add(showSignalStrength[i]); + showSignalStrength[i]->SetVisible(false); + } + /* -------------------------------------------------------------------------- */ + if (Singal_4 == nullptr) + { + Singal_4 = new UILabel(); + } + Singal_4->SetPosition(201, 176, 40, 47); + Singal_4->SetStyle(STYLE_TEXT_FONT, 34); + Singal_4->SetStyle(STYLE_LINE_HEIGHT, 40); + Singal_4->SetText("4G"); + Singal_4->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Singal_4->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Singal_4->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34); + Singal_4->SetVisible(false); + Add(Singal_4); + /* -------------------------------------------------------------------------- */ + SetSingalComponentsVisible(GetSignalStrength()); + + return true; + } + + // 获取信号强度 + int PullUpDownView::GetSignalStrength(void) + { + int SignalStrength = 4; // 信号强度 + return SignalStrength; + } + + // 根据信号强度设置信号组件是否可见 + void PullUpDownView::SetSingalComponentsVisible(int SignalStrength) + { + if (SignalStrength != 0) + { + for (int i = 0; i < 4; i++) + { + showSignalStrength[i]->SetVisible(true); + } + Singal_4->SetVisible(true); + } + else + { + NoSignal->SetVisible(true); + } + } + + // 清除信号强度相关组件 + void PullUpDownView::ClearAllSingalComponentsView() + { + if (NoSignal != nullptr) + { + delete NoSignal; + NoSignal = nullptr; + } + + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] != nullptr) + { + delete showSignalStrength[i]; + showSignalStrength[i] = nullptr; + } + } + + if (Singal_4 != nullptr) + { + delete Singal_4; + Singal_4 = nullptr; + } + } + bool PullUpDownView::InitView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitDropDownView caller:"); @@ -476,6 +692,14 @@ namespace OHOS /*更新勿扰模式状态*/ void PullUpDownView::UpdateDnotDisturbStatus(int status) { + for (int i = 0; i < MAX_INDEX; i++) + { + if (dropIconBackground[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropIconBackground[%d] is nullptr", i); + } + } + if (dropIconBackground[DNOTDISTURB_INDEX] != nullptr) { if (status) @@ -532,7 +756,7 @@ namespace OHOS uint8_t value = 0; value = battery_get_voltage(&voltage); PRINT("Read ALLData!\n"); - + // 更新界面显示 showTimeLabel->SetText(timeStr); showWeekLabel->SetText(weekStr); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/dropdown.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/dropdown.bin index 3d0f08bfd..d4305ccd9 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/dropdown.bin and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/dropdown.bin differ