Android MTK 6750 系统语言与输入法

需求一:要求只保留中文和英文两种语言
xxxx/frameworks/base/core/res/res/values/locale_config.xml

 <string-array translatable="false" name="supported_locales">
        <item>af-NA</item> <!-- Afrikaans (Namibia) -->
        <item>af-ZA</item> <!-- Afrikaans (South Africa) -->
        <item>agq-CM</item> <!-- Aghem (Cameroon) -->
        <item>ak-GH</item> <!-- Akan (Ghana) -->
                                    ..............
                                    .............
                                     .............
        <item>zh-Hant-TW</item> <!-- Chinese (Traditional Han,Taiwan) -->
        <item>zu-ZA</item> <!-- Zulu (South Africa) -->
         </string-array>

supported_locales中只保留English:

 <string-array translatable="false" name="supported_locales">
	    <item>en-US</item> <!-- English (United States) -->
</string-array>

需求二:解决在settings中添加语言时会自动切换切换输入法问题
frameworks/base/services/core/java/com/android/server/InputMethodManagerService.java

new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        synchronized(mMethodMap) {
							//yh
							//resetStateIfCurrentLocaleChangedLocked();
						}
                    }
                }, filter);
  

需求三:切换语言切换输入法
xxxx/packages/apps/Settings/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java

+import android.os.SystemProperties;
+import android.view.inputmethod.InputMethodManager;


 private static final String TAG = "LocaleDragAndDropAdapter";
 private static final String CFGKEY_SELECTED_LOCALES = "selectedLocales";
 
+private static final String NewInputMethodName = "com.android.inputmethod.latin/.LatinIME";
+private static final String NewInputMethodName2 = "com.sohu.inputmethod.sogou/.SogouIME";


 void onItemMove(int fromPosition, int toPosition) {
        if (fromPosition >= 0 && toPosition >= 0) {
            final LocaleStore.LocaleInfo saved = mFeedItemList.get(fromPosition);
            mFeedItemList.remove(fromPosition);
            mFeedItemList.add(toPosition, saved);
            ///
			if(toPosition==0&&saved.toString().equals("en-US"))
		     {
			         
			      ((InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
		             .setInputMethod(null, NewInputMethodName);
			
			}else if(toPosition==0&&saved.toString().equals("zh-CN")){
					
					((InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
						 .setInputMethod(null, NewInputMethodName2);
				}
				/
		 } else {
            // TODO: It looks like sometimes the RecycleView tries to swap item -1
            // I did not see it in a while, but if it happens, investigate and file a bug.
            Log.e(TAG, String.format(Locale.US,
                    "Negative position in onItemMove %d -> %d", fromPosition, toPosition));
        }
        notifyItemChanged(fromPosition); // to update the numbers
        notifyItemChanged(toPosition);
        notifyItemMoved(fromPosition, toPosition);
        // We don't call doTheUpdate() here because this method is called for each item swap.
        // So if we drag something across several positions it will be called several times.
    }

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值