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

  • Committer: edam
  • Date: 2011-06-11 08:22:04 UTC
  • Revision ID: edam@waxworlds.org-20110611082204-u2v1ri3a8iayq9b4
- added ContactReader interface
- added ContactsContactReader class to read old-style android.Contacts data
- updated FileChooser from import contacts app
- updated TODO
- added Doit activity
- added Exporter
- added VcardExporter that writes vCards

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * ContactsContactAccessor.java
 
2
 * ContactsContactReader.java
3
3
 *
4
 
 * Copyright (C) 2011 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2010 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 android.app.Activity;
27
27
import android.database.Cursor;
28
28
import android.provider.Contacts;
29
29
 
30
 
public class ContactsBackend implements ContactAccessor
 
30
public class ContactsContactReader implements ContactReader
31
31
{
32
32
        Activity _activity = null;
33
33
        Exporter _exporter = null;
34
34
        Cursor _cur = null;
35
35
 
36
 
        public ContactsBackend( Activity activity, Exporter exporter )
 
36
        public ContactsContactReader( Activity activity, Exporter exporter )
37
37
        {
38
38
                _activity = activity;
39
39
                _exporter = exporter;
65
65
                }
66
66
 
67
67
                // if there are no more contacts, abort
68
 
                if( _cur == null || !_cur.moveToNext() ) {
 
68
                if( !_cur.moveToNext() ) {
69
69
                        _cur = null;
70
70
                        return false;
71
71
                }
92
92
                                        Contacts.Organizations.COMPANY ) ),
93
93
                                cur.getString( cur.getColumnIndex(
94
94
                                        Contacts.Organizations.TITLE ) ) ) );
95
 
                cur.close();
96
95
 
97
96
                // get the phone numbers
98
97
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
109
108
                                        Contacts.Phones.TYPE ) ),
110
109
                                cur.getString( cur.getColumnIndex(
111
110
                                        Contacts.Phones.NUMBER ) ) ) );
112
 
                cur.close();
113
111
 
114
112
                // get the email and postal addresses
115
113
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
143
141
                                        cur.getString( cur.getColumnIndex(
144
142
                                                Contacts.ContactMethods.DATA ) ) ) );
145
143
                }
146
 
                cur.close();
147
144
 
148
145
                return true;
149
146
        }