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

  • Committer: edam
  • Date: 2012-12-20 16:49:39 UTC
  • Revision ID: tim@ed.am-20121220164939-j9mg98v0uofws7kw
added support for notes; rewrote backends so that all normalising of data is now done within the contacts cache; made the vCard unescape routine slightly more acceptant of non-standard escaped characters

Show diffs side-by-side

added added

removed removed

36
36
         */
37
37
        public static class CacheIdentifier
38
38
        {
39
 
                public enum Type { NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
 
39
                public enum Type {
 
40
                        NONE, NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
40
41
 
41
42
                private Type _type;
42
43
                private String _detail;
43
44
 
 
45
                protected CacheIdentifier()
 
46
                {
 
47
                        _type = Type.NONE;
 
48
                }
 
49
 
44
50
                /**
45
51
                 * Obtain a cache identifier.  This routine is designed to be as robust
46
52
                 * as possible (in terms of bad or null detail values), and to return
72
78
                 */
73
79
                public static CacheIdentifier factory( Importer.ContactData contact )
74
80
                {
75
 
                        CacheIdentifier identifier = null;
 
81
                        CacheIdentifier ret = null;
76
82
 
77
83
                        if( contact.hasName() )
78
 
                                identifier = factory( CacheIdentifier.Type.NAME,
 
84
                                ret = factory( CacheIdentifier.Type.NAME,
79
85
                                        contact.getName() );
80
 
                        if( identifier != null ) return identifier;
81
 
 
82
 
                        if( contact.hasPrimaryOrganisation() )
83
 
                                identifier = factory( CacheIdentifier.Type.ORGANISATION,
 
86
                        if( ret == null && contact.hasPrimaryOrganisation() )
 
87
                                ret = factory( CacheIdentifier.Type.ORGANISATION,
84
88
                                        contact.getPrimaryOrganisation() );
85
 
                        if( identifier != null ) return identifier;
86
 
 
87
 
                        if( contact.hasPrimaryNumber() )
88
 
                                identifier = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
 
89
                        if( ret == null && contact.hasPrimaryNumber() )
 
90
                                ret = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
89
91
                                        contact.getPrimaryNumber() );
90
 
                        if( identifier != null ) return identifier;
91
 
 
92
 
                        if( contact.hasPrimaryEmail() )
93
 
                                identifier = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
 
92
                        if( ret == null && contact.hasPrimaryEmail() )
 
93
                                ret = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
94
94
                                        contact.getPrimaryEmail() );
95
 
                        if( identifier != null ) return identifier;
96
95
 
97
 
                        return null;
 
96
                        return ret;
98
97
                }
99
98
 
100
99
                protected CacheIdentifier( Type type, String detail )