/android/import-contacts

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

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/ContactsContractBackend.java

  • Committer: Tim Marston
  • Date: 2013-05-10 12:16:15 UTC
  • Revision ID: tim@ed.am-20130510121615-g8qhsu0h3t0ymrt6
Tags: 1.3.2
fix spacing in NEWS

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * ContactsBackend.java
3
3
 *
4
 
 * Copyright (C) 2012 to 2013 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2012 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import 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/import-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
281
281
                        }
282
282
                }
283
283
                cur.close();
284
 
 
285
 
                // get all birthdays
286
 
                cur = _activity.getContentResolver().query(
287
 
                        ContactsContract.Data.CONTENT_URI,
288
 
                        new String[] {
289
 
                                ContactsContract.Data.RAW_CONTACT_ID,
290
 
                                CommonDataKinds.Event.START_DATE,
291
 
                        },
292
 
                        ContactsContract.Data.MIMETYPE + " = '" +
293
 
                                CommonDataKinds.Event.CONTENT_ITEM_TYPE + "' AND " +
294
 
                                CommonDataKinds.Event.TYPE + " = '" +
295
 
                                CommonDataKinds.Event.TYPE_BIRTHDAY + "'",
296
 
                        null, null );
297
 
                while( cur.moveToNext() ) {
298
 
                        Long raw_id = cur.getLong( cur.getColumnIndex(
299
 
                                ContactsContract.Data.RAW_CONTACT_ID ) );
300
 
                        Long id = raw_to_aggregate_ids.get( raw_id );
301
 
                        if( id != null )
302
 
                        {
303
 
                                String birthday = cur.getString( cur.getColumnIndex(
304
 
                                        CommonDataKinds.Event.START_DATE ) );
305
 
 
306
 
                                // add associated data
307
 
                                cache.addAssociatedBirthday( id, birthday );
308
 
                        }
309
 
                }
310
 
                cur.close();
311
284
        }
312
285
 
313
286
        @Override
370
343
         * Obtain the raw contact id for the phone-only raw contact that is
371
344
         * associated with the aggregate contact id.  One will be created if
372
345
         * necessary.
373
 
         *
374
346
         * @param id the aggregate contact id
375
347
         * @return the raw contact id
376
348
         * @throws ContactCreationException
557
529
                        ContactsContract.Data.CONTENT_URI, values );
558
530
        }
559
531
 
560
 
        @Override
561
 
        public void addContactBirthday( Long id, String birthday )
562
 
                throws ContactCreationException
563
 
        {
564
 
                ContentValues values = new ContentValues();
565
 
                values.put( ContactsContract.Data.RAW_CONTACT_ID,
566
 
                        obtainRawContact( id ) );
567
 
                values.put( ContactsContract.Data.MIMETYPE,
568
 
                        CommonDataKinds.Event.CONTENT_ITEM_TYPE );
569
 
                values.put(
570
 
                        CommonDataKinds.Event.TYPE, CommonDataKinds.Event.TYPE_BIRTHDAY );
571
 
                values.put(
572
 
                        CommonDataKinds.Event.START_DATE, birthday );
573
 
                _activity.getContentResolver().insert(
574
 
                        ContactsContract.Data.CONTENT_URI, values );
575
 
        }
576
532
}