PasswordEntryKeyboardpublic class PasswordEntryKeyboard extends android.inputmethodservice.Keyboard A basic, embed-able keyboard designed for password entry. Allows entry of all Latin-1 characters.
It has two modes: alpha and numeric. In alpha mode, it allows all Latin-1 characters and enables
an additional keyboard with symbols. In numeric mode, it shows a 12-key DTMF dialer-like
keypad with alpha characters hints. |
Fields Summary |
---|
private static final int | SHIFT_OFF | private static final int | SHIFT_ON | private static final int | SHIFT_LOCKED | public static final int | KEYCODE_SPACE | private android.graphics.drawable.Drawable | mShiftIcon | private android.graphics.drawable.Drawable | mShiftLockIcon | private android.graphics.drawable.Drawable[] | mOldShiftIcons | private Key[] | mShiftKeys | private Key | mEnterKey | private Key | mF1Key | private Key | mSpaceKey | private int | mShiftState | static int | sSpacebarVerticalCorrection |
Constructors Summary |
---|
public PasswordEntryKeyboard(android.content.Context context, int xmlLayoutResId)
this(context, xmlLayoutResId, 0);
| public PasswordEntryKeyboard(android.content.Context context, int xmlLayoutResId, int width, int height)
this(context, xmlLayoutResId, 0, width, height);
| public PasswordEntryKeyboard(android.content.Context context, int xmlLayoutResId, int mode)
super(context, xmlLayoutResId, mode);
init(context);
| public PasswordEntryKeyboard(android.content.Context context, int xmlLayoutResId, int mode, int width, int height)
super(context, xmlLayoutResId, mode, width, height);
init(context);
| public PasswordEntryKeyboard(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)
LatinKey key = new LatinKey(res, parent, x, y, parser);
final int code = key.codes[0];
if (code >=0 && code != '\n" && (code < 32 || code > 127)) {
// Log.w(TAG, "Key code for " + key.label + " is not latin-1");
key.label = " ";
key.setEnabled(false);
}
switch (key.codes[0]) {
case 10:
mEnterKey = key;
break;
case PasswordEntryKeyboardView.KEYCODE_F1:
mF1Key = key;
break;
case 32:
mSpaceKey = key;
break;
}
return key;
| void | enableShiftLock()Allows shiftlock to be turned on. See {@link #setShiftLocked(boolean)}
int i = 0;
for (int index : getShiftKeyIndices()) {
if (index >= 0 && i < mShiftKeys.length) {
mShiftKeys[i] = getKeys().get(index);
if (mShiftKeys[i] instanceof LatinKey) {
((LatinKey)mShiftKeys[i]).enableShiftLock();
}
mOldShiftIcons[i] = mShiftKeys[i].icon;
i++;
}
}
| private void | init(android.content.Context context)
final Resources res = context.getResources();
mShiftIcon = context.getDrawable(R.drawable.sym_keyboard_shift);
mShiftLockIcon = context.getDrawable(R.drawable.sym_keyboard_shift_locked);
sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.password_keyboard_spacebar_vertical_correction);
| public boolean | isShifted()Whether or not keyboard is shifted.
if (mShiftKeys[0] != null) {
return mShiftState != SHIFT_OFF;
} else {
return super.isShifted();
}
| void | setEnterKeyResources(android.content.res.Resources res, int previewId, int iconId, int labelId)Allows enter key resources to be overridden
if (mEnterKey != null) {
// Reset some of the rarely used attributes.
mEnterKey.popupCharacters = null;
mEnterKey.popupResId = 0;
mEnterKey.text = null;
mEnterKey.iconPreview = res.getDrawable(previewId);
mEnterKey.icon = res.getDrawable(iconId);
mEnterKey.label = res.getText(labelId);
// 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)Turn on shift lock. This turns on the LED for this key, if it has one.
It should be followed by a call to {@link KeyboardView#invalidateKey(int)}
or {@link KeyboardView#invalidateAllKeys()}
for (Key shiftKey : mShiftKeys) {
if (shiftKey != null) {
shiftKey.on = shiftLocked;
shiftKey.icon = mShiftLockIcon;
}
}
mShiftState = shiftLocked ? SHIFT_LOCKED : SHIFT_ON;
| public boolean | setShifted(boolean shiftState)Turn on shift mode. Sets shift mode and turns on icon for shift key.
It should be followed by a call to {@link KeyboardView#invalidateKey(int)}
or {@link KeyboardView#invalidateAllKeys()}
boolean shiftChanged = false;
if (shiftState == false) {
shiftChanged = mShiftState != SHIFT_OFF;
mShiftState = SHIFT_OFF;
} else if (mShiftState == SHIFT_OFF) {
shiftChanged = mShiftState == SHIFT_OFF;
mShiftState = SHIFT_ON;
}
for (int i = 0; i < mShiftKeys.length; i++) {
if (mShiftKeys[i] != null) {
if (shiftState == false) {
mShiftKeys[i].on = false;
mShiftKeys[i].icon = mOldShiftIcons[i];
} else if (mShiftState == SHIFT_OFF) {
mShiftKeys[i].on = false;
mShiftKeys[i].icon = mShiftIcon;
}
} else {
// return super.setShifted(shiftState);
}
}
return shiftChanged;
|
|