auto import from //depot/cupcake/@137055
This commit is contained in:
@@ -20,9 +20,14 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.Keyboard.Key;
|
||||
import android.inputmethodservice.Keyboard.Row;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
public class LatinKeyboard extends Keyboard {
|
||||
|
||||
private Key mEnterKey;
|
||||
|
||||
public LatinKeyboard(Context context, int xmlLayoutResId) {
|
||||
super(context, xmlLayoutResId);
|
||||
}
|
||||
@@ -35,7 +40,49 @@ public class LatinKeyboard extends Keyboard {
|
||||
@Override
|
||||
protected Key createKeyFromXml(Resources res, Row parent, int x, int y,
|
||||
XmlResourceParser parser) {
|
||||
return new LatinKey(res, parent, x, y, parser);
|
||||
Key key = new LatinKey(res, parent, x, y, parser);
|
||||
if (key.codes[0] == 10) {
|
||||
mEnterKey = key;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* This looks at the ime options given by the current editor, to set the
|
||||
* appropriate label on the keyboard's enter key (if it has one).
|
||||
*/
|
||||
void setImeOptions(Resources res, int options) {
|
||||
if (mEnterKey == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
|
||||
case EditorInfo.IME_ACTION_GO:
|
||||
mEnterKey.iconPreview = null;
|
||||
mEnterKey.icon = null;
|
||||
mEnterKey.label = res.getText(R.string.label_go_key);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_NEXT:
|
||||
mEnterKey.iconPreview = null;
|
||||
mEnterKey.icon = null;
|
||||
mEnterKey.label = res.getText(R.string.label_next_key);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_SEARCH:
|
||||
mEnterKey.icon = res.getDrawable(
|
||||
R.drawable.sym_keyboard_search);
|
||||
mEnterKey.label = null;
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_SEND:
|
||||
mEnterKey.iconPreview = null;
|
||||
mEnterKey.icon = null;
|
||||
mEnterKey.label = res.getText(R.string.label_send_key);
|
||||
break;
|
||||
default:
|
||||
mEnterKey.icon = res.getDrawable(
|
||||
R.drawable.sym_keyboard_return);
|
||||
mEnterKey.label = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static class LatinKey extends Keyboard.Key {
|
||||
|
||||
@@ -65,11 +65,11 @@ public class SoftKeyboard extends InputMethodService
|
||||
private long mLastShiftTime;
|
||||
private long mMetaState;
|
||||
|
||||
private Keyboard mSymbolsKeyboard;
|
||||
private Keyboard mSymbolsShiftedKeyboard;
|
||||
private Keyboard mQwertyKeyboard;
|
||||
private LatinKeyboard mSymbolsKeyboard;
|
||||
private LatinKeyboard mSymbolsShiftedKeyboard;
|
||||
private LatinKeyboard mQwertyKeyboard;
|
||||
|
||||
private Keyboard mCurKeyboard;
|
||||
private LatinKeyboard mCurKeyboard;
|
||||
|
||||
private String mWordSeparators;
|
||||
|
||||
@@ -208,6 +208,10 @@ public class SoftKeyboard extends InputMethodService
|
||||
// keyboard with no special features.
|
||||
mCurKeyboard = mQwertyKeyboard;
|
||||
}
|
||||
|
||||
// Update the label on the enter key, depending on what the application
|
||||
// says it will do.
|
||||
mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,6 +508,18 @@ public class SoftKeyboard extends InputMethodService
|
||||
}
|
||||
}
|
||||
|
||||
public void onText(CharSequence text) {
|
||||
InputConnection ic = getCurrentInputConnection();
|
||||
if (ic == null) return;
|
||||
ic.beginBatchEdit();
|
||||
if (mComposing.length() > 0) {
|
||||
commitTyped(ic);
|
||||
}
|
||||
ic.commitText(text, 0);
|
||||
ic.endBatchEdit();
|
||||
updateShiftKeyState(getCurrentInputEditorInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the list of available candidates from the current composing
|
||||
* text. This will need to be filled in by however you are determining
|
||||
|
||||
Reference in New Issue
Block a user