diff --git a/frameworks/resmgr/include/theme_pack_resource.h b/frameworks/resmgr/include/theme_pack_resource.h index 38b2947ace441f621183f2e93eb322198e2064d3..9514b0d0d199b9ac829a88135d51dd1129de02f4 100644 --- a/frameworks/resmgr/include/theme_pack_resource.h +++ b/frameworks/resmgr/include/theme_pack_resource.h @@ -172,6 +172,8 @@ private: std::shared_ptr themeConfig, const std::string &resTypeStr); const std::string GetThemeAppIconByAbilityName(const std::pair &bundleInfo, const std::string &name, const std::string &abilityName = ""); + static void AddIconValue(const std::string &bundleName, const std::string &moduleName, + const std::string &iconName, const std::string &path, const std::string &abilityName = ""); static ThemeResource *themeRes; }; } // namespace Resource diff --git a/frameworks/resmgr/src/theme_pack_resource.cpp b/frameworks/resmgr/src/theme_pack_resource.cpp index bc468e2389143ac1a4ac85bd046868f1d773f9a8..cfd7b8d6ad1c834f0c7671e83ae3c7de0bb6d434 100644 --- a/frameworks/resmgr/src/theme_pack_resource.cpp +++ b/frameworks/resmgr/src/theme_pack_resource.cpp @@ -343,6 +343,13 @@ std::string GetIconsBundleName(const std::string& iconPath) return iconPath.substr(pos + 1); } +void ThemeResource::AddIconValue(const std::string &bundleName, const std::string &moduleName, + const std::string &iconName, const std::string &path, const std::string &abilityName) +{ + ThemeKey themeKey = ThemeKey(bundleName, moduleName, ResType::MEDIA, iconName, abilityName); + themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); +} + const std::shared_ptr ThemeResource::LoadThemeIconResource(const std::string& iconPath) { if (iconPath.empty()) { @@ -365,28 +372,24 @@ const std::shared_ptr ThemeResource::LoadThemeIconResource(const continue; } std::string dynamicBundle = path.substr(iconPath.length() + 1, pos3 - iconPath.length() - 1); - ThemeKey themeKey = ThemeKey(bundleName, dynamicBundle, ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, dynamicBundle, iconName, path); continue; } auto pos3 = path.find('/', iconPath.length() + 1); if (pos3 == std::string::npos || pos3 < iconPath.length() + 1) { - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path); continue; } auto pos4 = path.find('/', pos3 + 1); if (pos4 == std::string::npos || pos4 < pos3 + 1 || pos4 != pos2) { - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path); continue; } std::string abilityName = path.substr(pos3 + 1, pos4 - pos3 - 1); - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName, abilityName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path, abilityName); } return themeResource; }