Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2f901ab authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make sure that Toast is always shown by Meta-Space.

It turns out that my previous CL [1] does not always show Toast when
Meta-Space is hit multiple times in a short period.  With this CL, we
attempt to make sure that the Toast is shown every time when Meta-Space
rotates the current IME subtype.

This CL also removes a rule that we do not show Toast when the IME
window has InputMethodService.IME_VISIBLE bit as it turns out to be
confusing.  In Android N, we just provide a consistent behavior
no matter the IME window is visible or not.

 [1]: If3fe17adbffe4c1125783fc77fed3cfe78fc7933
      ebda7d7a

Bug: 27547054
Bug: 28127795
Change-Id: I551c51cd672dba6e7693d23cb181007f51b0de9d
parent e544d408
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -2966,16 +2966,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                return;
            }
            setInputMethodLocked(nextSubtype.mImi.getId(), nextSubtype.mSubtypeId);
            if (mSubtypeSwitchedByShortCutToast != null) {
                mSubtypeSwitchedByShortCutToast.cancel();
                mSubtypeSwitchedByShortCutToast = null;
            }
            if ((mImeWindowVis & InputMethodService.IME_VISIBLE) != 0) {
                // IME window is shown.  The user should be able to visually understand that the
                // subtype is changed in most of cases.  To avoid UI overlap, we do not show a toast
                // in this case.
                return;
            }
            final InputMethodInfo newInputMethodInfo = mMethodMap.get(mCurMethodId);
            if (newInputMethodInfo == null) {
                return;
@@ -2983,8 +2973,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            final CharSequence toastText = InputMethodUtils.getImeAndSubtypeDisplayName(mContext,
                    newInputMethodInfo, mCurrentSubtype);
            if (!TextUtils.isEmpty(toastText)) {
                mSubtypeSwitchedByShortCutToast = Toast.makeText(mContext, toastText.toString(),
                if (mSubtypeSwitchedByShortCutToast == null) {
                    mSubtypeSwitchedByShortCutToast = Toast.makeText(mContext, toastText,
                            Toast.LENGTH_SHORT);
                } else {
                    mSubtypeSwitchedByShortCutToast.setText(toastText);
                }
                mSubtypeSwitchedByShortCutToast.show();
            }
        }