am 1b09ac4f: Merge "Add a showing input method picker option by longpressing setting key" into gingerbread
Merge commit '1b09ac4f93a0138a414094c374fa2ff12e39c71a' into gingerbread-plus-aosp * commit '1b09ac4f93a0138a414094c374fa2ff12e39c71a': Add a showing input method picker option by longpressing setting keymain
commit
e5ae8c62c8
|
@ -321,6 +321,9 @@
|
||||||
<!-- Menu item for launching Input method switcher -->
|
<!-- Menu item for launching Input method switcher -->
|
||||||
<string name="inputMethod">Input method</string>
|
<string name="inputMethod">Input method</string>
|
||||||
|
|
||||||
|
<!-- Menu item for launching Input method picker -->
|
||||||
|
<string name="selectInputMethod">Select input method</string>
|
||||||
|
|
||||||
<!-- Title for input language selection screen -->
|
<!-- Title for input language selection screen -->
|
||||||
<string name="language_selection_title">Input languages</string>
|
<string name="language_selection_title">Input languages</string>
|
||||||
<!-- Title summary for input language selection screen -->
|
<!-- Title summary for input language selection screen -->
|
||||||
|
|
|
@ -1083,6 +1083,40 @@ public class LatinIME extends InputMethodService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasMultipleEnabledIMEs() {
|
||||||
|
return ((InputMethodManager) getSystemService(
|
||||||
|
INPUT_METHOD_SERVICE)).getEnabledInputMethodList().size() > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showInputMethodPicker() {
|
||||||
|
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
|
||||||
|
.showInputMethodPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOptionKeyPressed() {
|
||||||
|
if (!isShowingOptionDialog()) {
|
||||||
|
if (hasMultipleEnabledIMEs()) {
|
||||||
|
showOptionsMenu();
|
||||||
|
} else {
|
||||||
|
launchSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOptionKeyLongPressed() {
|
||||||
|
if (!isShowingOptionDialog()) {
|
||||||
|
if (hasMultipleEnabledIMEs()) {
|
||||||
|
showInputMethodPicker();
|
||||||
|
} else {
|
||||||
|
launchSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShowingOptionDialog() {
|
||||||
|
return mOptionsDialog != null && mOptionsDialog.isShowing();
|
||||||
|
}
|
||||||
|
|
||||||
// Implementation of KeyboardViewListener
|
// Implementation of KeyboardViewListener
|
||||||
|
|
||||||
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
||||||
|
@ -1102,12 +1136,15 @@ public class LatinIME extends InputMethodService
|
||||||
// Shift key is handled in onPress().
|
// Shift key is handled in onPress().
|
||||||
break;
|
break;
|
||||||
case Keyboard.KEYCODE_CANCEL:
|
case Keyboard.KEYCODE_CANCEL:
|
||||||
if (mOptionsDialog == null || !mOptionsDialog.isShowing()) {
|
if (!isShowingOptionDialog()) {
|
||||||
handleClose();
|
handleClose();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LatinKeyboardView.KEYCODE_OPTIONS:
|
case LatinKeyboardView.KEYCODE_OPTIONS:
|
||||||
showOptionsMenu();
|
onOptionKeyPressed();
|
||||||
|
break;
|
||||||
|
case LatinKeyboardView.KEYCODE_OPTIONS_LONGPRESS:
|
||||||
|
onOptionKeyLongPressed();
|
||||||
break;
|
break;
|
||||||
case LatinKeyboardView.KEYCODE_NEXT_LANGUAGE:
|
case LatinKeyboardView.KEYCODE_NEXT_LANGUAGE:
|
||||||
toggleLanguage(false, true);
|
toggleLanguage(false, true);
|
||||||
|
@ -2400,7 +2437,7 @@ public class LatinIME extends InputMethodService
|
||||||
builder.setIcon(R.drawable.ic_dialog_keyboard);
|
builder.setIcon(R.drawable.ic_dialog_keyboard);
|
||||||
builder.setNegativeButton(android.R.string.cancel, null);
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
CharSequence itemSettings = getString(R.string.english_ime_settings);
|
CharSequence itemSettings = getString(R.string.english_ime_settings);
|
||||||
CharSequence itemInputMethod = getString(R.string.inputMethod);
|
CharSequence itemInputMethod = getString(R.string.selectInputMethod);
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
itemSettings, itemInputMethod},
|
itemSettings, itemInputMethod},
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.List;
|
||||||
public class LatinKeyboardView extends LatinKeyboardBaseView {
|
public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||||
|
|
||||||
static final int KEYCODE_OPTIONS = -100;
|
static final int KEYCODE_OPTIONS = -100;
|
||||||
|
static final int KEYCODE_OPTIONS_LONGPRESS = -101;
|
||||||
static final int KEYCODE_VOICE = -102;
|
static final int KEYCODE_VOICE = -102;
|
||||||
static final int KEYCODE_F1 = -103;
|
static final int KEYCODE_F1 = -103;
|
||||||
static final int KEYCODE_NEXT_LANGUAGE = -104;
|
static final int KEYCODE_NEXT_LANGUAGE = -104;
|
||||||
|
@ -76,7 +77,12 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onLongPress(Key key) {
|
protected boolean onLongPress(Key key) {
|
||||||
if (key.codes[0] == '0' && getKeyboard() == mPhoneKeyboard) {
|
if (key.codes[0] == KEYCODE_OPTIONS) {
|
||||||
|
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS_LONGPRESS, null,
|
||||||
|
LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE,
|
||||||
|
LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE);
|
||||||
|
return true;
|
||||||
|
} else if (key.codes[0] == '0' && getKeyboard() == mPhoneKeyboard) {
|
||||||
// Long pressing on 0 in phone number keypad gives you a '+'.
|
// Long pressing on 0 in phone number keypad gives you a '+'.
|
||||||
getOnKeyboardActionListener().onKey(
|
getOnKeyboardActionListener().onKey(
|
||||||
'+', null, LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE,
|
'+', null, LatinKeyboardBaseView.NOT_A_TOUCH_COORDINATE,
|
||||||
|
|
Loading…
Reference in New Issue