Search in sources :

Example 21 with ImeSubtypeListItem

use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project platform_frameworks_base by android.

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 22 with ImeSubtypeListItem

use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project platform_frameworks_base by android.

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);
}
Also used : ArrayList(java.util.ArrayList) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 23 with ImeSubtypeListItem

use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by DirtyUnicorns.

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 24 with ImeSubtypeListItem

use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by DirtyUnicorns.

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 25 with ImeSubtypeListItem

use of com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem in project android_frameworks_base by DirtyUnicorns.

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