MTK 切换语言后,桌面上的快捷方式名称没有切换到当前语言

切换语言后,桌面上的快捷方式名称没有切换到当前语言


这个是google默认设计,如果要修改的话,请按照以下步骤操作:

1、请修改LauncherModel.java的loadWorkspace()方法,修改为如下:

......

                             if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {

                                    info = getShortcutInfo(manager, intent, context, c, iconIndex,

                                            titleIndex, mLabelCache);

                                } else {

                                    info = getShortcutInfo(c, context, iconTypeIndex,

                                            iconPackageIndex, iconResourceIndex, iconIndex,

                                            titleIndex);

 

                                    //mtk add begin

                                    CharSequence title = getShortcutTitle(manager, intent);

                                    if(title != null ){

                                                info.title = title;

                                    }

                                    //mtk add end

 

                                    // App shortcuts that used to be automatically added to Launcher

                                    // didn't always have the correct intent flags set, so do that

                                    // here

                                    if (intent.getAction() != null &&

                                        intent.getCategories() != null &&

                                        intent.getAction().equals(Intent.ACTION_MAIN) &&

                                        intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {

                                        intent.addFlags(

                                            Intent.FLAG_ACTIVITY_NEW_TASK |

                                            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

                                    }

                                }

......

 

2、请在LauncherModel.java增加如下方法:

                                private CharSequence getShortcutTitle(PackageManager manager, Intent intent) {

                                                ComponentName componentName = intent.getComponent();

                                                if (componentName == null) {

                                                                return null;

                                                }

                                                try {

                                                                PackageInfo pi = manager.getPackageInfo( componentName.getPackageName(), 0);

                                                                if (!pi.applicationInfo.enabled) {

                                                                                // If we return null here, the corresponding item will be

                                                                                // removed from the launcher

                                                                                // db and will not appear in the workspace.

                                                                                return null;

                                                                }

                                                } catch (NameNotFoundException e) {

                                                                Log.d(TAG, "getPackInfo failed for package " + componentName.getPackageName());

                                                }

 

                                                ResolveInfo resolveInfo = manager.resolveActivity(intent, 0);

 

                                                if (resolveInfo != null) {

                                                                return resolveInfo.activityInfo.loadLabel(manager);

                                                }

                                                return null;

                                }

 
PS:标注为黄色的代码即为修改的代码

你可能感兴趣的:(MTK 切换语言后,桌面上的快捷方式名称没有切换到当前语言)