mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Recognize LOCATION in VEVENT
git-svn-id: https://zxing.googlecode.com/svn/trunk@1301 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
974d22fbd9
commit
047c932fcb
|
@ -59,11 +59,11 @@ public final class CalendarResultHandler extends ResultHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handleButtonPress(int index) {
|
public void handleButtonPress(int index) {
|
||||||
CalendarParsedResult calendarResult = (CalendarParsedResult) getResult();
|
CalendarParsedResult calendarResult = (CalendarParsedResult) getResult();
|
||||||
switch (index) {
|
if (index == 0) {
|
||||||
case 0:
|
addCalendarEvent(calendarResult.getSummary(),
|
||||||
addCalendarEvent(calendarResult.getSummary(), calendarResult.getStart(),
|
calendarResult.getStart(),
|
||||||
calendarResult.getEnd());
|
calendarResult.getEnd(),
|
||||||
break;
|
calendarResult.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,16 +143,21 @@ public abstract class ResultHandler {
|
||||||
* @param summary A description of the event
|
* @param summary A description of the event
|
||||||
* @param start The start time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
|
* @param start The start time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
|
||||||
* @param end The end time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
|
* @param end The end time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
|
||||||
|
* @param location a text description of the event location
|
||||||
*/
|
*/
|
||||||
final void addCalendarEvent(String summary, String start, String end) {
|
final void addCalendarEvent(String summary, String start, String end, String location) {
|
||||||
Intent intent = new Intent(Intent.ACTION_EDIT);
|
Intent intent = new Intent(Intent.ACTION_EDIT);
|
||||||
intent.setType("vnd.android.cursor.item/event");
|
intent.setType("vnd.android.cursor.item/event");
|
||||||
intent.putExtra("beginTime", calculateMilliseconds(start));
|
intent.putExtra("beginTime", calculateMilliseconds(start));
|
||||||
if (start.length() == 8) {
|
if (start.length() == 8) {
|
||||||
intent.putExtra("allDay", true);
|
intent.putExtra("allDay", true);
|
||||||
}
|
}
|
||||||
|
if (end == null) {
|
||||||
|
end = start;
|
||||||
|
}
|
||||||
intent.putExtra("endTime", calculateMilliseconds(end));
|
intent.putExtra("endTime", calculateMilliseconds(end));
|
||||||
intent.putExtra("title", summary);
|
intent.putExtra("title", summary);
|
||||||
|
intent.putExtra("eventLocation", location);
|
||||||
launchIntent(intent);
|
launchIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import com.google.zxing.Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Partially implements the iCalendar format's "VEVENT" format for specifying a
|
* Partially implements the iCalendar format's "VEVENT" format for specifying a
|
||||||
* calendar event. See RFC 2445. This supports SUMMARY, DTSTART and DTEND fields.
|
* calendar event. See RFC 2445. This supports SUMMARY, LOCATION, DTSTART and DTEND fields.
|
||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
|
@ -46,8 +46,9 @@ final class VEventResultParser extends ResultParser {
|
||||||
String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
|
String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
|
||||||
String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
|
String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
|
||||||
String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
|
String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
|
||||||
|
String location = VCardResultParser.matchSingleVCardPrefixedField("LOCATION", rawText, true);
|
||||||
try {
|
try {
|
||||||
return new CalendarParsedResult(summary, start, end, null, null, null);
|
return new CalendarParsedResult(summary, start, end, location, null, null);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,10 @@ public final class CalendarParsedResultTestCase extends TestCase {
|
||||||
|
|
||||||
public void testVEvent() {
|
public void testVEvent() {
|
||||||
doTest(
|
doTest(
|
||||||
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nDTEND:20080505T234555Z\r\n" +
|
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
|
||||||
|
"DTEND:20080505T234555Z\r\nLOCATION:Miami\r\n" +
|
||||||
"END:VEVENT\r\nEND:VCALENDAR",
|
"END:VEVENT\r\nEND:VCALENDAR",
|
||||||
null, "foo", null, "20080504T123456Z", "20080505T234555Z", null);
|
null, "foo", "Miami", "20080504T123456Z", "20080505T234555Z", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void doTest(String contents,
|
private static void doTest(String contents,
|
||||||
|
|
Loading…
Reference in a new issue