Use settings of the visibility of IME Switch button

Bug: 3141466

Change-Id: Ia5ef059af184d9c203a0065bf25b088e0529858e
This commit is contained in:
satok
2010-12-20 18:13:30 +09:00
parent dcc9dce073
commit d57896a64c

View File

@@ -48,6 +48,11 @@ public class InputMethodButton extends ImageView {
// IME shortcut button is disabled.
private static final int ID_IME_SHORTCUT_BUTTON = 0;
// These values are defined in Settings application.
private static final int ID_IME_BUTTON_VISIBILITY_AUTO = 0;
private static final int ID_IME_BUTTON_VISIBILITY_ALWAYS_SHOW = 1;
private static final int ID_IME_BUTTON_VISIBILITY_ALWAYS_HIDE = 2;
// other services we wish to talk to
private final InputMethodManager mImm;
private final int mId;
@@ -164,8 +169,17 @@ public class InputMethodButton extends ImageView {
private boolean needsToShowIMEButton() {
List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
final int size = imis.size();
return size > 1
|| (size == 1 && mImm.getEnabledInputMethodSubtypeList(imis.get(0)).size() > 1);
final int visibility = loadInputMethodSelectorVisibility();
switch (visibility) {
case ID_IME_BUTTON_VISIBILITY_AUTO:
return size > 1 || (size == 1
&& mImm.getEnabledInputMethodSubtypeList(imis.get(0)).size() > 1);
case ID_IME_BUTTON_VISIBILITY_ALWAYS_SHOW:
return true;
case ID_IME_BUTTON_VISIBILITY_ALWAYS_HIDE:
return false;
}
return false;
}
private void refreshStatusIcon(boolean keyboardShown) {
@@ -196,6 +210,11 @@ public class InputMethodButton extends ImageView {
}
}
private int loadInputMethodSelectorVisibility() {
return Settings.Secure.getInt(getContext().getContentResolver(),
Settings.Secure.INPUT_METHOD_SELECTOR_VISIBILITY, ID_IME_BUTTON_VISIBILITY_AUTO);
}
public void setIMEButtonVisible(IBinder token, boolean visible) {
mToken = token;
mKeyboardShown = visible ? needsToShowIMEButton() : false;