/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/org/waxworlds/edam/exportcontacts/ConfigureVCF.java

  • Committer: edam
  • Date: 2010-07-04 14:54:18 UTC
  • Revision ID: edam@waxworlds.org-20100704145418-vcpya2sxsop0dlrq
- initial checkin
- copied intro and basic vcf-configure activities from import-contacts
- copied WizzardActivity class from import-contacts

Show diffs side-by-side

added added

removed removed

23
23
 
24
24
package org.waxworlds.edam.exportcontacts;
25
25
 
26
 
import android.app.Dialog;
27
 
import android.content.DialogInterface;
28
26
import android.content.SharedPreferences;
29
27
import android.os.Bundle;
30
 
import android.view.View;
31
 
import android.widget.Button;
32
28
import android.widget.EditText;
33
29
 
34
30
public class ConfigureVCF extends WizardActivity
35
31
{
36
 
        public final static int DIALOG_FILECHOOSER = 1;
37
 
 
38
 
        private FileChooser _file_chooser = null;
39
 
 
40
 
        // the save path
41
 
        private String _path;
42
 
 
43
32
        @Override
44
33
        protected void onCreate( Bundle savedInstanceState )
45
34
        {
46
35
                setContentView( R.layout.configure_vcf );
47
36
                super.onCreate( savedInstanceState );
48
37
 
49
 
                setNextActivity( Doit.class );
50
 
 
51
 
                // create file chooser
52
 
                _file_chooser = new FileChooser( this );
53
 
                _file_chooser.setMode( FileChooser.MODE_DIR );
54
 
//              String[] extensions = { "vcf" };
55
 
//              _file_chooser.setExtensions( extensions );
56
 
                _file_chooser.setDismissListener(
57
 
                        new DialogInterface.OnDismissListener() {
58
 
                                public void onDismiss( DialogInterface dialog )
59
 
                                {
60
 
                                        if( _file_chooser.getOk() ) {
61
 
                                                _path = _file_chooser.getPath();
62
 
                                                updatePathButton();
63
 
                                        }
64
 
                                }
65
 
                        } );
66
 
                _file_chooser.setPathPrefix( "/sdcard" );
67
 
 
68
 
                Button path_button = (Button)findViewById( R.id.path );
69
 
                path_button.setOnClickListener( new View.OnClickListener() {
70
 
                        public void onClick( View view ) {
71
 
                                onBrowse();
72
 
                        }
73
 
                } );
 
38
//              setNextActivity( Doit.class );
74
39
        }
75
40
 
76
41
        @Override
79
44
 
80
45
                SharedPreferences.Editor editor = getSharedPreferences().edit();
81
46
 
82
 
                // path and filename
83
 
                editor.putString(  "path", _path );
84
 
                EditText filename = (EditText)findViewById( R.id.filename );
85
 
                editor.putString( "filename", filename.getText().toString() );
 
47
                // location
 
48
                EditText location = (EditText)findViewById( R.id.location );
 
49
                editor.putString( "location", location.getText().toString() );
86
50
 
87
51
                editor.commit();
88
52
        }
93
57
 
94
58
                SharedPreferences prefs = getSharedPreferences();
95
59
 
96
 
/*              // default filename
97
 
                Calendar now = Calendar.getInstance();
98
 
                NumberFormat formatter = new DecimalFormat( "00" );
99
 
                String date = now.get( Calendar.YEAR ) + "-" +
100
 
                        formatter.format( now.get( Calendar.MONTH ) ) + "-" +
101
 
                        formatter.format( now.get( Calendar.DAY_OF_MONTH ) );
102
 
*/
103
 
                // path and filename
104
 
                _path = prefs.getString( "path", "/" );
105
 
                updatePathButton();
106
 
                EditText filename = (EditText)findViewById( R.id.filename );
107
 
                filename.setText( prefs.getString( "filename",
108
 
                        "android-contacts.vcf" ) );
109
 
        }
110
 
 
111
 
        protected void updatePathButton()
112
 
        {
113
 
                Button path_button = (Button)findViewById( R.id.path );
114
 
                path_button.setText(
115
 
                        _file_chooser.prettyPrint( "/sdcard" + _path, true ) );
116
 
        }
117
 
 
118
 
        protected void onBrowse()
119
 
        {
120
 
                // get path
121
 
                Button path_button = (Button)findViewById( R.id.path );
122
 
 
123
 
                // set a path for this incantation
124
 
                _file_chooser.setPath( path_button.getText().toString() );
125
 
 
126
 
                showDialog( DIALOG_FILECHOOSER );
127
 
        }
128
 
 
129
 
        @Override
130
 
        protected Dialog onCreateDialog( int id )
131
 
        {
132
 
                Dialog ret = null;
133
 
 
134
 
                switch( id )
135
 
                {
136
 
                case DIALOG_FILECHOOSER:
137
 
                        ret = _file_chooser.onCreateDialog();
138
 
                        break;
139
 
                }
140
 
 
141
 
                return ret;
142
 
        }
143
 
 
144
 
        @Override
145
 
        protected void onPrepareDialog( int id, Dialog dialog )
146
 
        {
147
 
                switch( id )
148
 
                {
149
 
                case DIALOG_FILECHOOSER:
150
 
                        _file_chooser.onPrepareDialog( this, dialog );
151
 
                        break;
152
 
                }
153
 
 
154
 
                super.onPrepareDialog( id, dialog );
 
60
                // location
 
61
                EditText location = (EditText)findViewById( R.id.location );
 
62
                location.setText( prefs.getString( "location", "/sdcard/contacts.vcf" ) );
155
63
        }
156
64
}