summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2015-05-13 15:25:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-13 15:25:22 +0000
commit05fe90c10b54111a742187935f2890029b348bf5 (patch)
tree1c8c3d7bca76e9d7bd6f851ce5fc82197c800309
parenta58fbec633bb6b4fa1afe03fc25d5e81235202e1 (diff)
parentc6c7cd2736fc3b6511e329a969409622750f2a58 (diff)
downloadframeworks_base-05fe90c10b54111a742187935f2890029b348bf5.zip
frameworks_base-05fe90c10b54111a742187935f2890029b348bf5.tar.gz
frameworks_base-05fe90c10b54111a742187935f2890029b348bf5.tar.bz2
Merge "Show IME switcher also when hardware keyboard is connected." into mnc-dev
-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);