/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/org/waxworlds/edam/exportcontacts/VcardExporter.java

  • Committer: edam
  • Date: 2012-04-24 11:17:41 UTC
  • Revision ID: tim@ed.am-20120424111741-gbzn6qr4i574d9s4
renamed contact readers to accessors

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * Exporter.java
3
3
 *
4
 
 * Copyright (C) 2011 to 2012 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2011 Tim Marston <edam@waxworlds.org>
5
5
 *
6
6
 * This file is part of the Export Contacts program (hereafter referred
7
7
 * to as "this program"). For more information, see
8
 
 * http://ed.am/dev/android/export-contacts
 
8
 * http://www.waxworlds.org/edam/software/android/export-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
11
11
 * it under the terms of the GNU General Public License as published by
21
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
22
 */
23
23
 
24
 
package am.ed.exportcontacts;
 
24
package org.waxworlds.edam.exportcontacts;
25
25
 
26
26
import java.io.File;
27
27
import java.io.FileNotFoundException;
32
32
import java.util.Iterator;
33
33
 
34
34
import android.content.SharedPreferences;
 
35
import android.provider.Contacts;
35
36
 
36
37
public class VcardExporter extends Exporter
37
38
{
216
217
                        for( int a = 0; a < numbers.size(); a++ ) {
217
218
                                ArrayList< String > types = new ArrayList< String >();
218
219
                                switch( numbers.get( a ).getType() ) {
219
 
                                case ContactData.TYPE_HOME:
 
220
                                case Contacts.Phones.TYPE_HOME:
220
221
                                        types.add( "VOICE" ); types.add( "HOME" ); break;
221
 
                                case ContactData.TYPE_WORK:
 
222
                                case Contacts.Phones.TYPE_WORK:
222
223
                                        types.add( "VOICE" ); types.add( "WORK" ); break;
223
 
                                case ContactData.TYPE_FAX_HOME:
 
224
                                case Contacts.Phones.TYPE_FAX_HOME:
224
225
                                        types.add( "FAX" ); types.add( "HOME" ); break;
225
 
                                case ContactData.TYPE_FAX_WORK:
 
226
                                case Contacts.Phones.TYPE_FAX_WORK:
226
227
                                        types.add( "FAX" ); types.add( "WORK" ); break;
227
 
                                case ContactData.TYPE_PAGER:
 
228
                                case Contacts.Phones.TYPE_PAGER:
228
229
                                        types.add( "PAGER" ); break;
229
 
                                case ContactData.TYPE_MOBILE:
 
230
                                case Contacts.Phones.TYPE_MOBILE:
230
231
                                        types.add( "VOICE" ); types.add( "CELL" ); break;
231
232
                                }
232
233
                                if( a == 0 ) types.add( "PREF" );
244
245
                                ArrayList< String > types = new ArrayList< String >();
245
246
                                types.add( "INTERNET" );
246
247
                                switch( emails.get( a ).getType() ) {
247
 
                                case ContactData.TYPE_HOME:
 
248
                                case Contacts.ContactMethods.TYPE_HOME:
248
249
                                        types.add( "HOME" ); break;
249
 
                                case ContactData.TYPE_WORK:
 
250
                                case Contacts.ContactMethods.TYPE_WORK:
250
251
                                        types.add( "WORK" ); break;
251
252
                                }
252
253
                                out.append( fold( "EMAIL" +
263
264
                                ArrayList< String > types = new ArrayList< String >();
264
265
                                types.add( "POSTAL" );
265
266
                                switch( addresses.get( a ).getType() ) {
266
 
                                case ContactData.TYPE_HOME:
 
267
                                case Contacts.ContactMethods.TYPE_HOME:
267
268
                                        types.add( "HOME" ); break;
268
 
                                case ContactData.TYPE_WORK:
 
269
                                case Contacts.ContactMethods.TYPE_WORK:
269
270
                                        types.add( "WORK" ); break;
270
271
                                }
271
272
                                out.append( fold( "LABEL" +
274
275
                        }
275
276
                }
276
277
 
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
 
 
283
278
                // append footer
284
279
                out.append( "END:VCARD\n" );
285
280