mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 17:24:42 -04:00
feature模块独立编译打包,应用中心显示的应用图标和label不正确
Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
@@ -272,6 +272,103 @@ bool ResourceUtil::IslegalPath(const string &path)
|
||||
{
|
||||
return path == "element" || path == "media" || path == "profile";
|
||||
}
|
||||
|
||||
void ResourceUtil::StringReplace(string &sourceStr, const string &oldStr, const string &newStr)
|
||||
{
|
||||
string::size_type pos = 0;
|
||||
string::size_type oldSize = oldStr.size();
|
||||
string::size_type newSize = newStr.size();
|
||||
while ((pos = sourceStr.find(oldStr, pos)) != string::npos) {
|
||||
sourceStr.replace(pos, oldSize, newStr.c_str());
|
||||
pos += newSize;
|
||||
}
|
||||
}
|
||||
|
||||
string ResourceUtil::GetLocaleLimitkey(const KeyParam &KeyParam)
|
||||
{
|
||||
string str(reinterpret_cast<const char *>(&KeyParam.value));
|
||||
reverse(str.begin(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
string ResourceUtil::GetDeviceTypeLimitkey(const KeyParam &KeyParam)
|
||||
{
|
||||
auto ret = find_if(g_deviceMap.begin(), g_deviceMap.end(), [KeyParam](const auto &iter) {
|
||||
return KeyParam.value == static_cast<const int32_t>(iter.second);
|
||||
});
|
||||
if (ret == g_deviceMap.end()) {
|
||||
return string();
|
||||
}
|
||||
return ret->first;
|
||||
}
|
||||
|
||||
string ResourceUtil::GetResolutionLimitkey(const KeyParam &KeyParam)
|
||||
{
|
||||
auto ret = find_if(g_resolutionMap.begin(), g_resolutionMap.end(), [KeyParam](const auto &iter) {
|
||||
return KeyParam.value == static_cast<const int32_t>(iter.second);
|
||||
});
|
||||
if (ret == g_resolutionMap.end()) {
|
||||
return string();
|
||||
}
|
||||
return ret->first;
|
||||
}
|
||||
|
||||
string ResourceUtil::GetKeyParamValue(const KeyParam &KeyParam)
|
||||
{
|
||||
string val;
|
||||
switch (KeyParam.keyType) {
|
||||
case KeyType::ORIENTATION:
|
||||
val = KeyParam.value == static_cast<const int32_t>(OrientationType::VERTICAL) ? "vertical" : "horizontal";
|
||||
break;
|
||||
case KeyType::NIGHTMODE:
|
||||
val = KeyParam.value == static_cast<const int32_t>(NightMode::DARK) ? "dark" : "light";
|
||||
break;
|
||||
case KeyType::DEVICETYPE:
|
||||
val = GetDeviceTypeLimitkey(KeyParam);
|
||||
break;
|
||||
case KeyType::RESOLUTION:
|
||||
val = GetResolutionLimitkey(KeyParam);
|
||||
break;
|
||||
case KeyType::LANGUAGE:
|
||||
case KeyType::REGION:
|
||||
val = GetLocaleLimitkey(KeyParam);
|
||||
break;
|
||||
default:
|
||||
val = to_string(KeyParam.value);
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
string ResourceUtil::PaserKeyParam(const vector<KeyParam> &keyParams)
|
||||
{
|
||||
if (keyParams.size() == 0) {
|
||||
return "base";
|
||||
}
|
||||
string result;
|
||||
for (const auto &keyparam : keyParams) {
|
||||
string limitKey = GetKeyParamValue(keyparam);
|
||||
if (limitKey.empty()) {
|
||||
continue;
|
||||
}
|
||||
if (keyparam.keyType == KeyType::MCC) {
|
||||
limitKey = "mcc" + limitKey;
|
||||
}
|
||||
if (keyparam.keyType == KeyType::MNC) {
|
||||
limitKey = "mnc" + limitKey;
|
||||
}
|
||||
if (keyparam.keyType == KeyType::REGION || keyparam.keyType == KeyType::MNC) {
|
||||
result = result + "_" + limitKey;
|
||||
} else {
|
||||
result = result + "-" + limitKey;
|
||||
}
|
||||
}
|
||||
if (!result.empty()) {
|
||||
result = result.substr(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user