use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by AOSPA.
the class InputMethodSubtypeSwitchingControllerTest method testImeSubtypeListItem.
@SmallTest
public void testImeSubtypeListItem() throws Exception {
final List<ImeSubtypeListItem> items = new ArrayList<>();
addDummyImeSubtypeListItems(items, "LatinIme", "LatinIme", Arrays.asList("en_US", "fr", "en", "en_uk", "enn", "e", "EN_US"), true);
final ImeSubtypeListItem item_en_US = items.get(0);
final ImeSubtypeListItem item_fr = items.get(1);
final ImeSubtypeListItem item_en = items.get(2);
final ImeSubtypeListItem item_enn = items.get(3);
final ImeSubtypeListItem item_e = items.get(4);
final ImeSubtypeListItem item_EN_US = items.get(5);
assertTrue(item_en_US.mIsSystemLocale);
assertFalse(item_fr.mIsSystemLocale);
assertFalse(item_en.mIsSystemLocale);
assertFalse(item_en.mIsSystemLocale);
assertFalse(item_enn.mIsSystemLocale);
assertFalse(item_e.mIsSystemLocale);
assertFalse(item_EN_US.mIsSystemLocale);
assertTrue(item_en_US.mIsSystemLanguage);
assertFalse(item_fr.mIsSystemLanguage);
assertTrue(item_en.mIsSystemLanguage);
assertFalse(item_enn.mIsSystemLocale);
assertFalse(item_e.mIsSystemLocale);
assertFalse(item_EN_US.mIsSystemLocale);
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method shouldOfferSwitchingToNextInputMethod.
@Override
public boolean shouldOfferSwitchingToNextInputMethod(IBinder token) {
if (!calledFromValidUser()) {
return false;
}
synchronized (mMethodMap) {
if (!calledWithValidToken(token)) {
final int uid = Binder.getCallingUid();
Slog.e(TAG, "Ignoring shouldOfferSwitchingToNextInputMethod due to an invalid " + "token. uid:" + uid + " token:" + token);
return false;
}
final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(false, /* onlyCurrentIme */
mMethodMap.get(mCurMethodId), mCurrentSubtype, true);
if (nextSubtype == null) {
return false;
}
return true;
}
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method handleSwitchInputMethod.
private void handleSwitchInputMethod(final boolean forwardDirection) {
synchronized (mMethodMap) {
final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(false, mMethodMap.get(mCurMethodId), mCurrentSubtype, forwardDirection);
if (nextSubtype == null) {
return;
}
setInputMethodLocked(nextSubtype.mImi.getId(), nextSubtype.mSubtypeId);
final InputMethodInfo newInputMethodInfo = mMethodMap.get(mCurMethodId);
if (newInputMethodInfo == null) {
return;
}
final CharSequence toastText = InputMethodUtils.getImeAndSubtypeDisplayName(mContext, newInputMethodInfo, mCurrentSubtype);
if (!TextUtils.isEmpty(toastText)) {
if (mSubtypeSwitchedByShortCutToast == null) {
mSubtypeSwitchedByShortCutToast = Toast.makeText(mContext, toastText, Toast.LENGTH_SHORT);
} else {
mSubtypeSwitchedByShortCutToast.setText(toastText);
}
mSubtypeSwitchedByShortCutToast.show();
}
}
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by ResurrectionRemix.
the class InputMethodSubtypeSwitchingControllerTest method assertNextInputMethod.
private void assertNextInputMethod(final ControllerImpl controller, final boolean onlyCurrentIme, final ImeSubtypeListItem currentItem, final ImeSubtypeListItem nextItem, final ImeSubtypeListItem prevItem) {
InputMethodSubtype subtype = null;
if (currentItem.mSubtypeName != null) {
subtype = createDummySubtype(currentItem.mSubtypeName.toString());
}
final ImeSubtypeListItem nextIme = controller.getNextInputMethod(onlyCurrentIme, currentItem.mImi, subtype, true);
assertEquals(nextItem, nextIme);
final ImeSubtypeListItem prevIme = controller.getNextInputMethod(onlyCurrentIme, currentItem.mImi, subtype, false);
assertEquals(prevItem, prevIme);
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by ResurrectionRemix.
the class InputMethodSubtypeSwitchingControllerTest method assertRotationOrder.
private void assertRotationOrder(final ControllerImpl controller, final boolean onlyCurrentIme, final ImeSubtypeListItem... expectedRotationOrderOfImeSubtypeList) {
final int N = expectedRotationOrderOfImeSubtypeList.length;
for (int i = 0; i < N; i++) {
final int currentIndex = i;
final int prevIndex = (currentIndex + N - 1) % N;
final int nextIndex = (currentIndex + 1) % N;
final ImeSubtypeListItem currentItem = expectedRotationOrderOfImeSubtypeList[currentIndex];
final ImeSubtypeListItem nextItem = expectedRotationOrderOfImeSubtypeList[nextIndex];
final ImeSubtypeListItem prevItem = expectedRotationOrderOfImeSubtypeList[prevIndex];
assertNextInputMethod(controller, onlyCurrentIme, currentItem, nextItem, prevItem);
}
}
Aggregations