{
static OHOS::ColorType connectedColor[MAX_CONNECTEDSTATUS_ID] = {
Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff),
- Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff),
Color::GetColorFromRGBA(0x0d, 0x62, 0xff, 0xff),
};
static OHOS::ColorType disconnectedColor = Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff);
static const char *DROPDOWN_PHONECONNECTED_ = "/user/res/connectstatus/phone_bt_connected.bin";
static const char *DROPDOWN_PHONEDISCONNECTED_ = "/user/res/connectstatus/phone_bt_disconnected.bin";
- //耳机
- static const char *DROPDOWN_EARPHONESCONNECTED_ = "/user/res/connectstatus/earphone_connected.bin";
- static const char *DROPDOWN_EARPHONESDISCONNECTED_ = "/user/res/connectstatus/earphone_disconnected.bin";
-
//蓝牙
static const char *DROPDOWN_BLUETOOTHCONNECTED_ = "/user/res/connectstatus/bt_connected.bin";
static const char *DROPDOWN_BLUETOOTHDISCONNECTED_ = "/user/res/connectstatus/bt_disconnected.bin";
delete PhoneConnectedStatusImage;
PhoneConnectedStatusImage = nullptr;
- delete EarPhoneConnectedStatusImage;
- EarPhoneConnectedStatusImage = nullptr;
-
delete BluetoothConnectedStatusImage;
BluetoothConnectedStatusImage = nullptr;
bool ConnectedStatusView::initBackground(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectedStatusView::initBackground");
- int background_position_x = 33;
+ int background_position_x = 97;
for (int i = 0; i < MAX_CONNECTEDSTATUS_ID; i++)
{
background[i] = new UIImageView();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "background[%d] new fail!!", i);
return false;
}
- background[i]->SetPosition(background_position_x + i * 140, 113, 120, 200);
+ background[i]->SetPosition(background_position_x + i * 152, 113, 120, 200);
background[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
background[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
background[i]->SetStyle(STYLE_BORDER_RADIUS, 40);
}
StatusImageParams params = {
- .x = 63,
+ .x = 127,
.y = 135,
.width = 60,
.height = 60,
group->Add(PhoneConnectedStatusImage);
params = {
- .x = 203,
- .y = 135,
- .width = 60,
- .height = 60,
- .connectedImage = DROPDOWN_EARPHONESCONNECTED_,
- .disconnectedImage = DROPDOWN_EARPHONESDISCONNECTED_,
- .isConnected = pullUpDownView->GetEarPhoneConnectedStatus(),
- };
- EarPhoneConnectedStatusImage = InitStatusImage(params);
- group->Add(EarPhoneConnectedStatusImage);
-
- params = {
- .x = 343,
+ .x = 279,
.y = 135,
.width = 60,
.height = 60,
uint16_t deviceName[MAX_CONNECTEDSTATUS_ID] = {
STR_PHONE, // 手机
- STR_HEADSET, // 耳机
STR_BLUETOOTH, // 蓝牙
}; // 初始化设备名称数组
- int PhoneAndEarAndBluetooth_position_x = 53;
- int ConnectedStatusLabel_position_x = 59;
+ int PhoneAndEarAndBluetooth_position_x = 117;
+ int ConnectedStatusLabel_position_x = 123;
for (int i = 0; i < MAX_CONNECTEDSTATUS_ID; i++)
{
- LabelConfig titleConfig = {PhoneAndEarAndBluetooth_position_x + i * 140, 220, 80, 35, 30, 35, deviceName[i]};
+ LabelConfig titleConfig = {PhoneAndEarAndBluetooth_position_x + i * 152, 220, 80, 35, 30, 35, deviceName[i]};
PhoneAndEarAndBluetooth[i] = InitLabel(titleConfig);
group->Add(PhoneAndEarAndBluetooth[i]);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectedStatusLabel[%d] new fail!!", i);
return false;
}
- ConnectedStatusLabel[i]->SetPosition(ConnectedStatusLabel_position_x + i * 140, 258, 70, 27);
+ ConnectedStatusLabel[i]->SetPosition(ConnectedStatusLabel_position_x + i * 152, 258, 70, 27);
ConnectedStatusLabel[i]->SetStyle(STYLE_TEXT_FONT, 23);
ConnectedStatusLabel[i]->SetStyle(STYLE_LINE_HEIGHT, 27);
ConnectedStatusLabel[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
group->Add(ConnectedStatusLabel[i]);
}
UpdatePhoneConnectedStatus(pullUpDownView->GetPhoneConnectedStatus());
- UpdateEarPhoneConnectedStatus(pullUpDownView->GetEarPhoneConnectedStatus());
UpdateBlueToothConnectedStatus(pullUpDownView->GetBlueToothConnectedStatus());
return true;
updateConnectionStatus(params);
}
- // 更新蓝牙耳机连接状态
- void ConnectedStatusView::UpdateEarPhoneConnectedStatus(int status)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectedStatusView::UpdateEarPhoneConnectedStatus");
-
- ConnectionStatusParams params = {
- .statusImage = EarPhoneConnectedStatusImage,
- .statusLabel = ConnectedStatusLabel[EARPHONECONNECTESTATUS_ID],
- .status = status,
- .connectedImage = DROPDOWN_EARPHONESCONNECTED_,
- .disconnectedImage = DROPDOWN_EARPHONESDISCONNECTED_,
- .connectedText = STR_CONNECTED,
- .disconnectedText = STR_DISCONNECTED,
- .connectedColor = connectedColor[EARPHONECONNECTESTATUS_ID],
- .disconnectedColor = disconnectedColor,
- };
-
- updateConnectionStatus(params);
- }
-
// 更新蓝牙连接状态
void ConnectedStatusView::UpdateBlueToothConnectedStatus(int status)
{
{
#ifdef SUPPORT_BATTERY_SERVICE
#include "battery_hal.h"
-extern uint8_t get_charge_stat(void);
+ extern uint8_t get_charge_stat(void);
#endif
}
namespace OHOS
{
-
/* ---------------------------------- 坐标位置 ---------------------------------- */
// 手机连接状态
static constexpr const char *DROPDOWN_PHONECONNECTED_IMAGE = "/user/res/dropdown/phone_connect.bin";
static constexpr const char *DROPDOWN_PHONEDISCONNECTED_IMAGE = "/user/res/dropdown/phone_disconnect.bin";
- // 耳机连接状态
- static constexpr const char *DROPDOWN_EARPHONESCONNECTED_IMAGE = "/user/res/dropdown/earphones_connect.bin";
- static constexpr const char *DROPDOWN_EARPHONESDISCONNECTED_IMAGE = "/user/res/dropdown/earphones_disconnect.bin";
// 蓝牙连接状态
static constexpr const char *DROPDOWN_BLUETOOTHCONNECTED_IMAGE = "/user/res/dropdown/bluetooth_connect.bin";
static constexpr const char *DROPDOWN_BLUETOOTHDISCONNECTED_IMAGE = "/user/res/dropdown/bluetooth_disconnect.bin";
bool PullUpDownView::GetPhoneConnectedStatus(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetPhoneConnectedStatus");
- // uint8_t ret = uapi_dev_runtime_get_ble_connect_stat();
- // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret);
- // if (ret == 1)
- // return true;
- // else
- // return false;
-
return SettingModel::GetInstance().GetPhoneConnectStatus();
}
- // 获取蓝牙耳机连接状态
- bool PullUpDownView::GetEarPhoneConnectedStatus(void)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetEarPhoneConnectedStatus");
- // uint8_t ret = uapi_dev_runtime_get_earphone_connect_stat();
- // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "earphone connect stat = %d", ret);
- // if (ret == 1)
- // return true;
- // else
- // return false;
-
- return SettingModel::GetInstance().GetEarPhoneConnectStatus();
- }
// 获取蓝牙连接状态
bool PullUpDownView::GetBlueToothConnectedStatus(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetBlueToothConnectedStatus");
- // uint8_t ret = uapi_dev_runtime_get_br_connect_stat();
- // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "br connect stat = %d [0 no connect, 1 a2dp, 2 hfp, 3 both]", ret);
- // if (ret != 0)
- // return true;
- // else
- // return false;
-
return SettingModel::GetInstance().GetBlueToothConnectStatus();
}
// 设置蓝牙连接状态是否显示
void PullUpDownView::SetPhoneConnectedIsVisible(bool state)
{
- if (connectedStatusBackgroundButton && showPhoneConnectedStatus && showEarPhoneConnectedStatus && showBluetoothConnectedStatus)
+ if (connectedStatusBackgroundButton && showPhoneConnectedStatus && showBluetoothConnectedStatus)
{
if (!state)
{
int x = connectedStatusBackgroundButton->GetX();
int y = connectedStatusBackgroundButton->GetY();
showPhoneConnectedStatus->SetVisible(true);
- showEarPhoneConnectedStatus->SetPosition(x + 68, y + 13);
- showBluetoothConnectedStatus->SetPosition(x + 110, y + 13);
+ showBluetoothConnectedStatus->SetPosition(x + 68, y + 13);
}
else
{
int x = connectedStatusBackgroundButton->GetX();
int y = connectedStatusBackgroundButton->GetY();
showPhoneConnectedStatus->SetVisible(false);
- showEarPhoneConnectedStatus->SetPosition(x + 22, y + 13);
- showBluetoothConnectedStatus->SetPosition(showEarPhoneConnectedStatus->GetX() + showEarPhoneConnectedStatus->GetWidth() + 18, y + 13);
+ showBluetoothConnectedStatus->SetPosition(x + 22, y + 13);
}
connectedStatusBackgroundButton->Invalidate();
showPhoneConnectedStatus->Invalidate();
- showEarPhoneConnectedStatus->Invalidate();
showBluetoothConnectedStatus->Invalidate();
}
}
return;
}
- // 更新蓝牙耳机连接状态
- void PullUpDownView::UpdateEarPhoneStatus(int status)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateEarPhoneStatus");
- if (showEarPhoneConnectedStatus == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus nullptr");
- return;
- }
- showEarPhoneConnectedStatus->SetSrc(status ? DROPDOWN_EARPHONESCONNECTED_IMAGE : DROPDOWN_EARPHONESDISCONNECTED_IMAGE);
- showEarPhoneConnectedStatus->Invalidate();
-
- if (GetConnectedStatusView() != nullptr)
- GetConnectedStatusView()->UpdateEarPhoneConnectedStatus(status);
-
- return;
- }
// 更新蓝牙连接状态
void PullUpDownView::UpdateBlueToothStatus(int status)
{
return;
}
}
- /* -------------------------------- 显示耳机连接状态 -------------------------------- */
- if (showEarPhoneConnectedStatus == nullptr)
- {
- showEarPhoneConnectedStatus = DropDownConnectedStatusImageViweInit(x + 68, y + 13, 24, 24);
- if (showEarPhoneConnectedStatus == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus new fail");
- return;
- }
- }
/* -------------------------------- 显示蓝牙连接状态 -------------------------------- */
if (showBluetoothConnectedStatus == nullptr)
{
}
/* -------------------------------------------------------------------------- */
UpdatePhoneStatus(GetPhoneConnectedStatus());
- UpdateEarPhoneStatus(GetEarPhoneConnectedStatus());
UpdateBlueToothStatus(GetBlueToothConnectedStatus());
/* -------------------------------------------------------------------------- */
group[DROPDOWNVIEW]->Add(connectedStatusBackgroundButton);
group[DROPDOWNVIEW]->Add(showPhoneConnectedStatus);
- group[DROPDOWNVIEW]->Add(showEarPhoneConnectedStatus);
group[DROPDOWNVIEW]->Add(showBluetoothConnectedStatus);
}
delete showPhoneConnectedStatus;
showPhoneConnectedStatus = nullptr;
}
- if (showEarPhoneConnectedStatus != nullptr)
- {
- delete showEarPhoneConnectedStatus;
- showEarPhoneConnectedStatus = nullptr;
- }
if (showBluetoothConnectedStatus != nullptr)
{
delete showBluetoothConnectedStatus;
}
group1->SetPosition(132, 80, 202, 40);
group1->SetStyle(STYLE_BACKGROUND_OPA, 0);
- /* -------------------------------- NoSignal -------------------------------- */
- if (NoSignal == nullptr)
- {
- NoSignal = new UIImageView();
- if (NoSignal == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal new fail");
- return;
- }
- }
- NoSignal->SetPosition(0, (group1->GetHeight() - 38) / 2, 36, 38);
- NoSignal->SetAutoEnable(false);
- NoSignal->SetResizeMode(UIImageView::CENTER);
- NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE);
- NoSignal->SetVisible(false);
- group1->Add(NoSignal);
- /* ------------------------------- MobileData ------------------------------- */
- if (MobileData == nullptr)
- {
- MobileData = new UIImageView();
- if (MobileData == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MobileData new fail");
- return;
- }
- }
- MobileData->SetPosition(1, 4, 13, 15);
- MobileData->SetAutoEnable(false);
- MobileData->SetResizeMode(UIImageView::CENTER);
- MobileData->SetSrc(DROPDOWN_MOBILE_DATA_IMAGE);
- MobileData->SetVisible(false);
- group1->Add(MobileData);
- /* -------------------------------------------------------------------------- */
- // 定义一个结构体,用于存储 ImageView 的信息
- struct ImageViewInfo
- {
- int posX;
- int posY;
- int width;
- int height;
- };
- // 待添加的 ImageView 信息列表
- std::vector<ImageViewInfo> imageViewList = {
- {0, 28, 6, 6},
- {10, 20, 6, 14},
- {20, 12, 6, 22},
- {30, 4, 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;
- }
- }
- showSignalStrength[i]->SetPosition(imageViewList[i].posX, imageViewList[i].posY, imageViewList[i].width, imageViewList[i].height);
- showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- showSignalStrength[i]->SetStyle(STYLE_BORDER_RADIUS, 10);
- group1->Add(showSignalStrength[i]);
- showSignalStrength[i]->SetVisible(false);
- }
- /* -------------------------------- Singal_4 -------------------------------- */
- if (Singal_4 == nullptr)
- {
- Singal_4 = new UILabel();
- }
- Singal_4->SetPosition(0, 0, 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_EN, 34);
- Singal_4->SetVisible(false);
- group1->Add(Singal_4);
- /* ----------------------------------- HD ----------------------------------- */
- if (HD == nullptr)
- {
- HD = new UIImageView();
- if (HD == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HD new fail");
- return;
- }
- }
- HD->SetPosition(88 + 10, (group1->GetHeight() - 30) / 2, 46, 30);
- HD->SetAutoEnable(false);
- HD->SetResizeMode(UIImageView::CENTER);
- HD->SetSrc(DROPDOWN_HD_IMAGE);
- HD->SetVisible(false);
- group1->Add(HD);
+ group[DROPDOWNVIEW]->Add(group1);
/* ----------------------------------- 电池 ----------------------------------- */
batteryimage = new UIImageView();
if (batteryimage == nullptr)
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail");
return;
}
- batteryimage->SetPosition(HD->GetX() + HD->GetWidth() + 10, (group1->GetHeight() - 30) / 2, 48, 30);
+ batteryimage->SetPosition((group1->GetWidth() - 48) / 2, (group1->GetHeight() - 30) / 2, 48, 30);
std::string batteryimagesPath = "/user/res/Battery/Battery_White.bin";
batteryimage->SetSrc(batteryimagesPath.c_str());
group1->Add(batteryimage);
chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN);
chargeBatteryicon->SetVisible(false);
group1->Add(chargeBatteryicon);
- /* -------------------------------------------------------------------------- */
- group[DROPDOWNVIEW]->Add(group1);
/* --------------------------------- 显示日期和星期 -------------------------------- */
showDateAndWeekLabel = new UILabel();
if (showDateAndWeekLabel == nullptr)
showDateAndWeekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
group[DROPDOWNVIEW]->Add(showDateAndWeekLabel);
/* -------------------------------------------------------------------------- */
- UpdateSignalStrengthStatusAndBatteryPosition();
-/* -------------------------------------------------------------------------- */
MainPresenterSample::GetInstance()->UpdataBaseData();
/* -------------------------------------------------------------------------- */
UpdateBatteryProcess();
if (group1 != nullptr)
{
group1->RemoveAll();
- 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;
- }
- if (NoSignal != nullptr)
- {
- delete NoSignal;
- NoSignal = nullptr;
- }
- if (MobileData != nullptr)
- {
- delete MobileData;
- MobileData = nullptr;
- }
- if (HD != nullptr)
- {
- delete HD;
- HD = nullptr;
- }
if (batteryimage != nullptr)
{
delete batteryimage;
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAll_2 over!!");
}
- // 获取信号强度
- int PullUpDownView::GetSignalStrength(void)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetSignalStrength");
- int SignalStrength = 0;
- #ifdef SUPPORT_CAT1_SERVICE
- SignalStrength = uapi_dev_runtime_get_cat1_signal(); // 信号强度
- #endif
- return CalculateSignalBars(SignalStrength);
- }
-
- // 计算信号格
- int PullUpDownView::CalculateSignalBars(int signalStrength)
- {
-#if 0
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::CalculateSignalBars");
- if (signalStrength < 0 || signalStrength > 31 || signalStrength == 0)
- return 99; // 无信号 or Invalid signal strength
-
- // if (signalStrength == 32)
- // return 4; // Edge case where signalStrength is exactly at the upper boundary
-
- return (signalStrength / 8) + 1;
-#else
- if (signalStrength >= 1 && signalStrength <= 8) // 0信号
- {
- return 0;
- }
- else if (signalStrength >= 9 && signalStrength <= 16) // 1格信号,信号很弱偶尔可以接打电话,很容易失败
- {
- return 1;
- }
- else if (signalStrength >= 17 && signalStrength <= 21) // 2格信号,信号一般
- {
- return 2;
- }
- else if (signalStrength >= 22 && signalStrength <= 26) // 3格信号,信号较强
- {
- return 3;
- }
- else if (signalStrength >= 27 && signalStrength <= 31) // 4格信号,信号很强
- {
- return 4;
- }
- else
- {
- return 99; // Invalid signal strength
- }
-#endif
- }
-
- // 函数用于更新信号显示的UI
- void PullUpDownView::updateSignalDisplay()
- {
- #ifdef SUPPORT_CAT1_SERVICE
- int sim = uapi_dev_runtime_get_cat1_simstat();
- int cat1_powerOn = uapi_dev_runtime_get_cat1_powerstat();
- int signal = uapi_dev_runtime_get_cat1_signal();
- int network_on = uapi_dev_runtime_get_cat1_networkstat();
- int cat1_network_type = uapi_dev_runtime_get_cat1_networtype();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sim = %d", sim);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_powerOn = %d", cat1_powerOn);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "signal = %d", signal);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "network_on = %d", network_on);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_network_type = %d", cat1_network_type);
-
- const int SIGNAL_NO_SIGNAL = 99;
- const int NETWORK_TYPE_NO_NETWORK = 0;
- const int NETWORK_TYPE_4G = 4;
-
- if (sim == 0 || cat1_powerOn == 0)
- {
- // 无信号,无4G图标
- UpdateCat1NoSignalisplay(true);
- UpdateCat14GDisplay(false);
- UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
- UpdateCat1MobileDataDisplay(false);
- }
- else if (cat1_powerOn == 1 && sim != 0)
- {
- if (signal == SIGNAL_NO_SIGNAL) // 计算信号强度
- {
- // 无信号UI显示
- UpdateCat1NoSignalisplay(true);
- UpdateCat14GDisplay(false);
- UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
- }
- else
- {
- // 信号强度显示
- UpdateCat1NoSignalisplay(false);
- // UpdateCat14GDisplay(true);
- UpdateSignalBarDisplay(CalculateSignalBars(signal), true);
- }
-
- if (network_on == 0)
- {
- // 无信号,无4G图标 显示
- if (signal == SIGNAL_NO_SIGNAL)
- {
- UpdateCat1NoSignalisplay(true);
- }
- UpdateCat14GDisplay(false);
- UpdateCat1MobileDataDisplay(false);
- // UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
- }
- else
- {
- if (cat1_network_type == NETWORK_TYPE_NO_NETWORK)
- {
- // 无信号,无4G图标 显示
- if (signal == SIGNAL_NO_SIGNAL)
- {
- UpdateCat1NoSignalisplay(true);
- }
- UpdateCat14GDisplay(false);
- UpdateCat1MobileDataDisplay(false);
- // UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
- }
- else if (cat1_network_type == NETWORK_TYPE_4G)
- {
- // 有4G图标,正常显示信号
- UpdateCat1NoSignalisplay(false);
- UpdateCat14GDisplay(true);
- UpdateCat1MobileDataDisplay(true);
- // UpdateSignalBarDisplay(CalculateSignalBars(signal), true);
- }
- else
- {
- // 无4G图标,正常显示信号
- UpdateCat1NoSignalisplay(false);
- UpdateCat14GDisplay(false);
- UpdateCat1MobileDataDisplay(true);
- // UpdateSignalBarDisplay(CalculateSignalBars(signal), true);
- }
- }
- }
- #endif
- }
- // 更新信号强度显示
- void PullUpDownView::UpdateSignalBarDisplay(int signalBars, bool state)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateSignalBarDisplay");
- for (int i = 0; i < 4; i++)
- {
- showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, (i < signalBars) ? COLOR_SIGNAL_ON : COLOR_SIGNAL_OFF);
- showSignalStrength[i]->Invalidate();
- showSignalStrength[i]->SetVisible(state);
- }
- }
-
- // 更新无信号图标显示
- void PullUpDownView::UpdateCat1NoSignalisplay(bool state)
- {
- if (NoSignal != nullptr)
- {
- NoSignal->SetVisible(state);
- }
- }
-
- // 更新4G图标显示
- void PullUpDownView::UpdateCat14GDisplay(bool state)
- {
- if (Singal_4 != nullptr)
- {
- Singal_4->SetVisible(state);
- }
- UpdateHDDisplay(state && ConfigModel::GetInstance()->GetVoLTE_Call());
- }
-
- // 有HD一定有4G
- void PullUpDownView::UpdateHDDisplay(bool state)
- {
- if (HD != nullptr)
- {
- HD->SetVisible(state);
- }
- }
-
- /*更新移动数据图标显示*/
- void PullUpDownView::UpdateCat1MobileDataDisplay(bool state)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateCat1MobileDataDisplay %d", state);
- if (MobileData != nullptr)
- {
- MobileData->SetVisible(state);
- }
- }
-
- void PullUpDownView::UpdateXPosition(void)
- {
- // 判断相关组件是否有效
- if (MobileData && HD && Singal_4 && NoSignal && batteryimage && progress && chargeBatteryicon)
- {
- // 获取各个组件的可见状态
- bool mobileDataVisible = MobileData->IsVisible(); // 移动数据
- bool hdVisible = HD->IsVisible(); // HD [VoLTE开关]
- bool signal4Visible = Singal_4->IsVisible(); // 4G
- bool noSignalVisible = NoSignal->IsVisible(); // 无信号
-
- int x;
- int signalWidth = NoSignal->GetWidth();
- int batteryWidth = batteryimage->GetWidth();
- int spacing = 10;
-
- if (noSignalVisible) // 无信号时的处理
- {
- x = (group1->GetWidth() - (signalWidth + batteryWidth + spacing)) / 2;
- NoSignal->SetX(x);
- batteryimage->SetX(x + signalWidth + spacing);
- progress->SetX(batteryimage->GetX() + 7);
- }
- else // 有信号时的处理
- {
- if (!signal4Visible) // 无 4G
- {
- x = (group1->GetWidth() - (signalWidth + batteryWidth + spacing)) / 2;
- for (int i = 0; i < 4; i++)
- {
- if (showSignalStrength[i] != nullptr)
- {
- if (i != 0)
- {
- showSignalStrength[i]->SetX(showSignalStrength[i - 1]->GetX() + 10);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d]", showSignalStrength[i]->GetX());
- }
- else
- {
- showSignalStrength[i]->SetX(x);
- }
- }
- }
- batteryimage->SetX(showSignalStrength[3]->GetX() + spacing);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d]", batteryimage->GetX());
- progress->SetX(batteryimage->GetX() + 7);
- }
- else // 有 4G
- {
- int additionalWidth = hdVisible ? HD->GetWidth() : 0;
- x = (group1->GetWidth() - (signalWidth + Singal_4->GetWidth() + additionalWidth + batteryWidth + spacing * (2 + hdVisible))) / 2;
- for (int i = 0; i < 4; i++)
- {
- if (showSignalStrength[i] != nullptr)
- {
- if (i != 0)
- {
- showSignalStrength[i]->SetX(showSignalStrength[i - 1]->GetX() + 10);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d]", showSignalStrength[i]->GetX());
- }
- else
- {
- showSignalStrength[i]->SetX(x);
- }
- }
- }
- Singal_4->SetX(showSignalStrength[3]->GetX() + spacing);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d]", batteryimage->GetX());
- if (hdVisible) // 有 HD
- {
- HD->SetX(Singal_4->GetX() + Singal_4->GetWidth() + spacing);
- batteryimage->SetX(HD->GetX() + HD->GetWidth() + spacing);
- progress->SetX(batteryimage->GetX() + 7);
- }
- else // 无 HD
- {
- batteryimage->SetX(Singal_4->GetX() + Singal_4->GetWidth() + spacing);
- progress->SetX(batteryimage->GetX() + 7);
- }
- }
- if (mobileDataVisible) // 如果有移动数据图标,设置其位置
- {
- MobileData->SetX(showSignalStrength[0]->GetX());
- }
- }
- chargeBatteryicon->SetPosition(progress->GetX() + 6, batteryimage->GetY() + 2);
- // 使相关组件无效化以触发重绘
- MobileData->Invalidate();
- HD->Invalidate();
- Singal_4->Invalidate();
- NoSignal->Invalidate();
- batteryimage->Invalidate();
- progress->Invalidate();
- chargeBatteryicon->Invalidate();
- }
- }
-
// 更新信号强度和电池位置
void PullUpDownView::UpdateSignalStrengthStatusAndBatteryPosition()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateSignalStrengthStatusAndBatteryPosition");
- updateSignalDisplay(); // 函数用于更新信号显示的UI
- UpdateXPosition();
/*更新蓝牙连接状态*/
int a2dp = uapi_a2dp_snk_get_device_connect_state();
}
bool isCharging = false;
- #ifdef SUPPORT_BATTERY_SERVICE
+#ifdef SUPPORT_BATTERY_SERVICE
isCharging = get_charge_stat(); // 获取充电状态
- #endif
+#endif
if (isCharging)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UnLoad");
}
- /*更新勿扰模式状态*/
- void PullUpDownView::UpdateDnotDisturbStatus(int status)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateDnotDisturbStatus");
- }
-
UIBoxProgress *PullUpDownView::GetProgress()
{
return progress;