关于KK版本语言列表[Developer]Accented English问题
来源:互联网 发布:linux虚拟机 cpu 编辑:程序博客网 时间:2024/06/05 05:59
Accented English 是一种虚拟mapping出来的语言,source code的resource中并没有实际的values-zz-rZZ与source对应。仅仅会引起Settings中部分UI显示发生变化。这个对使用者而言是没有用的,所以屏蔽也无妨。
在语言设置中控制语言列表的是一个ListFragment =>
packages\apps\Settings\src\com\android\settings\LocalePicker.java
而Settings中的LocalePicker是extend
frameworks\base\core\java\com\android\internal\app\LocalePicker.java重写了isInDeveloperMode()方法
@Override protected boolean isInDeveloperMode() { final boolean showDev = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).getBoolean( DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); return showDev; }
在父类中的onActivityCreated()方法中可以看到有setListAdater(adapter);
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); <span style="color:#ff0000;">final ArrayAdapter<LocaleInfo> adapter = constructAdapter(getActivity(), isInDeveloperMode());</span> setListAdapter(adapter); }
public static ArrayAdapter<LocaleInfo> constructAdapter(Context context, final int layoutId, final int fieldId, final boolean isInDeveloperMode) { final Resources resources = context.getResources(); ArrayList<String> localeList = new ArrayList<String>(Arrays.asList( Resources.getSystem().getAssets().getLocales()));//获取系统支持的语言 if (isInDeveloperMode) { if (!localeList.contains("zz_ZZ")) { localeList.add("zz_ZZ"); } /** - TODO: Enable when zz_ZY Pseudolocale is complete * if (!localeList.contains("zz_ZY")) { * localeList.add("zz_ZY"); *} */ }.... .... for (int i = 0 ; i < origSize; i++ ) { final String s = locales[i]; final int len = s.length(); if (len == 5) { String language = s.substring(0, 2); String country = s.substring(3, 5); final Locale l = new Locale(language, country); if (finalSize == 0) { if (DEBUG) { Log.v(TAG, "adding initial "+ toTitleCase(l.getDisplayLanguage(l))); } preprocess[finalSize++] = new LocaleInfo(toTitleCase(l.getDisplayLanguage(l)), l); } else { if (preprocess[finalSize-1].locale.getLanguage().equals( language) && !preprocess[finalSize-1].locale.getLanguage().equals("zz")) {//如果语言是一样的话,在显示的时候需要将地区标注上去,如:中文(简体)、中文(繁体)等 preprocess[finalSize-1].label = toTitleCase( getDisplayName(preprocess[finalSize-1].locale, specialLocaleCodes, specialLocaleNames)); preprocess[finalSize++] = new LocaleInfo(toTitleCase( getDisplayName( l, specialLocaleCodes, specialLocaleNames)), l); } else { String displayName; if (s.equals("zz_ZZ")) { <span style="color:#ff0000;"> displayName = "[Developer] Accented English";</span> } else if (s.equals("zz_ZY")) { displayName = "[Developer] Fake Bi-Directional"; } else { displayName = toTitleCase(l.getDisplayLanguage(l)); } preprocess[finalSize++] = new LocaleInfo(displayName, l); } } } } .... }; }
在方法中当locale为zz_ZZ时,设置displayName为"[Deveploper] Accented English",这个就是显示在Settings语言列表中的Accented English,
在localelist中默认并不包含有zz_ZZ这个选项,只有在isInDeveloperMode为true时才会添加这个选项,即isInDeveploperMode()方法返回为true时才会添加。
现在需要去掉zz_ZZ这个选项的话,需要使isInDeveploperMode()返回为false,在父类中默认是返回false,而在Settings中LocalPicker.java有对这个方法的重写
@Override protected boolean isInDeveloperMode() { final boolean showDev = getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).getBoolean( DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); return showDev; }
showDev的返回值由DevelopmentSettings.PREF_SHOW的值来决定,如果不是在开发者模式下的话,默认的值就是false。但是连续点击版本号7下的话,可以进入开发者模式,那么此时showDev的值就变成true。这就是在User版(ro.build.tpye=user)默认是不会看到Accented English.
按上述分析,要屏蔽Accented English就很简单了,可以修改isInDeveloperMoed()强制性返回false,或者constructAdapter中去掉localeList.add("zz_ZZ");都可以。
- 关于KK版本语言列表[Developer]Accented English问题
- Android4.4系统设置会多一种语言:Developer Accented English修改问题
- 修改设置语言选项,删除 [Developer]Accented English或者增加其他自己喜欢的语种
- KK版本上应用权限无法获取的问题
- FAQ11755]92 KK版本出现亮点/横线显示异常问题
- 关于多语言版本编译的问题
- KK版本GMS预置
- [FAQ11414]android KK 4.4 版本后,user 版本su 权限严重被限制问题说明
- MT6582 KK版本加入modem
- MT6582 KK版本加入modem
- KK版本上部分号码不能识别成链接的问题
- 关于下拉列表问题
- 关于亚健康(KK记)
- 关于朋友(KK记)
- 关于 TestFlight 新提交的版本没有出现在 测试用户列表中的问题 iOS Swift
- 各类语言的.NET版本列表
- 关于maven版本问题
- 关于Gradle版本问题
- poj 2264 LCS(同时包含两个串的最短父串)
- 全局变量与局部变量定于一个数组赋值后反汇编区别
- malloc_free复杂结构
- 第一篇博客测试
- Linux网卡重命名
- 关于KK版本语言列表[Developer]Accented English问题
- Android手掌抑制功能的实现
- 4G新业务--RCS简介
- SQL各個命令的作用
- pageView的应用
- UVA 10600 ACM Contest and Blackout (次小生成树 Kruskal 封装)
- 如果你想实现自己的梦想,就要对其它机会说不
- 4:2:0 Video Pixel Formats
- malloc()和free()