【测试结果】:添加的设置快捷方式依然为中文
【预期结果】:显示为英文
【概率】:5/5
修改Launcher3 中的LauncherModel.java类
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1906,6 +1906,14 @@ public class LauncherModel extends BroadcastReceiver {
iconPackageIndex, iconResourceIndex, iconIndex,
titleIndex);
+ /* add by liuyanfeng 20150617 start */
+ String customTitle = getShortcutInfoTitle(manager, intent,
+ context, c, iconIndex, titleIndex, mLabelCache);
+ if (customTitle != null) {
+ info.title = customTitle;
+ }
+ /* end */
+
// App shortcuts that used to be automatically added to Launcher
// didn't always have the correct intent flags set, so do that
// here
@@ -2199,6 +2207,55 @@ public class LauncherModel extends BroadcastReceiver {
return loadedOldDb;
}
+ /* add by liuyanfeng 20150617 start */
+ public String getShortcutInfoTitle(PackageManager manager, Intent intent,
+ Context context, Cursor c, int iconIndex, int titleIndex,
+ HashMap<Object, CharSequence> labelCache) {
+ ComponentName componentName = intent.getComponent();
+ ResolveInfo resolveInfo = null;
+ CharSequence customTitle = null;
+ ComponentName oldComponent = intent.getComponent();
+ Intent newIntent = new Intent(intent.getAction(), null);
+ newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+ newIntent.setPackage(oldComponent.getPackageName());
+ List<ResolveInfo> infos = manager.queryIntentActivities(newIntent, 0);
+ for (ResolveInfo i : infos) {
+ ComponentName cn = new ComponentName(i.activityInfo.packageName,
+ i.activityInfo.name);
+ if (cn.equals(oldComponent)) {
+ resolveInfo = i;
+ }
+ }
+ if (resolveInfo == null) {
+ resolveInfo = manager.resolveActivity(intent, 0);
+ }
+
+ if (resolveInfo != null) {
+ ComponentName key = LauncherModel
+ .getComponentNameFromResolveInfo(resolveInfo);
+ if (labelCache != null && labelCache.containsKey(key)) {
+ customTitle = labelCache.get(key);
+ } else {
+ customTitle = resolveInfo.activityInfo.loadLabel(manager);
+ if (labelCache != null) {
+ labelCache.put(key, customTitle);
+ }
+ }
+ }
+
+ if (customTitle == null) {
+ if (c != null) {
+ customTitle = c.getString(titleIndex);
+ }
+ }
+
+ if (customTitle == null) {
+ customTitle = componentName.getClassName();
+ }
+ return customTitle.toString();
+ }
+ /* end */
+
/** Filters the set of items who are directly or indirectly (via another container) on the
* specified screen. */
private void filterCurrentWorkspaceItems(long currentScreenId,