Methods Summary |
---|
public void | append(java.lang.String text)
switch (mMode) {
case DIGITS_AND_LETTERS:
mDigits.getText().append(text);
mLetters.getText().append(text);
break;
case DIGITS_AND_LETTERS_NO_LETTERS:
case DIGITS_ONLY:
mDigits.getText().append(text);
break;
case DIGITS_AND_LETTERS_NO_DIGITS:
case LETTERS_ONLY:
mLetters.getText().append(text);
break;
}
|
public void | clearText()Clears both the digits and the filter text.
Editable text;
text = mLetters.getText();
text.clear();
text = mDigits.getText();
text.clear();
// Reset the mode based on the hardware type
if (mIsQwerty) {
setMode(DIGITS_AND_LETTERS);
} else {
setMode(DIGITS_ONLY);
}
|
public java.lang.CharSequence | getDigits()
if (mDigits.getVisibility() == View.VISIBLE) {
return mDigits.getText();
} else {
return "";
}
|
public java.lang.CharSequence | getFilterText()
if (mMode != DIGITS_ONLY) {
return getLetters();
} else {
return getDigits();
}
|
public java.lang.CharSequence | getLetters()
if (mLetters.getVisibility() == View.VISIBLE) {
return mLetters.getText();
} else {
return "";
}
|
public int | getMode()
return mMode;
|
public boolean | isQwertyKeyboard()
return mIsQwerty;
|
private void | makeDigitsPrimary()
if (mPrimary == mLetters) {
swapPrimaryAndHint(false);
}
|
private void | makeLettersPrimary()
if (mPrimary == mDigits) {
swapPrimaryAndHint(true);
}
|
protected void | onFinishInflate()
super.onFinishInflate();
// Setup the filter view
mInputFilters = new InputFilter[] { new InputFilter.AllCaps() };
mHint = (EditText) findViewById(com.android.internal.R.id.hint);
if (mHint == null) {
throw new IllegalStateException("DialerFilter must have a child EditText named hint");
}
mHint.setFilters(mInputFilters);
mLetters = mHint;
mLetters.setKeyListener(TextKeyListener.getInstance());
mLetters.setMovementMethod(null);
mLetters.setFocusable(false);
// Setup the digits view
mPrimary = (EditText) findViewById(com.android.internal.R.id.primary);
if (mPrimary == null) {
throw new IllegalStateException("DialerFilter must have a child EditText named primary");
}
mPrimary.setFilters(mInputFilters);
mDigits = mPrimary;
mDigits.setKeyListener(DialerKeyListener.getInstance());
mDigits.setMovementMethod(null);
mDigits.setFocusable(false);
// Look for an icon
mIcon = (ImageView) findViewById(com.android.internal.R.id.icon);
// Setup focus & highlight for this view
setFocusable(true);
// XXX Force the mode to QWERTY for now, since 12-key isn't supported
mIsQwerty = true;
setMode(DIGITS_AND_LETTERS);
|
protected void | onFocusChanged(boolean focused, int direction, android.graphics.Rect previouslyFocusedRect)Only show the icon view when focused, if there is one.
super.onFocusChanged(focused, direction, previouslyFocusedRect);
if (mIcon != null) {
mIcon.setVisibility(focused ? View.VISIBLE : View.GONE);
}
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
boolean handled = false;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_DPAD_CENTER:
break;
case KeyEvent.KEYCODE_DEL:
switch (mMode) {
case DIGITS_AND_LETTERS:
handled = mDigits.onKeyDown(keyCode, event);
handled &= mLetters.onKeyDown(keyCode, event);
break;
case DIGITS_AND_LETTERS_NO_DIGITS:
handled = mLetters.onKeyDown(keyCode, event);
if (mLetters.getText().length() == mDigits.getText().length()) {
setMode(DIGITS_AND_LETTERS);
}
break;
case DIGITS_AND_LETTERS_NO_LETTERS:
if (mDigits.getText().length() == mLetters.getText().length()) {
mLetters.onKeyDown(keyCode, event);
setMode(DIGITS_AND_LETTERS);
}
handled = mDigits.onKeyDown(keyCode, event);
break;
case DIGITS_ONLY:
handled = mDigits.onKeyDown(keyCode, event);
break;
case LETTERS_ONLY:
handled = mLetters.onKeyDown(keyCode, event);
break;
}
break;
default:
//mIsQwerty = msg.getKeyIsQwertyKeyboard();
switch (mMode) {
case DIGITS_AND_LETTERS:
handled = mLetters.onKeyDown(keyCode, event);
// pass this throw so the shift state is correct (for example,
// on a standard QWERTY keyboard, * and 8 are on the same key)
if (KeyEvent.isModifierKey(keyCode)) {
mDigits.onKeyDown(keyCode, event);
handled = true;
break;
}
// Only check to see if the digit is valid if the key is a printing key
// in the TextKeyListener. This prevents us from hiding the digits
// line when keys like UP and DOWN are hit.
// XXX note that KEYCODE_TAB is special-cased here for
// devices that share tab and 0 on a single key.
boolean isPrint = event.isPrintingKey();
if (isPrint || keyCode == KeyEvent.KEYCODE_SPACE
|| keyCode == KeyEvent.KEYCODE_TAB) {
char c = event.getMatch(DialerKeyListener.CHARACTERS);
if (c != 0) {
handled &= mDigits.onKeyDown(keyCode, event);
} else {
setMode(DIGITS_AND_LETTERS_NO_DIGITS);
}
}
break;
case DIGITS_AND_LETTERS_NO_LETTERS:
case DIGITS_ONLY:
handled = mDigits.onKeyDown(keyCode, event);
break;
case DIGITS_AND_LETTERS_NO_DIGITS:
case LETTERS_ONLY:
handled = mLetters.onKeyDown(keyCode, event);
break;
}
}
if (!handled) {
return super.onKeyDown(keyCode, event);
} else {
return true;
}
|
public boolean | onKeyUp(int keyCode, android.view.KeyEvent event)
boolean a = mLetters.onKeyUp(keyCode, event);
boolean b = mDigits.onKeyUp(keyCode, event);
return a || b;
|
protected void | onModeChange(int oldMode, int newMode)Called right after the mode changes to give subclasses the option to
restyle, etc.
|
public void | removeFilterWatcher(android.text.TextWatcher watcher)
Spannable text;
if (mMode != DIGITS_ONLY) {
text = mLetters.getText();
} else {
text = mDigits.getText();
}
text.removeSpan(watcher);
|
public void | setDigitsWatcher(android.text.TextWatcher watcher)
CharSequence text = mDigits.getText();
Spannable span = (Spannable)text;
span.setSpan(watcher, 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
public void | setFilterWatcher(android.text.TextWatcher watcher)
if (mMode != DIGITS_ONLY) {
setLettersWatcher(watcher);
} else {
setDigitsWatcher(watcher);
}
|
public void | setLettersWatcher(android.text.TextWatcher watcher)
CharSequence text = mLetters.getText();
Spannable span = (Spannable)text;
span.setSpan(watcher, 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
public void | setMode(int newMode)Change the mode of the widget.
switch (newMode) {
case DIGITS_AND_LETTERS:
makeDigitsPrimary();
mLetters.setVisibility(View.VISIBLE);
mDigits.setVisibility(View.VISIBLE);
break;
case DIGITS_ONLY:
makeDigitsPrimary();
mLetters.setVisibility(View.GONE);
mDigits.setVisibility(View.VISIBLE);
break;
case LETTERS_ONLY:
makeLettersPrimary();
mLetters.setVisibility(View.VISIBLE);
mDigits.setVisibility(View.GONE);
break;
case DIGITS_AND_LETTERS_NO_LETTERS:
makeDigitsPrimary();
mLetters.setVisibility(View.INVISIBLE);
mDigits.setVisibility(View.VISIBLE);
break;
case DIGITS_AND_LETTERS_NO_DIGITS:
makeLettersPrimary();
mLetters.setVisibility(View.VISIBLE);
mDigits.setVisibility(View.INVISIBLE);
break;
}
int oldMode = mMode;
mMode = newMode;
onModeChange(oldMode, newMode);
|
private void | swapPrimaryAndHint(boolean makeLettersPrimary)
Editable lettersText = mLetters.getText();
Editable digitsText = mDigits.getText();
KeyListener lettersInput = mLetters.getKeyListener();
KeyListener digitsInput = mDigits.getKeyListener();
if (makeLettersPrimary) {
mLetters = mPrimary;
mDigits = mHint;
} else {
mLetters = mHint;
mDigits = mPrimary;
}
mLetters.setKeyListener(lettersInput);
mLetters.setText(lettersText);
lettersText = mLetters.getText();
Selection.setSelection(lettersText, lettersText.length());
mDigits.setKeyListener(digitsInput);
mDigits.setText(digitsText);
digitsText = mDigits.getText();
Selection.setSelection(digitsText, digitsText.length());
// Reset the filters
mPrimary.setFilters(mInputFilters);
mHint.setFilters(mInputFilters);
|