/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
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
24
package org.waxworlds.edam.importcontacts;
1 by edam
Initial import
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
{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
35
	private Class< ? > _nextClass;
1 by edam
Initial import
36
37
	@Override
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
38
	protected void onCreate( Bundle savedInstanceState )
1 by edam
Initial import
39
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
40
		super.onCreate( savedInstanceState );
41
42
		// enable back button based on intent data
43
		Bundle extras = getIntent().getExtras();
44
		if( extras != null )//&& extras.getBoolean( "back-enabled" ) )
45
			( (Button)findViewById( R.id.back ) ).setEnabled( true );
11 by edam
- renamed ImportVCF class to ConfigureVCF
46
1 by edam
Initial import
47
		// set up next button
48
		Button next = (Button)findViewById( R.id.next );
49
		next.setOnClickListener( new View.OnClickListener() {
50
			public void onClick( View view ) {
10 by edam
- made behaviour of next button overridable
51
				onNext();
1 by edam
Initial import
52
			}
53
		} );
54
55
		// set up back button
56
		Button back = (Button)findViewById( R.id.back );
57
		back.setOnClickListener( new View.OnClickListener() {
58
			public void onClick( View view ) {
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
59
				onBack();
1 by edam
Initial import
60
			}
61
		} );
11 by edam
- renamed ImportVCF class to ConfigureVCF
62
	}
63
64
	@Override
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
65
	protected void  onActivityResult( int requestCode, int resultCode, Intent data )
11 by edam
- renamed ImportVCF class to ConfigureVCF
66
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
67
		if( resultCode == RESULT_OK ) {
68
			setResult( RESULT_OK );
69
			finish();
70
		}
11 by edam
- renamed ImportVCF class to ConfigureVCF
71
	}
72
10 by edam
- made behaviour of next button overridable
73
	protected void onNext()
74
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
75
		// create bundle with back enabled state
76
		Bundle bundle = new Bundle();
77
		bundle.putBoolean( "back-enabled", true );
78
		Intent i = new Intent( this, _nextClass );
79
		i.putExtras( bundle );
80
81
		// start next activity
82
		startActivityForResult( i, 0 );
83
	}
84
85
	protected void onBack()
86
	{
87
		setResult( RESULT_CANCELED );
88
		finish();
89
	}
90
91
	protected void setNextActivity( Class< ? > cls )
92
	{
93
		_nextClass = cls;
94
95
		// enable next button
1 by edam
Initial import
96
		( (Button)findViewById( R.id.next ) ).setEnabled( true );
97
	}
98
99
	public SharedPreferences getSharedPreferences()
100
	{
101
		return super.getSharedPreferences( "ImportContacts", 0 );
102
	}
13 by edam
- converted project to use Android 1.5 SDK
103
}