Skip to content

Commit

Permalink
Ignore status characters in front of nicks for the purpose of nick co…
Browse files Browse the repository at this point in the history
…mpletion
  • Loading branch information
rasher authored and pocmo committed Jun 9, 2011
1 parent 7c7ce7c commit d4e22f3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion application/src/org/yaaic/activity/ConversationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ private void doNickCompletion(EditText input) {
List<Integer> result = new ArrayList<Integer>();

for (int i = 0; i < users.length; i++) {
if (users[i].toLowerCase().startsWith(word)) {
String nick = removeStatusChar(users[i].toLowerCase());
if (nick.startsWith(word)) {
result.add(Integer.valueOf(i));
}
}
Expand Down Expand Up @@ -926,6 +927,7 @@ private void doNickCompletion(EditText input) {
private void insertNickCompletion(EditText input, String nick) {
int start = input.getSelectionStart();
int end = input.getSelectionEnd();
nick = removeStatusChar(nick);

if (start == 0) {
nick += ":";
Expand Down Expand Up @@ -953,4 +955,20 @@ public void run() {
private void openSoftKeyboard(View view) {
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

/**
* Remove the status char off the front of a nick if one is present
*
* @param nick
* @return nick without statuschar
*/
private String removeStatusChar(String nick)
{
/* Discard status characters */
if (nick.startsWith("@") || nick.startsWith("+")
|| nick.startsWith("%")) {
nick = nick.substring(1);
}
return nick;
}
}

0 comments on commit d4e22f3

Please sign in to comment.