mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-28 01:31:56 +00:00
!36796 [Bug]: 修复无障碍时Search的清空按钮播报不对,TextInput的清空按钮不播报,修复TextInput的密码模式下小眼睛不闪烁,修复theme的不合理代码
Merge pull request !36796 from guan0/master
This commit is contained in:
commit
94bb98c405
@ -88,7 +88,11 @@ static const std::set<std::string> stringAttrs = {
|
||||
"menu_has_filter",
|
||||
"calendar_picker_dialog_button_transparent",
|
||||
"calendar_picker_dialog_divider_transparent",
|
||||
"textfield_accessibility_property_delete"
|
||||
"textfield_accessibility_property_clear",
|
||||
"textfield_accessibility_show_password",
|
||||
"textfield_accessibility_hide_password",
|
||||
"rich_editor_show_handle",
|
||||
"text_show_handle"
|
||||
};
|
||||
|
||||
void ParseNumberUnit(const std::string& value, std::string& number, std::string& unit)
|
||||
|
@ -67,13 +67,8 @@ public:
|
||||
theme->linearSplitChildMinSize_ = pattern->GetAttr<double>(LINEAR_SPLIT_CHILD_MIN_SIZE, childMinSize);
|
||||
theme->isTextFadeout_ = pattern->GetAttr<std::string>("text_fadeout_enable", "") == "true";
|
||||
theme->fadeoutWidth_ = pattern->GetAttr<Dimension>("text_fadeout_width", 16.0_vp);
|
||||
RefPtr<ThemeStyle> textfieldPattern = themeConstants->GetPatternByName("textfield_pattern");
|
||||
if (!textfieldPattern) {
|
||||
LOGW("find pattern of textfield fail");
|
||||
return;
|
||||
}
|
||||
auto textfieldShowHandle = textfieldPattern->GetAttr<std::string>("textfield_show_handle", "0");
|
||||
theme->isShowHandle_ = StringUtils::StringToInt(textfieldShowHandle);
|
||||
auto textShowHandle = pattern->GetAttr<std::string>("text_show_handle", "0");
|
||||
theme->isShowHandle_ = StringUtils::StringToInt(textShowHandle);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -201,7 +201,9 @@ public:
|
||||
theme->cancelButtonIconColor_ = pattern->GetAttr<Color>("cancel_button_icon_color", Color());
|
||||
theme->previewUnderlineColor_ = pattern->GetAttr<Color>(PREVIEW_UNDERLINE_COLOR, Color());
|
||||
theme->previewBoardColor_ = pattern->GetAttr<Color>(PREVIEW_BOARD_COLOR, Color());
|
||||
theme->cancelButton_ = pattern->GetAttr<std::string>("textfield_accessibility_property_delete", "");
|
||||
theme->cancelButton_ = pattern->GetAttr<std::string>("textfield_accessibility_property_clear", "");
|
||||
theme->showPasswordPromptInformation_ = pattern->GetAttr<std::string>("textfield_accessibility_show_password", "");
|
||||
theme->hiddenPasswordPromptInformation_ = pattern->GetAttr<std::string>("textfield_accessibility_hide_password", "");
|
||||
}
|
||||
};
|
||||
|
||||
@ -592,6 +594,16 @@ public:
|
||||
return inlinePaddingRight_;
|
||||
}
|
||||
|
||||
const std::string& GetShowPasswordPromptInformation() const
|
||||
{
|
||||
return showPasswordPromptInformation_;
|
||||
}
|
||||
|
||||
const std::string& GetHiddenPasswordPromptInformation() const
|
||||
{
|
||||
return hiddenPasswordPromptInformation_;
|
||||
}
|
||||
|
||||
protected:
|
||||
TextFieldTheme() = default;
|
||||
|
||||
@ -692,6 +704,8 @@ private:
|
||||
std::string cancelButton_;
|
||||
|
||||
Dimension inlinePaddingRight_ = 12.0_vp;
|
||||
std::string showPasswordPromptInformation_;
|
||||
std::string hiddenPasswordPromptInformation_;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -76,13 +76,8 @@ public:
|
||||
theme->selectedBackgroundColor_ = pattern->GetAttr<Color>("selected_background_color", Color(0xff007dff));
|
||||
theme->previewUnderlineColor_ = pattern->GetAttr<Color>("preview_underline_color", Color(0xff007dff));
|
||||
theme->previewUnderlineWidth_ = pattern->GetAttr<Dimension>("preview_underline_width", 2.0_vp);
|
||||
RefPtr<ThemeStyle> textfieldPattern = themeConstants->GetPatternByName("textfield_pattern");
|
||||
if (!textfieldPattern) {
|
||||
LOGW("find pattern of textfield fail");
|
||||
return;
|
||||
}
|
||||
auto textfieldShowHandle = textfieldPattern->GetAttr<std::string>("textfield_show_handle", "0");
|
||||
theme->richeditorShowHandle_ = StringUtils::StringToInt(textfieldShowHandle);
|
||||
auto showHandle = pattern->GetAttr<std::string>("rich_editor_show_handle", "0");
|
||||
theme->richeditorShowHandle_ = StringUtils::StringToInt(showHandle);
|
||||
theme->textStyle_.SetTextColor(pattern->GetAttr<Color>("default_text_color", DEFAULT_TEXT_COLOR));
|
||||
theme->textStyle_.SetTextDecorationColor(pattern->GetAttr<Color>("default_text_color", DEFAULT_TEXT_COLOR));
|
||||
}
|
||||
|
@ -160,10 +160,31 @@ bool SearchPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
|
||||
} else {
|
||||
cancelButtonSize_ = cancelButtonGeometryNode->GetFrameSize();
|
||||
}
|
||||
|
||||
SetAccessibilityClearAction();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SearchPattern::SetAccessibilityClearAction()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto cancelButtonFrameNode = DynamicCast<FrameNode>(host->GetChildAtIndex(CANCEL_BUTTON_INDEX));
|
||||
CHECK_NULL_VOID(cancelButtonFrameNode);
|
||||
auto textAccessibilityProperty = cancelButtonFrameNode->GetAccessibilityProperty<AccessibilityProperty>();
|
||||
CHECK_NULL_VOID(textAccessibilityProperty);
|
||||
auto textFieldFrameNode = DynamicCast<FrameNode>(host->GetChildAtIndex(TEXTFIELD_INDEX));
|
||||
CHECK_NULL_VOID(textFieldFrameNode);
|
||||
auto textFieldPattern = textFieldFrameNode->GetPattern<TextFieldPattern>();
|
||||
CHECK_NULL_VOID(textFieldPattern);
|
||||
|
||||
auto layoutProperty = GetHost()->GetLayoutProperty<TextFieldLayoutProperty>();
|
||||
CHECK_NULL_VOID(layoutProperty);
|
||||
auto cleanNodeStyle = layoutProperty->GetCleanNodeStyleValue(CleanNodeStyle::INPUT);
|
||||
auto hasContent = cleanNodeStyle == CleanNodeStyle::CONSTANT ||
|
||||
(cleanNodeStyle == CleanNodeStyle::INPUT && textFieldPattern->IsOperation());
|
||||
textAccessibilityProperty->SetAccessibilityText(hasContent ? textFieldPattern->GetCancelButton() : "");
|
||||
}
|
||||
|
||||
void SearchPattern::OnModifyDone()
|
||||
{
|
||||
Pattern::OnModifyDone();
|
||||
|
@ -193,6 +193,7 @@ private:
|
||||
void OnModifyDone() override;
|
||||
void OnAfterModifyDone() override;
|
||||
void SetAccessibilityAction();
|
||||
void SetAccessibilityClearAction();
|
||||
void SetSearchFieldAccessibilityAction();
|
||||
void InitButtonAndImageClickEvent();
|
||||
void InitCancelButtonClickEvent();
|
||||
|
@ -513,11 +513,25 @@ bool TextFieldPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dir
|
||||
if (config.frameSizeChange) {
|
||||
ScheduleDisappearDelayTask();
|
||||
}
|
||||
SetAccessibilityDeleteAction();
|
||||
SetAccessibilityClearAction();
|
||||
SetAccessibilityPasswordIconAction();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextFieldPattern::SetAccessibilityDeleteAction()
|
||||
void TextFieldPattern::SetAccessibilityPasswordIconAction()
|
||||
{
|
||||
if (IsInPasswordMode() && IsShowPasswordIcon()) {
|
||||
auto passwordArea = AceType::DynamicCast<PasswordResponseArea>(responseArea_);
|
||||
CHECK_NULL_VOID(passwordArea);
|
||||
auto node = passwordArea->GetFrameNode();
|
||||
CHECK_NULL_VOID(node);
|
||||
auto textAccessibilityProperty = node->GetAccessibilityProperty<AccessibilityProperty>();
|
||||
CHECK_NULL_VOID(textAccessibilityProperty);
|
||||
textAccessibilityProperty->SetAccessibilityText(GetPasswordIconPromptInformation(passwordArea->IsObscured()));
|
||||
}
|
||||
}
|
||||
|
||||
void TextFieldPattern::SetAccessibilityClearAction()
|
||||
{
|
||||
if (IsShowCancelButtonMode()) {
|
||||
auto cleanNodeResponseArea = AceType::DynamicCast<CleanNodeResponseArea>(cleanNodeResponseArea_);
|
||||
@ -1431,6 +1445,15 @@ std::string TextFieldPattern::GetCancelButton()
|
||||
return theme->GetCancelButton();
|
||||
}
|
||||
|
||||
std::string TextFieldPattern::GetPasswordIconPromptInformation(bool show)
|
||||
{
|
||||
auto pipeline = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_RETURN(pipeline, "");
|
||||
auto theme = pipeline->GetTheme<TextFieldTheme>();
|
||||
CHECK_NULL_RETURN(theme, "");
|
||||
return show ? theme->GetShowPasswordPromptInformation() : theme->GetHiddenPasswordPromptInformation();
|
||||
}
|
||||
|
||||
void TextFieldPattern::UpdateShowCountBorderStyle()
|
||||
{
|
||||
auto host = GetHost();
|
||||
|
@ -861,6 +861,7 @@ public:
|
||||
void StripNextLine(std::wstring& data);
|
||||
bool IsShowHandle();
|
||||
std::string GetCancelButton();
|
||||
std::string GetPasswordIconPromptInformation(bool show);
|
||||
bool OnKeyEvent(const KeyEvent& event);
|
||||
int32_t GetLineCount() const;
|
||||
TextInputType GetKeyboard()
|
||||
@ -1440,7 +1441,8 @@ private:
|
||||
void SetAccessibilityActionGetAndSetCaretPosition();
|
||||
void SetAccessibilityMoveTextAction();
|
||||
void SetAccessibilityScrollAction();
|
||||
void SetAccessibilityDeleteAction();
|
||||
void SetAccessibilityClearAction();
|
||||
void SetAccessibilityPasswordIconAction();
|
||||
|
||||
void UpdateCopyAllStatus();
|
||||
void RestorePreInlineStates();
|
||||
|
@ -86,6 +86,11 @@ public:
|
||||
ChangeObscuredState();
|
||||
}
|
||||
|
||||
bool IsObscured() const
|
||||
{
|
||||
return isObscured_;
|
||||
}
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
void ClearArea() override
|
||||
|
Loading…
Reference in New Issue
Block a user