/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: 2014-03-01 17:36:18 UTC
  • Revision ID: tim@ed.am-20140301173618-vt1k4g5y6cs77oe5
fixed some lint warnings

Show diffs side-by-side

added added

removed removed

90
90
                                // get files
91
91
                                class VCardFilter implements FilenameFilter {
92
92
                                        public boolean accept( File dir, String name ) {
93
 
                                                return name.toLowerCase( Locale.ENGLISH )
94
 
                                                        .endsWith( ".vcf" );
 
93
                                                return name.toLowerCase( Locale.US ).endsWith( ".vcf" );
95
94
                                        }
96
95
                                }
97
96
                                files = file.listFiles( new VCardFilter() );
236
235
                                                importContact( vcard );
237
236
                                        }
238
237
                                        catch( Vcard.ParseException e ) {
239
 
                                                showContinueOrAbort(
 
238
                                                if( !showContinue(
240
239
                                                        getText( R.string.error_vcf_parse ).toString()
241
240
                                                        + fileName +
242
241
                                                        getText( R.string.error_vcf_parse_line ).toString()
243
 
                                                        + cli.getLineNumber() + ":\n" + e.getMessage() );
244
 
                                                skipContact();
 
242
                                                        + cli.getLineNumber() + ":\n" + e.getMessage() ) )
 
243
                                                {
 
244
                                                        finish( ACTION_ABORT );
 
245
                                                }
 
246
                                                else
 
247
                                                        skipContact();
245
248
                                        }
246
249
                                        catch( ContactData.ContactNotIdentifiableException e ) {
247
 
                                                showContinueOrAbort(
 
250
                                                if( !showContinue(
248
251
                                                        getText( R.string.error_vcf_parse ).toString()
249
252
                                                        + fileName +
250
253
                                                        getText( R.string.error_vcf_parse_line ).toString()
251
254
                                                        + vcard_start_line + ":\n" + getText(
252
 
                                                                R.string.error_vcf_notenoughinfo ).toString() );
253
 
                                                skipContact();
 
255
                                                                R.string.error_vcf_notenoughinfo ).toString()
 
256
                                                ) )
 
257
                                                {
 
258
                                                        finish( ACTION_ABORT );
 
259
                                                }
 
260
                                                else
 
261
                                                        skipContact();
254
262
                                        }
255
263
 
256
264
                                        // discard this vcard
264
272
                                        }
265
273
                                        catch( Vcard.ParseException e ) {
266
274
                                                skipContact();
267
 
                                                showContinueOrAbort(
 
275
                                                if( !showContinue(
268
276
                                                        getText( R.string.error_vcf_parse ).toString()
269
277
                                                        + fileName +
270
278
                                                        getText( R.string.error_vcf_parse_line ).toString()
271
 
                                                        + cli.getLineNumber() + "\n" + e.getMessage() );
 
279
                                                        + cli.getLineNumber() + "\n" + e.getMessage() ) )
 
280
                                                {
 
281
                                                        finish( ACTION_ABORT );
 
282
                                                }
272
283
 
273
284
                                                // Although we're continuing, we still need to abort
274
285
                                                // this vCard.  Further lines will be ignored until we
605
616
                                ) );
606
617
                                boolean is_interesting_field =
607
618
                                        interesting_fields.contains(
608
 
                                                name_param_parts[ 0 ].toUpperCase( Locale.ENGLISH ) );
 
619
                                                name_param_parts[ 0 ].toUpperCase( Locale.US ) );
609
620
 
610
621
                                // parse encoding parameter
611
622
                                String encoding = checkParam( name_param_parts, "ENCODING" );
612
623
                                if( encoding != null )
613
 
                                        encoding = encoding.toUpperCase( Locale.ENGLISH );
 
624
                                        encoding = encoding.toUpperCase( Locale.US );
614
625
                                if( is_interesting_field && encoding != null &&
615
626
                                        !encoding.equalsIgnoreCase( "8BIT" ) &&
616
627
                                        !encoding.equalsIgnoreCase( "QUOTED-PRINTABLE" ) )
622
633
                                // parse charset parameter
623
634
                                String charset = checkParam( name_param_parts, "CHARSET" );
624
635
                                if( charset != null )
625
 
                                        charset = charset.toUpperCase( Locale.ENGLISH );
 
636
                                        charset = charset.toUpperCase( Locale.US );
626
637
                                if( charset != null &&
627
638
                                        !charset.equalsIgnoreCase( "US-ASCII" ) &&
628
639
                                        !charset.equalsIgnoreCase( "ASCII" ) &&
1104
1115
                                // this is in the specs!)
1105
1116
                                String[] parts = type_params[ a ].split( "," );
1106
1117
                                for( int i = 0; i < parts.length; i++ ) {
1107
 
                                        String ucpart = parts[ i ].toUpperCase( Locale.ENGLISH );
 
1118
                                        String ucpart = parts[ i ].toUpperCase( Locale.US );
1108
1119
                                        if( valid_types.contains( ucpart ) )
1109
1120
                                                types.add( ucpart );
1110
1121
                                }
1113
1124
                        // get 2.1-style type param
1114
1125
                        if( _version.equals( "2.1" ) ) {
1115
1126
                                for( int i = 1; i < params.length; i++ ) {
1116
 
                                        String ucparam = params[ i ].toUpperCase( Locale.ENGLISH );
 
1127
                                        String ucparam = params[ i ].toUpperCase( Locale.US );
1117
1128
                                        if( valid_types.contains( ucparam ) )
1118
1129
                                                types.add( ucparam );
1119
1130
                                }