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 )
45
63
SharedPreferences.Editor editor = getSharedPreferences().edit();
48
EditText location = (EditText)findViewById( R.id.location );
49
editor.putString( "location", location.getText().toString() );
66
editor.putString( "path", _path );
67
EditText filename = (EditText)findViewById( R.id.filename );
68
editor.putString( "filename", filename.getText().toString() );
58
77
SharedPreferences prefs = getSharedPreferences();
61
EditText location = (EditText)findViewById( R.id.location );
62
location.setText( prefs.getString( "location", "/sdcard/contacts.vcf" ) );
79
/* // default filename
80
Calendar now = Calendar.getInstance();
81
NumberFormat formatter = new DecimalFormat( "00" );
82
String date = now.get( Calendar.YEAR ) + "-" +
83
formatter.format( now.get( Calendar.MONTH ) ) + "-" +
84
formatter.format( now.get( Calendar.DAY_OF_MONTH ) );
87
_path = prefs.getString( "path", "/" );
89
EditText filename = (EditText)findViewById( R.id.filename );
90
filename.setText( prefs.getString( "filename",
91
"android-contacts.vcf" ) );
94
protected void updatePathButton()
96
Button path_button = (Button)findViewById( R.id.path );
97
path_button.setText( FileChooser.prettyPrint(
98
getApplicationContext(), "/sdcard" + _path, false ) );
99
path_button.setCompoundDrawablesWithIntrinsicBounds(
100
getResources().getDrawable(
101
FileChooser.pathIcon( "/sdcard" + _path ) ), null,
102
getResources().getDrawable( R.drawable.browse ), null );
105
protected void onBrowse()
108
Button path_button = (Button)findViewById( R.id.path );
110
// create file chooser
111
if( _file_chooser == null ) {
112
_file_chooser = new FileChooser( FileChooser.MODE_DIR );
113
String[] extensions = { "vcf" };
114
_file_chooser.setExtensions( extensions );
115
_file_chooser.setDismissListener(
116
new DialogInterface.OnDismissListener() {
117
public void onDismiss( DialogInterface dialog )
119
_path = _file_chooser.getPath();
123
_file_chooser.setPathPrefix( "/sdcard" );
126
// set a path for this incantation
127
_file_chooser.setPath( path_button.getText().toString() );
129
showDialog( DIALOG_FILECHOOSER );
133
protected Dialog onCreateDialog( int id )
139
case DIALOG_FILECHOOSER:
140
ret = _file_chooser.onCreateDialog( this );
147
protected void onPrepareDialog( int id, Dialog dialog )
151
case DIALOG_FILECHOOSER:
152
_file_chooser.onPrepareDialog( this, dialog );
156
super.onPrepareDialog( id, dialog );