Put URL, birthday in notes as there's not a better place for them by Intent

git-svn-id: https://zxing.googlecode.com/svn/trunk@2131 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-01-21 17:53:24 +00:00
parent 27194b053a
commit 6a46c4ac54
2 changed files with 22 additions and 5 deletions

View file

@ -127,7 +127,9 @@ public final class AddressBookResultHandler extends ResultHandler {
address1,
address1Type,
addressResult.getOrg(),
addressResult.getTitle());
addressResult.getTitle(),
addressResult.getURL(),
addressResult.getBirthday());
break;
case 1:
String[] names = addressResult.getNames();

View file

@ -285,11 +285,11 @@ public abstract class ResultHandler {
}
final void addPhoneOnlyContact(String[] phoneNumbers,String[] phoneTypes) {
addContact(null, null, phoneNumbers, phoneTypes, null, null, null, null, null, null, null, null);
addContact(null, null, phoneNumbers, phoneTypes, null, null, null, null, null, null, null, null, null, null);
}
final void addEmailOnlyContact(String[] emails, String[] emailTypes) {
addContact(null, null, null, null, emails, emailTypes, null, null, null, null, null, null);
addContact(null, null, null, null, emails, emailTypes, null, null, null, null, null, null, null, null);
}
final void addContact(String[] names,
@ -303,7 +303,9 @@ public abstract class ResultHandler {
String address,
String addressType,
String org,
String title) {
String title,
String url,
String birthday) {
// Only use the first name in the array, if present.
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, ContactsContract.Contacts.CONTENT_URI);
@ -334,7 +336,20 @@ public abstract class ResultHandler {
}
}
putExtra(intent, ContactsContract.Intents.Insert.NOTES, note);
// No field for URL, birthday; use notes
StringBuilder aggregatedNotes = new StringBuilder();
for (String aNote : new String[] { url, birthday, note }) {
if (aNote != null) {
if (aggregatedNotes.length() > 0) {
aggregatedNotes.append('\n');
}
aggregatedNotes.append(aNote);
}
}
if (aggregatedNotes.length() > 0) {
putExtra(intent, ContactsContract.Intents.Insert.NOTES, aggregatedNotes.toString());
}
putExtra(intent, ContactsContract.Intents.Insert.IM_HANDLE, instantMessenger);
putExtra(intent, ContactsContract.Intents.Insert.POSTAL, address);
if (addressType != null) {