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

  • Committer: Tim Marston
  • Date: 2013-05-10 12:13:03 UTC
  • Revision ID: tim@ed.am-20130510121303-nuc8xu8pmlrixrye
bump version no.

Show diffs side-by-side

added added

removed removed

133
133
                        boolean in_vcard = false;
134
134
                        while( ( line = reader.readLine() ) != null )
135
135
                        {
136
 
                                if( !in_vcard ) {
 
136
                                if( !in_vcard )
 
137
                                {
137
138
                                        // look for vcard beginning
138
 
                                        if( line.matches( "^BEGIN:VCARD" ) ) {
 
139
                                        if( line.matches( "(?i)BEGIN[ \t]*:[ \t]*VCARD.*" ) ) {
139
140
                                                in_vcard = true;
140
141
                                                _vcard_count++;
141
142
                                        }
 
143
                                        // check for vMsg files
 
144
                                        else if( line.matches( "(?i)BEGIN[ \t]*:[ \t]*VMSG.*" ) ) {
 
145
                                                showError( getText( R.string.error_vcf_vmsgfile )
 
146
                                                        + file.getName() );
 
147
                                        }
142
148
                                }
143
 
                                else if( line.matches( "^END:VCARD" ) )
 
149
                                else if( line.matches( "(?i)END[ \t]*:[ \t]*VCARD.*" ) )
144
150
                                        in_vcard = false;
145
151
                        }
146
152
 
203
209
 
204
210
                        if( vcard == null ) {
205
211
                                // look for vcard beginning
206
 
                                if( line.matches( "^BEGIN[ \t]*:[ \t]*VCARD" ) ) {
 
212
                                if( line.matches( "(?i)BEGIN[ \t]*:[ \t]*VCARD.*" ) ) {
207
213
                                        setProgress( _progress++ );
208
214
                                        vcard = new Vcard();
209
215
                                        vcard_start_line = cli.getLineNumber();
211
217
                        }
212
218
                        else {
213
219
                                // look for vcard content or ending
214
 
                                if( line.matches( "^END[ \t]*:[ \t]*VCARD" ) )
 
220
                                if( line.matches( "(?i)END[ \t]*:[ \t]*VCARD.*" ) )
215
221
                                {
216
222
                                        // finalise the vcard/contact
217
223
                                        try {
478
484
 
479
485
                private String extractNameAndParamsFromLine( ContentLine content_line )
480
486
                {
481
 
                        return extractCollonPartFromLine( content_line, true );
 
487
                        return extractCollonPartFromLine( content_line, true ).trim();
482
488
                }
483
489
 
484
490
                private String extractValueFromLine( ContentLine content_line )
502
508
                                        name_and_params.equalsIgnoreCase( "VERSION" ) )
503
509
                                {
504
510
                                        // yes, get it!
505
 
                                        String value = extractValueFromLine( content_line );
 
511
                                        String value = extractValueFromLine( content_line ).trim();
506
512
                                        if( !value.equals( "2.1" ) && !value.equals( "3.0" ) )
507
513
                                                throw new ParseException( R.string.error_vcf_version );
508
514
                                        _version = value;