* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:46
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 18:27:22
+ * @LastEditTime: 2024-09-30 11:31:16
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
*/
#include "findphone/include/FindPhoneView.h"
void FindPhoneView::ClearAll()
{
- if (viewInitStatus == true)
+ if (container_ != nullptr)
{
- // UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
- // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
- // FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+
+ if (FindPhoneGroupView != nullptr)
+ {
+ FindPhoneGroupView->RemoveAll();
- if (container_ != nullptr)
+ if (FindPhoneTitleLabel != nullptr)
{
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
+ delete FindPhoneTitleLabel;
+ FindPhoneTitleLabel = nullptr;
}
- if (FindPhoneGroupView != nullptr)
+ if (FindPhoneImageView != nullptr)
{
- FindPhoneGroupView->RemoveAll();
-
- if (FindPhoneTitleLabel != nullptr)
- {
- delete FindPhoneTitleLabel;
- FindPhoneTitleLabel = nullptr;
- }
- if (FindPhoneImageView != nullptr)
- {
- delete FindPhoneImageView;
- FindPhoneImageView = nullptr;
- }
- if (FindPhoneImageAnimator != nullptr)
- {
- FindPhoneImageAnimator->Stop();
- delete FindPhoneImageAnimator;
- FindPhoneImageAnimator = nullptr;
- // FreeImagePathsArray(FindPhonePathsArray, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
- FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
- }
- if (FindPhoneLabel != nullptr)
- {
- delete FindPhoneLabel;
- FindPhoneLabel = nullptr;
- }
- if (FindPhoneLabelButton != nullptr)
- {
- delete FindPhoneLabelButton;
- FindPhoneLabelButton = nullptr;
- }
- delete FindPhoneGroupView;
- FindPhoneGroupView = nullptr;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
+ delete FindPhoneImageView;
+ FindPhoneImageView = nullptr;
+ }
+ if (FindPhoneImageAnimator != nullptr)
+ {
+ FindPhoneImageAnimator->Stop();
+ delete FindPhoneImageAnimator;
+ FindPhoneImageAnimator = nullptr;
+ FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ }
+ if (FindPhoneLabel != nullptr)
+ {
+ delete FindPhoneLabel;
+ FindPhoneLabel = nullptr;
}
+ if (FindPhoneLabelButton != nullptr)
+ {
+ delete FindPhoneLabelButton;
+ FindPhoneLabelButton = nullptr;
+ }
+ delete FindPhoneGroupView;
+ FindPhoneGroupView = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
}
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
return;
}
- FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+ FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneTitleLabel->SetText("查找手机");
- FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
- FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+ FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* ----------------------- FindPhoneImageView ---------------------- */
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
return;
}
- FindPhoneLabel->SetPosition(33, 270, 400, 40);
+ FindPhoneLabel->SetPosition(53, 270, 360, 35);
FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneLabel->SetText("蓝牙未连接");
- FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);
- FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);//蓝牙未连接
+ FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetPosition(0, 366, 466, 100);
FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON);
FindPhoneLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
- // FindPhoneLabelButton->SetText("关闭");
- FindPhoneLabelButton->SetTextId(STR_CLOSE);
+ FindPhoneLabelButton->SetTextId(STR_CLOSE);//关闭
FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
FindPhoneGroupView->Add(FindPhoneLabelButton);
container_->Add(FindPhoneGroupView);
}
- viewInitStatus = true;
}
/*蓝牙如果是已连接状态将初始化这个视图*/
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
return;
}
- FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+ FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneTitleLabel->SetText("查找手机");
- FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
- FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+ FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* ----------------------- FindPhoneImageAnimator ---------------------- */
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
return;
}
- FindPhoneLabel->SetPosition(33, 270, 400, 40);
+ FindPhoneLabel->SetPosition(53, 270, 360, 35);
FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneLabel->SetText("手机正在响铃/震动");
- FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);
- FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);//手机正在响铃/震动
+ FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneGroupView->Add(FindPhoneLabelButton);
container_->Add(FindPhoneGroupView);
}
- viewInitStatus = true;
}
void FindPhoneView::OnStart()
{
View<FindPhonePresenter>::OnStart();
- // if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
- // {
- // FindPhoneViewInit_BlueToothConnected();
- // senfindphoneSend(FINDPHONE_START);
- // }
- // else
- // {
- // FindPhoneViewInit_BlueToothDisConnected();
- // }
SetContainerView(new UIViewGroup());
if (GetContainer() == nullptr)
{
container_->SetTouchable(true);
container_->SetDraggable(true);
- if (!viewInitStatus)
+ if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
{
FindPhoneViewInit_BlueToothConnected();
- senfindphoneSend(FINDPHONE_START);
- viewInitStatus = true;
+ FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_START);
}
+ else
+ {
+ FindPhoneViewInit_BlueToothDisConnected();
+ }
+
RootView::GetInstance()->SetOnKeyActListener(presenter_);
}