/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-02 10:59:21 UTC
  • Revision ID: tim@ed.am-20140302105921-0q7ytfva236xsv8s
removed some unused code, fixed locale warnings and made showContinueOrAbort()
abort implicitly (rather than return false)

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