[TIMOB-9589] Android: Support modify contact
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-08-06T17:38:13.000+0000 |
| Affected Version/s | Release 2.0.0, Release 2.1.0 |
| Fix Version/s | Sprint 2012-16 API, Release 3.0.0 |
| Components | Android |
| Labels | api, module_media, parity, qe-testadded |
| Reporter | Vishal Duggal |
| Assignee | Hieu Pham |
| Created | 2012-06-15T21:52:06.000+0000 |
| Updated | 2013-12-10T06:08:37.000+0000 |
Description
Support for modify contact
Testing code:
1. Run this code 2. Look at contact and see if fields are populated correctlyvar photo = Ti.UI.createImageView({ image: 'KS_nav_views.png' }).toBlob(); var person = Ti.Contacts.createPerson({ firstName: 'Aaron', lastName: 'Smith', date: { anniversary: ['2002-11-11T11:23:30.000+0000'], other: ['2011-04-02T12:00:00.000+0000'] } }); person.organization = "google"; person.phone = { mobile: ['9999999991', '1234556677'], work: ['9999998888', '1234567789'] }; person.address = { work:[ { Street: '900 West Drive', City: 'New York', County: 'Berkshire', Country: 'U.S.A', ZIP: '99999' }, { Street: '456 New Ave.', City: 'San Jose', State: 'California', Country: 'U.S.A', ZIP: '94082' } ], home:[ { Street: '2 East Drive', City: 'Las Vegas', State: 'Nevada', Country: 'U.S.A', ZIP: '55555' } ]}; person.instantMessage = { home:[ { service: 'AIM', username: 'Dominator' }, { service: 'MSN', username: 'dominator@msn.com' } ], work:[ { service: 'Facebook', username: 'Dominator2' } ] }; person.url = { homepage: ['www.myspace.com'], work: ['www.apple.com', 'www.yahoo.com'] }; person.email = { home: ['hieu@google.com'], work: ['pham@google.com', 'hp007@appcelerator.com'] }; person.relatedNames = { parent: ['daddy', 'mommy'], assistant: ['mayhem'] }; person.date = { anniversary: ['2022-11-11T11:23:30.000+0000'], other: ['2003-04-02T12:00:00.000+0000'] }; person.firstName = "Ade"; person.lastName = "Crude"; person.birthday = "1999-01-01T12:00:00.000+0000"; person.organization = "GOOGLE"; person.note = "NOTE: MASS EFFECT"; person.nickname = "NICKNAME: THOR"; person.image = photo; Ti.Contacts.save([person]);[ERROR][V8Exception( 581)] Exception occurred at app.js:85: Uncaught TypeError: Object #
example is working with 2.2.0 b20120810194112! But when I try to read person.fullName I always get an empty string now!
strange behavior: inside my emulator I can download photos from facebook and save them to the person. Using the same program on my phone will save the wrong photo to a person Emulator: [INFO] Titanium SDK version: 3.0.0 (09/17/12 23:41 5486a27) Android 4.0.4 Phone: SGS2 Android 4.1.1 Download function
Saving:function downloadImage(_p,_id){ // p = ti.contact.person // id = facebook id var fbUserIcon = "http://graph.facebook.com/"+_id+"/picture?type=normal" var xhr = Titanium.Network.createHTTPClient(); xhr.open('GET', fbUserIcon, false); xhr.send(); xhr.onload = function() { if (xhr.readyState == 4) { _currentUser = _p; var f = Ti.Filesystem.getFile(_dir,_p.fullName +".jpg"); f.write(xhr.responseData); _photoURL = f; var photo = Ti.UI.createImageView({ image: f,width:100,height:100 }); _lbl.text = _p.fullName+"\n"+f.nativePath; _win_main.add(photo); } } }It displays the correct name and image on the screen but when I have a look at my contacts afterwards (on the phone) they are all mixed upvar photo = Ti.UI.createImageView({ image: _photoURL,width:100,height:100 }); _currentUser.image = photo.toBlob(); Ti.Contacts.save([_currentUser]);Closing issue. All fields are populated correctly. Tested and verified on: Titanium Studio, build: 3.0.0.201211121907 Titanium SDK, build: 3.0.0.v20121113111657 Device: Samsung Galaxy SIII (4.0.4)
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5021