/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 15:14:46 UTC
  • Revision ID: edam@waxworlds.org-20100704151446-2yah1u00ml5m3wq9
- added facility to enter a filename (instead of a directory to scan) and just use that

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() || !dir.isDirectory() )
 
70
                        if( !dir.exists() )
71
71
                                showError( R.string.error_locationnotfound );
72
72
 
73
 
                        // get files
74
 
                        class VCardFilter implements FilenameFilter {
75
 
                                public boolean accept( File dir, String name ) {
76
 
                                        return name.toLowerCase().endsWith( ".vcf" );
 
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
                                        }
77
81
                                }
78
 
                        }
79
 
                        files = dir.listFiles( new VCardFilter() );
 
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
                        }
80
90
                }
81
91
                catch( SecurityException e ) {
82
92
                        showError( R.string.error_locationpermissions );