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:标注为黄色的代码即为修改的代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值