am ddf41668: Merge "Support EditorInfo.IME_FLAG_FORCE_ASCII"
* commit 'ddf4166815b9e72fc7fe8091d664f9b12a9cbcad': Support EditorInfo.IME_FLAG_FORCE_ASCIImain
commit
76916e94b5
|
@ -26,12 +26,16 @@ public class EditorInfoCompatUtils {
|
||||||
EditorInfo.class, "IME_FLAG_NAVIGATE_NEXT");
|
EditorInfo.class, "IME_FLAG_NAVIGATE_NEXT");
|
||||||
private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField(
|
private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField(
|
||||||
EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS");
|
EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS");
|
||||||
|
private static final Field FIELD_IME_FLAG_FORCE_ASCII = CompatUtils.getField(
|
||||||
|
EditorInfo.class, "IME_FLAG_FORCE_ASCII");
|
||||||
private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField(
|
private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField(
|
||||||
EditorInfo.class, "IME_ACTION_PREVIOUS");
|
EditorInfo.class, "IME_ACTION_PREVIOUS");
|
||||||
private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils
|
private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils
|
||||||
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT);
|
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT);
|
||||||
private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils
|
private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils
|
||||||
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_PREVIOUS);
|
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_PREVIOUS);
|
||||||
|
private static final Integer OBJ_IME_FLAG_FORCE_ASCII = (Integer) CompatUtils
|
||||||
|
.getFieldValue(null, null, FIELD_IME_FLAG_FORCE_ASCII);
|
||||||
private static final Integer OBJ_IME_ACTION_PREVIOUS = (Integer) CompatUtils
|
private static final Integer OBJ_IME_ACTION_PREVIOUS = (Integer) CompatUtils
|
||||||
.getFieldValue(null, null, FIELD_IME_ACTION_PREVIOUS);
|
.getFieldValue(null, null, FIELD_IME_ACTION_PREVIOUS);
|
||||||
|
|
||||||
|
@ -47,6 +51,12 @@ public class EditorInfoCompatUtils {
|
||||||
return (imeOptions & OBJ_IME_FLAG_NAVIGATE_PREVIOUS) != 0;
|
return (imeOptions & OBJ_IME_FLAG_NAVIGATE_PREVIOUS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasFlagForceAscii(int imeOptions) {
|
||||||
|
if (OBJ_IME_FLAG_FORCE_ASCII == null)
|
||||||
|
return false;
|
||||||
|
return (imeOptions & OBJ_IME_FLAG_FORCE_ASCII) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static void performEditorActionNext(InputConnection ic) {
|
public static void performEditorActionNext(InputConnection ic) {
|
||||||
ic.performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
ic.performEditorAction(EditorInfo.IME_ACTION_NEXT);
|
||||||
}
|
}
|
||||||
|
@ -93,10 +103,19 @@ public class EditorInfoCompatUtils {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final StringBuilder flags = new StringBuilder();
|
||||||
if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
|
if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
|
||||||
return "flagNoEnterAction|" + action;
|
flags.append("flagNoEnterAction|");
|
||||||
} else {
|
}
|
||||||
return action;
|
if (hasFlagNavigateNext(imeOptions)) {
|
||||||
}
|
flags.append("flagNavigateNext|");
|
||||||
|
}
|
||||||
|
if (hasFlagNavigatePrevious(imeOptions)) {
|
||||||
|
flags.append("flagNavigatePrevious|");
|
||||||
|
}
|
||||||
|
if (hasFlagForceAscii(imeOptions)) {
|
||||||
|
flags.append("flagForceAscii|");
|
||||||
|
}
|
||||||
|
return flags + action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.util.Log;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.LocaleUtils;
|
import com.android.inputmethod.latin.LocaleUtils;
|
||||||
|
@ -179,7 +180,8 @@ public class KeyboardSet {
|
||||||
// TODO: Use InputMethodSubtype object as argument.
|
// TODO: Use InputMethodSubtype object as argument.
|
||||||
public Builder setSubtype(Locale inputLocale, boolean asciiCapable,
|
public Builder setSubtype(Locale inputLocale, boolean asciiCapable,
|
||||||
boolean touchPositionCorrectionEnabled) {
|
boolean touchPositionCorrectionEnabled) {
|
||||||
final boolean forceAscii = Utils.inPrivateImeOptions(
|
final boolean forceAscii = EditorInfoCompatUtils.hasFlagForceAscii(mParams.mImeOptions)
|
||||||
|
|| Utils.inPrivateImeOptions(
|
||||||
mPackageName, LatinIME.IME_OPTION_FORCE_ASCII, mEditorInfo);
|
mPackageName, LatinIME.IME_OPTION_FORCE_ASCII, mEditorInfo);
|
||||||
mParams.mLocale = (forceAscii && !asciiCapable) ? Locale.US : inputLocale;
|
mParams.mLocale = (forceAscii && !asciiCapable) ? Locale.US : inputLocale;
|
||||||
mParams.mTouchPositionCorrectionEnabled = touchPositionCorrectionEnabled;
|
mParams.mTouchPositionCorrectionEnabled = touchPositionCorrectionEnabled;
|
||||||
|
|
|
@ -104,10 +104,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
*/
|
*/
|
||||||
public static final String IME_OPTION_NO_SETTINGS_KEY = "noSettingsKey";
|
public static final String IME_OPTION_NO_SETTINGS_KEY = "noSettingsKey";
|
||||||
|
|
||||||
|
// TODO: Remove this private option.
|
||||||
/**
|
/**
|
||||||
* The private IME option used to indicate that the given text field needs
|
* The private IME option used to indicate that the given text field needs
|
||||||
* ASCII code points input.
|
* ASCII code points input.
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link EditorInfo#IME_FLAG_FORCE_ASCII}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("dep-ann")
|
||||||
public static final String IME_OPTION_FORCE_ASCII = "forceAscii";
|
public static final String IME_OPTION_FORCE_ASCII = "forceAscii";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue