LatinKeyboardpublic class LatinKeyboard extends android.inputmethodservice.Keyboard
Fields Summary |
---|
private android.graphics.drawable.Drawable | mShiftLockIcon | private android.graphics.drawable.Drawable | mShiftLockPreviewIcon | private android.graphics.drawable.Drawable | mOldShiftIcon | private android.graphics.drawable.Drawable | mOldShiftPreviewIcon | private Key | mShiftKey | private Key | mEnterKey | private static final int | SHIFT_OFF | private static final int | SHIFT_ON | private static final int | SHIFT_LOCKED | private int | mShiftState |
Constructors Summary |
---|
public LatinKeyboard(android.content.Context context, int xmlLayoutResId)
this(context, xmlLayoutResId, 0);
| public LatinKeyboard(android.content.Context context, int xmlLayoutResId, int mode)
super(context, xmlLayoutResId, mode);
mShiftLockIcon = context.getResources()
.getDrawable(R.drawable.sym_keyboard_shift_locked);
mShiftLockPreviewIcon = context.getResources()
.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
mShiftLockPreviewIcon.setBounds(0, 0,
mShiftLockPreviewIcon.getIntrinsicWidth(),
mShiftLockPreviewIcon.getIntrinsicHeight());
| public LatinKeyboard(android.content.Context context, int layoutTemplateResId, CharSequence characters, int columns, int horizontalPadding)
super(context, layoutTemplateResId, characters, columns, horizontalPadding);
|
Methods Summary |
---|
protected Key | createKeyFromXml(android.content.res.Resources res, Row parent, int x, int y, android.content.res.XmlResourceParser parser)
Key key = new LatinKey(res, parent, x, y, parser);
if (key.codes[0] == 10) {
mEnterKey = key;
}
return key;
| void | enableShiftLock()
int index = getShiftKeyIndex();
if (index >= 0) {
mShiftKey = getKeys().get(index);
if (mShiftKey instanceof LatinKey) {
((LatinKey)mShiftKey).enableShiftLock();
}
mOldShiftIcon = mShiftKey.icon;
mOldShiftPreviewIcon = mShiftKey.iconPreview;
}
| boolean | isShiftLocked()
return mShiftState == SHIFT_LOCKED;
| public boolean | isShifted()
if (mShiftKey != null) {
return mShiftState != SHIFT_OFF;
} else {
return super.isShifted();
}
| void | setImeOptions(android.content.res.Resources res, int mode, int options)
if (mEnterKey != null) {
// Reset some of the rarely used attributes.
mEnterKey.popupCharacters = null;
mEnterKey.popupResId = 0;
mEnterKey.text = null;
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_DONE:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_done_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.iconPreview = res.getDrawable(
R.drawable.sym_keyboard_feedback_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:
if (mode == KeyboardSwitcher.MODE_IM) {
mEnterKey.icon = null;
mEnterKey.iconPreview = null;
mEnterKey.label = ":-)";
mEnterKey.text = ":-) ";
mEnterKey.popupResId = R.xml.popup_smileys;
} else {
mEnterKey.iconPreview = res.getDrawable(
R.drawable.sym_keyboard_feedback_return);
mEnterKey.icon = res.getDrawable(
R.drawable.sym_keyboard_return);
mEnterKey.label = null;
}
break;
}
// Set the initial size of the preview icon
if (mEnterKey.iconPreview != null) {
mEnterKey.iconPreview.setBounds(0, 0,
mEnterKey.iconPreview.getIntrinsicWidth(),
mEnterKey.iconPreview.getIntrinsicHeight());
}
}
| void | setShiftLocked(boolean shiftLocked)
if (mShiftKey != null) {
if (shiftLocked) {
mShiftKey.on = true;
mShiftKey.icon = mShiftLockIcon;
mShiftState = SHIFT_LOCKED;
} else {
mShiftKey.on = false;
mShiftKey.icon = mShiftLockIcon;
mShiftState = SHIFT_ON;
}
}
| public boolean | setShifted(boolean shiftState)
boolean shiftChanged = false;
if (mShiftKey != null) {
if (shiftState == false) {
shiftChanged = mShiftState != SHIFT_OFF;
mShiftState = SHIFT_OFF;
mShiftKey.on = false;
mShiftKey.icon = mOldShiftIcon;
} else {
if (mShiftState == SHIFT_OFF) {
shiftChanged = mShiftState == SHIFT_OFF;
mShiftState = SHIFT_ON;
mShiftKey.icon = mShiftLockIcon;
}
}
} else {
return super.setShifted(shiftState);
}
return shiftChanged;
|
|