4
* Copyright (C) 2010 Tim Marston <tim@ed.am>
4
* Copyright (C) 2010 Tim Marston <edam@waxworlds.org>
6
6
* This file is part of the Export Contacts program (hereafter referred
7
7
* to as "this program"). For more information, see
8
* http://ed.am/dev/android/export-contacts
8
* http://www.waxworlds.org/edam/software/android/export-contacts
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/>.
24
package am.ed.exportcontacts;
24
package org.waxworlds.edam.exportcontacts;
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;
34
30
public class ConfigureVCF extends WizardActivity
36
public final static int DIALOG_FILECHOOSER = 1;
38
private FileChooser _file_chooser = null;
44
33
protected void onCreate( Bundle savedInstanceState )
46
35
setContentView( R.layout.configure_vcf );
47
36
super.onCreate( savedInstanceState );
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 ) {
38
// setNextActivity( Doit.class );
80
45
SharedPreferences.Editor editor = getSharedPreferences().edit();
83
editor.putString( "path", _path );
84
EditText filename = (EditText)findViewById( R.id.filename );
85
editor.putString( "filename", filename.getText().toString() );
48
EditText location = (EditText)findViewById( R.id.location );
49
editor.putString( "location", location.getText().toString() );
94
58
SharedPreferences prefs = getSharedPreferences();
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 );
61
EditText location = (EditText)findViewById( R.id.location );
62
location.setText( prefs.getString( "location", "/sdcard/contacts.vcf" ) );