mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2025-02-17 05:38:18 +00:00
commit
9a0a584201
@ -130,7 +130,6 @@ private:
|
||||
void NotifyPanelStatusInfo(const PanelStatusInfo &info);
|
||||
|
||||
ConcurrentMap<PanelType, std::shared_ptr<InputMethodPanel>> panels_{};
|
||||
std::atomic_bool isPanelKeyboard_{ false };
|
||||
std::atomic_bool isBound_{ false };
|
||||
sptr<InputMethodCoreStub> coreStub_{ nullptr };
|
||||
sptr<InputMethodAgentStub> agentStub_{ nullptr };
|
||||
|
@ -381,7 +381,7 @@ int32_t InputMethodAbility::ShowKeyboard()
|
||||
IMSA_HILOGE("InputMethodAbility::channel is nullptr");
|
||||
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
|
||||
}
|
||||
if (isPanelKeyboard_.load()) {
|
||||
if (panels_.Contains(SOFT_KEYBOARD)) {
|
||||
auto panel = GetSoftKeyboardPanel();
|
||||
if (panel == nullptr) {
|
||||
return ErrorCode::ERROR_IME;
|
||||
@ -704,10 +704,6 @@ int32_t InputMethodAbility::CreatePanel(const std::shared_ptr<AbilityRuntime::Co
|
||||
const PanelInfo &panelInfo, std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility::CreatePanel start.");
|
||||
bool isSoftKeyboard = panelInfo.panelType == PanelType::SOFT_KEYBOARD;
|
||||
if (isSoftKeyboard) {
|
||||
isPanelKeyboard_.store(true);
|
||||
}
|
||||
auto flag = panels_.ComputeIfAbsent(panelInfo.panelType,
|
||||
[&panelInfo, &context, &inputMethodPanel](const PanelType &panelType,
|
||||
std::shared_ptr<InputMethodPanel> &panel) {
|
||||
@ -720,11 +716,7 @@ int32_t InputMethodAbility::CreatePanel(const std::shared_ptr<AbilityRuntime::Co
|
||||
inputMethodPanel = nullptr;
|
||||
return false;
|
||||
});
|
||||
if (!flag) {
|
||||
isPanelKeyboard_.store(false);
|
||||
return ErrorCode::ERROR_OPERATE_PANEL;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
return flag ? ErrorCode::NO_ERROR : ErrorCode::ERROR_OPERATE_PANEL;
|
||||
}
|
||||
|
||||
int32_t InputMethodAbility::DestroyPanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
@ -733,12 +725,9 @@ int32_t InputMethodAbility::DestroyPanel(const std::shared_ptr<InputMethodPanel>
|
||||
if (inputMethodPanel == nullptr) {
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
PanelType panelType = inputMethodPanel->GetPanelType();
|
||||
if (panelType == PanelType::SOFT_KEYBOARD) {
|
||||
isPanelKeyboard_.store(false);
|
||||
}
|
||||
auto ret = inputMethodPanel->DestroyPanel();
|
||||
if (ret == ErrorCode::NO_ERROR) {
|
||||
PanelType panelType = inputMethodPanel->GetPanelType();
|
||||
panels_.Erase(panelType);
|
||||
}
|
||||
return ret;
|
||||
@ -810,7 +799,7 @@ int32_t InputMethodAbility::HideKeyboard(Trigger trigger)
|
||||
return ErrorCode::ERROR_CLIENT_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (isPanelKeyboard_.load()) {
|
||||
if (panels_.Contains(SOFT_KEYBOARD)) {
|
||||
auto panel = GetSoftKeyboardPanel();
|
||||
if (panel == nullptr) {
|
||||
return ErrorCode::ERROR_IME;
|
||||
|
@ -48,7 +48,6 @@ public:
|
||||
inputMethodAbility_->dataChannelObject_ = nullptr;
|
||||
inputMethodAbility_->imeListener_ = nullptr;
|
||||
inputMethodAbility_->panels_.Clear();
|
||||
inputMethodAbility_->isPanelKeyboard_ = false;
|
||||
}
|
||||
static sptr<InputMethodAbility> inputMethodAbility_;
|
||||
};
|
||||
@ -294,12 +293,11 @@ HWTEST_F(InputMethodAbilityExceptionTest, testShowKeyboard_002, TestSize.Level0)
|
||||
// panel exist, PanelFlag == FLG_CANDIDATE_COLUMN
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
panel->panelFlag_ = FLG_CANDIDATE_COLUMN;
|
||||
inputMethodAbility_->isPanelKeyboard_ = true;
|
||||
inputMethodAbility_->panels_.Insert(SOFT_KEYBOARD, panel);
|
||||
ret = inputMethodAbility_->ShowKeyboard();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
// panel not exist
|
||||
inputMethodAbility_->isPanelKeyboard_ = false;
|
||||
inputMethodAbility_->panels_.Clear();
|
||||
ret = inputMethodAbility_->ShowKeyboard();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
@ -332,7 +330,6 @@ HWTEST_F(InputMethodAbilityExceptionTest, testHideKeyboard_001, TestSize.Level0)
|
||||
auto panel = std::make_shared<InputMethodPanel>();
|
||||
panel->panelFlag_ = FLG_CANDIDATE_COLUMN;
|
||||
inputMethodAbility_->panels_.Insert(SOFT_KEYBOARD, panel);
|
||||
inputMethodAbility_->isPanelKeyboard_ = true;
|
||||
ret = inputMethodAbility_->HideKeyboard();
|
||||
EXPECT_EQ(ret, ErrorCode::NO_ERROR);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user