107 lines
3.8 KiB
C++
107 lines
3.8 KiB
C++
#include "TjdUiAppSettingPresenter.h"
|
|
#include "NativeAbility.h"
|
|
#include "TjdUiAppIds.h"
|
|
#include "TjdUiAppListModel.h"
|
|
#include "TjdUiAppSettingModel.h"
|
|
#include "TjdUiAppSettingView.h"
|
|
#include "TjdUiRegisterManager.h"
|
|
#include "TjdUiUtils.h"
|
|
#include "audio_manager.h"
|
|
|
|
namespace TJD {
|
|
|
|
TJD_REGIST_NATIVE_MENU(TJD_APP_VIEW_SETTING, TjdUiAppSettingView, TjdUiAppSettingPresenter, IMG_MENU_LIST_MENU_SET,
|
|
STR_ID_28);
|
|
|
|
static TjdUiAppSettingPresenter *g_pv_AppSettingPresenter = nullptr;
|
|
|
|
TjdUiAppSettingPresenter::TjdUiAppSettingPresenter() { g_pv_AppSettingPresenter = this; }
|
|
|
|
TjdUiAppSettingPresenter::~TjdUiAppSettingPresenter() { g_pv_AppSettingPresenter = nullptr; }
|
|
|
|
TjdUiAppSettingPresenter *TjdUiAppSettingPresenter::GetInstance(void) { return g_pv_AppSettingPresenter; }
|
|
|
|
void TjdUiAppSettingPresenter::OnStart()
|
|
{
|
|
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(this, KeyModelType::APP_KEY_TYPE);
|
|
}
|
|
|
|
void TjdUiAppSettingPresenter::OnStop()
|
|
{
|
|
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::APP_KEY_TYPE);
|
|
OHOS::FocusManager::GetInstance()->ClearFocus();
|
|
}
|
|
|
|
bool TjdUiAppSettingPresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
|
|
{
|
|
if (!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
|
|
return true;
|
|
}
|
|
ViewExitEvent(false);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool TjdUiAppSettingPresenter::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
std::string viewId = view.GetViewId();
|
|
if (viewId.empty()) {
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool TjdUiAppSettingPresenter::OnClickSettingItem(SettingCaseInfo caseInfo, bool open)
|
|
{
|
|
if (caseInfo.index == SettingItemIndex::SETTING_BLUETOOTH_INDEX) {
|
|
return SetOpenBle(open);
|
|
} else if (caseInfo.index == SettingItemIndex::SETTING_PINCH_TO_ANSWER_INDEX) {
|
|
SetPinchToAnswer(open);
|
|
} else if (caseInfo.index == SettingItemIndex::SETTING_COVER_TO_TURN_OFF_SCREEN_INDEX) {
|
|
SetCoverToTurnOffScreen(open);
|
|
} else {
|
|
isEnterSettingItem_ = true;
|
|
OHOS::NativeAbility::GetInstance().ChangeSlice(caseInfo.sliceId, OHOS::TransitionType::TRANSITION_INVALID,
|
|
OHOS::gSliceDefaultPriority, true);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TjdUiAppSettingPresenter::ViewExitEvent(bool isSwipe) { OHOS::NativeAbility::GetInstance().ChangePreSlice(); }
|
|
|
|
bool TjdUiAppSettingPresenter::SetOpenBle(bool open) { return TjdUiAppSettingModel::GetInstance()->SetOpenBle(open); }
|
|
|
|
bool TjdUiAppSettingPresenter::IsOpenBle() { return TjdUiAppSettingModel::GetInstance()->IsOpenBle(); }
|
|
|
|
std::string TjdUiAppSettingPresenter::GetUserName() { return TjdUiAppSettingModel::GetInstance()->GetUserName(); }
|
|
|
|
bool TjdUiAppSettingPresenter::IsPinchToAnswer() { return TjdUiAppSettingModel::GetInstance()->GetPinchToAnswer(); }
|
|
|
|
bool TjdUiAppSettingPresenter::IsCoverToTurnOffScreen()
|
|
{
|
|
return TjdUiAppSettingModel::GetInstance()->GetCoverToTurnOffScreen();
|
|
}
|
|
|
|
void TjdUiAppSettingPresenter::SetPinchToAnswer(bool enable)
|
|
{
|
|
TjdUiAppSettingModel::GetInstance()->SetPinchToAnswer(enable);
|
|
}
|
|
|
|
void TjdUiAppSettingPresenter::SetCoverToTurnOffScreen(bool enable)
|
|
{
|
|
TjdUiAppSettingModel::GetInstance()->SetCoverToTurnOffScreen(enable);
|
|
}
|
|
|
|
void TjdUiAppSettingPresenter::SetHeadItemY(int y) { TjdUiAppSettingModel::GetInstance()->SetHeadItemY(y); }
|
|
|
|
int TjdUiAppSettingPresenter::GetHeadItemY(void) { return TjdUiAppSettingModel::GetInstance()->GetHeadItemY(); }
|
|
|
|
void TjdUiAppSettingPresenter::SetStartIndex(uint16_t index)
|
|
{
|
|
TjdUiAppSettingModel::GetInstance()->SetStartIndex(index);
|
|
}
|
|
|
|
uint16_t TjdUiAppSettingPresenter::GetStartIndex(void) { return TjdUiAppSettingModel::GetInstance()->GetStartIndex(); }
|
|
|
|
} // namespace TJD
|