parent
e38f79182d
commit
dc110b2a6a
|
@ -20,6 +20,7 @@ import android.os.Build;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.RichInputMethodSubtype;
|
import com.android.inputmethod.latin.RichInputMethodSubtype;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -69,7 +70,8 @@ public final class InputMethodSubtypeCompatUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
|
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
|
||||||
return InputMethodSubtypeCompatUtils.isAsciiCapableWithAPI(subtype);
|
return isAsciiCapableWithAPI(subtype)
|
||||||
|
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
|
|
|
@ -315,9 +315,12 @@ public final class SubtypeSwitcher {
|
||||||
|
|
||||||
public RichInputMethodSubtype getEmojiSubtype() {
|
public RichInputMethodSubtype getEmojiSubtype() {
|
||||||
if (mEmojiSubtype == null) {
|
if (mEmojiSubtype == null) {
|
||||||
mEmojiSubtype = new RichInputMethodSubtype(
|
final InputMethodSubtype rawEmojiSubtype =
|
||||||
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||||
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI));
|
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI);
|
||||||
|
if (null != rawEmojiSubtype) {
|
||||||
|
mEmojiSubtype = new RichInputMethodSubtype(rawEmojiSubtype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mEmojiSubtype != null) {
|
if (mEmojiSubtype != null) {
|
||||||
return mEmojiSubtype;
|
return mEmojiSubtype;
|
||||||
|
|
|
@ -151,25 +151,25 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRestorable() {
|
public void testRestorable() {
|
||||||
final InputMethodSubtype EN_UK_DVORAK =
|
final InputMethodSubtype EN_US_DVORAK =
|
||||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||||
Locale.US.toString(), "dvorak");
|
Locale.US.toString(), "dvorak");
|
||||||
final InputMethodSubtype ZZ_AZERTY =
|
final InputMethodSubtype ZZ_AZERTY =
|
||||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||||
SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
|
SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
|
||||||
assertEnUsDvorak(EN_UK_DVORAK);
|
assertEnUsDvorak(EN_US_DVORAK);
|
||||||
assertAzerty(ZZ_AZERTY);
|
assertAzerty(ZZ_AZERTY);
|
||||||
|
|
||||||
// Make sure the subtype can be stored and restored in a deterministic manner.
|
// Make sure the subtype can be stored and restored in a deterministic manner.
|
||||||
final InputMethodSubtype[] subtypes = { EN_UK_DVORAK, ZZ_AZERTY };
|
final InputMethodSubtype[] subtypes = { EN_US_DVORAK, ZZ_AZERTY };
|
||||||
final String prefSubtype = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
|
final String prefSubtype = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
|
||||||
final InputMethodSubtype[] restoredSubtypes =
|
final InputMethodSubtype[] restoredSubtypes =
|
||||||
AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
|
AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
|
||||||
assertEquals(2, restoredSubtypes.length);
|
assertEquals(2, restoredSubtypes.length);
|
||||||
final InputMethodSubtype restored_EN_UK_DVORAK = restoredSubtypes[0];
|
final InputMethodSubtype restored_EN_US_DVORAK = restoredSubtypes[0];
|
||||||
final InputMethodSubtype restored_ZZ_AZERTY = restoredSubtypes[1];
|
final InputMethodSubtype restored_ZZ_AZERTY = restoredSubtypes[1];
|
||||||
|
|
||||||
assertEnUsDvorak(restored_EN_UK_DVORAK);
|
assertEnUsDvorak(restored_EN_US_DVORAK);
|
||||||
assertAzerty(restored_ZZ_AZERTY);
|
assertAzerty(restored_ZZ_AZERTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,9 +310,11 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
||||||
assertNotNull("Hebrew", HEBREW);
|
assertNotNull("Hebrew", HEBREW);
|
||||||
|
|
||||||
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
||||||
|
final InputMethodSubtype rawSubtype = subtype.getRawSubtype();
|
||||||
final String subtypeName = SubtypeLocaleUtils
|
final String subtypeName = SubtypeLocaleUtils
|
||||||
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
|
.getSubtypeDisplayNameInSystemLocale(rawSubtype);
|
||||||
if (subtype.equals(ARABIC) || subtype.equals(FARSI) || subtype.equals(HEBREW)) {
|
if (rawSubtype.equals(ARABIC) || rawSubtype.equals(FARSI)
|
||||||
|
|| rawSubtype.equals(HEBREW)) {
|
||||||
assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
||||||
} else {
|
} else {
|
||||||
assertFalse(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
assertFalse(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
||||||
|
|
Loading…
Reference in New Issue