/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: 2010-12-14 16:00:39 UTC
  • Revision ID: edam@waxworlds.org-20101214160039-u37uvpw7wn3tmo3d
Tags: 1.1
- bump version to 1.1

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