From 8e1a37e98af7a71105eb2dc738ca5c6f909c7477 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 25 Apr 2026 14:27:40 +0800 Subject: [PATCH] =?utf8?q?applist1201patch=E5=90=88=E5=B9=B6,=E7=80=91?= =?utf8?q?=E5=B8=83=E6=B5=81=EF=BC=8C=E8=B6=B3=E7=90=83=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../applist/include/FootballDesktopFragment.h | 150 ++++----- .../include/WaterfallDesktopFragment.h | 80 ++--- .../applist/src/FootballDesktopFragment.cpp | 318 +++++++++--------- .../applist/src/WaterfallDesktopFragment.cpp | 264 +++++++-------- .../themestyle/src/ThemeStyleCatalog.cpp | 16 +- 5 files changed, 418 insertions(+), 410 deletions(-) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/FootballDesktopFragment.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/FootballDesktopFragment.h index a5851cdfd..7c107603b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/FootballDesktopFragment.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/FootballDesktopFragment.h @@ -1,87 +1,87 @@ -// /* -// * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. -// * Description: FootballDesktopFragment.h -// * Author: -// * Create: 2025-07-04 -// */ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: FootballDesktopFragment.h + * Author: + * Create: 2025-07-04 + */ -// #ifndef FOOTBALL_DESKTOP_FRAGMENT_H -// #define FOOTBALL_DESKTOP_FRAGMENT_H +#ifndef FOOTBALL_DESKTOP_FRAGMENT_H +#define FOOTBALL_DESKTOP_FRAGMENT_H -// #include "UIDesktopFragment.h" -// #include "components/ui_icosahedron_view.h" +#include "UIDesktopFragment.h" +#include "components/ui_icosahedron_view.h" -// namespace OHOS { -// class FootballAnimatorCallback; -// class FootballItemView; -// class FootballDesktopFragment : public UIDesktopFragment { -// public: -// bool OnClick(UIView &view, const ClickEvent &event) override; -// void AddAppItemToList(const AppItem &item) override; -// void ClearAppItemToList() override; -// void RefreshAppList() override; +namespace OHOS { +class FootballAnimatorCallback; +class FootballItemView; +class FootballDesktopFragment : public UIDesktopFragment { +public: + bool OnClick(UIView &view, const ClickEvent &event) override; + void AddAppItemToList(const AppItem &item) override; + void ClearAppItemToList() override; + void RefreshAppList() override; -// protected: -// void OnCreateView(void* data) override; -// void OnDestroyView() override; -// void OnResumeView() override; +protected: + void OnCreateView(void* data) override; + void OnDestroyView() override; + void OnResumeView() override; -// private: -// UIIcosahedronView* footballList_ = nullptr; -// List footballItemList_; -// ImageInfo* footballDefaultImg_ = nullptr; -// FootballAnimatorCallback* callback_ = nullptr; -// Animator* enterAnimator_ = nullptr; -// }; +private: + UIIcosahedronView* footballList_ = nullptr; + List footballItemList_; + ImageInfo* footballDefaultImg_ = nullptr; + FootballAnimatorCallback* callback_ = nullptr; + Animator* enterAnimator_ = nullptr; +}; -// class FootballAnimatorCallback : public AnimatorCallback { -// public: -// explicit FootballAnimatorCallback(UIView* view, int16_t startPos, int16_t endPos) -// : startPos_(startPos), -// endPos_(endPos), -// startTime_(0), -// animator_(new Animator(this, view, 1000, false)) {} // 1000:duration of animator_, in milliseconds. +class FootballAnimatorCallback : public AnimatorCallback { +public: + explicit FootballAnimatorCallback(UIView* view, int16_t startPos, int16_t endPos) + : startPos_(startPos), + endPos_(endPos), + startTime_(0), + animator_(new Animator(this, view, 1000, false)) {} // 1000:duration of animator_, in milliseconds. -// ~FootballAnimatorCallback() override -// { -// if (animator_ != nullptr) { -// delete animator_; -// animator_ = nullptr; -// } -// } + ~FootballAnimatorCallback() override + { + if (animator_ != nullptr) { + delete animator_; + animator_ = nullptr; + } + } -// void Callback(UIView* view) override; + void Callback(UIView* view) override; -// Animator* GetAnimator() const -// { -// return animator_; -// } + Animator* GetAnimator() const + { + return animator_; + } -// void SetStartTime(uint32_t time) -// { -// isStartAnim_ = false; -// startTime_ = time; -// } -// protected: -// int16_t startPos_; -// int16_t endPos_; -// uint32_t startTime_; -// bool isStartAnim_ = false; -// Animator* animator_; -// }; + void SetStartTime(uint32_t time) + { + isStartAnim_ = false; + startTime_ = time; + } +protected: + int16_t startPos_; + int16_t endPos_; + uint32_t startTime_; + bool isStartAnim_ = false; + Animator* animator_; +}; -// class FootballItemView : public UIImageView { -// public: -// explicit FootballItemView() {} -// ~FootballItemView() override; -// bool SetItemInfo(const AppItem &itemInfo); -// AppViewId GetViewId(); -// const char *GetAppUid(); -// private: -// FootballItemView(const FootballItemView &); -// FootballItemView &operator = (const FootballItemView &); -// AppItem itemInfo_; -// }; -// } +class FootballItemView : public UIImageView { +public: + explicit FootballItemView() {} + ~FootballItemView() override; + bool SetItemInfo(const AppItem &itemInfo); + AppViewId GetViewId(); + const char *GetAppUid(); +private: + FootballItemView(const FootballItemView &); + FootballItemView &operator = (const FootballItemView &); + AppItem itemInfo_; +}; +} -// #endif // FOOTBALL_DESKTOP_FRAGMENT_H +#endif // FOOTBALL_DESKTOP_FRAGMENT_H diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/WaterfallDesktopFragment.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/WaterfallDesktopFragment.h index 96a73d28e..4a2fa1833 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/WaterfallDesktopFragment.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/include/WaterfallDesktopFragment.h @@ -1,47 +1,47 @@ -// /* -// * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. -// * Description: WaterfallDesktopFragment.h -// * Author: -// * Create: 2025-07-04 -// */ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: WaterfallDesktopFragment.h + * Author: + * Create: 2025-07-04 + */ -// #ifndef WATERFALL_DESKTOP_FRAGMENT_H -// #define WATERFALL_DESKTOP_FRAGMENT_H +#ifndef WATERFALL_DESKTOP_FRAGMENT_H +#define WATERFALL_DESKTOP_FRAGMENT_H -// #include "UIDesktopFragment.h" -// #include "components/ui_waterfall_list.h" +#include "UIDesktopFragment.h" +#include "components/ui_waterfall_list.h" -// namespace OHOS { -// class WaterfallItemView; -// class WaterfallDesktopFragment : public UIDesktopFragment { -// public: -// bool OnClick(UIView &view, const ClickEvent &event) override; -// void AddAppItemToList(const AppItem &item) override; -// void ClearAppItemToList() override; -// void RefreshAppList() override; +namespace OHOS { +class WaterfallItemView; +class WaterfallDesktopFragment : public UIDesktopFragment { +public: + bool OnClick(UIView &view, const ClickEvent &event) override; + void AddAppItemToList(const AppItem &item) override; + void ClearAppItemToList() override; + void RefreshAppList() override; -// protected: -// void OnCreateView(void* data) override; -// void OnDestroyView() override; -// void OnResumeView() override; +protected: + void OnCreateView(void* data) override; + void OnDestroyView() override; + void OnResumeView() override; -// private: -// UIWaterfallList* waterfallList_{nullptr}; -// List waterfallItemList_; -// }; +private: + UIWaterfallList* waterfallList_{nullptr}; + List waterfallItemList_; +}; -// class WaterfallItemView : public UIImageView { -// public: -// explicit WaterfallItemView() {} -// ~WaterfallItemView(); -// bool SetItemInfo(const AppItem &itemInfo); -// AppViewId GetViewId(); -// const char *GetAppUid(); -// private: -// WaterfallItemView(const WaterfallItemView &); -// WaterfallItemView &operator = (const WaterfallItemView &); -// AppItem itemInfo_; -// }; -// } +class WaterfallItemView : public UIImageView { +public: + explicit WaterfallItemView() {} + ~WaterfallItemView(); + bool SetItemInfo(const AppItem &itemInfo); + AppViewId GetViewId(); + const char *GetAppUid(); +private: + WaterfallItemView(const WaterfallItemView &); + WaterfallItemView &operator = (const WaterfallItemView &); + AppItem itemInfo_; +}; +} -// #endif // WATERFALL_DESKTOP_FRAGMENT_H +#endif // WATERFALL_DESKTOP_FRAGMENT_H diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/FootballDesktopFragment.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/FootballDesktopFragment.cpp index a57ea87e3..91b3d3d7d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/FootballDesktopFragment.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/FootballDesktopFragment.cpp @@ -1,174 +1,174 @@ -// /* -// * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. -// * Description: FootballDesktopFragment.cpp -// * Author: -// * Create: 2025-07-04 -// */ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: FootballDesktopFragment.cpp + * Author: + * Create: 2025-07-04 + */ -// #include "applist/include/FootballDesktopFragment.h" -// #include "applist/include/DesktopFactory.h" -// #include "common/image_cache_manager.h" -// #include "common/screen.h" -// #include "hal_tick.h" +#include "applist/include/FootballDesktopFragment.h" +#include "applist/include/DesktopFactory.h" +#include "common/image_cache_manager.h" +#include "common/screen.h" +#include "hal_tick.h" -// namespace OHOS { -// REGIST_DESKTOP_STYLE(FOOTBALL_STYLE, FootballDesktopFragment); +namespace OHOS { +REGIST_DESKTOP_STYLE(FOOTBALL_STYLE, FootballDesktopFragment); -// void FootballDesktopFragment::OnCreateView(void* data) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnCreateView "); -// if (footballList_ == nullptr) { -// footballList_ = new UIIcosahedronView(); -// } -// footballList_->SetThrowDrag(true); -// if (footballDefaultImg_ == nullptr) { -// footballDefaultImg_ = ImageCacheManager::GetInstance().LoadSingleRes(PNG_APPLIST_NOTSETUSE_IMG); -// if (footballDefaultImg_ == nullptr) { -// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "load res faild"); -// return; -// } -// } -// if (callback_ == nullptr) { -// callback_ = new FootballAnimatorCallback(footballList_, 30, 200); // 30: Initial Size 200: Final display size -// } -// footballList_->SetDefaultImage(footballDefaultImg_); -// footballList_->SetPosition(0, 0, fragmentView_.GetWidth(), fragmentView_.GetHeight()); -// enterAnimator_ = callback_->GetAnimator(); -// fragmentView_.Add(footballList_); -// if (callback_ != nullptr) { -// callback_->SetStartTime(HALTick::GetInstance().GetTime()); -// } -// } +void FootballDesktopFragment::OnCreateView(void* data) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnCreateView "); + if (footballList_ == nullptr) { + footballList_ = new UIIcosahedronView(); + } + footballList_->SetThrowDrag(true); + if (footballDefaultImg_ == nullptr) { + footballDefaultImg_ = ImageCacheManager::GetInstance().LoadSingleRes(PNG_APPLIST_NOTSETUSE_IMG); + if (footballDefaultImg_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "load res faild"); + return; + } + } + if (callback_ == nullptr) { + callback_ = new FootballAnimatorCallback(footballList_, 30, 200); // 30: Initial Size 200: Final display size + } + footballList_->SetDefaultImage(footballDefaultImg_); + footballList_->SetPosition(0, 0, fragmentView_.GetWidth(), fragmentView_.GetHeight()); + enterAnimator_ = callback_->GetAnimator(); + fragmentView_.Add(footballList_); + if (callback_ != nullptr) { + callback_->SetStartTime(HALTick::GetInstance().GetTime()); + } +} -// void FootballDesktopFragment::OnDestroyView() -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnDestroyView"); -// ClearAppItemToList(); -// if (footballList_ != nullptr) { -// delete footballList_; -// footballList_ = nullptr; -// } -// if (footballDefaultImg_ != nullptr) { -// ImageCacheManager::GetInstance().UnloadSingleRes(PNG_APPLIST_NOTSETUSE_IMG); -// footballDefaultImg_ = nullptr; -// } -// if (callback_ != nullptr) { -// delete callback_; -// callback_ = nullptr; -// } -// enterAnimator_ = nullptr; -// } +void FootballDesktopFragment::OnDestroyView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnDestroyView"); + ClearAppItemToList(); + if (footballList_ != nullptr) { + delete footballList_; + footballList_ = nullptr; + } + if (footballDefaultImg_ != nullptr) { + ImageCacheManager::GetInstance().UnloadSingleRes(PNG_APPLIST_NOTSETUSE_IMG); + footballDefaultImg_ = nullptr; + } + if (callback_ != nullptr) { + delete callback_; + callback_ = nullptr; + } + enterAnimator_ = nullptr; +} -// void FootballDesktopFragment::OnResumeView() -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnResumeView"); -// if (enterAnimator_ != nullptr) { -// enterAnimator_->Start(); -// } -// } +void FootballDesktopFragment::OnResumeView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnResumeView"); + if (enterAnimator_ != nullptr) { + enterAnimator_->Start(); + } +} -// bool FootballDesktopFragment::OnClick(UIView &view, const ClickEvent &event) -// { -// UNUSED(event); -// FootballItemView *itemView = dynamic_cast(&view); -// AppViewId viewId = itemView->GetViewId(); -// char *uid = (char *)itemView->GetAppUid(); +bool FootballDesktopFragment::OnClick(UIView &view, const ClickEvent &event) +{ + UNUSED(event); + FootballItemView *itemView = dynamic_cast(&view); + AppViewId viewId = itemView->GetViewId(); + char *uid = (char *)itemView->GetAppUid(); -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnClick viewid = %d", viewId); -// return SwitchView(viewId, uid, TransitionType::TRANSITION_INVALID, FOOTBALL_STYLE); -// } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::OnClick viewid = %d", viewId); + return SwitchView(viewId, uid, TransitionType::TRANSITION_INVALID, FOOTBALL_STYLE); +} -// void FootballDesktopFragment::AddAppItemToList(const AppItem &item) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::AddAppItemToList"); -// FootballItemView *itemView = new FootballItemView(); -// if (!itemView->SetItemInfo(item)) { -// delete itemView; -// return; -// } -// itemView->SetTouchable(true); -// itemView->SetOnClickListener(this); -// footballList_->Add(itemView); -// footballItemList_.PushBack(itemView); -// } +void FootballDesktopFragment::AddAppItemToList(const AppItem &item) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::AddAppItemToList"); + FootballItemView *itemView = new FootballItemView(); + if (!itemView->SetItemInfo(item)) { + delete itemView; + return; + } + itemView->SetTouchable(true); + itemView->SetOnClickListener(this); + footballList_->Add(itemView); + footballItemList_.PushBack(itemView); +} -// void FootballDesktopFragment::ClearAppItemToList() -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::ClearAppItemToList"); -// if (enterAnimator_ != nullptr) { -// enterAnimator_->Stop(); -// } -// if (footballList_ != nullptr) { -// footballList_->RemoveAll(); -// } -// ListNode* viewNode = footballItemList_.Head(); -// while (viewNode != footballItemList_.End()) { -// delete(viewNode->data_); -// viewNode = viewNode->next_; -// } -// footballItemList_.Clear(); -// } +void FootballDesktopFragment::ClearAppItemToList() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::ClearAppItemToList"); + if (enterAnimator_ != nullptr) { + enterAnimator_->Stop(); + } + if (footballList_ != nullptr) { + footballList_->RemoveAll(); + } + ListNode* viewNode = footballItemList_.Head(); + while (viewNode != footballItemList_.End()) { + delete(viewNode->data_); + viewNode = viewNode->next_; + } + footballItemList_.Clear(); +} -// void FootballDesktopFragment::RefreshAppList(void) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::RefreshAppList"); -// footballList_->RefreshIcosahedron(); -// } +void FootballDesktopFragment::RefreshAppList(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FootballDesktopFragment::RefreshAppList"); + footballList_->RefreshIcosahedron(); +} -// void FootballAnimatorCallback::Callback(UIView *view) -// { -// if (HALTick::GetInstance().GetElapseTime(startTime_) < 300) { // 300, empirical coefficient -// return; -// } -// if (!isStartAnim_) { -// animator_->Stop(); -// animator_->Start(); -// isStartAnim_ = true; -// } -// UIIcosahedronView* footView = dynamic_cast(view); -// int16_t el = EasingEquation::LinearEaseNone(startPos_, endPos_, animator_->GetRunTime(), animator_->GetTime()); -// footView->SetSideLength(el); -// footView->RefreshIcosahedron(); -// const Vector3 rotateStart(Screen::GetInstance().GetWidth() / 2.0, // 2.0: divisor -// Screen::GetInstance().GetHeight() / 2.0, 0); // 2.0: divisor -// const Vector3 rotateEnd(0, 0, 0); -// // 270 : stop angle -// int16_t angle = EasingEquation::LinearEaseNone(0, 270, animator_->GetRunTime(), animator_->GetTime()); -// footView->RotatePlanes(angle, rotateStart, rotateEnd); -// } +void FootballAnimatorCallback::Callback(UIView *view) +{ + if (HALTick::GetInstance().GetElapseTime(startTime_) < 300) { // 300, empirical coefficient + return; + } + if (!isStartAnim_) { + animator_->Stop(); + animator_->Start(); + isStartAnim_ = true; + } + UIIcosahedronView* footView = dynamic_cast(view); + int16_t el = EasingEquation::LinearEaseNone(startPos_, endPos_, animator_->GetRunTime(), animator_->GetTime()); + footView->SetSideLength(el); + footView->RefreshIcosahedron(); + const Vector3 rotateStart(Screen::GetInstance().GetWidth() / 2.0, // 2.0: divisor + Screen::GetInstance().GetHeight() / 2.0, 0); // 2.0: divisor + const Vector3 rotateEnd(0, 0, 0); + // 270 : stop angle + int16_t angle = EasingEquation::LinearEaseNone(0, 270, animator_->GetRunTime(), animator_->GetTime()); + footView->RotatePlanes(angle, rotateStart, rotateEnd); +} -// FootballItemView::~FootballItemView() -// { -// if (itemInfo_.iconHexagon == nullptr && itemInfo_.hexagonPath != nullptr) { -// ImageCacheManager::GetInstance().UnloadOneInMultiRes(itemInfo_.hexagonId, itemInfo_.hexagonPath); -// } -// } +FootballItemView::~FootballItemView() +{ + if (itemInfo_.iconHexagon == nullptr && itemInfo_.hexagonPath != nullptr) { + ImageCacheManager::GetInstance().UnloadOneInMultiRes(itemInfo_.hexagonId, itemInfo_.hexagonPath); + } +} -// bool FootballItemView::SetItemInfo(const AppItem &itemInfo) -// { -// itemInfo_ = itemInfo; -// if (itemInfo.iconHexagon == nullptr && itemInfo.hexagonPath != nullptr) { -// ImageInfo* image = -// ImageCacheManager::GetInstance().LoadOneInMultiRes(itemInfo.hexagonId, itemInfo.hexagonPath); -// if (image == nullptr) { -// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Load App Icon path %s Image %x fail", -// itemInfo.hexagonId, itemInfo.hexagonPath); -// return false; -// } -// SetSrc(image); -// } else { -// SetSrc(itemInfo.iconHexagon); -// } -// return true; -// } +bool FootballItemView::SetItemInfo(const AppItem &itemInfo) +{ + itemInfo_ = itemInfo; + if (itemInfo.iconHexagon == nullptr && itemInfo.hexagonPath != nullptr) { + ImageInfo* image = + ImageCacheManager::GetInstance().LoadOneInMultiRes(itemInfo.hexagonId, itemInfo.hexagonPath); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Load App Icon path %s Image %x fail", + itemInfo.hexagonId, itemInfo.hexagonPath); + return false; + } + SetSrc(image); + } else { + SetSrc(itemInfo.iconHexagon); + } + return true; +} -// AppViewId FootballItemView::GetViewId() -// { -// return static_cast(itemInfo_.id); -// } +AppViewId FootballItemView::GetViewId() +{ + return static_cast(itemInfo_.id); +} -// const char *FootballItemView::GetAppUid() -// { -// return itemInfo_.uid; -// } -// } +const char *FootballItemView::GetAppUid() +{ + return itemInfo_.uid; +} +} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/WaterfallDesktopFragment.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/WaterfallDesktopFragment.cpp index 6e73e2c62..bdf8ac2fd 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/WaterfallDesktopFragment.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/WaterfallDesktopFragment.cpp @@ -1,146 +1,146 @@ -// /* -// * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. -// * Description: WaterfallDesktopFragment.cpp -// * Author: -// * Create: 2025-07-04 -// */ +/* + * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved. + * Description: WaterfallDesktopFragment.cpp + * Author: + * Create: 2025-07-04 + */ -// #include "applist/include/WaterfallDesktopFragment.h" -// #include "applist/include/DesktopFactory.h" -// #include "common/image_cache_manager.h" -// #include "common/screen.h" +#include "applist/include/WaterfallDesktopFragment.h" +#include "applist/include/DesktopFactory.h" +#include "common/image_cache_manager.h" +#include "common/screen.h" -// namespace OHOS { -// REGIST_DESKTOP_STYLE(WATERFALL_STYLE, WaterfallDesktopFragment); +namespace OHOS { +REGIST_DESKTOP_STYLE(WATERFALL_STYLE, WaterfallDesktopFragment); -// void WaterfallDesktopFragment::OnCreateView(void* data) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnCreateView "); -// if (waterfallList_ == nullptr) { -// waterfallList_ = new UIWaterfallList(); -// } -// waterfallList_->SetPosition(0, 0, fragmentView_.GetWidth(), fragmentView_.GetHeight()); -// imgDistance_ = waterfallList_->GetWidth() * 0.25991; // 0.25991, empirical coefficient -// imgSize_ = waterfallList_->GetWidth() * 0.23348; // 0.23348, empirical coefficient -// waterfallList_->SetImageDistance(imgDistance_); -// waterfallList_->SetImageSizeInCenter(imgSize_); -// int16_t blankSize = waterfallList_->GetRelativeRect().GetWidth() > waterfallList_->GetRelativeRect().GetHeight() ? -// waterfallList_->GetRelativeRect().GetWidth() / 2 : waterfallList_->GetRelativeRect().GetHeight() / 2; // 2, half -// waterfallList_->SetThrowDrag(true); -// uint16_t layoutHeight = static_cast(imgDistance_ * Sin(60)); -// waterfallList_->SetReboundSize(layoutHeight); // 60: degree, row's layout height -// waterfallList_->SetScrollBlankSize(layoutHeight, UIAbstractScroll::Direction::TOP); -// waterfallList_->SetScrollBlankSize(Screen::GetInstance().GetHeight() / 2 - layoutHeight, // 2: half -// UIAbstractScroll::Direction::BOTTOM); -// waterfallList_->RequestFocus(); -// waterfallList_->SetRotateFactor(10); // 10, empirical coefficient -// waterfallList_->SetOnRotateListener(this); -// waterfallList_->SetTouchable(false); -// waterfallList_->SetDraggable(false); // ensure that it can't be dragged during animation to avoid error display -// fragmentView_.Add(waterfallList_); -// } +void WaterfallDesktopFragment::OnCreateView(void* data) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnCreateView "); + if (waterfallList_ == nullptr) { + waterfallList_ = new UIWaterfallList(); + } + waterfallList_->SetPosition(0, 0, fragmentView_.GetWidth(), fragmentView_.GetHeight()); + imgDistance_ = waterfallList_->GetWidth() * 0.25991; // 0.25991, empirical coefficient + imgSize_ = waterfallList_->GetWidth() * 0.23348; // 0.23348, empirical coefficient + waterfallList_->SetImageDistance(imgDistance_); + waterfallList_->SetImageSizeInCenter(imgSize_); + int16_t blankSize = waterfallList_->GetRelativeRect().GetWidth() > waterfallList_->GetRelativeRect().GetHeight() ? + waterfallList_->GetRelativeRect().GetWidth() / 2 : waterfallList_->GetRelativeRect().GetHeight() / 2; // 2, half + waterfallList_->SetThrowDrag(true); + uint16_t layoutHeight = static_cast(imgDistance_ * Sin(60)); + waterfallList_->SetReboundSize(layoutHeight); // 60: degree, row's layout height + waterfallList_->SetScrollBlankSize(layoutHeight, UIAbstractScroll::Direction::TOP); + waterfallList_->SetScrollBlankSize(Screen::GetInstance().GetHeight() / 2 - layoutHeight, // 2: half + UIAbstractScroll::Direction::BOTTOM); + waterfallList_->RequestFocus(); + waterfallList_->SetRotateFactor(10); // 10, empirical coefficient + waterfallList_->SetOnRotateListener(this); + waterfallList_->SetTouchable(false); + waterfallList_->SetDraggable(false); // ensure that it can't be dragged during animation to avoid error display + fragmentView_.Add(waterfallList_); +} -// void WaterfallDesktopFragment::OnDestroyView() -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnDestroyView"); -// ClearAppItemToList(); -// if (waterfallList_ != nullptr) { -// delete waterfallList_; -// waterfallList_ = nullptr; -// } -// } +void WaterfallDesktopFragment::OnDestroyView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnDestroyView"); + ClearAppItemToList(); + if (waterfallList_ != nullptr) { + delete waterfallList_; + waterfallList_ = nullptr; + } +} -// void WaterfallDesktopFragment::OnResumeView() -// { -// if (waterfallList_ != nullptr) { -// waterfallList_->SetTouchable(true); -// waterfallList_->SetDraggable(true); // resume touchable after transition animation -// } -// } +void WaterfallDesktopFragment::OnResumeView() +{ + if (waterfallList_ != nullptr) { + waterfallList_->SetTouchable(true); + waterfallList_->SetDraggable(true); // resume touchable after transition animation + } +} -// bool WaterfallDesktopFragment::OnClick(UIView &view, const ClickEvent &event) -// { -// UNUSED(event); -// WaterfallItemView *itemView = dynamic_cast(&view); -// UIWaterfallList *waterfallView = dynamic_cast(itemView->GetParent()); -// if (waterfallView == nullptr || itemView == nullptr) { -// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "waterfallView or itemView is nullptr"); -// return false; -// } -// AppViewId viewId = itemView->GetViewId(); -// char *uid = (char *)itemView->GetAppUid(); -// waterfallView->SetDraggable(false); -// waterfallView->Scale(1.0f, itemView->GetViewIndex()); +bool WaterfallDesktopFragment::OnClick(UIView &view, const ClickEvent &event) +{ + UNUSED(event); + WaterfallItemView *itemView = dynamic_cast(&view); + UIWaterfallList *waterfallView = dynamic_cast(itemView->GetParent()); + if (waterfallView == nullptr || itemView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "waterfallView or itemView is nullptr"); + return false; + } + AppViewId viewId = itemView->GetViewId(); + char *uid = (char *)itemView->GetAppUid(); + waterfallView->SetDraggable(false); + waterfallView->Scale(1.0f, itemView->GetViewIndex()); -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnClick viewid = %d", viewId); -// return SwitchView(viewId, uid, TransitionType::TRANSITION_WATERFALL, APPLIST_STYLE); -// } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::OnClick viewid = %d", viewId); + return SwitchView(viewId, uid, TransitionType::TRANSITION_WATERFALL, APPLIST_STYLE); +} -// void WaterfallDesktopFragment::AddAppItemToList(const AppItem &item) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::AddAppItemToList"); -// WaterfallItemView *itemView = new WaterfallItemView(); -// if (!itemView->SetItemInfo(item)) { -// delete itemView; -// return; -// } -// itemView->SetTouchable(true); -// itemView->SetOnClickListener(this); -// waterfallList_->Add(itemView); -// waterfallItemList_.PushBack(itemView); -// } +void WaterfallDesktopFragment::AddAppItemToList(const AppItem &item) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::AddAppItemToList"); + WaterfallItemView *itemView = new WaterfallItemView(); + if (!itemView->SetItemInfo(item)) { + delete itemView; + return; + } + itemView->SetTouchable(true); + itemView->SetOnClickListener(this); + waterfallList_->Add(itemView); + waterfallItemList_.PushBack(itemView); +} -// void WaterfallDesktopFragment::ClearAppItemToList() -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::ClearAppItemToList"); -// if (waterfallList_ != nullptr) { -// waterfallList_->RemoveAll(); -// } -// ListNode* viewNode = waterfallItemList_.Head(); -// while (viewNode != waterfallItemList_.End()) { -// delete(viewNode->data_); -// viewNode = viewNode->next_; -// } -// waterfallItemList_.Clear(); -// } +void WaterfallDesktopFragment::ClearAppItemToList() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::ClearAppItemToList"); + if (waterfallList_ != nullptr) { + waterfallList_->RemoveAll(); + } + ListNode* viewNode = waterfallItemList_.Head(); + while (viewNode != waterfallItemList_.End()) { + delete(viewNode->data_); + viewNode = viewNode->next_; + } + waterfallItemList_.Clear(); +} -// void WaterfallDesktopFragment::RefreshAppList(void) -// { -// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::RefreshAppList"); -// waterfallList_->LayoutChildren(true); -// } +void WaterfallDesktopFragment::RefreshAppList(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WaterfallDesktopFragment::RefreshAppList"); + waterfallList_->LayoutChildren(true); +} -// WaterfallItemView::~WaterfallItemView() -// { -// if (itemInfo_.iconSmall == nullptr && itemInfo_.resPath != nullptr) { -// ImageCacheManager::GetInstance().UnloadOneInMultiRes(itemInfo_.resId, itemInfo_.resPath); -// } -// } +WaterfallItemView::~WaterfallItemView() +{ + if (itemInfo_.iconSmall == nullptr && itemInfo_.resPath != nullptr) { + ImageCacheManager::GetInstance().UnloadOneInMultiRes(itemInfo_.resId, itemInfo_.resPath); + } +} -// bool WaterfallItemView::SetItemInfo(const AppItem &itemInfo) -// { -// itemInfo_ = itemInfo; -// if (itemInfo.iconSmall == nullptr && itemInfo.resPath != nullptr) { -// ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes(itemInfo.resId, itemInfo.resPath); -// if (image == nullptr) { -// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Load App Icon path %s Image %x fail", -// itemInfo.resId, itemInfo.resPath); -// return false; -// } -// SetSrc(image); -// } else { -// SetSrc(itemInfo.iconSmall); -// } -// return true; -// } +bool WaterfallItemView::SetItemInfo(const AppItem &itemInfo) +{ + itemInfo_ = itemInfo; + if (itemInfo.iconSmall == nullptr && itemInfo.resPath != nullptr) { + ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes(itemInfo.resId, itemInfo.resPath); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Load App Icon path %s Image %x fail", + itemInfo.resId, itemInfo.resPath); + return false; + } + SetSrc(image); + } else { + SetSrc(itemInfo.iconSmall); + } + return true; +} -// AppViewId WaterfallItemView::GetViewId() -// { -// return static_cast(itemInfo_.id); -// } +AppViewId WaterfallItemView::GetViewId() +{ + return static_cast(itemInfo_.id); +} -// const char *WaterfallItemView::GetAppUid() -// { -// return itemInfo_.uid; -// } -// } +const char *WaterfallItemView::GetAppUid() +{ + return itemInfo_.uid; +} +} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/themestyle/src/ThemeStyleCatalog.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/themestyle/src/ThemeStyleCatalog.cpp index 91e2c993c..5d2f1f87f 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/themestyle/src/ThemeStyleCatalog.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/themestyle/src/ThemeStyleCatalog.cpp @@ -12,20 +12,28 @@ static constexpr const char *VIEW_ID_HEXAGONS = "themestyleHexagons"; static constexpr const char *VIEW_ID_ARC_LIST = "themestyleArcList"; static constexpr const char *VIEW_ID_PLANET = "themestylePlanet"; static constexpr const char *VIEW_ID_SPHERE = "themestyleSphere"; +static constexpr const char *VIEW_ID_FOOTBALL = "themestyleFootball"; +static constexpr const char *VIEW_ID_WATERFALL = "themestyleWaterfall"; static constexpr const char *IMG_LIST = "/user/res/themestyle/list.bin"; static constexpr const char *IMG_HEXAGONS = "/user/res/themestyle/hexagons.bin"; static constexpr const char *IMG_ARCLIST = "/user/res/themestyle/arclist.bin"; -static constexpr const char *IMG_DIALPLATE = "/user/res/themestyle/dialplate.bin"; +static constexpr const char *IMG_DIALPLATE = "/user/res/themestyle/planet.bin"; static constexpr const char *IMG_SPHERE = "/user/res/themestyle/sphere.bin"; +static constexpr const char *IMG_FOOTBALL = "/user/res/themestyle/football.bin"; +static constexpr const char *IMG_WATERFALL = "/user/res/themestyle/waterfall.bin"; /** Ordered rows on the “显示方式” settings page (label + checkbox + preview). */ static const ThemeStyleSettingsRow kThemeStyleSettingsRows[] = { {ThemeStyle::APPLIST_STYLE, THEMESTYLE_VALUE_LIST, VIEW_ID_LIST, STR_LIST_DISPLAY, IMG_LIST, 0}, {ThemeStyle::ARC_SCALE_LIST_STYLE, THEMESTYLE_VALUE_ARC_SCALE_LIST, VIEW_ID_ARC_LIST, STR_ARC_SCALE_LIST_DISPLAY,IMG_ARCLIST, 1}, {ThemeStyle::HEXAGONS_STYLE, THEMESTYLE_VALUE_HEXAGONS, VIEW_ID_HEXAGONS, STR_CELLULAR_DISPLAY, IMG_HEXAGONS, 2}, + #if 0 {ThemeStyle::PLANET_STYLE, THEMESTYLE_VALUE_PLANET, VIEW_ID_PLANET, STR_GRID_DISPLAY, IMG_DIALPLATE, ThemeStyleSettingsRow::kNotInDropdownCycle}, {ThemeStyle::SPHERE_STYLE, THEMESTYLE_VALUE_SPHERE, VIEW_ID_SPHERE, STR_GRID_DISPLAY, IMG_SPHERE, ThemeStyleSettingsRow::kNotInDropdownCycle}, + {ThemeStyle::FOOTBALL_STYLE, THEMESTYLE_VALUE_FOOTBALL, VIEW_ID_FOOTBALL, STR_GRID_DISPLAY, IMG_FOOTBALL, ThemeStyleSettingsRow::kNotInDropdownCycle}, + {ThemeStyle::WATERFALL_STYLE, THEMESTYLE_VALUE_WATERFALL, VIEW_ID_WATERFALL, STR_WATERFALL_DISPLAY, IMG_WATERFALL, ThemeStyleSettingsRow::kNotInDropdownCycle}, + #endif }; struct ThemeStylePersistPair @@ -55,9 +63,6 @@ static ThemeStyle NormalizeStyleForDropdown(ThemeStyle s) else if (s == ThemeStyle::FOOTBALL_STYLE || s == ThemeStyle::SPHERE_STYLE) { return ThemeStyle::APPLIST_STYLE; } - else if (s == ThemeStyle::PLANET_STYLE) { - return ThemeStyle::APPLIST_STYLE; - } return s; } } // namespace @@ -158,6 +163,9 @@ ThemeStyle GetThemeStyleDropdownNextStyle(ThemeStyle current) return ThemeStyle::HEXAGONS_STYLE; } if (norm == ThemeStyle::HEXAGONS_STYLE) { + return ThemeStyle::PLANET_STYLE; + } + if (norm == ThemeStyle::PLANET_STYLE) { return ThemeStyle::APPLIST_STYLE; } return ThemeStyle::APPLIST_STYLE; -- 2.17.1