Bug 712018 - Add white list to support IME on physical keyboard. r=cpeterson

This commit is contained in:
Makoto Kato 2012-10-26 15:49:08 +09:00
Родитель 354cbfbbe3
Коммит 45ac26374f
2 изменённых файлов: 35 добавлений и 15 удалений

Просмотреть файл

@ -39,7 +39,6 @@ import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
@ -89,7 +88,6 @@ class GeckoInputConnection
private static String mIMETypeHint = "";
private static String mIMEModeHint = "";
private static String mIMEActionHint = "";
private static Boolean sIsPreJellyBeanAsusTransformer;
private String mCurrentInputMethod;
@ -871,6 +869,9 @@ class GeckoInputConnection
String prevInputMethod = mCurrentInputMethod;
mCurrentInputMethod = InputMethods.getCurrentInputMethod(app);
if (DEBUG) {
Log.d(LOGTAG, "IME: CurrentInputMethod=" + mCurrentInputMethod);
}
// If the user has changed IMEs, then notify input method observers.
if (mCurrentInputMethod != prevInputMethod) {
@ -885,7 +886,7 @@ class GeckoInputConnection
}
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (hasBuggyHardwareKeyboardLayout())
if (InputMethods.canUseInputMethodOnHKB(mCurrentInputMethod))
return false;
switch (event.getAction()) {
@ -1204,18 +1205,6 @@ class GeckoInputConnection
return "\"" + s.toString().replace('\n', UNICODE_CRARR) + "\"";
}
private static boolean hasBuggyHardwareKeyboardLayout() {
// Asus Transformers generate en-US keycodes for HKB keys, regardless of system locale or
// keyboard layout. This bug is reportedly fixed in JB. See bug 669361 and bug 712018.
if (sIsPreJellyBeanAsusTransformer == null) {
sIsPreJellyBeanAsusTransformer = Build.VERSION.SDK_INT < 16 &&
"asus".equals(Build.BRAND) &&
"EeePad".equals(Build.BOARD);
}
// The locale may change while Firefox is running, but the device and OS should not. :)
return sIsPreJellyBeanAsusTransformer && !Locale.getDefault().equals(Locale.US);
}
private static final class Span {
public final int start;
public final int end;

Просмотреть файл

@ -6,15 +6,20 @@
package org.mozilla.gecko;
import android.content.Context;
import android.os.Build;
import android.provider.Settings.Secure;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
final class InputMethods {
public static final String METHOD_ATOK = "com.justsystems.atokmobile.service/.AtokInputMethodService";
public static final String METHOD_GOOGLE_JAPANESE_INPUT = "com.google.android.inputmethod.japanese/.MozcService";
public static final String METHOD_IWNN = "jp.co.omronsoft.iwnnime.ml/.standardcommon.IWnnLanguageSwitcher";
public static final String METHOD_OPENWNN_PLUS = "com.owplus.ime.openwnnplus/.OpenWnnJAJP";
public static final String METHOD_SIMEJI = "com.adamrocker.android.input.simeji/.OpenWnnSimeji";
public static final String METHOD_SWYPE = "com.swype.android.inputmethod/.SwypeInputMethod";
@ -32,6 +37,16 @@ final class InputMethods {
public static final String METHOD_TOUCHPAL_KEYBOARD = "com.cootek.smartinputv5/.TouchPalIME";
*/
// this is white list of IME support for hardware physical keyboard
private static final Collection<String> sHKBWhiteList = Arrays.asList(new String[] {
METHOD_ATOK,
METHOD_GOOGLE_JAPANESE_INPUT,
METHOD_IWNN,
METHOD_OPENWNN_PLUS,
METHOD_SIMEJI,
});
private static Boolean sIsPreJellyBeanAsusTransformer;
private InputMethods() {}
public static String getCurrentInputMethod(Context context) {
@ -52,4 +67,20 @@ final class InputMethods {
public static InputMethodManager getInputMethodManager(Context context) {
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}
public static boolean canUseInputMethodOnHKB(String inputMethod) {
if (sHKBWhiteList.contains(inputMethod)) {
return true;
}
// Asus Transformers generate en-US keycodes for HKB keys, regardless of system locale or
// keyboard layout. This bug is reportedly fixed in JB. See bug 669361 and bug 712018.
if (sIsPreJellyBeanAsusTransformer == null) {
sIsPreJellyBeanAsusTransformer = Build.VERSION.SDK_INT < 16 &&
"asus".equals(Build.BRAND) &&
"EeePad".equals(Build.BOARD);
}
// The locale may change while Firefox is running, but the device and OS should not. :)
return sIsPreJellyBeanAsusTransformer && !Locale.getDefault().equals(Locale.US);
}
}