/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
{
35
	private int _nextState = 0;
36
37
	@Override
38
	protected void onCreate(Bundle savedInstanceState)
39
	{
40
		super.onCreate(savedInstanceState);
41
42
		// set up next button
43
		Button next = (Button)findViewById( R.id.next );
44
		next.setOnClickListener( new View.OnClickListener() {
45
			public void onClick( View view ) {
46
				switchToState( _nextState );
47
			}
48
		} );
49
50
		// set up back button
51
		Button back = (Button)findViewById( R.id.back );
52
		back.setOnClickListener( new View.OnClickListener() {
53
			public void onClick( View view ) {
54
				setResult( RESULT_OK );
55
				finish();
56
			}
57
		} );
58
59
		// enable back button?
60
		Bundle extras = getIntent().getExtras();
61
		if( extras != null ) {
62
			Boolean backstate = extras.getBoolean( "backstate" );
63
			if( backstate != null )
64
				( (Button)findViewById( R.id.back ) ).setEnabled( true );
65
		}
66
	}
67
68
	protected void setNextState( int nextState )
69
	{
70
		// set next state and enable button
71
		_nextState = nextState;
72
		( (Button)findViewById( R.id.next ) ).setEnabled( true );
73
	}
74
75
	private void switchToState( int newState )
76
	{
77
		if( newState != 0 )
78
		{
79
			// create result data bundle
80
			Bundle bundle = new Bundle();
81
			bundle.putInt( "nextstate", newState );
82
83
			// create response intent and finish
84
			Intent i = new Intent();
85
			i.putExtras( bundle );
86
			setResult( RESULT_OK, i );
87
			finish();
88
		}
89
	}
90
91
	public SharedPreferences getSharedPreferences()
92
	{
93
		return super.getSharedPreferences( "ImportContacts", 0 );
94
	}
95
}