Merge "Handle null InputMethodSubtype."
commit
491ca900a7
|
@ -46,6 +46,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
|
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
|
||||||
|
@ -329,7 +330,7 @@ public class RichInputMethodManager {
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
static void forceSubtype(@Nonnull final InputMethodSubtype subtype) {
|
static void forceSubtype(@Nonnull final InputMethodSubtype subtype) {
|
||||||
sForcedSubtypeForTesting = new RichInputMethodSubtype(subtype);
|
sForcedSubtypeForTesting = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -488,8 +489,8 @@ public class RichInputMethodManager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentSubtype(@Nonnull final InputMethodSubtype subtype) {
|
private void updateCurrentSubtype(@Nullable final InputMethodSubtype subtype) {
|
||||||
mCurrentRichInputMethodSubtype = new RichInputMethodSubtype(subtype);
|
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShortcutIme() {
|
private void updateShortcutIme() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrichment class for InputMethodSubtype to enable concurrent multi-lingual input.
|
* Enrichment class for InputMethodSubtype to enable concurrent multi-lingual input.
|
||||||
|
@ -147,6 +148,15 @@ public final class RichInputMethodSubtype {
|
||||||
return SubtypeLocaleUtils.getKeyboardLayoutSetName(mSubtype);
|
return SubtypeLocaleUtils.getKeyboardLayoutSetName(mSubtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RichInputMethodSubtype getRichInputMethodSubtype(
|
||||||
|
@Nullable final InputMethodSubtype subtype) {
|
||||||
|
if (subtype == null) {
|
||||||
|
return getNoLanguageSubtype();
|
||||||
|
} else {
|
||||||
|
return new RichInputMethodSubtype(subtype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dummy no language QWERTY subtype. See {@link R.xml.method}.
|
// Dummy no language QWERTY subtype. See {@link R.xml.method}.
|
||||||
private static final int SUBTYPE_ID_OF_DUMMY_NO_LANGUAGE_SUBTYPE = 0xdde0bfd3;
|
private static final int SUBTYPE_ID_OF_DUMMY_NO_LANGUAGE_SUBTYPE = 0xdde0bfd3;
|
||||||
private static final String EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE =
|
private static final String EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE =
|
||||||
|
|
|
@ -260,7 +260,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo);
|
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo);
|
||||||
builder.setKeyboardGeometry(
|
builder.setKeyboardGeometry(
|
||||||
SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT);
|
SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT);
|
||||||
builder.setSubtype(new RichInputMethodSubtype(subtype));
|
builder.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype));
|
||||||
builder.setIsSpellChecker(true /* isSpellChecker */);
|
builder.setIsSpellChecker(true /* isSpellChecker */);
|
||||||
builder.disableTouchPositionCorrectionData();
|
builder.disableTouchPositionCorrectionData();
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -159,7 +159,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||||
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
||||||
final Builder builder = new Builder(context, editorInfo);
|
final Builder builder = new Builder(context, editorInfo);
|
||||||
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
|
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
|
||||||
.setSubtype(new RichInputMethodSubtype(subtype))
|
.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype))
|
||||||
.setVoiceInputKeyEnabled(voiceInputKeyEnabled)
|
.setVoiceInputKeyEnabled(voiceInputKeyEnabled)
|
||||||
.setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled)
|
.setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled)
|
||||||
.setSplitLayoutEnabledByUser(splitLayoutEnabled);
|
.setSplitLayoutEnabledByUser(splitLayoutEnabled);
|
||||||
|
|
|
@ -318,4 +318,11 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase {
|
||||||
public void testAdditionalSubtypeForSpacebarInFrench() {
|
public void testAdditionalSubtypeForSpacebarInFrench() {
|
||||||
testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
|
testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRichInputMethodSubtypeForNullInputMethodSubtype() {
|
||||||
|
RichInputMethodSubtype subtype = RichInputMethodSubtype.getRichInputMethodSubtype(null);
|
||||||
|
assertNotNull(subtype);
|
||||||
|
assertEquals("zz", subtype.getRawSubtype().getLocale());
|
||||||
|
assertEquals("keyboard", subtype.getRawSubtype().getMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue