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

  • Committer: Tim Marston
  • Date: 2013-07-19 15:55:07 UTC
  • Revision ID: tim@ed.am-20130719155507-qb78vx8m4s1ngyut
added suopport for birthdays

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * Importer.java
3
3
 *
4
 
 * Copyright (C) 2009 to 2012 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2009 to 2013 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
142
142
                protected HashMap< String, PreferredDetail > _emails = null;
143
143
                protected HashMap< String, TypeDetail > _addresses = null;
144
144
                protected HashSet< String > _notes = null;
 
145
                protected String _birthday = null;
145
146
 
146
147
                private ContactsCache.CacheIdentifier _cache_identifier = null;
147
148
 
362
363
                        return _notes;
363
364
                }
364
365
 
 
366
                public void setBirthday( String birthday )
 
367
                {
 
368
                        _birthday = birthday;
 
369
                }
 
370
 
 
371
                public boolean hasBirthday()
 
372
                {
 
373
                        return _birthday != null;
 
374
                }
 
375
 
 
376
                public String getBirthday()
 
377
                {
 
378
                        return _birthday;
 
379
                }
 
380
 
365
381
                protected void finalise()
366
382
                        throws ContactNotIdentifiableException
367
383
                {
762
778
                                importContactOrganisations( id, contact.getOrganisations() );
763
779
                        if( contact.hasNotes() )
764
780
                                importContactNotes( id, contact.getNotes() );
 
781
                        if( contact.hasBirthday() )
 
782
                                importContactBirthday( id, contact.getBirthday() );
765
783
                }
766
784
                catch( Backend.ContactCreationException e )
767
785
                {
874
892
                }
875
893
        }
876
894
 
877
 
        private void importContactNotes( Long id,
878
 
                HashSet< String > datas )
 
895
        private void importContactNotes( Long id, HashSet< String > datas )
879
896
                throws ContactCreationException
880
897
        {
881
898
                // add notes
895
912
                        // date from another file
896
913
                        _contacts_cache.addAssociatedNote( id, note );
897
914
                }
898
 
 
 
915
        }
 
916
 
 
917
        private void importContactBirthday( Long id, String birthday )
 
918
                throws ContactCreationException
 
919
        {
 
920
                // we don't want to import this birthday if it already exists
 
921
                if( _contacts_cache.hasAssociatedBirthday( id, birthday ) )
 
922
                        return;
 
923
 
 
924
                // add birthday
 
925
                _backend.addContactBirthday( id, birthday );
 
926
 
 
927
                // and update the cache
 
928
                _contacts_cache.addAssociatedBirthday( id, birthday );
899
929
        }
900
930
 
901
931
        synchronized protected void checkAbort() throws AbortImportException