summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2015-05-12 15:00:33 -0700
committerYohei Yukawa <yukawa@google.com>2015-05-12 15:05:45 -0700
commitc6c7cd2736fc3b6511e329a969409622750f2a58 (patch)
treeeb200e066a5921bc48fd792e8420df19aee32808
parentf038295e98846e3e359854b1642b362643bd6053 (diff)
downloadframeworks_base-c6c7cd2736fc3b6511e329a969409622750f2a58.zip
frameworks_base-c6c7cd2736fc3b6511e329a969409622750f2a58.tar.gz
frameworks_base-c6c7cd2736fc3b6511e329a969409622750f2a58.tar.bz2
Show IME switcher also when hardware keyboard is connected.
As per discussion with UX team, we start showing IME switcher UI not only when there are multiple IMEs are enabled but also when a hardware keyboard is connected. This CL also simplifies needsToShowImeSwitchOngoingNotification() by renaming it with shouldShowImeSwitcherLocked() and unifying related condition checking into that method. Bug: 19496012 Change-Id: Id44724a2a46190382c283a52ece8edffb740807d
-rw-r--r--services/core/java/com/android/server/InputMethodManagerService.java93
1 files changed, 49 insertions, 44 deletions
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index e856a93..f5d323d 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -1624,53 +1624,61 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
- private boolean needsToShowImeSwitchOngoingNotification() {
+ private boolean shouldShowImeSwitcherLocked() {
if (!mShowOngoingImeSwitcherForPhones) return false;
if (mSwitchingDialog != null) return false;
if (isScreenLocked()) return false;
- synchronized (mMethodMap) {
- List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked();
- final int N = imis.size();
- if (N > 2) return true;
- if (N < 1) return false;
- int nonAuxCount = 0;
- int auxCount = 0;
- InputMethodSubtype nonAuxSubtype = null;
- InputMethodSubtype auxSubtype = null;
- for(int i = 0; i < N; ++i) {
- final InputMethodInfo imi = imis.get(i);
- final List<InputMethodSubtype> subtypes =
- mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
- final int subtypeCount = subtypes.size();
- if (subtypeCount == 0) {
- ++nonAuxCount;
- } else {
- for (int j = 0; j < subtypeCount; ++j) {
- final InputMethodSubtype subtype = subtypes.get(j);
- if (!subtype.isAuxiliary()) {
- ++nonAuxCount;
- nonAuxSubtype = subtype;
- } else {
- ++auxCount;
- auxSubtype = subtype;
- }
+ if ((mImeWindowVis & InputMethodService.IME_ACTIVE) == 0) return false;
+ if (mWindowManagerService.isHardKeyboardAvailable()) {
+ // When physical keyboard is attached, we show the ime switcher (or notification if
+ // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently
+ // exists in the IME switcher dialog. Might be OK to remove this condition once
+ // SHOW_IME_WITH_HARD_KEYBOARD settings finds a good place to live.
+ return true;
+ }
+ if ((mImeWindowVis & InputMethodService.IME_VISIBLE) == 0) return false;
+
+ List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked();
+ final int N = imis.size();
+ if (N > 2) return true;
+ if (N < 1) return false;
+ int nonAuxCount = 0;
+ int auxCount = 0;
+ InputMethodSubtype nonAuxSubtype = null;
+ InputMethodSubtype auxSubtype = null;
+ for(int i = 0; i < N; ++i) {
+ final InputMethodInfo imi = imis.get(i);
+ final List<InputMethodSubtype> subtypes =
+ mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
+ final int subtypeCount = subtypes.size();
+ if (subtypeCount == 0) {
+ ++nonAuxCount;
+ } else {
+ for (int j = 0; j < subtypeCount; ++j) {
+ final InputMethodSubtype subtype = subtypes.get(j);
+ if (!subtype.isAuxiliary()) {
+ ++nonAuxCount;
+ nonAuxSubtype = subtype;
+ } else {
+ ++auxCount;
+ auxSubtype = subtype;
}
}
}
- if (nonAuxCount > 1 || auxCount > 1) {
- return true;
- } else if (nonAuxCount == 1 && auxCount == 1) {
- if (nonAuxSubtype != null && auxSubtype != null
- && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale())
- || auxSubtype.overridesImplicitlyEnabledSubtype()
- || nonAuxSubtype.overridesImplicitlyEnabledSubtype())
- && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
- return false;
- }
- return true;
+ }
+ if (nonAuxCount > 1 || auxCount > 1) {
+ return true;
+ } else if (nonAuxCount == 1 && auxCount == 1) {
+ if (nonAuxSubtype != null && auxSubtype != null
+ && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale())
+ || auxSubtype.overridesImplicitlyEnabledSubtype()
+ || nonAuxSubtype.overridesImplicitlyEnabledSubtype())
+ && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
+ return false;
}
- return false;
+ return true;
}
+ return false;
}
private boolean isKeyguardLocked() {
@@ -1697,11 +1705,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
mImeWindowVis = vis;
mInputShown = ((mImeWindowVis & InputMethodService.IME_VISIBLE) != 0);
mBackDisposition = backDisposition;
- final boolean iconVisibility = ((vis & (InputMethodService.IME_ACTIVE)) != 0)
- && (mWindowManagerService.isHardKeyboardAvailable()
- || (vis & (InputMethodService.IME_VISIBLE)) != 0);
- final boolean needsToShowImeSwitcher = iconVisibility
- && needsToShowImeSwitchOngoingNotification();
+ // mImeWindowVis should be updated before calling shouldShowImeSwitcherLocked().
+ final boolean needsToShowImeSwitcher = shouldShowImeSwitcherLocked();
if (mStatusBar != null) {
mStatusBar.setImeWindowStatus(token, vis, backDisposition,
needsToShowImeSwitcher);