/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/Exporter.java

  • Committer: Tim Marston
  • Date: 2013-06-22 19:31:44 UTC
  • Revision ID: tim@ed.am-20130622193144-0lo7w92qagow0kmu
minor style tweaks

Show diffs side-by-side

added added

removed removed

4
4
 * Copyright (C) 2011 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Export Contacts program (hereafter referred
7
 
 * to as "this program"). For more information, see
 
7
 * to as "this program").  For more information, see
8
8
 * http://ed.am/dev/android/export-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
50
50
         */
51
51
        public class ContactData
52
52
        {
 
53
                public final static int TYPE_HOME = 0;
 
54
                public final static int TYPE_WORK = 1;
 
55
                public final static int TYPE_MOBILE = 2;        // only used with phones
 
56
                public final static int TYPE_FAX_HOME = 3;      // only used with phones
 
57
                public final static int TYPE_FAX_WORK = 4;      // only used with phones
 
58
                public final static int TYPE_PAGER = 5;         // only used with phones
 
59
 
53
60
                class OrganisationDetail
54
61
                {
55
62
                        protected String _org;
143
150
                protected ArrayList< NumberDetail > _numbers = null;
144
151
                protected ArrayList< EmailDetail > _emails = null;
145
152
                protected ArrayList< AddressDetail > _addresses = null;
 
153
                protected ArrayList< String > _notes = null;
146
154
 
147
155
                public void setName( String name )
148
156
                {
206
214
                        return _addresses;
207
215
                }
208
216
 
 
217
                public void addNote( String note )
 
218
                {
 
219
                        if( _notes == null )
 
220
                                _notes = new ArrayList< String >();
 
221
                        _notes.add( note );
 
222
                }
 
223
 
 
224
                public ArrayList< String > getNotes()
 
225
                {
 
226
                        return _notes;
 
227
                }
 
228
 
209
229
                public String getPrimaryIdentifier()
210
230
                {
211
231
                        if( _name != null )
265
285
        protected void exportContacts() throws AbortExportException
266
286
        {
267
287
                // set up a contact reader
268
 
                ContactAccessor contact_reader =
269
 
                        new ContactsContactAccessor( _doit, this );
270
 
                int num_contacts = contact_reader.getNumContacts();
 
288
                Backend backend = null;
 
289
                if( Integer.parseInt( android.os.Build.VERSION.SDK ) >= 5 )
 
290
                        backend = new ContactsContractBackend( _doit, this );
 
291
                else
 
292
                        backend = new ContactsBackend( _doit, this );
 
293
 
 
294
                // check we have contacts
 
295
                int num_contacts = backend.getNumContacts();
271
296
                if( num_contacts == 0 )
272
297
                        showError( R.string.error_nothingtodo );
273
298
 
283
308
                while( true ) {
284
309
                        checkAbort();
285
310
                        ContactData contact = new ContactData();
286
 
                        if( !contact_reader.getNextContact( contact ) )
 
311
                        if( !backend.getNextContact( contact ) )
287
312
                                break;
288
313
 
289
314
                        // export this one
402
427
                checkAbort();
403
428
                _doit._handler.sendMessage( Message.obtain(
404
429
                        _doit._handler, Doit.MESSAGE_SETMAXPROGRESS,
405
 
                        new Integer( max_progress ) ) );
 
430
                        Integer.valueOf( max_progress ) ) );
406
431
        }
407
432
 
408
433
        protected void setTmpProgress( int tmp_progress )
411
436
                checkAbort();
412
437
                _doit._handler.sendMessage( Message.obtain(
413
438
                        _doit._handler, Doit.MESSAGE_SETTMPPROGRESS,
414
 
                        new Integer( tmp_progress ) ) );
 
439
                        Integer.valueOf( tmp_progress ) ) );
415
440
        }
416
441
 
417
442
        protected void setProgress( int progress ) throws AbortExportException
419
444
                checkAbort();
420
445
                _doit._handler.sendMessage( Message.obtain(
421
446
                        _doit._handler, Doit.MESSAGE_SETPROGRESS,
422
 
                        new Integer( progress ) ) );
 
447
                        Integer.valueOf( progress ) ) );
423
448
        }
424
449
 
425
450
        protected void finish( int action ) throws AbortExportException