{ "id": "60808", "key": "TIMOB-176", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11216", "name": "Release 0.8.0", "archived": true, "released": true, "releaseDate": "2009-11-20" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:52:14.000+0000", "created": "2011-04-15T02:24:48.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "feature", "ios", "iphone" ], "versions": [], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:52:14.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Description

\n

The purpose of this API is to display a contacts dialog and\nallow a user to select a contact

\n

Examples

\n
\n\n//\n// show contact picker\n//\n\n//\n//  if array of details is specified, the detail view will be shown\n//  when the contact is selected.  this will also trigger e.key, and e.index in the success callback\n//\nTitanium.Contacts.showContactPicker({\n\n   success:function(event)\n   {\n        // e.contact\n        // e.key\n        // e.index\n\n   },\n   cancel:function()\n   {\n    // user canceled\n   },\n   details:[array of constants]\n);\n\n//\n// Supported Contact property names \n//\nfirstName\nlastName\nmiddleName\nprefix\nsuffix\nnickname\nfirstNamePhonetic\nlastNamePhonetic\nmiddleNamePhonetic\norganization\njobTitle\ndepartment\nbirthday\nnote\ncreationDate\nmodificationDate\nimageData\nphoneNumber\naddress\nemail\n\n//\n//  get all contacts\n//\nvar contacts = Titanium.Contacts.getAllContacts()\nvar c = contacts[0];\nvar birthday = c.birthday\n\n// remove contact\nTitanium.Contacts.removeContact(c);\n\n// modify contact\nc.firstName = 'Fred';\nTitanium.Contacts.saveContact(c);\n\n\n//\n// create new contact\n//\nvar c = Titanium.Contacts.createContact({\n    firstName:'Fred',\n    lastName:'Smith'\n\n})\n\nTitanium.Contacts.addContact(c);\n\n//\n// create new contact using multi-value fields like email, phone and address\n//\nvar c = Titanium.Contacts.createContact({\n    email:[{label:'home', value:'foo@foo.com'}],\n    phone:[{label:'home', value:'3032223333'}],\n    address:[{label:'home', value:[{city:'Foo', state:'GA', zip:'40344', street1:'value', street2:'value'}]\n})\n
{html}", "attachment": [], "flagged": false, "summary": "API - Contacts Dialog", "creator": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "122890", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

We'll probably want to add functionality later on for being able\nto pick not only a person, but other UI features:

\n

Pick a person and a property (IE, phone number out of several),\ncomplete with a filter of what to show.
\n(See \nhttp://developer.apple.com/IPhone/library/documentation/AddressBook...:\n)

\n

View a person that's been chosen from the database, filter of\nwhat to show, allow editing of it, etc. The callback should return\na boolean on whether to act on user input. (IE, if the user touched\nthe phone number, to launch the phone)
\n(See \nhttp://developer.apple.com/IPhone/library/documentation/AddressBook...\n)

\n

Present an 'add a person' dialog, with prepopulated properties,\nand let them add it to the address book.
\n(See \nhttp://developer.apple.com/IPhone/library/documentation/AddressBook...\n)

\n

Present an 'unknown person' (IE, could be new person, could be\nold person and the data needs merging) which has the new person\ndynamicness as well as the ability to launch actions like view a\nperson.
\n(See \nhttp://developer.apple.com/IPhone/library/documentation/AddressBook...\n)

{html}", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:48.000+0000", "updated": "2011-04-15T02:24:48.000+0000" }, { "id": "122891", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Notes to self:

\n

More flies in the ointment. While the properties are integers on\nthe native side, accessing images are done with a completely\ndifferent function. Fetching this all for getAllContacts is\nprohibitive. The image blobs alone would take too much memory all\nat one time.

\n

Not only that, but it's unlikely that Android will have the same\nvalues. So perhaps we should use string values and do the mapping\nnative-side.

\n

So the data sent to the callback must be an array of\nlazy-loading objects with the following properties:

\n

_REFID:,

\n

_CACHE:{dict of fetched values},

\n

_DELTA:{dict of js-set values},

\n

getFoo:function(){

\n

if(this.DELTA.foo)return this.DELTA.foo;

\n

if(this.CACHE.foo===undefined)this.CACHE.foo =\nTi.TIDO('contacts','getContactProperty',[this.REFID,'foo']);

\n

return this._CACHE.foo;

\n

},

\n

setFoo:function(newFoo){this._DELTA.foo=newFoo;}

\n

appropriate setters and getters for every foo. I'm thinking\nmaking an object class for this. The win here also is that there\nneed not be any native-side caching contacts, and when saving a\ncontact, only the delta need be sent back.

\n

Actually, this pattern may be very useful in other objects.

{html}", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:48.000+0000", "updated": "2011-04-15T02:24:48.000+0000" }, { "id": "122892", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

this is mostly implemented and tested for iphone.

\n

however, it crashes when you pass @ symbol to email\nproperty when creating a contact.

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:48.000+0000", "updated": "2011-04-15T02:24:48.000+0000" }, { "id": "122893", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Ready for testing.

{html}", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:49.000+0000", "updated": "2011-04-15T02:24:49.000+0000" }, { "id": "122894", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

add read only properties w/ getters.

\n

displayLabel (map to display value in \"pick list\" style, e.g.\nCompany if no person name)
\ndisplayName (constructed from Person Name Attributes Prefix, First,\nMiddle, Last Suffix)
\ndisplayAddress (Address String a concatenation of the pieces)
\ndisplayPhoneticName (same as displayName using phonetic values,\ndoes not include prefix and suffix)

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:49.000+0000", "updated": "2011-04-15T02:24:49.000+0000" }, { "id": "122895", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Ready for testing.

{html}", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:24:49.000+0000", "updated": "2011-04-15T02:24:49.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }