接到一个需求,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)
搞定~
相关链接