/android/export-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/export-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/exportcontacts/VcardExporter.java

  • Committer: edam
  • Date: 2012-12-21 13:26:31 UTC
  • Revision ID: tim@ed.am-20121221132631-ofj30d60lvuxp4a3
added ContactsContract backend; removed references to Contacts types (conversion to/from backend types now done in backends); added support for exporting NOTEs

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import java.util.Iterator;
33
33
 
34
34
import android.content.SharedPreferences;
35
 
import android.provider.Contacts;
36
35
 
37
36
public class VcardExporter extends Exporter
38
37
{
217
216
                        for( int a = 0; a < numbers.size(); a++ ) {
218
217
                                ArrayList< String > types = new ArrayList< String >();
219
218
                                switch( numbers.get( a ).getType() ) {
220
 
                                case Contacts.Phones.TYPE_HOME:
 
219
                                case ContactData.TYPE_HOME:
221
220
                                        types.add( "VOICE" ); types.add( "HOME" ); break;
222
 
                                case Contacts.Phones.TYPE_WORK:
 
221
                                case ContactData.TYPE_WORK:
223
222
                                        types.add( "VOICE" ); types.add( "WORK" ); break;
224
 
                                case Contacts.Phones.TYPE_FAX_HOME:
 
223
                                case ContactData.TYPE_FAX_HOME:
225
224
                                        types.add( "FAX" ); types.add( "HOME" ); break;
226
 
                                case Contacts.Phones.TYPE_FAX_WORK:
 
225
                                case ContactData.TYPE_FAX_WORK:
227
226
                                        types.add( "FAX" ); types.add( "WORK" ); break;
228
 
                                case Contacts.Phones.TYPE_PAGER:
 
227
                                case ContactData.TYPE_PAGER:
229
228
                                        types.add( "PAGER" ); break;
230
 
                                case Contacts.Phones.TYPE_MOBILE:
 
229
                                case ContactData.TYPE_MOBILE:
231
230
                                        types.add( "VOICE" ); types.add( "CELL" ); break;
232
231
                                }
233
232
                                if( a == 0 ) types.add( "PREF" );
245
244
                                ArrayList< String > types = new ArrayList< String >();
246
245
                                types.add( "INTERNET" );
247
246
                                switch( emails.get( a ).getType() ) {
248
 
                                case Contacts.ContactMethods.TYPE_HOME:
 
247
                                case ContactData.TYPE_HOME:
249
248
                                        types.add( "HOME" ); break;
250
 
                                case Contacts.ContactMethods.TYPE_WORK:
 
249
                                case ContactData.TYPE_WORK:
251
250
                                        types.add( "WORK" ); break;
252
251
                                }
253
252
                                out.append( fold( "EMAIL" +
264
263
                                ArrayList< String > types = new ArrayList< String >();
265
264
                                types.add( "POSTAL" );
266
265
                                switch( addresses.get( a ).getType() ) {
267
 
                                case Contacts.ContactMethods.TYPE_HOME:
 
266
                                case ContactData.TYPE_HOME:
268
267
                                        types.add( "HOME" ); break;
269
 
                                case Contacts.ContactMethods.TYPE_WORK:
 
268
                                case ContactData.TYPE_WORK:
270
269
                                        types.add( "WORK" ); break;
271
270
                                }
272
271
                                out.append( fold( "LABEL" +
275
274
                        }
276
275
                }
277
276
 
 
277
                // append notes
 
278
                ArrayList< String > notes = contact.getNotes();
 
279
                if( notes != null )
 
280
                        for( int a = 0; a < notes.size(); a++ )
 
281
                                out.append( fold( "NOTE:" + escape( notes.get( a ) ) ) + "\n" );
 
282
 
278
283
                // append footer
279
284
                out.append( "END:VCARD\n" );
280
285