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

  • Committer: edam
  • Date: 2011-06-11 11:34:38 UTC
  • Revision ID: edam@waxworlds.org-20110611113438-wu67n6akbyyln7kf
- fixed a couple of comment headers
- updated TODO
- fixed a bug where a "continue or abort" dialog always continued
- close cursors to prevent leaked resources
- fixed string that referred to Import Contacts app

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * Exporter.java
3
3
 *
4
 
 * Copyright (C) 2011 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.util.ArrayList;
27
27
 
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
 
 
60
53
                class OrganisationDetail
61
54
                {
62
55
                        protected String _org;
150
143
                protected ArrayList< NumberDetail > _numbers = null;
151
144
                protected ArrayList< EmailDetail > _emails = null;
152
145
                protected ArrayList< AddressDetail > _addresses = null;
153
 
                protected ArrayList< String > _notes = null;
154
146
 
155
147
                public void setName( String name )
156
148
                {
214
206
                        return _addresses;
215
207
                }
216
208
 
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
 
 
229
209
                public String getPrimaryIdentifier()
230
210
                {
231
211
                        if( _name != null )
285
265
        protected void exportContacts() throws AbortExportException
286
266
        {
287
267
                // set up a contact reader
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();
 
268
                ContactReader contact_reader = new ContactsContactReader( _doit, this );
 
269
                int num_contacts = contact_reader.getNumContacts();
296
270
                if( num_contacts == 0 )
297
271
                        showError( R.string.error_nothingtodo );
298
272
 
308
282
                while( true ) {
309
283
                        checkAbort();
310
284
                        ContactData contact = new ContactData();
311
 
                        if( !backend.getNextContact( contact ) )
 
285
                        if( !contact_reader.getNextContact( contact ) )
312
286
                                break;
313
287
 
314
288
                        // export this one
427
401
                checkAbort();
428
402
                _doit._handler.sendMessage( Message.obtain(
429
403
                        _doit._handler, Doit.MESSAGE_SETMAXPROGRESS,
430
 
                        Integer.valueOf( max_progress ) ) );
 
404
                        new Integer( max_progress ) ) );
431
405
        }
432
406
 
433
407
        protected void setTmpProgress( int tmp_progress )
436
410
                checkAbort();
437
411
                _doit._handler.sendMessage( Message.obtain(
438
412
                        _doit._handler, Doit.MESSAGE_SETTMPPROGRESS,
439
 
                        Integer.valueOf( tmp_progress ) ) );
 
413
                        new Integer( tmp_progress ) ) );
440
414
        }
441
415
 
442
416
        protected void setProgress( int progress ) throws AbortExportException
444
418
                checkAbort();
445
419
                _doit._handler.sendMessage( Message.obtain(
446
420
                        _doit._handler, Doit.MESSAGE_SETPROGRESS,
447
 
                        Integer.valueOf( progress ) ) );
 
421
                        new Integer( progress ) ) );
448
422
        }
449
423
 
450
424
        protected void finish( int action ) throws AbortExportException