/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 10:44:01 UTC
  • Revision ID: tim@ed.am-20121221104401-onydwv9k4e4heode
added thank you message to intro

Show diffs side-by-side

added added

removed removed

202
202
                                        buffer.limit() - buffer.position(), "US-ASCII" );
203
203
                        }
204
204
                        catch( UnsupportedEncodingException e ) {
205
 
                                // we know US-ASCII *is* supported, so appease the compiler...
 
205
                                // we know US-ASCII is supported, so appease the compiler...
206
206
                                line = "";
207
207
                        }
208
208
 
504
504
                        else
505
505
                        {
506
506
                                // name and params and the position in the buffer where the
507
 
                                // "value" part of the line starts
 
507
                                // "value" part of the line start
508
508
                                String name_and_params;
509
509
                                int pos;
510
510
 
540
540
                                }
541
541
                                else
542
542
                                {
543
 
                                        // skip empty lines
544
 
                                        if( line.trim().length() == 0 ) return;
545
 
 
546
543
                                        // get name and params from line, and since we're not
547
544
                                        // parsing a subsequent line in a multi-line, this should
548
545
                                        // not fail, or it's an error
577
574
                                                "FN", "ORG", "TITLE", "TEL", "EMAIL", "ADR", "LABEL" }
578
575
                                ) );
579
576
                                boolean is_interesting_field =
580
 
                                        interesting_fields.contains(
581
 
                                                name_param_parts[ 0 ].toUpperCase( Locale.US ) );
 
577
                                        interesting_fields.contains( name_param_parts[ 0 ] );
582
578
 
583
579
                                // parse encoding parameter
584
580
                                String encoding = checkParam( name_param_parts, "ENCODING" );
1063
1059
                        String type_params[] = checkParams( params, "TYPE" );
1064
1060
                        for( int a = 0; a < type_params.length; a++ )
1065
1061
                        {
1066
 
                                // check for a comma-separated list of types (why? I don't think
1067
 
                                // this is in the specs!)
 
1062
                                // check for a comma-separated list of types (why? this isn't in
 
1063
                                // the specs!)
1068
1064
                                String[] parts = type_params[ a ].split( "," );
1069
 
                                for( int i = 0; i < parts.length; i++ ) {
1070
 
                                        String ucpart = parts[ i ].toUpperCase( Locale.US );
1071
 
                                        if( valid_types.contains( ucpart ) )
1072
 
                                                types.add( ucpart );
1073
 
                                }
 
1065
                                for( int i = 0; i < parts.length; i++ )
 
1066
                                        parts[ i ] = parts[ i ].toUpperCase( Locale.US );
 
1067
                                for( int i = 0; i < parts.length; i++ )
 
1068
                                        if( valid_types.contains( parts[ i ] ) )
 
1069
                                                types.add( parts[ i ] );
1074
1070
                        }
1075
1071
 
1076
1072
                        // get 2.1-style type param
1077
1073
                        if( _version.equals( "2.1" ) ) {
1078
 
                                for( int i = 1; i < params.length; i++ ) {
1079
 
                                        String ucparam = params[ i ].toUpperCase( Locale.US );
1080
 
                                        if( valid_types.contains( ucparam ) )
1081
 
                                                types.add( ucparam );
1082
 
                                }
 
1074
                                for( int i = 1; i < params.length; i++ )
 
1075
                                        if( valid_types.contains( params[ i ] ) )
 
1076
                                                types.add( params[ i ] );
1083
1077
                        }
1084
1078
 
1085
1079
                        return types;