mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 13:04:05 -08:00
Per dominik.wild, added support for "sms:number:body" format URIs
git-svn-id: https://zxing.googlecode.com/svn/trunk@565 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a16084242c
commit
7dbc556789
|
@ -80,6 +80,15 @@ final class SMSMMSResultParser extends ResultParser {
|
|||
subject = (String) nameValuePairs.get("subject");
|
||||
body = (String) nameValuePairs.get("body");
|
||||
}
|
||||
// Thanks to dominik.wild for suggesting this enhancement to support
|
||||
// smsto:number:body URIs
|
||||
if (body == null) {
|
||||
int bodyStart = number.indexOf(':');
|
||||
if (bodyStart >= 0) {
|
||||
body = number.substring(bodyStart + 1);
|
||||
number = number.substring(0, bodyStart);
|
||||
}
|
||||
}
|
||||
return new SMSParsedResult("sms:" + number, number, via, subject, body, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,13 +110,16 @@ public final class ParsedReaderResultTestCase extends TestCase {
|
|||
doTestResult("BEGIN:VCARD\r\nEND:VCARD", ParsedResultType.ADDRESSBOOK);
|
||||
doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", ParsedResultType.ADDRESSBOOK);
|
||||
doTestResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", ParsedResultType.ADDRESSBOOK);
|
||||
doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", ParsedResultType.ADDRESSBOOK);
|
||||
doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\n" +
|
||||
"END:VCARD", ParsedResultType.ADDRESSBOOK);
|
||||
doTestResult("BEGIN:VCARD", ParsedResultType.URI); // yeah we end up guessing "URI" here
|
||||
}
|
||||
|
||||
public void testVEvent() {
|
||||
doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nDTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR", ParsedResultType.CALENDAR);
|
||||
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nDTEND:20080505T234555Z\r\nEND:VEVENT", ParsedResultType.CALENDAR);
|
||||
doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
|
||||
"DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR", ParsedResultType.CALENDAR);
|
||||
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
|
||||
"DTEND:20080505T234555Z\r\nEND:VEVENT", ParsedResultType.CALENDAR);
|
||||
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
|
||||
doTestResult("BEGIN:VEVENT", ParsedResultType.URI); // See above note on why this is URI
|
||||
}
|
||||
|
@ -127,6 +130,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
|
|||
doTestResult("smsto:+15551212", ParsedResultType.SMS);
|
||||
doTestResult("sms:+15551212;via=999333", ParsedResultType.SMS);
|
||||
doTestResult("sms:+15551212?subject=foo&body=bar", ParsedResultType.SMS);
|
||||
doTestResult("sms:+15551212:subject", ParsedResultType.SMS);
|
||||
}
|
||||
|
||||
public void testMMS() {
|
||||
|
@ -135,6 +139,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
|
|||
doTestResult("mmsto:+15551212", ParsedResultType.SMS);
|
||||
doTestResult("mms:+15551212;via=999333", ParsedResultType.SMS);
|
||||
doTestResult("mms:+15551212?subject=foo&body=bar", ParsedResultType.SMS);
|
||||
doTestResult("mms:+15551212:subject", ParsedResultType.SMS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue