зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-inbound to mozilla-central. a=merge
This commit is contained in:
Коммит
484394bb2a
|
@ -16,8 +16,11 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
final public class InputMethods {
|
final public class InputMethods {
|
||||||
public static final String METHOD_ANDROID_LATINIME = "com.android.inputmethod.latin/.LatinIME";
|
public static final String METHOD_ANDROID_LATINIME = "com.android.inputmethod.latin/.LatinIME";
|
||||||
public static final String METHOD_ATOK = "com.justsystems.atokmobile.service/.AtokInputMethodService";
|
// ATOK has a lot of package names since they release custom versions.
|
||||||
|
public static final String METHOD_ATOK_PREFIX = "com.justsystems.atokmobile.";
|
||||||
|
public static final String METHOD_ATOK_OEM_PREFIX = "com.atok.mobile.";
|
||||||
public static final String METHOD_GOOGLE_JAPANESE_INPUT = "com.google.android.inputmethod.japanese/.MozcService";
|
public static final String METHOD_GOOGLE_JAPANESE_INPUT = "com.google.android.inputmethod.japanese/.MozcService";
|
||||||
|
public static final String METHOD_ATOK_OEM_SOFTBANK = "com.mobiroo.n.justsystems.atok/.AtokInputMethodService";
|
||||||
public static final String METHOD_GOOGLE_LATINIME = "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME";
|
public static final String METHOD_GOOGLE_LATINIME = "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME";
|
||||||
public static final String METHOD_HTC_TOUCH_INPUT = "com.htc.android.htcime/.HTCIMEService";
|
public static final String METHOD_HTC_TOUCH_INPUT = "com.htc.android.htcime/.HTCIMEService";
|
||||||
public static final String METHOD_IWNN = "jp.co.omronsoft.iwnnime.ml/.standardcommon.IWnnLanguageSwitcher";
|
public static final String METHOD_IWNN = "jp.co.omronsoft.iwnnime.ml/.standardcommon.IWnnLanguageSwitcher";
|
||||||
|
@ -59,14 +62,29 @@ final public class InputMethods {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean needsSoftResetWorkaround(String inputMethod) {
|
public static boolean needsSoftResetWorkaround(final String inputMethod) {
|
||||||
// Stock latin IME on Android 4.2 and above
|
// Stock latin IME on Android 4.2 and above
|
||||||
return Build.VERSION.SDK_INT >= 17 &&
|
return Build.VERSION.SDK_INT >= 17 &&
|
||||||
(METHOD_ANDROID_LATINIME.equals(inputMethod) ||
|
(METHOD_ANDROID_LATINIME.equals(inputMethod) ||
|
||||||
METHOD_GOOGLE_LATINIME.equals(inputMethod));
|
METHOD_GOOGLE_LATINIME.equals(inputMethod));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldCommitCharAsKey(String inputMethod) {
|
/**
|
||||||
|
* Check input method if we require a workaround to remove composition in
|
||||||
|
* {@link android.view.inputmethod.InputMethodManager.updateSelection}.
|
||||||
|
*
|
||||||
|
* @param inputMethod The input method name by {@link #getCurrentInputMethod}.
|
||||||
|
* @return true if {@link android.view.inputmethod.InputMethodManager.updateSelection}
|
||||||
|
* doesn't remove the composition, use {@link android.view.inputmethod.InputMehtodManager.restartInput}
|
||||||
|
* to remove it in this case.
|
||||||
|
*/
|
||||||
|
public static boolean needsRestartInput(final String inputMethod) {
|
||||||
|
return inputMethod.startsWith(METHOD_ATOK_PREFIX) ||
|
||||||
|
inputMethod.startsWith(METHOD_ATOK_OEM_PREFIX) ||
|
||||||
|
METHOD_ATOK_OEM_SOFTBANK.equals(inputMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldCommitCharAsKey(final String inputMethod) {
|
||||||
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
|
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,19 @@ public final class SessionTextInput {
|
||||||
final View view = session.getTextInput().getView();
|
final View view = session.getTextInput().getView();
|
||||||
final InputMethodManager imm = getInputMethodManager(view);
|
final InputMethodManager imm = getInputMethodManager(view);
|
||||||
if (imm != null) {
|
if (imm != null) {
|
||||||
|
// When composition start and end is -1,
|
||||||
|
// InputMethodManager.updateSelection will remove composition
|
||||||
|
// on most IMEs. But ATOK series do nothing. So we have to
|
||||||
|
// restart input method to remove composition as workaround.
|
||||||
|
if (compositionStart < 0 && compositionEnd < 0 &&
|
||||||
|
InputMethods.needsRestartInput(
|
||||||
|
InputMethods.getCurrentInputMethod(view.getContext()))) {
|
||||||
|
try {
|
||||||
|
imm.restartInput(view);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Log.e(LOGTAG, "Error restarting input", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
imm.updateSelection(view, selStart, selEnd, compositionStart, compositionEnd);
|
imm.updateSelection(view, selStart, selEnd, compositionStart, compositionEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче