modified highlight nick behaviour to better work with quotes
This commit is contained in:
parent
59f82cbd34
commit
c324f0c8df
|
@ -34,6 +34,7 @@ import android.widget.AbsListView;
|
||||||
import android.widget.AbsListView.OnScrollListener;
|
import android.widget.AbsListView.OnScrollListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
@ -849,16 +850,22 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void highlightInConference(String nick) {
|
protected void highlightInConference(String nick) {
|
||||||
String oldString = mEditMessage.getText().toString().trim();
|
final Editable editable = mEditMessage.getText();
|
||||||
if (oldString.isEmpty() || mEditMessage.getSelectionStart() == 0) {
|
String oldString = editable.toString().trim();
|
||||||
|
final int pos = mEditMessage.getSelectionStart();
|
||||||
|
if (oldString.isEmpty() || pos == 0) {
|
||||||
mEditMessage.getText().insert(0, nick + ": ");
|
mEditMessage.getText().insert(0, nick + ": ");
|
||||||
} else {
|
} else {
|
||||||
if (mEditMessage.getText().charAt(
|
final char before = editable.charAt(pos - 1);
|
||||||
mEditMessage.getSelectionStart() - 1) != ' ') {
|
final char after = editable.length() > pos ? editable.charAt(pos) : '\0';
|
||||||
nick = " " + nick;
|
if (before == '\n') {
|
||||||
|
editable.insert(pos, nick + ": ");
|
||||||
|
} else {
|
||||||
|
editable.insert(pos,(Character.isWhitespace(before)? "" : " ") + nick + (Character.isWhitespace(after) ? "" : " "));
|
||||||
|
if (Character.isWhitespace(after)) {
|
||||||
|
mEditMessage.setSelection(mEditMessage.getSelectionStart()+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mEditMessage.getText().insert(mEditMessage.getSelectionStart(),
|
|
||||||
nick + " ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue