mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-04 00:02:03 +08:00
Merge remote branch 'macdonst-contactSpec/contactSpec'
This commit is contained in:
@@ -2,117 +2,86 @@
|
||||
var Contact = function(id, displayName, name, nickname, phoneNumbers, emails, addresses,
|
||||
ims, organizations, published, updated, birthday, anniversary, gender, note,
|
||||
preferredUsername, photos, tags, relationships, urls, accounts, utcOffset, connected) {
|
||||
this.id = id || '';
|
||||
this.displayName = displayName || '';
|
||||
this.id = id || null;
|
||||
this.displayName = displayName || null;
|
||||
this.name = name || null; // ContactName
|
||||
this.nickname = nickname || '';
|
||||
this.nickname = nickname || null;
|
||||
this.phoneNumbers = phoneNumbers || null; // ContactField[]
|
||||
this.emails = emails || null; // ContactField[]
|
||||
this.addresses = addresses || null; // ContactAddress[]
|
||||
this.ims = ims || null; // ContactField[]
|
||||
this.organizations = organizations || null; // ContactOrganization[]
|
||||
this.published = published || '';
|
||||
this.updated = updated || '';
|
||||
this.birthday = birthday || '';
|
||||
this.anniversary = anniversary || '';
|
||||
this.gender = gender || '';
|
||||
this.note = note || '';
|
||||
this.preferredUsername = preferredUsername || '';
|
||||
this.published = published || null;
|
||||
this.updated = updated || null;
|
||||
this.birthday = birthday || null;
|
||||
this.anniversary = anniversary || null;
|
||||
this.gender = gender || null;
|
||||
this.note = note || null;
|
||||
this.preferredUsername = preferredUsername || null;
|
||||
this.photos = photos || null; // ContactField[]
|
||||
this.tags = tags || null; // ContactField[]
|
||||
this.relationships = relationships || null; // ContactField[]
|
||||
this.urls = urls || null; // ContactField[]
|
||||
this.accounts = accounts || null; // ContactAccount[]
|
||||
this.utcOffset = utcOffset || '';
|
||||
this.connected = connected || '';
|
||||
this.utcOffset = utcOffset || null;
|
||||
this.connected = connected || null;
|
||||
};
|
||||
|
||||
var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
|
||||
this.formatted = formatted || '';
|
||||
this.familyName = familyName || '';
|
||||
this.givenName = givenName || '';
|
||||
this.middleName = middle || '';
|
||||
this.honorificPrefix = prefix || '';
|
||||
this.honorificSuffix = suffix || '';
|
||||
this.formatted = formatted || null;
|
||||
this.familyName = familyName || null;
|
||||
this.givenName = givenName || null;
|
||||
this.middleName = middle || null;
|
||||
this.honorificPrefix = prefix || null;
|
||||
this.honorificSuffix = suffix || null;
|
||||
};
|
||||
|
||||
var ContactField = function(type, value, primary) {
|
||||
this.type = type || '';
|
||||
this.value = value || '';
|
||||
this.primary = primary || '';
|
||||
this.type = type || null;
|
||||
this.value = value || null;
|
||||
this.primary = primary || null;
|
||||
};
|
||||
|
||||
var ContactAddress = function(formatted, streetAddress, locality, region, postalCode, country) {
|
||||
this.formatted = formatted || '';
|
||||
this.streetAddress = streetAddress || '';
|
||||
this.locality = locality || '';
|
||||
this.region = region || '';
|
||||
this.postalCode = postalCode || '';
|
||||
this.country = country || '';
|
||||
this.formatted = formatted || null;
|
||||
this.streetAddress = streetAddress || null;
|
||||
this.locality = locality || null;
|
||||
this.region = region || null;
|
||||
this.postalCode = postalCode || null;
|
||||
this.country = country || null;
|
||||
};
|
||||
|
||||
var ContactOrganization = function(name, dept, title, startDate, endDate, location, desc) {
|
||||
this.name = name || '';
|
||||
this.department = dept || '';
|
||||
this.title = title || '';
|
||||
this.startDate = startDate || '';
|
||||
this.endDate = endDate || '';
|
||||
this.location = location || '';
|
||||
this.description = desc || '';
|
||||
this.name = name || null;
|
||||
this.department = dept || null;
|
||||
this.title = title || null;
|
||||
this.startDate = startDate || null;
|
||||
this.endDate = endDate || null;
|
||||
this.location = location || null;
|
||||
this.description = desc || null;
|
||||
};
|
||||
|
||||
var ContactAccount = function(domain, username, userid) {
|
||||
this.domain = domain || '';
|
||||
this.username = username || '';
|
||||
this.userid = userid || '';
|
||||
this.domain = domain || null;
|
||||
this.username = username || null;
|
||||
this.userid = userid || null;
|
||||
}
|
||||
|
||||
var Contacts = function() {
|
||||
this.inProgress = false;
|
||||
this.records = [];
|
||||
this.records = new Array();
|
||||
}
|
||||
|
||||
Contacts.prototype.find = function(obj, win, fail) {
|
||||
// Contacts.prototype.find = function(obj, win, fail) {
|
||||
Contacts.prototype.find = function(fields, win, fail, options) {
|
||||
this.win = win;
|
||||
this.fail = fail;
|
||||
if(obj.name != null) {
|
||||
// Build up the search term that we'll use in SQL, based on the structure/contents of the contact object passed into find.
|
||||
var searchTerm = '';
|
||||
if (obj.name.givenName && obj.name.givenName.length > 0) {
|
||||
searchTerm = obj.name.givenName.split(' ').join('%');
|
||||
}
|
||||
if (obj.name.familyName && obj.name.familyName.length > 0) {
|
||||
searchTerm += obj.name.familyName.split(' ').join('%');
|
||||
}
|
||||
if (!obj.name.familyName && !obj.name.givenName && obj.name.formatted) {
|
||||
searchTerm = obj.name.formatted;
|
||||
}
|
||||
PhoneGap.execAsync(null, null, "Contacts", "search", [searchTerm, "", ""]);
|
||||
}
|
||||
|
||||
PhoneGap.execAsync(null, null, "Contacts", "search", [fields, options]);
|
||||
};
|
||||
|
||||
Contacts.prototype.droidFoundContact = function(name, npa, email) {
|
||||
this.records = new Array();
|
||||
var contact = new Contact();
|
||||
contact.name = new ContactName();
|
||||
contact.name.formatted = name;
|
||||
contact.name.givenName = name;
|
||||
contact.emails = new Array();
|
||||
var mail = new ContactField();
|
||||
mail.type = "home";
|
||||
mail.value = email;
|
||||
mail.primary = true;
|
||||
contact.emails.push(mail);
|
||||
contact.phones = new Array();
|
||||
phone = new ContactField();
|
||||
phone.type = "home";
|
||||
phone.value = npa;
|
||||
contact.phones.push(phone);
|
||||
this.records.push(contact);
|
||||
};
|
||||
|
||||
Contacts.prototype.droidDone = function() {
|
||||
this.win(this.records);
|
||||
Contacts.prototype.droidDone = function(contacts) {
|
||||
this.win(eval('(' + contacts + ')'));
|
||||
};
|
||||
|
||||
Contacts.prototype.remove = function(contact) {
|
||||
@@ -135,11 +104,12 @@ Contacts.prototype.m_foundContacts = function(win, contacts) {
|
||||
var ContactFindOptions = function(filter, multiple, limit, updatedSince) {
|
||||
this.filter = filter || '';
|
||||
this.multiple = multiple || true;
|
||||
this.limit = limit || 0;
|
||||
this.limit = limit || Number.MAX_VALUE;
|
||||
this.updatedSince = updatedSince || '';
|
||||
};
|
||||
|
||||
var ContactError = function() {
|
||||
this.code=null;
|
||||
};
|
||||
|
||||
ContactError.INVALID_ARGUMENT_ERROR = 0;
|
||||
@@ -152,6 +122,6 @@ ContactError.TIMEOUT_ERROR = 6;
|
||||
ContactError.UNKNOWN_ERROR = 7;
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
if(typeof navigator.service == "undefined") navigator.service = new Object();
|
||||
if(typeof navigator.service == "undefined") navigator.service = new Object();
|
||||
if(typeof navigator.service.contacts == "undefined") navigator.service.contacts = new Contacts();
|
||||
});
|
||||
|
||||
@@ -290,6 +290,28 @@ PhoneGap.stringify = function(args) {
|
||||
if ((type == "number") || (type == "boolean")) {
|
||||
s = s + args[i];
|
||||
}
|
||||
else if (args[i] instanceof Array) {
|
||||
s = s + "[" + args[i] + "]";
|
||||
}
|
||||
else if (args[i] instanceof Object) {
|
||||
var start = true;
|
||||
s = s + '{';
|
||||
for (var name in args[i]) {
|
||||
if (!start) {
|
||||
s = s + ',';
|
||||
}
|
||||
s = s + '"' + name + '":';
|
||||
var nameType = typeof args[i][name];
|
||||
if ((nameType == "number") || (nameType == "boolean")) {
|
||||
s = s + args[i][name];
|
||||
}
|
||||
else {
|
||||
s = s + '"' + args[i][name] + '"';
|
||||
}
|
||||
start=false;
|
||||
}
|
||||
s = s + '}';
|
||||
}
|
||||
else {
|
||||
s = s + '"' + args[i] + '"';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user