/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
 *
50 by edam
updated all URLs, email addresses and package names to ed.am
4
 * Copyright (C) 2009 Tim Marston <tim@ed.am>
6 by edam
- added GPL header comments to all files
5
 *
6
 * This file is part of the Import Contacts program (hereafter referred
7
 * to as "this program"). For more information, see
50 by edam
updated all URLs, email addresses and package names to ed.am
8
 * http://ed.am/dev/android/import-contacts
6 by edam
- added GPL header comments to all files
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
50 by edam
updated all URLs, email addresses and package names to ed.am
24
package am.ed.importcontacts;
1 by edam
Initial import
25
26
import android.app.Activity;
27
import android.content.Intent;
28
import android.content.SharedPreferences;
26 by edam
- take over orientation and keyboard hiden/shown config changes, to prevent our activities being restarted
29
import android.content.res.Configuration;
1 by edam
Initial import
30
import android.os.Bundle;
31
import android.view.View;
32
import android.widget.Button;
33
34
public class WizardActivity extends Activity
35
{
41 by edam
- updated TODO
36
	private Class< ? > _next_class;
1 by edam
Initial import
37
38
	@Override
41 by edam
- updated TODO
39
	protected void onCreate( Bundle saved_instance_state )
1 by edam
Initial import
40
	{
41 by edam
- updated TODO
41
		super.onCreate( saved_instance_state );
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
42
43
		// enable back button based on intent data
44
		Bundle extras = getIntent().getExtras();
45
		if( extras != null )//&& extras.getBoolean( "back-enabled" ) )
46
			( (Button)findViewById( R.id.back ) ).setEnabled( true );
11 by edam
- renamed ImportVCF class to ConfigureVCF
47
1 by edam
Initial import
48
		// set up next button
49
		Button next = (Button)findViewById( R.id.next );
50
		next.setOnClickListener( new View.OnClickListener() {
51
			public void onClick( View view ) {
10 by edam
- made behaviour of next button overridable
52
				onNext();
1 by edam
Initial import
53
			}
54
		} );
55
56
		// set up back button
57
		Button back = (Button)findViewById( R.id.back );
58
		back.setOnClickListener( new View.OnClickListener() {
59
			public void onClick( View view ) {
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
60
				onBack();
1 by edam
Initial import
61
			}
62
		} );
11 by edam
- renamed ImportVCF class to ConfigureVCF
63
	}
64
65
	@Override
41 by edam
- updated TODO
66
	protected void onActivityResult( int request_code, int result_code,
36 by edam
- formatting: removed some double-indents on overrunning lines
67
		Intent data )
11 by edam
- renamed ImportVCF class to ConfigureVCF
68
	{
41 by edam
- updated TODO
69
		if( result_code == RESULT_OK ) {
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
70
			setResult( RESULT_OK );
71
			finish();
72
		}
11 by edam
- renamed ImportVCF class to ConfigureVCF
73
	}
74
10 by edam
- made behaviour of next button overridable
75
	protected void onNext()
76
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
77
		// create bundle with back enabled state
78
		Bundle bundle = new Bundle();
79
		bundle.putBoolean( "back-enabled", true );
41 by edam
- updated TODO
80
		Intent i = new Intent( this, _next_class );
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
81
		i.putExtras( bundle );
82
83
		// start next activity
84
		startActivityForResult( i, 0 );
85
	}
86
87
	protected void onBack()
88
	{
89
		setResult( RESULT_CANCELED );
90
		finish();
91
	}
92
93
	protected void setNextActivity( Class< ? > cls )
94
	{
41 by edam
- updated TODO
95
		_next_class = cls;
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
96
97
		// enable next button
1 by edam
Initial import
98
		( (Button)findViewById( R.id.next ) ).setEnabled( true );
99
	}
100
101
	public SharedPreferences getSharedPreferences()
102
	{
103
		return super.getSharedPreferences( "ImportContacts", 0 );
104
	}
26 by edam
- take over orientation and keyboard hiden/shown config changes, to prevent our activities being restarted
105
106
	@Override
41 by edam
- updated TODO
107
	public void onConfigurationChanged( Configuration new_config ) {
108
		super.onConfigurationChanged( new_config );
26 by edam
- take over orientation and keyboard hiden/shown config changes, to prevent our activities being restarted
109
	}
13 by edam
- converted project to use Android 1.5 SDK
110
}