预装应用修改其桌面显示名称


接到一个需求,Chromium应用在中文语言下显示中文“浏览器”而不是 “Chromium”;因为没有源码,从自身修改是不可能的,同事给一思路,从Launcher入手,显示时修改!思维niubility~

 直接上代码

diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 2e4992b5b..31c808b45 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -60,6 +60,9 @@ import com.sprd.ext.LauncherAppMonitor;
 import com.sprd.ext.grid.HotseatController;
 import com.sprd.ext.notificationdots.NotifyDotsNumUtils;
 import com.sprd.ext.unreadnotifier.DotDrawUtils;
+import android.os.SystemProperties;
+import java.util.Locale;
+
 
 import java.text.NumberFormat;
 
@@ -73,6 +76,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
     private static final int DISPLAY_WORKSPACE = 0;
     private static final int DISPLAY_ALL_APPS = 1;
     private static final int DISPLAY_FOLDER = 2;
+    private static final String TAG ="BubbleTextView";
+
+
+    private void printLog (String msg) {
+        Log.d(TAG,msg);
+
+    }
 
     private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};
 
@@ -291,7 +301,26 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
         mDotParams.color = IconPalette.getMutedColor(info.iconColor, 0.54f);
 
         setIcon(iconDrawable);
-        setText(info.title);
+
+        printLog("applyIconAndLabel: info.title:"+ info.title);
+        Locale currentLocale = getResources().getConfiguration().locale;
+        if (currentLocale != null) {
+            String currentLanguage = currentLocale.getLanguage();
+            if("zh".equals(currentLanguage)) {
+                if (("Chromium").equals(info.title)) {
+                    printLog("setting chinese name");
+                    setText("浏览器");
+                } else {
+                    setText(info.title);
+                }
+                                                                                                                                         
+            }else {                                                                                                                      
+                setText(info.title);                                                                                                     
+            }                                                                                                                            
+        }else {                                                                                                                          
+                setText(info.title);                                                                                                     
+        }                                                                                                                                
+                                                                                                                                         
         if (info.contentDescription != null) {                                                                                           
             setContentDescription(info.isDisabled()                                                                                      
                     ? getContext().getString(R.string.disabled_app_label, info.contentDescription)    

搞定~

ps:chromium浏览器设置主页

相关链接

在安卓launcher中强制修改app展示的名字

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值