/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/FileChooser.java

  • Committer: edam
  • Date: 2011-05-02 18:28:24 UTC
  • Revision ID: edam@waxworlds.org-20110502182824-acgdi3qfxfzqgely
- fixed logic for vcard field types (home, work, cell, etc) so it works
- updated NEWS and TODO
- rewrote most of ContactsCache, including a new ContactIdentifier class to identify contacts in the cache and new cache building code
- contacts now identified in the same way that Andoid displays them (by name, or organisation, or number, or email, in that order)
- propper handling and support for organisations and titles
- validation of imported contact now done by Importer, not VcfImporter
- separated sanitisation and normalisation (for cache lookups)
- generacised PhoneData, EmailData and AddressData classes
- ContactData is now aware of primary numbers, emails and organisations (defaults to the first prefrred one seen, or the first one seen where none is preferred)

Show diffs side-by-side

added added

removed removed

25
25
 
26
26
import java.io.File;
27
27
import java.io.FileFilter;
 
28
import java.io.IOException;
28
29
import java.util.ArrayList;
29
30
import java.util.Collections;
30
31
import java.util.Comparator;
33
34
import android.app.Dialog;
34
35
import android.content.Context;
35
36
import android.content.DialogInterface;
 
37
import android.os.Environment;
36
38
import android.view.LayoutInflater;
37
39
import android.view.View;
38
40
import android.view.View.OnClickListener;
322
324
 
323
325
        public static int pathIcon( String path )
324
326
        {
325
 
                if( path.equals( "/sdcard/" ) )
 
327
                // get sdcard path
 
328
                String sdcard_path;
 
329
                try {
 
330
                        sdcard_path = Environment.getExternalStorageDirectory()
 
331
                                .getCanonicalPath();
 
332
                        if( sdcard_path.charAt( sdcard_path.length() - 1 ) != '/' )
 
333
                                sdcard_path += "/";
 
334
                }
 
335
                catch( IOException e ) {
 
336
                        sdcard_path = null;
 
337
                }
 
338
 
 
339
                // special paths
 
340
                if( sdcard_path != null && path.equals( sdcard_path ) )
326
341
                        return R.drawable.sdcard;
327
342
 
 
343
                // default
328
344
                return R.drawable.directory;
329
345
        }
330
346
 
332
348
        {
333
349
                String path = full_path;
334
350
 
 
351
                // get sdcard path
 
352
                String sdcard_path;
 
353
                try {
 
354
                        sdcard_path = Environment.getExternalStorageDirectory()
 
355
                                .getCanonicalPath();
 
356
                        if( sdcard_path.charAt( sdcard_path.length() - 1 ) != '/' )
 
357
                                sdcard_path += "/";
 
358
                }
 
359
                catch( IOException e ) {
 
360
                        sdcard_path = null;
 
361
                }
 
362
 
335
363
                // special names
336
 
                if( path.equals( "/sdcard/" ) )
 
364
                if( sdcard_path != null && path.equals( sdcard_path ) )
337
365
                        return " " + _context.getString( R.string.filechooser_path_sdcard );
338
366
 
339
367
                // remove prefix, if present
384
412
                        }
385
413
                }
386
414
                File[] files = dir.listFiles( new DirFilter() );
387
 
                for( int i = 0; i < files.length; i++ )
388
 
                        _items.add( new RowItem( files[ i ].getName(), true ) );
 
415
                if( files != null )
 
416
                        for( int i = 0; i < files.length; i++ )
 
417
                                _items.add( new RowItem( files[ i ].getName(), true ) );
389
418
 
390
419
                // get files
391
420
                if( _mode == MODE_FILE )
402
431
                                }
403
432
                        }
404
433
                        files = dir.listFiles( new VCardFilter() );
405
 
                        for( int i = 0; i < files.length; i++ )
406
 
                                _items.add( new RowItem( files[ i ].getName(), false ) );
 
434
                        if( files != null )
 
435
                                for( int i = 0; i < files.length; i++ )
 
436
                                        _items.add( new RowItem( files[ i ].getName(), false ) );
407
437
                }
408
438
 
409
439
                // sort