import java.util.ArrayList;
import java.util.Calendar;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* This is the base class for a set of classes that implement views (day view
private String mDateRange;
private TextView mTitleTextView;
-
+
public CalendarView(CalendarActivity activity) {
super(activity);
mResources = activity.getResources();
return rf;
}
+ private Pattern drawTextSanitizerFilter = Pattern.compile("[\t\n],");
+
+ // Sanitize a string before passing it to drawText or else we get little
+ // squares. For newlines and tabs before a comma, delete the character.
+ // Otherwise, just replace them with a space.
+ private String drawTextSanitizer(String string) {
+ Matcher m = drawTextSanitizerFilter.matcher(string);
+ string = m.replaceAll(",").replace('\n', ' ').replace('\n', ' ');
+ return string;
+ }
+
private void drawEventText(Event event, RectF rf, Canvas canvas, Paint p, int topMargin) {
if (!mDrawTextInEventRect) {
return;
// Truncate the event title to a known (large enough) limit
String text = event.getTitleAndLocation();
+
+ text = drawTextSanitizer(text);
+
int len = text.length();
if (len > MAX_EVENT_TEXT_LEN) {
text = text.substring(0, MAX_EVENT_TEXT_LEN);