93 lines
3.2 KiB
C++
93 lines
3.2 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: wuchangxin
|
|
*
|
|
* Create: 2025-03-11
|
|
*--------------------------------------------------------------------------*/
|
|
#include "TjdUiAppFindDevicePresenter.h"
|
|
#include "TjdUiAppFindDeviceView.h"
|
|
#include "TjdUiMsgCenter.h"
|
|
#include "TjdUiRegisterManager.h"
|
|
#include "TjdUiScreenManage.h"
|
|
#include "TjdUiOnKeyListener.h"
|
|
#include "broadcast_feature.h"
|
|
#include "dock/input_device.h"
|
|
#include "notification_manager.h"
|
|
#include "wearable_log.h"
|
|
|
|
namespace TJD {
|
|
|
|
static TjdUiAppFindDevicePresenter *g_pv_AppFindDevicePresenter = nullptr;
|
|
TjdUiAppFindDeviceView *g_FindDeviceView = nullptr;
|
|
TjdUiAppFindDevicePresenter::TjdUiAppFindDevicePresenter() {}
|
|
|
|
TjdUiAppFindDevicePresenter::~TjdUiAppFindDevicePresenter() {}
|
|
|
|
TjdUiAppFindDevicePresenter *TjdUiAppFindDevicePresenter::GetInstance(void) { return g_pv_AppFindDevicePresenter; }
|
|
|
|
bool TjdUiAppFindDevicePresenter::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
ViewExitEvent(view);
|
|
return true;
|
|
}
|
|
|
|
void TjdUiAppFindDevicePresenter::ViewExitEvent(OHOS::UIView &view)
|
|
{
|
|
OHOS::NotificationManager::GetInstance()->StopNotify();
|
|
return;
|
|
}
|
|
|
|
bool TjdUiAppFindDevicePresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
|
|
{
|
|
if(!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
|
|
return true;
|
|
}
|
|
ViewExitEvent(view);
|
|
|
|
return true;
|
|
}
|
|
|
|
void TjdUiFindDeviceMsgCenterMessageProc(const Topic topic, Request *req)
|
|
{
|
|
OHOS::NotificationManager::GetInstance()->SetNotifyPriority(TjdUiMsgCenterGetPriority(topic));
|
|
OHOS::NotificationManager::GetInstance()->ShowNotify(
|
|
[]() -> OHOS::UIViewGroup * {
|
|
g_pv_AppFindDevicePresenter = new TjdUiAppFindDevicePresenter();
|
|
|
|
if (g_FindDeviceView == nullptr) {
|
|
g_FindDeviceView = new TjdUiAppFindDeviceView();
|
|
g_FindDeviceView->SetOnDragListener(g_pv_AppFindDevicePresenter);
|
|
g_FindDeviceView->SetOnClickListener(g_pv_AppFindDevicePresenter);
|
|
}
|
|
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(g_pv_AppFindDevicePresenter,
|
|
KeyModelType::SYS_KEY_TYPE);
|
|
OHOS::NotificationManager::GetInstance()->RegisterNotifyCleanupFunction([]() {
|
|
OHOS::NotificationManager::GetInstance()->SetNotifyPriority(TJD_UI_PRIO_LOWEST);
|
|
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::SYS_KEY_TYPE);
|
|
OHOS::RootView::GetInstance()->Remove(g_FindDeviceView);
|
|
delete g_FindDeviceView;
|
|
delete g_pv_AppFindDevicePresenter;
|
|
g_FindDeviceView = nullptr;
|
|
g_FindDeviceView = nullptr;
|
|
RunPopOutPageCallback();
|
|
});
|
|
return g_FindDeviceView;
|
|
},
|
|
static_cast<uint16_t>(topic), true
|
|
|
|
);
|
|
}
|
|
|
|
extern "C"
|
|
{
|
|
void TjdUiMsgCenterFindDeviceTrigger(void)
|
|
{
|
|
GraphicService::GetInstance()->PostGraphicEvent(
|
|
std::bind(TjdUiMsgEventPublish, TJDUI_TOPIC_EVENT_FIND_DEVICE, nullptr, 0));
|
|
}
|
|
}
|
|
|
|
} // namespace TJD
|