public class TextEntryMonitor
extends java.lang.Object
implements android.text.TextWatcher
The TextEntryMonitor, one of which is created by the RTTCallActivity at a time, listens for input on the user's text field (EditText), and keeps track of which characters have changed. It sends those characters in the real-time call via the SipClient.
There are two modes, real time and en bloc, specified in the constructor.
Real-time mode:
If text is added or deleted at the end, TextEntryMonitor tells the SipClient to send
the new characters (possibly '\b') in the real-time call. If edits are made earlier in the text,
it undoes them, since the user is not allowed to add or remove text anywhere besides the
end of the field. Keeping track of these edits is pretty annoying, and you need to understand how
the Android.text.TextWatcher interface works before touching any of this.
En bloc mode:
Text is not sent character by character. It is only sent as complete messages, when checkAndSend()
is called.
Constructor and Description |
---|
TextEntryMonitor(android.widget.EditText watchThis,
boolean realTime,
SipClient sipClient,
java.lang.CharSequence startText,
boolean screenRotated)
The only constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterTextChanged(android.text.Editable s) |
void |
beforeTextChanged(java.lang.CharSequence s,
int start,
int count,
int after) |
void |
checkAndSend()
Used in the case when the user has chosen to send entire messages, not individual characters,
i.e.
|
void |
onTextChanged(java.lang.CharSequence s,
int start,
int before,
int count)
onTextChanged is the bulk of the logic to determine which characters to send to the other party when the user enters text.
|
public TextEntryMonitor(android.widget.EditText watchThis, boolean realTime, SipClient sipClient, java.lang.CharSequence startText, boolean screenRotated)
watchThis
- the text field to monitor for changesrealTime
- whether the text should be sent in real time, character by character, or only when checkAndSend() is calledsipClient
- the global hub for all things SIP, and who is responsible for sending the real-time text charsstartText
- initial text to populate the field with, to be ignored (likely put there because the activity is destroyed and recreated)screenRotated
- whether this new TextEntryMonitor is being created due to screen rotation, i.e. the activity is destroyed and recreatedpublic void onTextChanged(java.lang.CharSequence s, int start, int before, int count)
onTextChanged
in interface android.text.TextWatcher
public void beforeTextChanged(java.lang.CharSequence s, int start, int count, int after)
beforeTextChanged
in interface android.text.TextWatcher
public void afterTextChanged(android.text.Editable s)
afterTextChanged
in interface android.text.TextWatcher
public void checkAndSend()