From f7c80d1da02d837c5bd468c85a3ea784a406feaf Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Sat, 6 Jul 2024 10:54:52 +0000 Subject: [PATCH] Merge #478 into sdk602patch0626 from refs/changes/478/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/478/head: (5 commits squashed) - Ai语音修改,遗留Label闪屏和字数过长后段不显示问题, 与蓝鹊app联调经常发送了语音没有返回内容 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 添加applist的足球显示样式 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/478 --- .../nativeui/aivoice/src/AiVoiceView.cpp | 9 +- .../nativeui/applist/include/AppItemView.h | 24 ++- .../nativeui/applist/include/ApplistModel.h | 25 +-- .../applist/include/ApplistPresenter.h | 2 +- .../nativeui/applist/include/ApplistView.h | 63 ++++++- .../nativeui/applist/src/AppItemView.cpp | 17 +- .../nativeui/applist/src/ApplistModel.cpp | 20 +- .../nativeui/applist/src/ApplistPresenter.cpp | 31 ++-- .../nativeui/applist/src/ApplistView.cpp | 174 ++++++++++++++---- .../themestyle/include/ThemeStyleModel.h | 6 +- .../themestyle/include/ThemeStylePresenter.h | 6 +- .../themestyle/include/ThemeStyleView.h | 10 +- .../themestyle/src/ThemeStyleModel.cpp | 9 +- .../themestyle/src/ThemeStylePresenter.cpp | 19 +- .../themestyle/src/ThemeStyleView.cpp | 9 +- 15 files changed, 288 insertions(+), 136 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index f994949ab..dfff18833 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-05 20:27:09 + * @LastEditTime: 2024-07-06 10:12:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -114,6 +114,7 @@ namespace OHOS label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(70); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); return label; } @@ -151,13 +152,13 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewLabel"); LabelConfig labelConfig = { .left = 83, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, .textId = STR_AI_INTELLIGENT_ASSISTANT, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; title = AiVoiceViewLabelInit(labelConfig); if (title == nullptr) @@ -174,7 +175,7 @@ namespace OHOS .fontSize = 30, .lineHeigh = 35, .textId = STR_START_CHAT, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; startChatLabel = AiVoiceViewLabelInit(labelConfig); if (startChatLabel == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/AppItemView.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/AppItemView.h index 080a52e0f..1c644c774 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/AppItemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/AppItemView.h @@ -1,17 +1,11 @@ /* * @Author: luozheng 1732036298@qq.com - * @Date: 2024-04-08 16:43:48 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-02 19:45:18 + * @Date: 2024-07-06 17:36:42 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-06 18:25:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/applist/include/AppItemView.h */ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: AppItemView.h - * Author: - * Create: 2021-09-18 - */ #ifndef APP_ITEM_VIEW_H #define APP_ITEM_VIEW_H @@ -58,6 +52,18 @@ private: AppItem itemInfo_ = { VIEW_INVALID, nullptr, nullptr, nullptr,nullptr,STR_EXERCISE_GENERAL, nullptr }; }; +class FootballItemView : public UIImageView { +public: + explicit FootballItemView() {} + ~FootballItemView() {} + void SetItemInfo(const AppItem &itemInfo); + AppViewId GetViewId(); + const char *GetAppUid(); +private: + FootballItemView(const FootballItemView &); + FootballItemView &operator = (const FootballItemView &); + AppItem itemInfo_ = { VIEW_INVALID, nullptr, nullptr, nullptr,nullptr, STR_EXERCISE_GENERAL,nullptr }; +}; } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h index 8ea91609f..40059b702 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h @@ -1,10 +1,4 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-04-08 16:43:48 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-02 20:03:25 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistModel.h - */ + /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: ApplistModel.h @@ -12,15 +6,15 @@ * Create: 2021-09-18 */ -#ifndef APPLIST_MODEL_H -#define APPLIST_MODEL_H +#ifndef _APPLIST_MODEL_H_ +#define _APPLIST_MODEL_H_ #include "bundle_info.h" #include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" -#include "ohos_types.h" +#include "ohos_types.h" +#include "components/ui_label_ext.h" +#include "language/font/ui_resource_string.h" #include "ThemeStyleModel.h" #define APP_MAX_NUM 50 @@ -38,13 +32,6 @@ typedef struct { #define AppListStyle ThemeStyle -// typedef enum : uint16_t -// { -// APPLIST_STYLE, // 列表显示 -// HEXAGONS_STYLE, // 蜂窝显示 -// FOOTBALL_STYLE, //足球 -// MAX_THEME_STYLE, -// } AppListStyle; class ApplistPresenter; class ApplistModel { public: diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h index ec4bcc2a1..29d65a1ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistPresenter.h @@ -37,7 +37,7 @@ namespace OHOS { int GetHeadItemY(void); uint8_t GetListItemNum(void); ApplistView* GetAppListView(); - bool GetIsUseListStyle(void); + AppListStyle GetCurrentStyle(void); private: AppItemView *itemViewSele{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h index 762ba31b5..dc2e81e85 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/include/ApplistView.h @@ -3,13 +3,15 @@ #define APPLIST_VIEW_H #include "View.h" +#include "animator/animator_manager.h" #include "components/root_view.h" #include "components/ui_view_group.h" #include "components/ui_scroll_view.h" #include "components/ui_label.h" -#include "components/ui_label_ext.h" #include "components/ui_list.h" #include "components/ui_custom_hexagons_list.h" +#include "components/ui_icosahedron_view.h" +#include "gfx_utils/list.h" #include "window/window.h" #include "ohos_types.h" #include "BaseView.h" @@ -17,7 +19,7 @@ #include "ChangeSliceListener.h" #include "drag_event.h" #include "UiConfig.h" - +#include "components/ui_label_ext.h" namespace OHOS { class AppListOnDragListener : public UIView::OnDragListener { public: @@ -61,6 +63,42 @@ private: bool continueDrag{false}; }; +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; + } + } + + void Callback(UIView* view) override; + + 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_; +}; + class ApplistPresenter; class ApplistView : public View { public: @@ -75,25 +113,34 @@ public: void AddAppItemToList(const AppItem &item); void ClearAppItemToList(); void RefreshAppList(void); + private: - void HexagonsStyleOnStart(); + /* for list style */ void ListStyleOnStart(); - void HexagonsStyleOnSetUpView(); void ListStyleOnSetUpView(); - void HexagonsStyleOnStop(); void ListStyleOnStop(); - - /* for list style */ ApplistAdapter *listAdapter_{nullptr}; UIList *contentList_{nullptr}; UIView::OnDragListener *dragListener{nullptr}; /* for hexagons style */ + void HexagonsStyleOnStart(); + void HexagonsStyleOnSetUpView(); + void HexagonsStyleOnStop(); UICustomHexagonsList* hexagonsList_{nullptr}; - std::list listHexagonsView_; + List listHexagonsView_; uint16_t imgSize_ = 0; uint16_t imgDistance_ = 0; + /* for football style */ + void FootballStyleOnStart(); + void FootballStyleOnSetUpView(); + void FootballStyleOnStop(); + UIIcosahedronView* footballList_ = nullptr; + List footballItemList_; + ImageInfo* footballDefaultImg_ = nullptr; + FootballAnimatorCallback* callback_ = nullptr; + Animator* enterAnimator_ = nullptr; }; } #endif // APPLIST_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/AppItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/AppItemView.cpp index ae1aed091..e329bb7e3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/AppItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/AppItemView.cpp @@ -16,7 +16,7 @@ namespace OHOS { static constexpr int16 APP_ITEM_LABEL_HEIGHT = 110; static constexpr int16 NUM_20 = 20; - static constexpr int16 APP_ITEM_FONT_SIZE = 36; + static constexpr int16 APP_ITEM_FONT_SIZE = 40; static constexpr int16 APP_ITEM_SELECTED_FONT_SIZE = 44; AppItemView::AppItemView() @@ -119,4 +119,19 @@ namespace OHOS { { return itemInfo_.uid; } + + void FootballItemView::SetItemInfo(const AppItem &itemInfo) + { + itemInfo_ = itemInfo; + } + + AppViewId FootballItemView::GetViewId() + { + return itemInfo_.id; + } + + const char *FootballItemView::GetAppUid() + { + return itemInfo_.uid; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 93a8e662c..eae7c6e40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -14,12 +14,12 @@ #include "wearable_log.h" #include "UiConfig.h" -#include "AppViewIDs.h" +#include "ApplistModel.h" +#include "applist/include/ApplistPresenter.h" +#include "SetDesktopModel.h" #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "applist/include/ApplistModel.h" -#include "applist/include/ApplistPresenter.h" -#include "SetDesktopModel.h" #include "themestyle/include/ThemeStyleModel.h" #include "set_desktop/include/SetDesktopView.h" namespace OHOS @@ -249,18 +249,6 @@ namespace OHOS AppListStyle ApplistModel::GetCurrentStyle(void) { - uint8_t currenStyle = SetDesktopView::GetInstance()->GetCurrentSelectedStyle(); - if (currenStyle == 1) - { // 1: hexagons desktop style - return HEXAGONS_STYLE; - } - else if (currenStyle == 2) - { // 2: football desktop style - return FOOTBALL_STYLE; - } - else - { - return APPLIST_STYLE; - } + return ThemeStyleModel::GetInstance().GetAppListDisplayStyle(); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 13e77d442..66c5c1255 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -8,12 +8,12 @@ #include "ApplistPresenter.h" #include "ability_manager.h" #include "securec.h" -#include "ConfigModel.h" -#include "traing/include/TraingModel.h" #include "components/ui_hexagons_list.h" #include "TransitionType.h" #include "AppViewIDs.h" - +#include "ConfigModel.h" +#include "traing/include/TraingModel.h" +#include namespace OHOS { ApplistPresenter::ApplistPresenter() { @@ -103,15 +103,12 @@ namespace OHOS { AppViewId viewId = VIEW_INVALID; char *uid = nullptr; TransitionType type = TransitionType::TRANSITION_INVALID; - if (GetIsUseListStyle()) { - AppItemView *itemView = dynamic_cast(&view); - if (itemView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "itemView is nullptr", viewId); - return false; - } + AppListStyle style = GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + FootballItemView *itemView = dynamic_cast(&view); viewId = itemView->GetViewId(); uid = (char *)itemView->GetAppUid(); - } else { + } else if (style == AppListStyle::HEXAGONS_STYLE) { HexagonsItemView *itemView = dynamic_cast(&view); UIHexagonsList* hexagonsView = dynamic_cast(itemView->GetParent()); if (hexagonsView == nullptr || itemView == nullptr) { @@ -123,8 +120,16 @@ namespace OHOS { hexagonsView->SetDraggable(false); hexagonsView->Scale(1.0f, itemView->GetViewIndex()); // switch focus to click view type = TransitionType::TRANSITION_HEXAGONS; + } else { + AppItemView *itemView = dynamic_cast(&view); + if (itemView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "itemView is nullptr", viewId); + return false; + } + viewId = itemView->GetViewId(); + uid = (char *)itemView->GetAppUid(); } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId,type); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId,type); if (viewId < VIEW_MAX_INTER_APP) { //NativeAbility::GetInstance().ChangeSlice(viewId, type); NativeAbility::GetInstance().EnterSlice(viewId, type); @@ -188,9 +193,9 @@ namespace OHOS { return model->GetAppListNum(); } - bool ApplistPresenter::GetIsUseListStyle(void) + AppListStyle ApplistPresenter::GetCurrentStyle(void) { - return model->GetCurrentStyle() == APPLIST_STYLE; + return model->GetCurrentStyle(); } ApplistView* ApplistPresenter::GetAppListView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index 2ffae5356..b3a13c922 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -9,6 +9,8 @@ #include "ApplistView.h" #include "ApplistPresenter.h" #include "AppItemView.h" +#include "common/image_cache_manager.h" +#include "hal_tick.h" namespace OHOS { static constexpr int16 NUM_2 = 2; @@ -39,27 +41,62 @@ ApplistView::~ApplistView() delete hexagonsList_; hexagonsList_ = nullptr; } + if (callback_ != nullptr) { + delete callback_; + callback_ = nullptr; + } + enterAnimator_ = nullptr; } void ApplistView::OnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart "); View::OnStart(); - if (presenter_->GetIsUseListStyle()) { - ListStyleOnStart(); - } else { + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + FootballStyleOnStart(); + } else if (style == AppListStyle::HEXAGONS_STYLE) { HexagonsStyleOnStart(); + } else { + ListStyleOnStart(); + } +} + +//足球OnStart +void ApplistView::FootballStyleOnStart() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::FootballStyleOnStart "); + 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, 250); // 30: Initial Size 250: Final display size + } + footballList_->SetDefaultImage(footballDefaultImg_); + footballList_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + enterAnimator_ = callback_->GetAnimator(); + SetContainerView(footballList_); + if (callback_ != nullptr) { + callback_->SetStartTime(HALTick::GetInstance().GetTime()); } } +//蜂窝OnStart void ApplistView::HexagonsStyleOnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnStart "); if (hexagonsList_ == nullptr) { hexagonsList_ = new UICustomHexagonsList(); } - hexagonsList_->SetPosition(0, 0, - Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); // 2, two + hexagonsList_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); imgDistance_ = hexagonsList_->GetWidth() * 0.25991; // 0.25991, empirical coefficient imgSize_ = hexagonsList_->GetWidth() * 0.23348; // 0.23348, empirical coefficient hexagonsList_->SetImageDistance(imgDistance_); @@ -74,6 +111,7 @@ void ApplistView::HexagonsStyleOnStart() SetContainerView(hexagonsList_); } +//列表OnStart void ApplistView::ListStyleOnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnStart"); @@ -114,18 +152,32 @@ void ApplistView::OnSetUpView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnSetUpView"); View::OnSetUpView(); - if (presenter_->GetIsUseListStyle() == true) { - ListStyleOnSetUpView(); - } else { + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + FootballStyleOnSetUpView(); + } else if (style == AppListStyle::HEXAGONS_STYLE) { HexagonsStyleOnSetUpView(); + } else { + ListStyleOnSetUpView(); + } +} + +//足球OnSetUpView +void ApplistView::FootballStyleOnSetUpView() +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnSetUpView"); + if (enterAnimator_ != nullptr) { + enterAnimator_->Start(); } } +//蜂窝OnSetUpView void ApplistView::HexagonsStyleOnSetUpView() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnSetUpView "); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnSetUpView"); } +//列表OnSetUpView void ApplistView::ListStyleOnSetUpView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnSetUpView"); @@ -162,11 +214,14 @@ void ApplistView::OnTearDownView() void ApplistView::OnStop() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStop"); - if (presenter_->GetIsUseListStyle()) { + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + FootballStyleOnStop(); + } else if (style == AppListStyle::HEXAGONS_STYLE) { + HexagonsStyleOnStop(); + } else { ListStyleOnStop(); RootView::GetInstance()->ClearOnKeyActListener(); - } else { - HexagonsStyleOnStop(); } View::OnStop(); if (container_ != nullptr) { @@ -179,18 +234,44 @@ void ApplistView::OnStop() return; } +//足球OnStop +void ApplistView::FootballStyleOnStop() +{ + if (enterAnimator_ != nullptr) { + enterAnimator_->Stop(); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::FootballStyleOnStop"); + if (footballDefaultImg_ != nullptr) { + ImageCacheManager::GetInstance().UnloadSingleRes(PNG_APPLIST_NOTSETUSE_IMG); + footballDefaultImg_ = nullptr; + } + if (footballList_ != nullptr) { + footballList_->RemoveAll(); + } + ListNode* viewNode = footballItemList_.Head(); + while (viewNode != footballItemList_.End()) { + delete(viewNode->data_); + viewNode = viewNode->next_; + } + footballItemList_.Clear(); +} + +//蜂窝OnStop void ApplistView::HexagonsStyleOnStop() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::HexagonsStyleOnStop"); if (hexagonsList_ != nullptr) { hexagonsList_->RemoveAll(); } - for (auto iter : listHexagonsView_) { - delete iter; + ListNode* viewNode = listHexagonsView_.Head(); + while (viewNode != listHexagonsView_.End()) { + delete(viewNode->data_); + viewNode = viewNode->next_; } - listHexagonsView_.clear(); + listHexagonsView_.Clear(); } +//列表OnStop void ApplistView::ListStyleOnStop() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnStop"); @@ -202,43 +283,72 @@ void ApplistView::ListStyleOnStop() void ApplistView::AddAppItemToList(const AppItem &item) { - if (presenter_->GetIsUseListStyle()) { - listAdapter_->AddListItem(item); - } else { + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + FootballItemView* itemView = new FootballItemView(); + itemView->SetItemInfo(item); + itemView->SetSrc(item.iconHexagon); + itemView->SetTouchable(true); + itemView->SetOnClickListener(presenter_); + footballList_->Add(itemView); + footballItemList_.PushBack(itemView); + } else if (style == AppListStyle::HEXAGONS_STYLE) { HexagonsItemView *itemView = new HexagonsItemView(); itemView->SetItemInfo(item); itemView->SetSrc(item.iconSmall); itemView->SetTouchable(true); itemView->SetOnClickListener(presenter_); - hexagonsList_->Add(itemView); - listHexagonsView_.push_back(itemView); + listHexagonsView_.PushBack(itemView); + } else { + listAdapter_->AddListItem(item); } } void ApplistView::ClearAppItemToList() { - if (presenter_->GetIsUseListStyle()) { - listAdapter_->ClearItem(); + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == FOOTBALL_STYLE) { + FootballStyleOnStop(); + } else if (style == AppListStyle::HEXAGONS_STYLE) { + HexagonsStyleOnStop(); } else { - if (hexagonsList_ != nullptr) { - hexagonsList_->RemoveAll(); - } - for (auto iter : listHexagonsView_) { - delete iter; - } - listHexagonsView_.clear(); + listAdapter_->ClearItem(); } } void ApplistView::RefreshAppList(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::RefreshAppList"); - if (presenter_->GetIsUseListStyle()) { - contentList_->RefreshList(); - } else { + AppListStyle style = presenter_->GetCurrentStyle(); + if (style == AppListStyle::FOOTBALL_STYLE) { + footballList_->RefreshIcosahedron(); + } else if (style == AppListStyle::HEXAGONS_STYLE) { hexagonsList_->LayoutChildren(true); + } else { + contentList_->RefreshList(); } } +void FootballAnimatorCallback::Callback(UIView *view) +{ + if (HALTick::GetInstance().GetElapseTime(startTime_) < 300) { + 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); +} } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h index 00dd7e39a..9368b8b6a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-02 20:02:35 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-06 16:43:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h */ #ifndef SET_THEMESTYLE_MODEL_H @@ -52,8 +52,6 @@ namespace OHOS static ThemeStyleModel &GetInstance(void); ThemeStyle GetAppListDisplayStyle(void); void SetAppListDisplayStyle(ThemeStyle style); - uint16_t GetSelectThemeStyleId(void); - void SetSelectThemeStyleId(uint16_t Id); private: ThemeStyleModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStylePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStylePresenter.h index 199d279e6..61a16e946 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStylePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStylePresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-14 18:12:38 + * @LastEditTime: 2024-07-06 16:41:49 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStylePresenter.h */ @@ -25,9 +25,7 @@ namespace OHOS ThemeStylePresenter(); ~ThemeStylePresenter() override; static ThemeStylePresenter *GetInstance(); - - bool GetListStyleState(void); - bool GetHexagonsStyleState(void); + ThemeStyle GetSelectThemeStyleId(void); void OnStart() override; void OnPause() override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h index 8aa173706..2ff78385b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-14 18:38:50 + * @LastEditTime: 2024-07-06 18:33:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h */ @@ -24,13 +24,15 @@ namespace OHOS { - static constexpr const uint16_t MAX_STYLE = MAX_THEME_STYLE; + static constexpr const uint16_t MAX_STYLE = MAX_THEME_STYLE-1; static constexpr char *THEME_STYLE_LIST = "themestyleList"; // 列表 static constexpr char *THEME_STYLE_HEXAGONS = "themestyleHexagons"; // 蜂窝 + static constexpr char *THEME_STYLE_FOOTBALL = "themestyleFootball"; // 足球 static constexpr char *THEMESTYLEVIEWEXIT = "ThemeStyleViewExit"; // exit - static constexpr char *THEMESTYLE_LIST_IMAGEPATH = "/user/res/themestyle/list.bin"; - static constexpr char *THEMESTYLE_HEXAGONS_IMAGEPATH = "/user/res/themestyle/hexagons.bin"; + static constexpr char *THEMESTYLE_LIST_IMAGEPATH = "/user/res/themestyle/list.bin"; + static constexpr char *THEMESTYLE_HEXAGONS_IMAGEPATH = "/user/res/themestyle/hexagons.bin"; + static constexpr char *THEMESTYLE_FOOTBALL_IMAGEPATH = "/user/res/themestyle/grid.bin"; class ThemeStylePresenter; class ThemeStyleView : public View diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp index f4febd17a..c3f2406db 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-07 09:21:47 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-22 16:33:24 + * @LastEditTime: 2024-07-06 16:43:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThemeStyleModel.cpp */ @@ -83,11 +83,4 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetAppListDisplayStyle fail!!"); } } - - // 获取选中的样式Id - uint16_t ThemeStyleModel::GetSelectThemeStyleId(void) - { - return GetAppListDisplayStyle(); - } - } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStylePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStylePresenter.cpp index cb2b0b7fb..ed2ae474b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStylePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStylePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 16:43:48 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-15 11:44:48 + * @LastEditTime: 2024-07-06 18:08:24 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThemeStylePresenter.cpp */ @@ -81,6 +81,10 @@ namespace OHOS { ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::HEXAGONS_STYLE); } + else if (viewId == THEME_STYLE_FOOTBALL) + { + ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::FOOTBALL_STYLE); + } uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); if (preSlice == VIEW_APPLIST) @@ -132,16 +136,11 @@ namespace OHOS return true; } - // 获取当前主题是否是蜂窝 - bool ThemeStylePresenter::GetHexagonsStyleState(void) - { - return (ThemeStyleModel::GetInstance().GetAppListDisplayStyle() == ThemeStyle::HEXAGONS_STYLE); - } - - // 获取当前主题是否是列表 - bool ThemeStylePresenter::GetListStyleState(void) + // 获取选中的样式Id + ThemeStyle ThemeStylePresenter::GetSelectThemeStyleId(void) { - return (ThemeStyleModel::GetInstance().GetAppListDisplayStyle() == ThemeStyle::APPLIST_STYLE); + ThemeStyle style = ThemeStyleModel::GetInstance().GetAppListDisplayStyle(); + return style; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp index caf87d295..062a071a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-14 18:41:37 + * @LastEditTime: 2024-07-06 18:34:04 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp */ @@ -160,6 +160,8 @@ namespace OHOS }; int top = 120; + // const char *viewId[MAX_STYLE] = {THEME_STYLE_LIST, THEME_STYLE_HEXAGONS, THEME_STYLE_FOOTBALL}; + // uint16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY, STR_GRID_DISPLAY}; const char *viewId[MAX_STYLE] = {THEME_STYLE_LIST, THEME_STYLE_HEXAGONS}; uint16_t textId[MAX_STYLE] = {STR_LIST_DISPLAY, STR_CELLULAR_DISPLAY}; for (int i = 0; i < MAX_STYLE; i++) @@ -208,6 +210,7 @@ namespace OHOS .src = THEMESTYLE_LIST_IMAGEPATH, }; int y = 150; + //const char *src[MAX_STYLE] = {THEMESTYLE_LIST_IMAGEPATH, THEMESTYLE_HEXAGONS_IMAGEPATH, THEMESTYLE_FOOTBALL_IMAGEPATH}; const char *src[MAX_STYLE] = {THEMESTYLE_LIST_IMAGEPATH, THEMESTYLE_HEXAGONS_IMAGEPATH}; for (int i = 0; i < MAX_STYLE; i++) { @@ -278,12 +281,12 @@ namespace OHOS ClearAll(); } - //更新按钮的选中状态 + // 更新按钮的选中状态 void ThemeStyleView::UpdateSelectedStyle(void) { for (int i = 0; i < MAX_STYLE; i++) { - if (i == ThemeStyleModel::GetInstance().GetSelectThemeStyleId()) + if (i == presenter_->GetSelectThemeStyleId()) { ThemeStyleLabelButton[i]->SetImageSrc(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_ON_IMAGE); } -- 2.17.1