use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by DirtyUnicorns.
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);
}
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by DirtyUnicorns.
the class InputMethodSubtypeSwitchingControllerTest method addDummyImeSubtypeListItems.
private static void addDummyImeSubtypeListItems(List<ImeSubtypeListItem> items, String imeName, String imeLabel, List<String> subtypeLocales, boolean supportsSwitchingToNextInputMethod) {
final ResolveInfo ri = new ResolveInfo();
final ServiceInfo si = new ServiceInfo();
final ApplicationInfo ai = new ApplicationInfo();
ai.packageName = DUMMY_PACKAGE_NAME;
ai.enabled = true;
si.applicationInfo = ai;
si.enabled = true;
si.packageName = DUMMY_PACKAGE_NAME;
si.name = imeName;
si.exported = true;
si.nonLocalizedLabel = imeLabel;
ri.serviceInfo = si;
List<InputMethodSubtype> subtypes = null;
if (subtypeLocales != null) {
subtypes = new ArrayList<>();
for (String subtypeLocale : subtypeLocales) {
subtypes.add(createDummySubtype(subtypeLocale));
}
}
final InputMethodInfo imi = new InputMethodInfo(ri, DUMMY_IS_AUX_IME, DUMMY_SETTING_ACTIVITY_NAME, subtypes, DUMMY_IS_DEFAULT_RES_ID, DUMMY_FORCE_DEFAULT, supportsSwitchingToNextInputMethod);
if (subtypes == null) {
items.add(new ImeSubtypeListItem(imeName, null, /* variableName */
imi, NOT_A_SUBTYPE_ID, null, SYSTEM_LOCALE));
} else {
for (int i = 0; i < subtypes.size(); ++i) {
final String subtypeLocale = subtypeLocales.get(i);
items.add(new ImeSubtypeListItem(imeName, subtypeLocale, imi, i, subtypeLocale, SYSTEM_LOCALE));
}
}
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by ResurrectionRemix.
the class InputMethodManagerService method switchToNextInputMethod.
@Override
public boolean switchToNextInputMethod(IBinder token, boolean onlyCurrentIme) {
if (!calledFromValidUser()) {
return false;
}
synchronized (mMethodMap) {
if (!calledWithValidToken(token)) {
final int uid = Binder.getCallingUid();
Slog.e(TAG, "Ignoring switchToNextInputMethod due to an invalid token. uid:" + uid + " token:" + token);
return false;
}
final ImeSubtypeListItem nextSubtype = mSwitchingController.getNextInputMethodLocked(onlyCurrentIme, mMethodMap.get(mCurMethodId), mCurrentSubtype, true);
if (nextSubtype == null) {
return false;
}
setInputMethodWithSubtypeIdLocked(token, nextSubtype.mImi.getId(), nextSubtype.mSubtypeId);
return true;
}
}
use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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();
}
}
}
Aggregations