/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts
6 by edam
- added GPL header comments to all files
1
/*
2
 * WizardActivity.java
3
 *
4
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
5
 *
6
 * This file is part of the Import Contacts program (hereafter referred
7
 * to as "this program"). For more information, see
8
 * http://www.waxworlds.org/edam/software/android/import-contacts
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
1 by edam
Initial import
24
package org.waxworlds.importcontacts;
25
26
import android.app.Activity;
27
import android.content.Intent;
28
import android.content.SharedPreferences;
29
import android.os.Bundle;
30
import android.view.View;
31
import android.widget.Button;
32
33
public class WizardActivity extends Activity
34
{
11 by edam
- renamed ImportVCF class to ConfigureVCF
35
	private int _nextState;
36
	private boolean _backEnabled;
1 by edam
Initial import
37
38
	@Override
39
	protected void onCreate(Bundle savedInstanceState)
40
	{
41
		super.onCreate(savedInstanceState);
42
11 by edam
- renamed ImportVCF class to ConfigureVCF
43
		_nextState = 0;
44
45
		// deal with saved state vs. defaults
46
		if( savedInstanceState == null)
47
		{
48
			_backEnabled = false;
49
50
			Bundle extras = getIntent().getExtras();
51
			if( extras != null )
52
				_backEnabled = extras.getBoolean( "backstate" );
53
		}
54
		else
55
		{
56
			_backEnabled = savedInstanceState.getBoolean( "_backEnabled" );
57
		}
58
59
		// enable/disable back button
60
		( (Button)findViewById( R.id.back ) ).setEnabled( _backEnabled );
61
1 by edam
Initial import
62
		// set up next button
63
		Button next = (Button)findViewById( R.id.next );
64
		next.setOnClickListener( new View.OnClickListener() {
65
			public void onClick( View view ) {
10 by edam
- made behaviour of next button overridable
66
				onNext();
1 by edam
Initial import
67
			}
68
		} );
69
70
		// set up back button
71
		Button back = (Button)findViewById( R.id.back );
72
		back.setOnClickListener( new View.OnClickListener() {
73
			public void onClick( View view ) {
74
				setResult( RESULT_OK );
75
				finish();
76
			}
77
		} );
11 by edam
- renamed ImportVCF class to ConfigureVCF
78
	}
79
80
	@Override
81
	protected void onSaveInstanceState( Bundle outState ) {
82
		super.onSaveInstanceState(outState);
83
		outState.putBoolean( "_backEnabled", _backEnabled );
84
	}
85
/*
86
	@Override
87
	protected void onPause()
88
	{
89
		super.onPause();
90
	}
91
92
	@Override
93
	protected void onResume()
94
	{
95
		super.onResume();
96
	}
97
*/
10 by edam
- made behaviour of next button overridable
98
	protected void onNext()
99
	{
100
		switchToState( _nextState );
101
	}
102
1 by edam
Initial import
103
	protected void setNextState( int nextState )
104
	{
105
		// set next state and enable button
106
		_nextState = nextState;
107
		( (Button)findViewById( R.id.next ) ).setEnabled( true );
108
	}
109
110
	private void switchToState( int newState )
111
	{
112
		if( newState != 0 )
113
		{
114
			// create result data bundle
115
			Bundle bundle = new Bundle();
116
			bundle.putInt( "nextstate", newState );
117
118
			// create response intent and finish
119
			Intent i = new Intent();
120
			i.putExtras( bundle );
121
			setResult( RESULT_OK, i );
122
			finish();
123
		}
124
	}
125
126
	public SharedPreferences getSharedPreferences()
127
	{
128
		return super.getSharedPreferences( "ImportContacts", 0 );
129
	}
13 by edam
- converted project to use Android 1.5 SDK
130
}