mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 17:21:11 +00:00
适配AI新增字段的修改
Signed-off-by: f00574385 <fengsumei@huawei.com> Change-Id: I51e50524ef1c561d4ddb0c5c4a8a278720694220
This commit is contained in:
parent
8b662ceb49
commit
5ffb2ef2c9
@ -220,13 +220,19 @@ void AIWriteAdapter::BindModalUIExtensionCallback(
|
||||
callbacks.onResult = [](int32_t code, const AAFwk::Want& want) {
|
||||
TAG_LOGD(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "UIExtension onResult, code: %{public}d", code);
|
||||
};
|
||||
callbacks.onDestroy = []() {
|
||||
callbacks.onDestroy = [weak = WeakClaim(this)]() {
|
||||
TAG_LOGD(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "UIExtension onDestroy.");
|
||||
auto aiWriteAdapter = weak.Upgrade();
|
||||
CHECK_NULL_VOID(aiWriteAdapter);
|
||||
aiWriteAdapter->CloseModalUIExtension();
|
||||
};
|
||||
callbacks.onError = [](int32_t code, const std::string& name, const std::string& message) {
|
||||
callbacks.onError = [weak = WeakClaim(this)](int32_t code, const std::string& name, const std::string& message) {
|
||||
TAG_LOGE(AceLogTag::ACE_UIEXTENSIONCOMPONENT,
|
||||
"UIExtension onError, code: %{public}d, name: %{public}s, message: %{public}s",
|
||||
code, name.c_str(), message.c_str());
|
||||
auto aiWriteAdapter = weak.Upgrade();
|
||||
CHECK_NULL_VOID(aiWriteAdapter);
|
||||
aiWriteAdapter->CloseModalUIExtension();
|
||||
};
|
||||
callbacks.onRelease = [](int32_t code) {
|
||||
TAG_LOGD(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "UIExtension onRelease, code: %{public}d", code);
|
||||
|
@ -112,6 +112,8 @@ static const std::set<std::string> stringAttrs = {
|
||||
"textfield_writting_ability_name",
|
||||
"rich_editor_writting_bundle_name",
|
||||
"rich_editor_writting_ability_name",
|
||||
"textfield_writting_is_support",
|
||||
"rich_editor_writting_is_support",
|
||||
"ai_write_menu_name",
|
||||
"textfield_accessibility_clear"
|
||||
};
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
theme->hasHiddenPassword_ = pattern->GetAttr<std::string>("textfield_has_hidden_password", "");
|
||||
theme->aiWriteBundleName_ = pattern->GetAttr<std::string>("textfield_writting_bundle_name", "");
|
||||
theme->aiWriteAbilityName_ = pattern->GetAttr<std::string>("textfield_writting_ability_name", "");
|
||||
|
||||
theme->aiWriteIsSupport_ = pattern->GetAttr<std::string>("textfield_writting_is_support", "");
|
||||
}
|
||||
};
|
||||
|
||||
@ -655,6 +655,11 @@ public:
|
||||
{
|
||||
return aiWriteAbilityName_;
|
||||
}
|
||||
|
||||
const std::string& GetAIWriteIsSupport() const
|
||||
{
|
||||
return aiWriteIsSupport_;
|
||||
}
|
||||
protected:
|
||||
TextFieldTheme() = default;
|
||||
|
||||
@ -765,6 +770,7 @@ private:
|
||||
std::string hidePassword_;
|
||||
std::string aiWriteBundleName_;
|
||||
std::string aiWriteAbilityName_;
|
||||
std::string aiWriteIsSupport_;
|
||||
std::string cancelImageText_;
|
||||
};
|
||||
|
||||
|
@ -10433,13 +10433,24 @@ TextStyle RichEditorPattern::GetDefaultTextStyle()
|
||||
bool RichEditorPattern::IsShowAIWrite()
|
||||
{
|
||||
CHECK_NULL_RETURN(!textSelector_.SelectNothing(), false);
|
||||
auto textFieldTheme = GetTheme<RichEditorTheme>();
|
||||
CHECK_NULL_RETURN(textFieldTheme, false);
|
||||
auto bundleName = textFieldTheme->GetAIWriteBundleName();
|
||||
auto abilityName = textFieldTheme->GetAIWriteAbilityName();
|
||||
auto theme = GetTheme<RichEditorTheme>();
|
||||
CHECK_NULL_RETURN(theme, false);
|
||||
auto bundleName = theme->GetAIWriteBundleName();
|
||||
auto abilityName = theme->GetAIWriteAbilityName();
|
||||
if (bundleName.empty() || abilityName.empty()) {
|
||||
return false;
|
||||
}
|
||||
aiWriteAdapter_->SetBundleName(bundleName);
|
||||
aiWriteAdapter_->SetAbilityName(abilityName);
|
||||
return aiWriteAdapter_->GetAISupportFromMetadata(bundleName, abilityName);
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT,
|
||||
"BundleName: %{public}s, abilityName: %{public}s", bundleName.c_str(), abilityName.c_str());
|
||||
|
||||
auto isAISupport = false;
|
||||
if (theme->GetAIWriteIsSupport() == "true") {
|
||||
isAISupport = true;
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isAISupport: %{public}d", isAISupport);
|
||||
return isAISupport;
|
||||
}
|
||||
|
||||
void RichEditorPattern::GetAIWriteInfo(AIWriteInfo& info)
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
theme->textStyle_.SetTextDecorationColor(pattern->GetAttr<Color>("default_text_color", DEFAULT_TEXT_COLOR));
|
||||
theme->aiWriteBundleName_ = pattern->GetAttr<std::string>("rich_editor_writting_bundle_name", "");
|
||||
theme->aiWriteAbilityName_ = pattern->GetAttr<std::string>("rich_editor_writting_ability_name", "");
|
||||
theme->aiWriteIsSupport_ = pattern->GetAttr<std::string>("rich_editor_writting_is_support", "");
|
||||
}
|
||||
};
|
||||
|
||||
@ -197,6 +198,11 @@ public:
|
||||
{
|
||||
return aiWriteAbilityName_;
|
||||
}
|
||||
|
||||
const std::string& GetAIWriteIsSupport() const
|
||||
{
|
||||
return aiWriteIsSupport_;
|
||||
}
|
||||
protected:
|
||||
RichEditorTheme() = default;
|
||||
|
||||
@ -224,6 +230,7 @@ private:
|
||||
bool richeditorShowHandle_ = false;
|
||||
std::string aiWriteBundleName_;
|
||||
std::string aiWriteAbilityName_;
|
||||
std::string aiWriteIsSupport_;
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -8365,9 +8365,19 @@ bool TextFieldPattern::IsShowAIWrite()
|
||||
CHECK_NULL_RETURN(textFieldTheme, false);
|
||||
auto bundleName = textFieldTheme->GetAIWriteBundleName();
|
||||
auto abilityName = textFieldTheme->GetAIWriteAbilityName();
|
||||
if (bundleName.empty() || abilityName.empty()) {
|
||||
return false;
|
||||
}
|
||||
aiWriteAdapter_->SetBundleName(bundleName);
|
||||
aiWriteAdapter_->SetAbilityName(abilityName);
|
||||
auto isAISupport = aiWriteAdapter_->GetAISupportFromMetadata(bundleName, abilityName);
|
||||
TAG_LOGI(AceLogTag::ACE_TEXT_FIELD,
|
||||
"BundleName: %{public}s, abilityName: %{public}s", bundleName.c_str(), abilityName.c_str());
|
||||
|
||||
auto isAISupport = false;
|
||||
if (textFieldTheme->GetAIWriteIsSupport() == "true") {
|
||||
isAISupport = true;
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "isAISupport: %{public}d", isAISupport);
|
||||
return IsUnspecifiedOrTextType() && isAISupport;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user