/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-06-22 17:29:31 UTC
  • Revision ID: tim@ed.am-20130622172931-ujydoni23t3a543b
minor style tweaks

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
7
 * to as "this program").  For more information, see
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
557
530
                        ContactsContract.Data.CONTENT_URI, values );
558
531
        }
559
532
 
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
533
}