24
24
package org.waxworlds.edam.exportcontacts;
26
import android.app.Dialog;
27
import android.content.DialogInterface;
26
28
import android.content.SharedPreferences;
27
29
import android.os.Bundle;
30
import android.view.View;
31
import android.widget.Button;
28
32
import android.widget.EditText;
30
34
public class ConfigureVCF extends WizardActivity
36
public final static int DIALOG_FILECHOOSER = 1;
38
private FileChooser _file_chooser = null;
33
44
protected void onCreate( Bundle savedInstanceState )
35
46
setContentView( R.layout.configure_vcf );
36
47
super.onCreate( savedInstanceState );
38
// setNextActivity( Doit.class );
49
setNextActivity( Doit.class );
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 )
60
if( _file_chooser.getOk() ) {
61
_path = _file_chooser.getPath();
66
_file_chooser.setPathPrefix( "/sdcard" );
68
Button path_button = (Button)findViewById( R.id.path );
69
path_button.setOnClickListener( new View.OnClickListener() {
70
public void onClick( View view ) {
45
80
SharedPreferences.Editor editor = getSharedPreferences().edit();
48
EditText location = (EditText)findViewById( R.id.location );
49
editor.putString( "location", location.getText().toString() );
83
editor.putString( "path", _path );
84
EditText filename = (EditText)findViewById( R.id.filename );
85
editor.putString( "filename", filename.getText().toString() );
58
94
SharedPreferences prefs = getSharedPreferences();
61
EditText location = (EditText)findViewById( R.id.location );
62
location.setText( prefs.getString( "location", "/sdcard/contacts.vcf" ) );
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 ) );
104
_path = prefs.getString( "path", "/" );
106
EditText filename = (EditText)findViewById( R.id.filename );
107
filename.setText( prefs.getString( "filename",
108
"android-contacts.vcf" ) );
111
protected void updatePathButton()
113
Button path_button = (Button)findViewById( R.id.path );
115
_file_chooser.prettyPrint( "/sdcard" + _path, true ) );
118
protected void onBrowse()
121
Button path_button = (Button)findViewById( R.id.path );
123
// set a path for this incantation
124
_file_chooser.setPath( path_button.getText().toString() );
126
showDialog( DIALOG_FILECHOOSER );
130
protected Dialog onCreateDialog( int id )
136
case DIALOG_FILECHOOSER:
137
ret = _file_chooser.onCreateDialog();
145
protected void onPrepareDialog( int id, Dialog dialog )
149
case DIALOG_FILECHOOSER:
150
_file_chooser.onPrepareDialog( this, dialog );
154
super.onPrepareDialog( id, dialog );