diff --git a/frameworks/resmgr/include/res_config_impl.h b/frameworks/resmgr/include/res_config_impl.h index f269d3174cf885704315322ba40d1a2b143de96a..36c710a148dfc8b76440f4c869985de869f57532 100644 --- a/frameworks/resmgr/include/res_config_impl.h +++ b/frameworks/resmgr/include/res_config_impl.h @@ -109,6 +109,12 @@ public: */ void SetThemeId(uint32_t themeId); + /** + * Set resConfig themeIcon + * @param isIcon the resConfig themeIcon flag + */ + void SetThemeIcon(bool isIcon); + #ifdef SUPPORT_GRAPHICS const ResLocale *GetResPreferredLocale() const; @@ -137,6 +143,8 @@ public: uint32_t GetThemeId() const; + bool GetThemeIcon() const; + DeviceType GetDeviceType() const; /** @@ -264,6 +272,7 @@ private: bool isAppColorMode_; bool isAppDarkRes_; uint32_t themeId_; + bool isThemeIcon_; }; } // namespace Resource } // namespace Global diff --git a/frameworks/resmgr/include/theme_pack_manager.h b/frameworks/resmgr/include/theme_pack_manager.h index 94ac43537383b9c6f0731dd4517ddbcd0f0ec301..0a009b6788872aad5e869075a983097494fdb1ad 100644 --- a/frameworks/resmgr/include/theme_pack_manager.h +++ b/frameworks/resmgr/include/theme_pack_manager.h @@ -156,6 +156,8 @@ public: * @return true if update theme by the user id, else not update */ bool IsUpdateByUserId(int32_t userId); + + void LoadThemeIconRes(const std::string &bundleName, const std::string &moduleName, int32_t userId); private: ThemePackManager(); std::string themeMask; diff --git a/frameworks/resmgr/src/res_config_impl.cpp b/frameworks/resmgr/src/res_config_impl.cpp index 061c44be40654bc7066eede4232a67aaaa97026e..d8d8cb3c1c8323f80371b48e99e2689685298161 100644 --- a/frameworks/resmgr/src/res_config_impl.cpp +++ b/frameworks/resmgr/src/res_config_impl.cpp @@ -57,7 +57,8 @@ ResConfigImpl::ResConfigImpl() isCompletedScript_(false), isAppColorMode_(false), isAppDarkRes_(false), - themeId_(0) + themeId_(0), + isThemeIcon_(false) {} #ifdef SUPPORT_GRAPHICS @@ -192,6 +193,11 @@ void ResConfigImpl::SetThemeId(uint32_t themeId) this->themeId_ = themeId; } +void ResConfigImpl::SetThemeIcon(bool isIcon) +{ + this->isThemeIcon_ = isIcon; +} + ScreenDensity ResConfigImpl::ConvertDensity(float density) { float deviceDpi = density * Utils::DPI_BASE; @@ -279,6 +285,11 @@ uint32_t ResConfigImpl::GetThemeId() const return this->themeId_; } +bool ResConfigImpl::GetThemeIcon() const +{ + return this->isThemeIcon_; +} + DeviceType ResConfigImpl::GetDeviceType() const { return this->deviceType_; diff --git a/frameworks/resmgr/src/resource_manager_impl.cpp b/frameworks/resmgr/src/resource_manager_impl.cpp index c1d4f07af078d254f662194f6e51605031d99316..4d20d2f101a868df7b6de4d36c93065e3901f91e 100644 --- a/frameworks/resmgr/src/resource_manager_impl.cpp +++ b/frameworks/resmgr/src/resource_manager_impl.cpp @@ -1150,8 +1150,13 @@ RState ResourceManagerImpl::UpdateResConfig(ResConfig &resConfig, bool isUpdateT { auto themePackManager = ThemePackManager::GetThemePackManager(); if (themePackManager->UpdateThemeId(resConfig.GetThemeId())) { - RESMGR_HILOGD(RESMGR_TAG, "The theme enabled"); - themePackManager->LoadThemeRes(bundleInfo.first, bundleInfo.second, userId); + if (resConfig.GetThemeIcon()) { + RESMGR_HILOGD(RESMGR_TAG, "The themeIcon enabled"); + themePackManager->LoadThemeIconRes(bundleInfo.first, bundleInfo.second, userId); + } else { + RESMGR_HILOGD(RESMGR_TAG, "The theme enabled"); + themePackManager->LoadThemeRes(bundleInfo.first, bundleInfo.second, userId); + } } #if !defined(__WINNT__) && !defined(__IDE_PREVIEW__) && !defined(__ARKUI_CROSS__) HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); diff --git a/frameworks/resmgr/src/theme_pack_manager.cpp b/frameworks/resmgr/src/theme_pack_manager.cpp index da9d144d7ee6a987287da242863dbe7907f8c2ec..4c4b013a364e8d79d1741dc4e726fe24b4487c10 100644 --- a/frameworks/resmgr/src/theme_pack_manager.cpp +++ b/frameworks/resmgr/src/theme_pack_manager.cpp @@ -157,6 +157,27 @@ void ThemePackManager::LoadThemeRes(const std::string &bundleName, const std::st return; } +void ThemePackManager::LoadThemeIconRes(const std::string &bundleName, const std::string &moduleName, int32_t userId) +{ + UpdateUserId(userId); + std::vector iconDirs; + if (Utils::IsFileExist(themeFlagA)) { + iconDirs = GetRootDir(themeIconsA); + } else if (Utils::IsFileExist(themeFlagB)) { + iconDirs = GetRootDir(themeIconsB); + } else { + if (Utils::IsFileExist(ReplaceUserIdInPath(absoluteThemeFlagA, userId))) { + iconDirs = GetRootDir(ReplaceUserIdInPath(absoluteThemeIconsA, userId)); + } else if (Utils::IsFileExist(ReplaceUserIdInPath(absoluteThemeFlagB, userId))) { + iconDirs = GetRootDir(ReplaceUserIdInPath(absoluteThemeIconsB, userId)); + } else { + RESMGR_HILOGE(RESMGR_TAG, "LoadThemesRes failed, userId = %{public}d, bundleName = %{public}s", + userId, bundleName.c_str()); + } + } + LoadThemeIconsResource(bundleName, moduleName, iconDirs, userId); +} + void ThemePackManager::LoadSAThemeRes(const std::string &bundleName, const std::string &moduleName, int32_t userId, std::vector &rootDirs, std::vector &iconDirs) { @@ -166,8 +187,10 @@ void ThemePackManager::LoadSAThemeRes(const std::string &bundleName, const std:: } else if (Utils::IsFileExist(ReplaceUserIdInPath(absoluteThemeFlagB, userId))) { rootDirs = GetRootDir(ReplaceUserIdInPath(absoluteThemeSkinB, userId)); iconDirs = GetRootDir(ReplaceUserIdInPath(absoluteThemeIconsB, userId)); + } else { + RESMGR_HILOGE(RESMGR_TAG, "LoadThemesRes failed, userId = %{public}d, bundleName = %{public}s", + userId, bundleName.c_str()); } - return; } const std::string ThemePackManager::ReplaceUserIdInPath(const std::string &originalPath, int32_t userId) diff --git a/interfaces/inner_api/include/res_config.h b/interfaces/inner_api/include/res_config.h index 3eb17bdbf0dcea0480d68d7c75406dfefc48a9ea..d8c0af99218fe08ed3a610599e608c96645ead3b 100644 --- a/interfaces/inner_api/include/res_config.h +++ b/interfaces/inner_api/include/res_config.h @@ -49,6 +49,8 @@ public: virtual void SetThemeId(uint32_t themeId) = 0; + virtual void SetThemeIcon(bool isIcon) = 0; + #ifdef SUPPORT_GRAPHICS virtual const Locale *GetLocaleInfo() const = 0; #endif @@ -67,6 +69,8 @@ public: virtual uint32_t GetThemeId() const = 0; + virtual bool GetThemeIcon() const = 0; + virtual bool Copy(ResConfig &other, bool isRead = false) = 0; virtual void SetInputDevice(InputDevice inputDevice) = 0;