赞
踩
在android系统中从一个语言环境切换到另一个语言环境的时候,会涉及到更换app名称的事件。比如从中文切换到英文或者其他语言的时候,app的名称从中文切换到英文或者其他语言。先获取app的名称或者包名,然后根据这个包名或者app名给这个应用对应的其他语言的app名称 。废话不多说,直接进入代码,红色的为主要的代码部分
packages/apps/Trebuchet/src/com/android/laucher3/iconCache
private CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,
HashMap<Object, CharSequence> labelCache, UserHandleCompat user,
boolean usePackageIcon, int unreadNum) {
CacheKey cacheKey = new CacheKey(componentName, user);
CacheEntry entry = mCache.get(cacheKey);
boolean isCustomTitle = false;
String activity = null;
if (info != null) {
boolean condition = (mContext.getResources().
getBoolean(R.bool.config_launcher_stkAppRename))
&& info.getComponentName().getPackageName().toString()
.equalsIgnoreCase(STK_PACKAGE_NAME);
activity = info.getComponentName().getClassName().toString();
if (condition
&& !TextUtils.isEmpty(((LauncherApplication) mContext)
.getStkAppName(activity))) {
isCustomTitle = true;
}
}
if (entry == null || unreadNum >= 0) {
entry = new CacheEntry();
mCache.put(cacheKey, entry);
if (info != null) {
ComponentName labelKey = info.getComponentName();
if (labelCache != null && labelCache.containsKey(labelKey)) {
if (isCustomTitle) {
entry.title = ((LauncherApplication) mContext)
.getStkAppName(activity);
} else {
entry.title = labelCache.get(labelKey).toString();
}
} else {
if (isCustomTitle) {
entry.title = ((LauncherApplication) mContext)
.getStkAppName(activity);
} else {
entry.title = info.getLabel().toString();
}
if (labelCache != null) {
labelCache.put(labelKey, entry.title);
}
}
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
entry.icon = Utilities.createIconBitmap(
info.getBadgedIcon(mIconDpi), mContext, unreadNum);
} else {
entry.title = "";
Bitmap preloaded = getPreloadedIcon(componentName, user);
if (preloaded != null) {
if (DEBUG) Log.d(TAG, "using preloaded icon for " +
componentName.toShortString());
entry.icon = preloaded;
} else {
if (usePackageIcon) {
CacheEntry packageEntry = getEntryForPackage(
componentName.getPackageName(), user);
if (packageEntry != null) {
if (DEBUG) Log.d(TAG, "using package default icon for " +
componentName.toShortString());
entry.icon = packageEntry.icon;
entry.title = packageEntry.title;
}
}
if (entry.icon == null) {
if (DEBUG) Log.d(TAG, "using default icon for " +
componentName.toShortString());
entry.icon = getDefaultIcon(user);
}
}
}
}
if(componentName!=null){
//tergun add
if(Local.getLocaleLanguage().equals("mn-CN")) {
if(componentName.getPackageName().equals("com.android.contacts")){
entry.title=mContext.getString(R.string.delete_zone_label_workspace);
}else if(entry.title.equals("WeChat")){
entry.title=mContext.getString(R.string.wechat);
}
}
//tergun end
}
return entry;
}
求评论
能帮你解决问题就打个赏吧
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。