您的位置:首页 > 移动开发 > Android开发

android 输入法软键盘屏蔽掉中文切换

2016-11-08 16:32 399 查看
android4.4.2屏蔽掉输入法的中文情节,

直接上路子:

diff --git a/packages/inputmethods/PinyinIME/res/xml/skb_sym2.xml b/packages/inputmethods/Pinyi

nIME/res/xml/skb_sym2.xml

index a55f91e..e0bdefd 100644
--- a/packages/inputmethods/PinyinIME/res/xml/skb_sym2.xml
+++ b/packages/inputmethods/PinyinIME/res/xml/skb_sym2.xml
@@ -55,7 +55,8 @@

<row width="14.696%p" key_type="1">

<key code="-2" label="中 符" width="20%p" repeat="true">
- <toggle_state state_id="@string/toggle_en_sym2" label="英 符" code="-2"/>
+ <!--toggle_state state_id="@string/toggle_en_sym2" label="英 符" code="-2"-->

+ <toggle_state state_id="@string/toggle_en_sym2" label="En" code="-2"/>
</key>

<key code="-3" key_type="3" label="\?123"/>

<key code="62" key_type="5" width="30.608%p"/>

diff --git a/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.ja

va b/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.java

index b8cc504..21c2fa0 100644
--- a/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.java
+++ b/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/SoftKeyboard.java
@@ -86,6 +86,10 @@ public class SoftKeyboard {

*/

private List<KeyRow> mKeyRows;

+ //vinci add for ignore switching btn

+ private int switchRow = 2;

+ private int switchNum = 0;

+

/**

* Background of the soft keyboard. If it is null, the one in the soft

* keyboard template will be used.

@@ -316,7 +320,10 @@ public class SoftKeyboard {

SoftKey sKey = softKeys.get(i);

if (sKey.mLeft <= x && sKey.mTop <= y && sKey.mRight > x

&& sKey.mBottom > y) {
- return sKey;
+ if (switchRow < row && switchNum == i)

+ return null;

+ else

+ return sKey;

}

}

}

@@ -341,6 +348,8 @@ public class SoftKeyboard {

if (dis < nearestDis) {

nearestDis = dis;

nearestKey = sKey;
+ if (switchRow < row && switchNum == i)

+ return null;

}

}

}

--- a/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
+++ b/packages/inputmethods/PinyinIME/src/com/android/inputmethod/pinyin/InputModeSwitcher.java
@@ -139,17 +139,17 @@ public class InputModeSwitcher {

/**

* Mode for inputing Chinese with soft keyboard.

*/
- public static final int MODE_SKB_CHINESE = (MASK_SKB_LAYOUT_QWERTY | MASK_LANGUAGE_CN);
+ public static final int MODE_SKB_CHINESE = (MASK_SKB_LAYOUT_QWERTY | MASK_LANGUAGE_EN);

/**

* Mode for inputing basic symbols for Chinese mode with soft keyboard.

*/
- public static final int MODE_SKB_SYMBOL1_CN = (MASK_SKB_LAYOUT_SYMBOL1 | MASK_LANGUAGE_CN)
;
+ public static final int MODE_SKB_SYMBOL1_CN = (MASK_SKB_LAYOUT_SYMBOL1 | MASK_LANGUAGE_EN)
;

/**

* Mode for inputing more symbols for Chinese mode with soft keyboard.

*/
- public static final int MODE_SKB_SYMBOL2_CN = (MASK_SKB_LAYOUT_SYMBOL2 | MASK_LANGUAGE_CN);
+ public static final int MODE_SKB_SYMBOL2_CN = (MASK_SKB_LAYOUT_SYMBOL2 | MASK_LANGUAGE_EN);

/**

* Mode for inputing English lower characters with soft keyboard.

@@ -191,7 +191,7 @@ public class InputModeSwitcher {

/**

* Mode for inputing Chinese with a hardware keyboard.

*/
- public static final int MODE_HKB_CHINESE = (MASK_LANGUAGE_CN);
+ public static final int MODE_HKB_CHINESE = (MASK_LANGUAGE_EN);

/**

* Mode for inputing English with a hardware keyboard

具体实现原理就是屏蔽掉左下角切换button,不再赘述。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息