/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

1
1
/*
2
2
 * FileChooser.java
3
3
 *
4
 
 * Copyright (C) 2010 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2010 Tim Marston <edam@waxworlds.org>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
7
 * to as "this program"). For more information, see
8
 
 * http://ed.am/dev/android/import-contacts
 
8
 * http://www.waxworlds.org/edam/software/android/import-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
11
11
 * it under the terms of the GNU General Public License as published by
21
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
22
 */
23
23
 
24
 
package am.ed.importcontacts;
 
24
package org.waxworlds.edam.importcontacts;
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