From ea0ec06c9d13415fe0e008bbfc66c1dcca47209a Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 11:51:01 +0000 Subject: [PATCH 01/20] update resources/rk3568/pages/confirm.json. Signed-off-by: bluesky_wang --- resources/rk3568/pages/confirm.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/rk3568/pages/confirm.json b/resources/rk3568/pages/confirm.json index 4a68a808..71b69b9f 100644 --- a/resources/rk3568/pages/confirm.json +++ b/resources/rk3568/pages/confirm.json @@ -9,7 +9,11 @@ "bgColor": "#f1f3f5ff", "fontColor": "#000000e6", "align" : "center", - "style" : "normal" + "style" : "normal", + "focusedBgColor": "#f1f3f5ff", + "focusedFontColor": "#000000e6", + "focusable" : false, + "lineBreakMode" : "ellipsis" }, "UIImageView": { "imgCnt" : 1, -- Gitee From 44441f7615064989e565ea995def466233cb6e29 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 11:51:57 +0000 Subject: [PATCH 02/20] update resources/rk3568/pages/menu.json. Signed-off-by: bluesky_wang --- resources/rk3568/pages/menu.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/rk3568/pages/menu.json b/resources/rk3568/pages/menu.json index d2b11fba..078c2747 100644 --- a/resources/rk3568/pages/menu.json +++ b/resources/rk3568/pages/menu.json @@ -23,7 +23,11 @@ "bgColor": "#f1f3f5ff", "fontColor": "#000000e6", "align" : "center", - "style" : "normal" + "style": "normal", + "focusedBgColor": "#f1f3f5ff", + "focusedFontColor": "#000000e6", + "focusable": false, + "lineBreakMode" : "ellipsis" }, "UIImageView": { "imgCnt" : 1, -- Gitee From 39c5026e849ac5f28d27f34d3ab2869d802a0b79 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 11:52:47 +0000 Subject: [PATCH 03/20] update resources/rk3568/pages/upd.json. Signed-off-by: bluesky_wang --- resources/rk3568/pages/upd.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/rk3568/pages/upd.json b/resources/rk3568/pages/upd.json index ed27e99e..ba88fe0f 100644 --- a/resources/rk3568/pages/upd.json +++ b/resources/rk3568/pages/upd.json @@ -87,7 +87,11 @@ "bgColor": "#000000ff", "fontColor": "#ffffffe6", "align" : "center", - "style" : "normal" + "style" : "normal", + "focusedBgColor": "#000000ff", + "focusedFontColor": "#ffffffe6", + "focusable": false, + "lineBreakMode" : "ellipsis" }, "UIImageView": { "imgCnt" : 1, -- Gitee From c1c75b47311b2cfcd3c78751b34cb7333e225870 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 11:59:06 +0000 Subject: [PATCH 04/20] update services/ui/control/event_listener.cpp. Signed-off-by: bluesky_wang --- services/ui/control/event_listener.cpp | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/services/ui/control/event_listener.cpp b/services/ui/control/event_listener.cpp index 97e583d9..19b2515a 100644 --- a/services/ui/control/event_listener.cpp +++ b/services/ui/control/event_listener.cpp @@ -80,13 +80,31 @@ void CallBackDecorator::CallbackWithGuard(Callback cb, OHOS::UIView &view) } } -bool LabelOnTouchListener::OnRelease(OHOS::UIView &view, [[maybe_unused]] const OHOS::ReleaseEvent &event) +bool LabelOnEventListener::OnClick(OHOS::UIView &view, [[maybe_unused]] const OHOS::ClickEvent &event) { - // wrap cb_ with CallBackDecorator, then call operator()() CallBackDecorator{cb_}(view, cb_.isAsync); return isConsumed_; } +bool LabelOnEventListener::OnPress(OHOS::UIView &view, [[maybe_unused]] const OHOS::PressEvent &event) +{ + KeyListener::SetButtonPressed(true); + return true; +} + +bool LabelOnEventListener::OnRelease(OHOS::UIView &view, [[maybe_unused]] const OHOS::ReleaseEvent &event) +{ + KeyListener::SetButtonPressed(false); + CallBackDecorator{cb_}(view, cb_.isAsync); + return isConsumed_; +} + +bool LabelOnEventListener::OnCancel(OHOS::UIView &view, [[maybe_unused]] const OHOS::CancelEvent &event) +{ + KeyListener::SetButtonPressed(false); + return true; +} + bool BtnOnEventListener::OnClick(OHOS::UIView &view, [[maybe_unused]] const OHOS::ClickEvent &event) { CallBackDecorator{cb_}(view, cb_.isAsync); @@ -160,9 +178,9 @@ bool KeyListener::ProcessPowerKey(OHOS::UIView &view, const OHOS::KeyEvent &even LOG(ERROR) << "focused view is nullptr"; return false; } - // triggering button press event by key only supports label button - if (pView->GetViewType() != OHOS::UI_LABEL_BUTTON) { - LOG(ERROR) << "focused view is not label button"; + // triggering button press event by key supports labelButton and label + if (!((pView->GetViewType() == OHOS::UI_LABEL_BUTTON) || (pView->GetViewType() == OHOS::UI_LABEL))) { + LOG(ERROR) << "focused view is not label button or label; return false; } int16_t centerX = pView->GetX() + static_cast(static_cast(pView->GetWidth()) >> 1u); -- Gitee From 75d92c02f93f4483fe70f8f7b173748963f2a454 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:02:22 +0000 Subject: [PATCH 05/20] update services/ui/control/event_listener.h. Signed-off-by: bluesky_wang --- services/ui/control/event_listener.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/ui/control/event_listener.h b/services/ui/control/event_listener.h index 1fb01d96..969dee84 100644 --- a/services/ui/control/event_listener.h +++ b/services/ui/control/event_listener.h @@ -45,12 +45,15 @@ private: static std::mutex mtx_; }; -class LabelOnTouchListener final : public OHOS::UIView::OnTouchListener { +class LabelOnEventListener final : public OHOS::UIView::OnClickListener, public OHOS::UIView::OnTouchListener { public: - LabelOnTouchListener(Callback cb, bool isConsumed) + LabelOnEventListener(Callback cb, bool isConsumed) : cb_(cb), isConsumed_(isConsumed) {} - ~LabelOnTouchListener() = default; + ~LabelOnEventListener() = default; + bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; + bool OnPress(OHOS::UIView &view, const OHOS::PressEvent &event) override; bool OnRelease(OHOS::UIView &view, const OHOS::ReleaseEvent &event) override; + bool OnCancel(OHOS::UIView &view, const OHOS::CancelEvent &event) override; private: Callback cb_; -- Gitee From 73085c403ac4acae344366ea4594d4da9811f036 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:05:04 +0000 Subject: [PATCH 06/20] update services/ui/control/event_manager.cpp. Signed-off-by: bluesky_wang --- services/ui/control/event_manager.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/services/ui/control/event_manager.cpp b/services/ui/control/event_manager.cpp index cbb95ffc..43839c19 100644 --- a/services/ui/control/event_manager.cpp +++ b/services/ui/control/event_manager.cpp @@ -38,16 +38,21 @@ EventManager &EventManager::GetInstance() return instance; } -void EventManager::Add(const ComInfo &viewId, std::unique_ptr listener) +void EventManager::Add(const ComInfo &viewId, std::unique_ptr listener) { if (!pgMgr_.IsValidCom(viewId)) { LOG(ERROR) << "not an valid view " << viewId; return; } auto com = pgMgr_[viewId.pageId][viewId.comId].As(); - labelOnTouchListener_.push_back(std::move(listener)); + // both click and touch listener + LabelOnEventListener *labelListener = listener.get(); + // save this listener + labelOnClickListener_.push_back(std::move(listener)); + com->SetOnClickListener(labelListener); + // this touch listener used to disable volume key when pressing button com->SetTouchable(true); - com->SetOnTouchListener(labelOnTouchListener_.back().get()); + com->SetOnTouchListener(labelListener); } void EventManager::Add(const ComInfo &viewId, std::unique_ptr listener) @@ -89,9 +94,10 @@ void EventManager::Add(const ComInfo &viewId, EventType evt, Callback cb) switch (evt) { case EventType::CLICKEVENT: Add(viewId, std::make_unique(cb, true)); + Add(viewId, std::make_unique(cb, true)); break; case EventType::TOUCHEVENT: - Add(viewId, std::make_unique(cb, true)); + Add(viewId, std::make_unique(cb, true)); break; case EventType::DRAGEVENT: Add(viewId, std::make_unique(cb, true)); -- Gitee From b49226f902c327fe409463e70d965dedb84f542e Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:06:06 +0000 Subject: [PATCH 07/20] update services/ui/control/event_manager.h. Signed-off-by: bluesky_wang --- services/ui/control/event_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/ui/control/event_manager.h b/services/ui/control/event_manager.h index 9165b961..4a13f3e2 100644 --- a/services/ui/control/event_manager.h +++ b/services/ui/control/event_manager.h @@ -32,7 +32,7 @@ public: EventManager(); ~EventManager() = default; static EventManager &GetInstance(); - void Add(const ComInfo &viewId, std::unique_ptr listener); + void Add(const ComInfo &viewId, std::unique_ptr listener); void Add(const ComInfo &viewId, std::unique_ptr listener); void Add(const ComInfo &viewId, std::unique_ptr listener); void Add(const ComInfo &viewId, EventType evt, Callback cb); @@ -40,7 +40,7 @@ public: private: PageManager &pgMgr_; std::unique_ptr helper_ {}; - std::vector> labelOnTouchListener_; + std::vector> labelOnClickListener_; std::vector> btnOnClickListener_; std::vector> btnOnDragListener; }; -- Gitee From 95b1ec084e758ed2aba4bab06b7f3120ab37361d Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:09:01 +0000 Subject: [PATCH 08/20] update services/ui/updater_ui_traits.h. Signed-off-by: bluesky_wang --- services/ui/updater_ui_traits.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/ui/updater_ui_traits.h b/services/ui/updater_ui_traits.h index 3a971a35..474b3285 100644 --- a/services/ui/updater_ui_traits.h +++ b/services/ui/updater_ui_traits.h @@ -76,7 +76,11 @@ DEFINE_TRAIT(UxLabelInfo, TextLabelAdapter::COMPONENT_TYPE, (std::string, align), (std::string, fontColor), (std::string, bgColor), - (std::string, style) + (std::string, style), + (std::string, focusedFontColor), + (std::string, focusedBgColor), + (bool, focusable), + (std::string, lineBreakMode) ); DEFINE_TRAIT(UxImageInfo, ImgViewAdapter::COMPONENT_TYPE, -- Gitee From 181dab2eeddf8f7e2aa4bbc0b1bfc633eb2626c8 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:14:01 +0000 Subject: [PATCH 09/20] update services/ui/view/component/text_label_adapter.cpp. Signed-off-by: bluesky_wang --- .../ui/view/component/text_label_adapter.cpp | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/services/ui/view/component/text_label_adapter.cpp b/services/ui/view/component/text_label_adapter.cpp index 88ea6068..1e7b4d67 100644 --- a/services/ui/view/component/text_label_adapter.cpp +++ b/services/ui/view/component/text_label_adapter.cpp @@ -13,11 +13,62 @@ * limitations under the License. */ #include "text_label_adapter.h" +#include "dock/focus_manager.h" #include "language/language_ui.h" #include "log/log.h" +#include "page/view_proxy.h" #include "updater_ui_const.h" #include "view_api.h" namespace Updater { +struct TextLabelAdapter::TextLabelOnFocusListener : public OHOS::UIView::OnFocusListener { + DISALLOW_COPY_MOVE(TextLabelOnFocusListener); +public: + TextLabelOnFocusListener(const OHOS::ColorType &focusedFontColor, const OHOS::ColorType &unfocusedFontcolor, + const OHOS::ColorType &focusedBgColor, const OHOS::ColorType &unfocusedBgcolor) + : focusedFontcolor_(focusedFontColor), unfocusedFontcolor_(unfocusedFontcolor), focusedBgcolor_(focusedBgColor), + unfocusedBgcolor_(unfocusedBgcolor) + {} + + ~TextLabelOnFocusListener() {} + + bool OnFocus(OHOS::UIView &view) override + { + TextLabelAdapter *label = nullptr; + if (view.GetViewType() != OHOS::UI_LABEL) { + return false; + } + label = static_cast(&view); + LOG(DEBUG) << "key OnFocus"; + label->SetStyle(OHOS::STYLE_TEXT_COLOR, focusedFontcolor_.full); + label->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, focusedBgcolor_.full); + label->Invalidate(); + return true; + } + + bool OnBlur(OHOS::UIView &view) override + { + TextLabelAdapter *label = nullptr; + if (view.GetViewType() != OHOS::UI_LABEL) { + return false; + } + label = static_cast(&view); + LOG(DEBUG) << "key OnBlur"; + label->SetStyle(OHOS::STYLE_TEXT_COLOR, unfocusedFontcolor_.full); + label->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, unfocusedBgcolor_.full); + label->Invalidate(); + return true; + } +private: + OHOS::ColorType focusedFontcolor_; + OHOS::ColorType unfocusedFontcolor_; + OHOS::ColorType focusedBgcolor_; + OHOS::ColorType unfocusedBgcolor_; +}; + +TextLabelAdapter::TextLabelAdapter() = default; + +TextLabelAdapter::~TextLabelAdapter() = default; + TextLabelAdapter::TextLabelAdapter(const UxViewInfo &info) { const UxLabelInfo &spec = std::get(info.specificInfo); @@ -32,6 +83,19 @@ TextLabelAdapter::TextLabelAdapter(const UxViewInfo &info) auto bgColor = StrToColor(spec.bgColor); this->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, bgColor.full); this->SetStyle(OHOS::STYLE_BACKGROUND_OPA, bgColor.alpha); + if (spec.focusable) { + LOG(DEBUG) << "init focus listener for " << viewId_; + InitFocus(fontColor, bgColor, StrToColor(spec.focusedFontColor), + StrToColor(spec.focusedBgColor)); + } else { + this->SetFocusable(false); + this->SetTouchable(false); + } + + if (spec.lineBreakMode == "marquee") { + this->SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE); + this->SetRollSpeed(80); // 80: label roll speed + } } bool TextLabelAdapter::IsValid(const UxLabelInfo &info) @@ -57,4 +121,19 @@ void TextLabelAdapter::SetText(const std::string &txt) } OHOS::UILabel::SetText(txt.c_str()); } + +bool TextLabelAdapter::OnPressEvent(const OHOS::PressEvent &event) +{ + OHOS::FocusManager::GetInstance()->ClearFocus(); + OHOS::FocusManager::GetInstance()->RequestFocus(this); + return UIView::OnPressEvent(event); +} + +void TextLabelAdapter::InitFocus(const OHOS::ColorType &fontColor, const OHOS::ColorType &bgColor, + const OHOS::ColorType &focusedFontColor, const OHOS::ColorType &focusedBgColor) +{ + focusListener_ = std::make_unique(focusedFontColor, fontColor, focusedBgColor, bgColor); + this->SetFocusable(true); + this->SetOnFocusListener(focusListener_.get()); +} } // namespace Updater -- Gitee From 6134546558b07387e03794d6a9084399f45fc1b1 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:20:10 +0000 Subject: [PATCH 10/20] update services/ui/view/component/text_label_adapter.h. Signed-off-by: bluesky_wang --- services/ui/view/component/text_label_adapter.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/ui/view/component/text_label_adapter.h b/services/ui/view/component/text_label_adapter.h index def8fe53..caabeb31 100644 --- a/services/ui/view/component/text_label_adapter.h +++ b/services/ui/view/component/text_label_adapter.h @@ -27,19 +27,29 @@ struct UxLabelInfo { std::string fontColor; std::string bgColor; std::string style; + std::string focusedFontColor; + std::string focusedBgColor; + bool focusable; + std::string lineBreakMode; }; struct UxViewInfo; class TextLabelAdapter : public OHOS::UILabel, public ComponentCommon { DISALLOW_COPY_MOVE(TextLabelAdapter); + struct TextLabelOnFocusListener; static constexpr uint32_t MAX_FONT_SIZE = 200; public: using SpecificInfoType = UxLabelInfo; static constexpr auto COMPONENT_TYPE = "UILabel"; - TextLabelAdapter() = default; + TextLabelAdapter(); explicit TextLabelAdapter(const UxViewInfo &info); - virtual ~TextLabelAdapter() = default; + virtual ~TextLabelAdapter(); + bool OnPressEvent(const OHOS::PressEvent& event) override; void SetText(const std::string &txt); static bool IsValid(const UxLabelInfo &info); +private: + void InitFocus(const OHOS::ColorType &fontColor, const OHOS::ColorType &bgColor, + const OHOS::ColorType &focusedFontColor, const OHOS::ColorType &focusedBgColor); + std::unique_ptr focusListener_ {}; }; } // namespace Updater #endif -- Gitee From 6fc37eb340a40ac9287ac3ca98457f043d83cb4d Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:23:18 +0000 Subject: [PATCH 11/20] update test/unittest/test_data/ui/layout/all.json. Signed-off-by: bluesky_wang --- test/unittest/test_data/ui/layout/all.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unittest/test_data/ui/layout/all.json b/test/unittest/test_data/ui/layout/all.json index ba9fd10c..36f327d4 100644 --- a/test/unittest/test_data/ui/layout/all.json +++ b/test/unittest/test_data/ui/layout/all.json @@ -15,7 +15,11 @@ "fontSize" : 10, "bgColor" : "#ffffffff", "fontColor" : "#ffffffff", - "style" : "normal" + "style" : "normal", + "focusedBgColor" : "#ffffffff", + "focusedFontColor" : "#ffffffff", + "focusable" : false, + "lineBreakMode" : "ellipsis" }, { "id" : "image_view", -- Gitee From 9336cd4d35f0d715726c90b1f237923504c7c09c Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:24:58 +0000 Subject: [PATCH 12/20] update test/unittest/test_data/ui/layout/commonInvalid.json. Signed-off-by: bluesky_wang --- test/unittest/test_data/ui/layout/commonInvalid.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unittest/test_data/ui/layout/commonInvalid.json b/test/unittest/test_data/ui/layout/commonInvalid.json index 18ec97e9..883862c0 100644 --- a/test/unittest/test_data/ui/layout/commonInvalid.json +++ b/test/unittest/test_data/ui/layout/commonInvalid.json @@ -9,7 +9,11 @@ "bgColor" : "#000000ff", "fontColor" : "#ffffffff", "align" : "center", - "style" : "normal" + "style" : "normal", + "focusedBgColor" : "#000000ff", + "focusedFontColor" : "#ffffffff", + "focusable" : false, + "lineBreakMode" : "ellipsis" } }, "coms" : [ -- Gitee From 435afee639bd653d55af2adb3adfe6c891eb466f Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:25:56 +0000 Subject: [PATCH 13/20] update test/unittest/test_data/ui/layout/label.json. Signed-off-by: bluesky_wang --- test/unittest/test_data/ui/layout/label.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unittest/test_data/ui/layout/label.json b/test/unittest/test_data/ui/layout/label.json index c202a6b6..0e586368 100644 --- a/test/unittest/test_data/ui/layout/label.json +++ b/test/unittest/test_data/ui/layout/label.json @@ -16,7 +16,11 @@ "fontSize" : 10, "bgColor" : "#ffffffff", "fontColor" : "#ffffffff", - "style" : "normal" + "style" : "normal", + "focusedBgColor" : "#ffffffff", + "focusedFontColor" : "#ffffffff", + "focusable" : false, + "lineBreakMode" : "ellipsis" } ] } \ No newline at end of file -- Gitee From 188395e319dbaa7fec24acf864944546567bc253 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:28:04 +0000 Subject: [PATCH 14/20] update test/unittest/test_data/ui/layout/menu.json. Signed-off-by: bluesky_wang --- test/unittest/test_data/ui/layout/menu.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unittest/test_data/ui/layout/menu.json b/test/unittest/test_data/ui/layout/menu.json index 8fa63107..c202d46c 100644 --- a/test/unittest/test_data/ui/layout/menu.json +++ b/test/unittest/test_data/ui/layout/menu.json @@ -9,7 +9,11 @@ "bgColor" : "#000000ff", "fontColor" : "#ffffffff", "align" : "center", - "style" : "normal" + "style" : "normal", + "focusedBgColor" : "#000000ff", + "focusedFontColor" : "#ffffffff", + "focusable" : false, + "lineBreakMode" : "ellipsis" } }, "coms" : [ -- Gitee From 6f8de2dcaf91a7c6ee8aebedd218163b988e6d88 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:28:42 +0000 Subject: [PATCH 15/20] update test/unittest/test_data/ui/layout/typeInvalid.json. Signed-off-by: bluesky_wang --- test/unittest/test_data/ui/layout/typeInvalid.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unittest/test_data/ui/layout/typeInvalid.json b/test/unittest/test_data/ui/layout/typeInvalid.json index 0b0fe0e8..1e5dfdaa 100644 --- a/test/unittest/test_data/ui/layout/typeInvalid.json +++ b/test/unittest/test_data/ui/layout/typeInvalid.json @@ -9,7 +9,11 @@ "bgColor" : "#000000ff", "fontColor" : "#ffffffff", "align" : "center", - "style" : "normal" + "style" : "normal", + "focusedBgColor" : "#000000ff", + "focusedFontColor" : "#ffffffff", + "focusable" : false, + "lineBreakMode" : "ellipsis" } }, "coms" : [ -- Gitee From bec1f00be29c2f6d90ed84145b797bc065827ada Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:32:02 +0000 Subject: [PATCH 16/20] update test/unittest/updater_ui_test/view/ui_component_unittest.cpp. Signed-off-by: bluesky_wang --- .../unittest/updater_ui_test/view/ui_component_unittest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unittest/updater_ui_test/view/ui_component_unittest.cpp b/test/unittest/updater_ui_test/view/ui_component_unittest.cpp index 20911d03..69de97b8 100644 --- a/test/unittest/updater_ui_test/view/ui_component_unittest.cpp +++ b/test/unittest/updater_ui_test/view/ui_component_unittest.cpp @@ -360,7 +360,8 @@ HWTEST_F(UpdaterUiComponentUnitTest, test_text_label_adapter_is_info_valid, Test HWTEST_F(UpdaterUiComponentUnitTest, test_text_label_adapter_constructor, TestSize.Level0) { constexpr auto labelText = "hello"; - UxLabelInfo specInfo {100, "hello", "center", "#000000ff", "#000000ff", "normal"}; + UxLabelInfo specInfo {100, "hello", "center", "#000000ff", "#000000ff", "normal", + "#000000ff", "#000000ff", false, "ellipsis"}; UxViewCommonInfo commonInfo {0, 0, 0, 0, "id", "UILabel", false}; UxViewInfo info {commonInfo, specInfo}; TextLabelAdapter textLabel {info}; @@ -379,7 +380,8 @@ HWTEST_F(UpdaterUiComponentUnitTest, test_text_label_adapter_constructor, TestSi HWTEST_F(UpdaterUiComponentUnitTest, test_text_label_adapter_set_text, TestSize.Level0) { TextLabelAdapter textLabel {UxViewInfo {{0, 0, 0, 0, "id", "UILabel", false}, - UxLabelInfo {255, "", "", "#000000ff", "#000000ff", "normal"}}}; + UxLabelInfo {255, "", "", "#000000ff", "#000000ff", "normal", + "#000000ff", "#000000ff", false, "ellipsis"}}}; constexpr auto testString = "test text"; textLabel.SetText(testString); EXPECT_STREQ(textLabel.GetText(), testString); -- Gitee From edb29fa1067aa8d75b80eb765f4becc7310372fc Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:33:50 +0000 Subject: [PATCH 17/20] update test/unittest/updater_ui_test/view/ui_layout_unittest.cpp. Signed-off-by: bluesky_wang --- .../view/ui_layout_unittest.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/unittest/updater_ui_test/view/ui_layout_unittest.cpp b/test/unittest/updater_ui_test/view/ui_layout_unittest.cpp index 5f719696..8717fe4a 100644 --- a/test/unittest/updater_ui_test/view/ui_layout_unittest.cpp +++ b/test/unittest/updater_ui_test/view/ui_layout_unittest.cpp @@ -108,7 +108,11 @@ HWTEST_F(UpdaterUiLayoutParserUnitTest, test_label_parser, TestSize.Level0) "center", "#ffffffff", "#ffffffff", - "normal" + "normal", + "#ffffffff", + "#ffffffff", + false, + "ellipsis" } }; EXPECT_EQ(pageInfo.viewInfos[0], expectedLabel); } @@ -151,7 +155,11 @@ HWTEST_F(UpdaterUiLayoutParserUnitTest, test_all, TestSize.Level1) "center", "#ffffffff", "#ffffffff", - "normal" + "normal", + "#ffffffff", + "#ffffffff", + false, + "ellipsis" } }; EXPECT_EQ(pageInfo.viewInfos[0], expectedLabel); @@ -180,7 +188,11 @@ HWTEST_F(UpdaterUiLayoutParserUnitTest, test_all_default, TestSize.Level0) "center", "#ffffffff", "#000000ff", - "normal" + "normal", + "#ffffffff", + "#000000ff", + false, + "ellipsis" } }; expected.commonInfo.visible = false; EXPECT_EQ(expected.commonInfo, pageInfo.viewInfos[0].commonInfo); -- Gitee From 351518088e15adf39ba820c3083ecb684703e022 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 12:41:34 +0000 Subject: [PATCH 18/20] update test/unittest/updater_ui_test/view/ui_page_manager_unittest.cpp. Signed-off-by: bluesky_wang --- .../view/ui_page_manager_unittest.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/unittest/updater_ui_test/view/ui_page_manager_unittest.cpp b/test/unittest/updater_ui_test/view/ui_page_manager_unittest.cpp index 5466d498..e2c6c4c0 100644 --- a/test/unittest/updater_ui_test/view/ui_page_manager_unittest.cpp +++ b/test/unittest/updater_ui_test/view/ui_page_manager_unittest.cpp @@ -74,7 +74,8 @@ const std::vector UpdaterUiPageManagerUnitTest::pageInfos_ = { UxViewCommonInfo { 300, 400, 600, 200, "label_id_0", "UILabel", true}, UxLabelInfo { - 50, "this is page1", "center", "#ff0000ff", "#000000ff", "normal"}}, + 50, "this is page1", "center", "#ff0000ff", "#000000ff", "normal", + "#ff0000ff", "#000000ff", false, "ellipsis"}}, UxViewInfo { UxViewCommonInfo { 300, 700, 400, 400, "image_view", "UIImageView", false}, @@ -90,7 +91,8 @@ const std::vector UpdaterUiPageManagerUnitTest::pageInfos_ = { UxViewCommonInfo { 300, 400, 600, 200, "label_id_0", "UILabel", true}, UxLabelInfo { - 50, "this is page2", "center", "#00ff00ff", "#000000ff", "normal"}}, + 50, "this is page2", "center", "#00ff00ff", "#000000ff", "normal", + "#00ff00ff", "#000000ff", false, "ellipsis"}}, UxViewInfo { UxViewCommonInfo { 300, 700, 400, 400, "image_view", "UIImageView", false}, @@ -105,7 +107,8 @@ const std::vector UpdaterUiPageManagerUnitTest::pageInfos_ = { UxViewCommonInfo { 300, 400, 600, 200, "label_id_0", "UILabel", true}, UxLabelInfo { - 50, "this is page2", "center", "#0000ffff", "#000000ff", "normal"}}, + 50, "this is page2", "center", "#0000ffff", "#000000ff", "normal", + "#0000ffff", "#000000ff", false, "ellipsis"}}, UxViewInfo { UxViewCommonInfo { 300, 700, 400, 400, "image_view", "UIImageView", false}, @@ -142,7 +145,8 @@ HWTEST_F(UpdaterUiPageManagerUnitTest, test_page_manager_init_failed, TestSize.L UxViewCommonInfo { 300, 400, 600, 200, "label_id_0", "UILabel", true}, UxLabelInfo { - 50, "this is page1", "center", "#ff0ff", "#0", "normal"}}}, {}} + 50, "this is page1", "center", "#ff0ff", "#0", "normal", + "#ff0ff", "#0", false, "ellipsis"}}}, {}} }; EXPECT_FALSE(GetInstance().Init(pageInfo, "page1")); } @@ -156,7 +160,8 @@ HWTEST_F(UpdaterUiPageManagerUnitTest, test_page_manager_init_failed, TestSize.L UxViewCommonInfo { 300, 400, 600, 200, "label_id_0", "UILabel", true}, UxLabelInfo { - 50, "this is page1", "center", "#000000ff", "#000000ff", "normal"}}}, + 50, "this is page1", "center", "#000000ff", "#000000ff", "normal", + "#000000ff", "#000000ff", false, "ellipsis"}}}, {{UxSubPageInfo {"", "#000000ff", {"label_id_0"}}}}}}; EXPECT_FALSE(GetInstance().Init(pageInfo, "page1")); -- Gitee From 7d0145ab1737ec790a1e8d2b991a7408ceb3be0e Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 13:14:48 +0000 Subject: [PATCH 19/20] update services/ui/control/event_listener.cpp. Signed-off-by: bluesky_wang --- services/ui/control/event_listener.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/ui/control/event_listener.cpp b/services/ui/control/event_listener.cpp index 19b2515a..0f7ce6b8 100644 --- a/services/ui/control/event_listener.cpp +++ b/services/ui/control/event_listener.cpp @@ -91,14 +91,14 @@ bool LabelOnEventListener::OnPress(OHOS::UIView &view, [[maybe_unused]] const OH KeyListener::SetButtonPressed(true); return true; } - + bool LabelOnEventListener::OnRelease(OHOS::UIView &view, [[maybe_unused]] const OHOS::ReleaseEvent &event) { KeyListener::SetButtonPressed(false); CallBackDecorator{cb_}(view, cb_.isAsync); return isConsumed_; } - + bool LabelOnEventListener::OnCancel(OHOS::UIView &view, [[maybe_unused]] const OHOS::CancelEvent &event) { KeyListener::SetButtonPressed(false); @@ -180,7 +180,7 @@ bool KeyListener::ProcessPowerKey(OHOS::UIView &view, const OHOS::KeyEvent &even } // triggering button press event by key supports labelButton and label if (!((pView->GetViewType() == OHOS::UI_LABEL_BUTTON) || (pView->GetViewType() == OHOS::UI_LABEL))) { - LOG(ERROR) << "focused view is not label button or label; + LOG(ERROR) << "focused view is not label button or label"; return false; } int16_t centerX = pView->GetX() + static_cast(static_cast(pView->GetWidth()) >> 1u); -- Gitee From b4699b6e45b8fa8d608f7958d08dab5bc3355db6 Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Sat, 15 Mar 2025 13:18:57 +0000 Subject: [PATCH 20/20] update services/ui/view/component/text_label_adapter.cpp. Signed-off-by: bluesky_wang --- services/ui/view/component/text_label_adapter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/ui/view/component/text_label_adapter.cpp b/services/ui/view/component/text_label_adapter.cpp index 1e7b4d67..5c94d9ee 100644 --- a/services/ui/view/component/text_label_adapter.cpp +++ b/services/ui/view/component/text_label_adapter.cpp @@ -28,9 +28,9 @@ public: : focusedFontcolor_(focusedFontColor), unfocusedFontcolor_(unfocusedFontcolor), focusedBgcolor_(focusedBgColor), unfocusedBgcolor_(unfocusedBgcolor) {} - + ~TextLabelOnFocusListener() {} - + bool OnFocus(OHOS::UIView &view) override { TextLabelAdapter *label = nullptr; @@ -44,7 +44,7 @@ public: label->Invalidate(); return true; } - + bool OnBlur(OHOS::UIView &view) override { TextLabelAdapter *label = nullptr; @@ -64,9 +64,9 @@ private: OHOS::ColorType focusedBgcolor_; OHOS::ColorType unfocusedBgcolor_; }; - + TextLabelAdapter::TextLabelAdapter() = default; - + TextLabelAdapter::~TextLabelAdapter() = default; TextLabelAdapter::TextLabelAdapter(const UxViewInfo &info) @@ -91,7 +91,7 @@ TextLabelAdapter::TextLabelAdapter(const UxViewInfo &info) this->SetFocusable(false); this->SetTouchable(false); } - + if (spec.lineBreakMode == "marquee") { this->SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE); this->SetRollSpeed(80); // 80: label roll speed @@ -128,7 +128,7 @@ bool TextLabelAdapter::OnPressEvent(const OHOS::PressEvent &event) OHOS::FocusManager::GetInstance()->RequestFocus(this); return UIView::OnPressEvent(event); } - + void TextLabelAdapter::InitFocus(const OHOS::ColorType &fontColor, const OHOS::ColorType &bgColor, const OHOS::ColorType &focusedFontColor, const OHOS::ColorType &focusedBgColor) { -- Gitee