切换语言时,默认的输入法请为对应输入法

来源:互联网 发布:linux下解压zip包 编辑:程序博客网 时间:2024/05/01 17:42

InputMethodManagerService.java 中


    private void resetDefaultImeLocked(Context context) {
        // Do not reset the default (current) IME when it is a 3rd-party IME
        
       //qiuyaobo,20170504,begin
       if(OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R3_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R8_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_QHD_R9_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R6_HELLO) { 
            if (mCurMethodId != null
                    && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))
                    && (!mMethodMap.get(mCurMethodId).getPackageName().equals("com.thihaayekyaw.frozenkeyboard"))) {
                return;   
            }
            
        }else   
        //qiuyaobo,20170504,end      
        if (mCurMethodId != null
                && !InputMethodUtils.isSystemIme(mMethodMap.get(mCurMethodId))) {
            return;
        }


        InputMethodInfo defIm = null;
        for (InputMethodInfo imi : mMethodList) {
            if (defIm == null && mSystemReady) {


//qiuyaobo,20170504,begin
            if (OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R3_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R8_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_QHD_R9_SINGTECH || OptConfig.SUN_SUBCUSTOM_C7367_HWD_FWVGA_R6_HELLO) {
           String locale_language =context.getResources().getConfiguration().locale.getLanguage();
           
           if(locale_language.equals("my") && (imi.getPackageName().equals("com.thihaayekyaw.frozenkeyboard"))){ 
                        defIm = imi;
                        Slog.i(TAG, "Selected default: " + imi.getId());
                    }
                } else {
                //qiuyaobo,20170504,end
               final Locale systemLocale = context.getResources().getConfiguration().locale;
               if (InputMethodUtils.isSystemImeThatHasSubtypeOf(imi, context,
                       true /* checkDefaultAttribute */, systemLocale, false /* checkCountry */,
                       InputMethodUtils.SUBTYPE_MODE_ANY)) {
                   defIm = imi;
                   Slog.i(TAG, "Selected default: " + imi.getId());
               }
           
           //qiuyaobo,20170504,begin    
           }
           //qiuyaobo,20170504,end
            }
        }
        if (defIm == null && mMethodList.size() > 0) {
            defIm = InputMethodUtils.getMostApplicableDefaultIME(
                    mSettings.getEnabledInputMethodListLocked());
            if (defIm != null) {
                Slog.i(TAG, "Default found, using " + defIm.getId());
            } else {
                Slog.i(TAG, "No default found");
            }
        }
        if (defIm != null) {
            setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
        }
    }

0 0