/android/export-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/export-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/exportcontacts/ConfigureVCF.java

  • Committer: edam
  • Date: 2012-04-24 11:29:44 UTC
  • Revision ID: tim@ed.am-20120424112944-6fic236bul6r9cqi
changed all the URLs to ed.am, including copyrights, package names and project
site

Show diffs side-by-side

added added

removed removed

4
4
 * Copyright (C) 2010 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Export Contacts program (hereafter referred
7
 
 * to as "this program").  For more information, see
 
7
 * to as "this program"). For more information, see
8
8
 * http://ed.am/dev/android/export-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
23
23
 
24
24
package am.ed.exportcontacts;
25
25
 
26
 
import java.io.IOException;
27
 
 
28
 
import android.app.AlertDialog;
29
26
import android.app.Dialog;
30
27
import android.content.DialogInterface;
31
28
import android.content.SharedPreferences;
32
29
import android.os.Bundle;
33
 
import android.os.Environment;
34
30
import android.view.View;
35
31
import android.widget.Button;
36
32
import android.widget.EditText;
38
34
public class ConfigureVCF extends WizardActivity
39
35
{
40
36
        public final static int DIALOG_FILECHOOSER = 1;
41
 
        public final static int DIALOG_NOSDCARD = 2;
42
37
 
43
38
        private FileChooser _file_chooser = null;
44
39
 
53
48
 
54
49
                setNextActivity( Doit.class );
55
50
 
56
 
                // get sdcard prefix
57
 
                String sdcard_prefix = getSdCardPathPrefix();
58
 
                if( sdcard_prefix == null )
59
 
                        showDialog( DIALOG_NOSDCARD );
60
 
 
61
51
                // create file chooser
62
52
                _file_chooser = new FileChooser( this );
63
53
                _file_chooser.setMode( FileChooser.MODE_DIR );
118
108
                        "android-contacts.vcf" ) );
119
109
        }
120
110
 
121
 
        static protected String getSdCardPathPrefix()
122
 
        {
123
 
                // check sdcard status
124
 
                String state = Environment.getExternalStorageState();
125
 
                if( !Environment.MEDIA_MOUNTED.equals( state ) &&
126
 
                        !Environment.MEDIA_MOUNTED_READ_ONLY.equals( state ) )
127
 
                {
128
 
                        // no sdcard mounted
129
 
                        return null;
130
 
                }
131
 
 
132
 
                // get sdcard path
133
 
                String sdcard_path;
134
 
                try {
135
 
                        sdcard_path = Environment.getExternalStorageDirectory()
136
 
                                .getCanonicalPath();
137
 
                        if( sdcard_path.charAt( sdcard_path.length() - 1 ) == '/' )
138
 
                                sdcard_path =
139
 
                                        sdcard_path.substring( 0, sdcard_path.length() - 1 );
140
 
                }
141
 
                catch( IOException e ) {
142
 
                        sdcard_path = null;
143
 
                }
144
 
 
145
 
                return sdcard_path;
146
 
        }
147
 
 
148
111
        protected void updatePathButton()
149
112
        {
150
113
                Button path_button = (Button)findViewById( R.id.path );
173
136
                case DIALOG_FILECHOOSER:
174
137
                        ret = _file_chooser.onCreateDialog();
175
138
                        break;
176
 
 
177
 
                case DIALOG_NOSDCARD:
178
 
                        ret = new AlertDialog.Builder( this )
179
 
                        .setIcon( R.drawable.alert_dialog_icon )
180
 
                        .setTitle( R.string.error_title )
181
 
                        .setMessage( R.string.error_nosdcard )
182
 
                        .setPositiveButton( R.string.error_ok,
183
 
                                new DialogInterface.OnClickListener() {
184
 
                                        public void onClick(DialogInterface dialog,
185
 
                                                int whichButton)
186
 
                                        {
187
 
                                                // close the whole app!
188
 
                                                setResult( RESULT_OK );
189
 
                                                finish();
190
 
                                        }
191
 
                                } )
192
 
                        .create();
193
 
                        break;
194
139
                }
195
140
 
196
141
                return ret;