Search in sources :

Example 41 with ImeSubtypeListItem

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);
    }
}
Also used : ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Example 42 with ImeSubtypeListItem

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));
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) ApplicationInfo(android.content.pm.ApplicationInfo) InputMethodInfo(android.view.inputmethod.InputMethodInfo) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Example 43 with ImeSubtypeListItem

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;
    }
}
Also used : ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Example 44 with ImeSubtypeListItem

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;
    }
}
Also used : ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Example 45 with ImeSubtypeListItem

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();
        }
    }
}
Also used : InputMethodInfo(android.view.inputmethod.InputMethodInfo) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Aggregations

ImeSubtypeListItem (com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)50 SmallTest (android.test.suitebuilder.annotation.SmallTest)15 InputMethodInfo (android.view.inputmethod.InputMethodInfo)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)15 ControllerImpl (com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ControllerImpl)10 ArrayList (java.util.ArrayList)10 AlertDialog (android.app.AlertDialog)5 Context (android.content.Context)5 DialogInterface (android.content.DialogInterface)5 OnCancelListener (android.content.DialogInterface.OnCancelListener)5 OnClickListener (android.content.DialogInterface.OnClickListener)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 ResolveInfo (android.content.pm.ResolveInfo)5 ServiceInfo (android.content.pm.ServiceInfo)5 TypedArray (android.content.res.TypedArray)5 Drawable (android.graphics.drawable.Drawable)5 LocaleList (android.os.LocaleList)5 ContextThemeWrapper (android.view.ContextThemeWrapper)5 LayoutInflater (android.view.LayoutInflater)5 View (android.view.View)5