Methods Summary |
---|
public void | beginSession(TextInputComponent component)Start a text input session for the given TextInputComponent.
The TextInputComponent can be used to determine the initial
input mode, constraints, etc.
if (component == null) {
throw new IllegalArgumentException(
"Null TextInputComponent in beginSession()");
}
if (this.textComponent == null) {
this.textComponent = component;
} else if (this.textComponent != component) {
throw new IllegalStateException(
"InputModeHandler in use by another TextInputComponent");
}
// Select a suitable InputMode
selectInputMode();
|
public void | clear(int num)Clear the particular number of symbols
if (num == 0) {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"WARNING: BasicTextInput.clear calld with 0");
}
return;
}
textComponent.clear(num);
|
public void | commit(java.lang.String input)Called by an InputMode in order to automatically commit the given
input to the Text component. For example, when the timer expires
in an AlphaNumeric InputMode it will commit the current pending
character.
if (input != null && textComponent != null) {
textComponent.commit(input);
}
|
private void | endInputMode(InputMode mode)End the expired input mode.
if (mode != null) {
mode.endInput();
if (mode.hasDisplayable() && textComponent != null) {
currentDisplay.setCurrent(previousScreen);
previousScreen = null;
currentDisplay = null;
}
}
|
public void | endSession()End the current text input session and do not commit any pending
characters to the buffer.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[BTIS.endSession]");
}
if (currentMode != null) {
endInputMode(currentMode);
setInputMode(null);
}
textComponent = null;
stickyMode = null;
|
public InputMode[] | getAvailableModes()List the appropriate InputModes available for the current input
session. This method may be used by UI components in order to make
certain input mode choices available to the user for selection.
If this handler is not currently in an active text input session,
this method returns null.
if (textComponent == null) {
throw new IllegalStateException(
"Call to InputModeHandler while outside of a valid session");
}
int constraints = textComponent.getConstraints();
Vector v = new Vector();
for (int i = 0; i < inputModeSet.length; i++) {
if (inputModeSet[i].supportsConstraints(constraints)) {
v.addElement(inputModeSet[i]);
}
}
if (v.size() == 0) {
return null;
}
InputMode[] modes = new InputMode[v.size()];
v.copyInto(modes);
return modes;
|
public int | getAvailableSize()Returns the available size (number of characters) that can be
stored in this TextInputComponent .
return textComponent != null ? textComponent.getAvailableSize() : 0;
|
public InputMode | getCurrentInputMode()Retrieve the InputMode which is the current "active" mode
for this TextInputSession. This does not necessarily mean there is
any pending input with the InputMode itself, it means that if this
TextInputSession receives key input, the returned InputMode will be
the mode which processes that input.
return currentMode;
|
public java.lang.String[] | getMatchList()Gets the possible string matches
return currentMode != null ? currentMode.getMatchList() : new String[0];
|
public java.lang.String | getNextMatch()An iterative method to return the next available match given
the key processing thus far. If the return value of hasMoreMatches()
is true, this method will return a non-null String and will iterate
through the entire set of available matches until the set is exhausted.
Each subsequent call to processKey() will reset the iterator over
the set of available matches regardless if the key resulted in a change
to the set.
The two methods, hasMoreMatches() and getNextMatch(), can be used by
the User Interface system to retrieve the current set of pending inputs
and possibly present a chooser option to the user.
try {
return currentMode.getNextMatch();
} catch (Throwable t) {
// Since InputModes are pluggable, we'll catch any possible
// Throwable when calling into one
// IMPL_NOTE : log the throwable
}
return null;
|
public char | getPendingChar()return the pending char
used to bypass the asynchronous commit mechanism
e.g. to immediately commit a char before moving the cursor
return currentMode != null ? currentMode.getPendingChar() : 0;
|
public boolean | hasMoreMatches()If the InputMode supports multiple matches and more matches are
available this method will return true, false otherwise.
try {
return currentMode.hasMoreMatches();
} catch (Throwable t) {
// Since InputModes are pluggable, we'll catch any possible
// Throwable when calling into one
// IMPL_NOTE : log the throwable
}
return false;
|
public void | inputModeCompleted()Called by an InputMode in order to signal that the input process
has been completed with respect to the InputMode. Subsequent key
input should be handled in a new input session, possibly by the
same InputMode or by a different InputMode alltogether. For example,
when the timer expires in an AlphaNumeric InputMode, the character
is committed and the AlphaNumeric InputMode signals its completion.
Further key input may start a new session with the AlphaNumeric
InputMode or possibly some other InputMode.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[Basic.inputModeCompleted()] >>> ");
}
try {
if (currentMode != null) {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[Basic.inputModeCompleted()] !=null");
}
endInputMode(currentMode);
setInputMode(null);
}
// Select a suitable InputMode
selectInputMode();
} catch (Exception e) {
e.printStackTrace();
}
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[Basic.inputModeCompleted()] <<<< ");
}
|
public boolean | isClearKey(int keyCode)Returns true if the keyCode is used as 'clear'
return textComponent != null &&
textComponent.isClearKey(keyCode);
|
public boolean | isSymbol(char c)Check if the given char is symbol
return SymbolInputMode.isSymbol(c);
|
public int | processKey(int keyCode, boolean longPress)This method abstracts key processing to a single call (from
the assorted key press, release, repeat events). This method
should be called from the TextInputComponent to pass along
key input from the user. The TextInputComponent is responsible
for determining what key events should be processed (ie,
key events trigger processing on press or on release).
try {
return currentMode.processKey(keyCode, longPress);
} catch (Throwable t) {
// Since InputModes are pluggable, we'll catch any possible
// Throwable when calling into one
// IMPL_NOTE : log the throwable
}
return InputMode.KEYCODE_NONE;
|
protected void | selectInputMode()Based on the constraints of the current TextInputComponent,
select the most appropriate InputMode from the list available.
This method will also start the session with the InputMode by
calling the InputMode's beginInput() method.
if (textComponent == null) {
throw new IllegalStateException(
"Attempted input on null TextInputComponent");
}
int constraints = textComponent.getConstraints();
InputMode newMode = null;
if (stickyMode != null && stickyMode.supportsConstraints(constraints)) {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[BTIS.selectInputMode] setting mode to sticky:" +
stickyMode.getName());
}
newMode = stickyMode;
} else {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[BTIS.selectInputMode] not setting mode to sticky");
}
for (int i = 0; i < inputModeSet.length; i++) {
if (inputModeSet[i].supportsConstraints(constraints)) {
boolean[][] map = inputModeSet[i].getIsConstraintsMap();
int index = 0;
String is = textComponent.getInitialInputMode();
for (; index < INPUT_SUBSETS.length; index++) {
if (INPUT_SUBSETS[index].equals(is))
break;
}
int constraint = constraints &
TextField.CONSTRAINT_MASK;
if (constraint < TextInputSession.MAX_CONSTRAINTS &&
map[index][constraint]) {
newMode = inputModeSet[i];
break;
}
}
}
}
if (newMode != null) {
if (newMode != currentMode) {
endInputMode(currentMode);
setInputMode(newMode);
}
} else {
throw new IllegalStateException(
"No InputMode found supporting the current constraints");
}
|
public void | setCurrentInputMode(InputMode mode)Set this TextInputSession's current "active" InputMode to the
given mode. The given mode must be one of the InputModes listed
in the array of InputModes returned from the getAvailableModes()
method of this TextInputSession. Calling this method will terminate
any existing input session with the current InputMode and will
result in any subsequent key input being processed by the given
InputMode. If the given mode is already the current "active"
InputMode, this method has no effect. If this TextInputSession
is not currently in an input session (ie, there is no active
TextInputComponent), this method has no effect.
if (mode == null || mode == currentMode) {
return;
}
for (int i = 0; i < inputModeSet.length; i++) {
if (inputModeSet[i] == mode) {
try {
endInputMode(currentMode);
setInputMode(inputModeSet[i]);
} catch (Throwable t) {
// IMPL_NOTE Log exception?
}
break;
}
}
|
private void | setInputMode(InputMode mode)Set the required input mode. Sticky mode can be set as the old mode just
in case it will have to be reverted back. Text component has to be
notified about the mode change.
InputMode oldMode = currentMode;
currentMode = mode;
if (currentMode != null && textComponent != null) {
currentMode.beginInput(this,
textComponent.getInitialInputMode(),
textComponent.getConstraints());
if (currentMode.hasDisplayable()) {
currentDisplay = textComponent.getDisplay();
previousScreen = currentDisplay.getCurrent();
currentDisplay.setCurrent(currentMode.getDisplayable());
stickyMode = oldMode;
} else {
stickyMode = currentMode;
}
textComponent.notifyModeChanged();
}
|
public void | subInputModeChanged()Called by an InputMode to inform a TextComponent of a sub-inputMode
change.
textComponent.notifyModeChanged();
|