From d4e22f3846a6bbb78a5c4191c6e8af4620b6db99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=A4ggqvist?= Date: Thu, 9 Jun 2011 01:28:43 +0200 Subject: [PATCH] Ignore status characters in front of nicks for the purpose of nick completion --- .../yaaic/activity/ConversationActivity.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java index 605f8b1..542dfbb 100644 --- a/application/src/org/yaaic/activity/ConversationActivity.java +++ b/application/src/org/yaaic/activity/ConversationActivity.java @@ -893,7 +893,8 @@ public class ConversationActivity extends Activity implements ServiceConnection, List result = new ArrayList(); 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)); } } @@ -926,6 +927,7 @@ public class ConversationActivity extends Activity implements ServiceConnection, private void insertNickCompletion(EditText input, String nick) { int start = input.getSelectionStart(); int end = input.getSelectionEnd(); + nick = removeStatusChar(nick); if (start == 0) { nick += ":"; @@ -953,4 +955,20 @@ public class ConversationActivity extends Activity implements ServiceConnection, 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; + } }