/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-07-19 15:57:39 UTC
  • Revision ID: tim@ed.am-20130719155739-50w182nof760psos
Tags: 1.3.3
bump version no. to 1.3.3

Show diffs side-by-side

added added

removed removed

149
149
                                else if( line.matches( "(?i)END[ \t]*:[ \t]*VCARD.*" ) )
150
150
                                        in_vcard = false;
151
151
                        }
152
 
                        reader.close();
153
152
 
154
153
                }
155
154
                catch( FileNotFoundException e ) {
177
176
                        FileInputStream istream = new FileInputStream( file );
178
177
                        byte[] content = new byte[ (int)file.length() ];
179
178
                        istream.read( content );
180
 
                        istream.close();
 
179
                        istream = null;
181
180
 
182
181
                        // import
183
182
                        importVCardFileContent( content, file.getName() );
472
471
                private String extractCollonPartFromLine( ContentLine content_line,
473
472
                        boolean former )
474
473
                {
 
474
                        String ret = null;
 
475
 
475
476
                        // split line into name and value parts and check to make sure we
476
477
                        // only got 2 parts and that the first part is not zero in length
477
478
                        String[] parts = content_line.getUsAsciiLine().split( ":", 2 );
478
479
                        if( parts.length == 2 && parts[ 0 ].length() > 0 )
479
 
                                return parts[ former? 0 : 1 ].trim();
 
480
                                ret = parts[ former? 0 : 1 ];
480
481
 
481
 
                        return null;
 
482
                        return ret;
482
483
                }
483
484
 
484
485
                private String extractNameAndParamsFromLine( ContentLine content_line )
485
486
                {
486
 
                        return extractCollonPartFromLine( content_line, true );
 
487
                        return extractCollonPartFromLine( content_line, true ).trim();
487
488
                }
488
489
 
489
490
                private String extractValueFromLine( ContentLine content_line )
507
508
                                        name_and_params.equalsIgnoreCase( "VERSION" ) )
508
509
                                {
509
510
                                        // yes, get it!
510
 
                                        String value = extractValueFromLine( content_line );
511
 
                                        if( value == null || (
512
 
                                                !value.equals( "2.1" ) && !value.equals( "3.0" ) ) )
513
 
                                        {
 
511
                                        String value = extractValueFromLine( content_line ).trim();
 
512
                                        if( !value.equals( "2.1" ) && !value.equals( "3.0" ) )
514
513
                                                throw new ParseException( R.string.error_vcf_version );
515
 
                                        }
516
514
                                        _version = value;
517
515
 
518
516
                                        // parse any buffers we've been accumulating while we waited