/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: edam
  • Date: 2012-12-21 21:05:13 UTC
  • Revision ID: tim@ed.am-20121221210513-scyf50006hqadgjw
updated NEWS

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