package js.rbuddy;

import android.content.Context;
import android.text.InputType;
import android.text.method.TextKeyListener;
import android.widget.ArrayAdapter;
import android.widget.MultiAutoCompleteTextView;

public class TagsEditText extends MultiAutoCompleteTextView {
	public TagsEditText(Context context) {
		super(context);

		setInputType(InputType.TYPE_CLASS_TEXT);
		setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
		setKeyListener(TextKeyListener.getInstance(true,
				TextKeyListener.Capitalize.NONE));

		TagSetFile tf = RBuddyApp.sharedInstance().tagSetFile();

		ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
				android.R.layout.simple_dropdown_item_1line, tf.tagNamesList());
		setAdapter(adapter);

		setHint("Tags");
	}

}

@@ -370,16 +370,19 @@
 _TEXT);%0A
+%09%09%0A
 %09%09setTok
@@ -396,39 +396,11 @@
 new 
-MultiAutoCompleteTextView.Comma
+Our
 Toke
@@ -743,10 +743,1059 @@
 %22);%0A%09%7D%0A%0A
+%09/**%0A%09 * Tokenizer that recognizes both periods and commas as delimeters%0A%09 */%0A%09private static class OurTokenizer implements Tokenizer %7B%0A%0A%09%09private static boolean isDelim(char c) %7B%0A%09%09%09return c == ',' %7C%7C c == '.';%0A%09%09%7D%0A%0A%09%09private static boolean isWhitesp(char c) %7B%0A%09%09%09return c %3C= ' ';%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public int findTokenStart(CharSequence text, int cursor) %7B%0A%09%09%09int i = cursor;%0A%09%09%09while (i %3E 0 && !isDelim(text.charAt(i - 1))) %7B%0A%09%09%09%09i--;%0A%09%09%09%7D%0A%09%09%09while (i %3C cursor && isWhitesp(text.charAt(i)))%0A%09%09%09%09i++;%0A%09%09%09return i;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public int findTokenEnd(CharSequence text, int cursor) %7B%0A%09%09%09int i = cursor;%0A%09%09%09int len = text.length();%0A%0A%09%09%09while (i %3C len && !isDelim(text.charAt(i))) %7B%0A%09%09%09%09i++;%0A%09%09%09%7D%0A%09%09%09while (i %3E cursor && isWhitesp(text.charAt(i - 1)))%0A%09%09%09%09i--;%0A%09%09%09return i;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public CharSequence terminateToken(CharSequence text) %7B%0A%09%09%09int i = text.length();%0A%0A%09%09%09while (i %3E 0 && isWhitesp(text.charAt(i - 1))) %7B%0A%09%09%09%09i--;%0A%09%09%09%7D%0A%09%09%09if (i %3E 0 && isDelim(text.charAt(i - 1))) %7B%0A%09%09%09%09return text;%0A%09%09%09%7D%0A%0A%09%09%09return text + %22, %22;%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

Fix for issue #16, a new tokenizer that recognizes commas and periods