/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/org/waxworlds/edam/importcontacts/VCFImporter.java

  • Committer: edam
  • Date: 2010-07-04 14:44:48 UTC
  • Revision ID: edam@waxworlds.org-20100704144448-1m30v811opup20fs
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
- massively simplified the WizzardActivity class so it works propperly
- moved all code to org.waxworlds.edam
- added an "aborted" message when the importion is aborted
- simplified the 3 actions the worker thread can take when stopping (only 2 were actualy used) to "aborted" or "alldone"
- changed intro message to match website
- bugfix: don't blow up when the My Contacts group is missing

Show diffs side-by-side

added added

removed removed

67
67
                        // open directory
68
68
                        String location = prefs.getString( "location", "" );
69
69
                        File dir = new File( location );
70
 
                        if( !dir.exists() )
 
70
                        if( !dir.exists() || !dir.isDirectory() )
71
71
                                showError( R.string.error_locationnotfound );
72
72
 
73
 
                        // directory, or file?
74
 
                        if( dir.isDirectory() )
75
 
                        {
76
 
                                // get files
77
 
                                class VCardFilter implements FilenameFilter {
78
 
                                        public boolean accept( File dir, String name ) {
79
 
                                                return name.toLowerCase().endsWith( ".vcf" );
80
 
                                        }
 
73
                        // get files
 
74
                        class VCardFilter implements FilenameFilter {
 
75
                                public boolean accept( File dir, String name ) {
 
76
                                        return name.toLowerCase().endsWith( ".vcf" );
81
77
                                }
82
 
                                files = dir.listFiles( new VCardFilter() );
83
 
                        }
84
 
                        else
85
 
                        {
86
 
                                // use just this file
87
 
                                files = new File[ 1 ];
88
 
                                files[ 0 ] = dir;
89
 
                        }
 
78
                        }
 
79
                        files = dir.listFiles( new VCardFilter() );
90
80
                }
91
81
                catch( SecurityException e ) {
92
82
                        showError( R.string.error_locationpermissions );
461
451
                                        !charset.equals( "UTF-8" ) && !charset.equals( "UTF-16" ) )
462
452
                                throw new ParseException( R.string.error_vcf_charset );
463
453
                        if( ( encoding = checkParam( params, "ENCODING" ) ) != null &&
464
 
                                        !encoding.equals( "QUOTED-PRINTABLE" ) &&
465
 
                                        !encoding.equals( "8BIT" ) ) //&& !encoding.equals( "BASE64" ) )
 
454
                                        !encoding.equals( "QUOTED-PRINTABLE" ) )
466
455
                                throw new ParseException( R.string.error_vcf_encoding );
467
456
 
468
457
                        // do decoding?
469
458
                        if( encoding != null && encoding.equals( "QUOTED-PRINTABLE" ) )
470
459
                                return unencodeQuotedPrintable( value, charset );
471
 
//                      if( encoding != null && encoding.equals( "BASE64" ) )
472
 
//                              return unencodeBase64( value, charset );
473
460
 
474
461
                        // nothing to do!
475
462
                        return value;