/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;
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
{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
36
	private Class< ? > _nextClass;
1 by edam
Initial import
37
38
	@Override
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
39
	protected void onCreate( Bundle savedInstanceState )
1 by edam
Initial import
40
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
41
		super.onCreate( savedInstanceState );
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
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
66
	protected void  onActivityResult( int requestCode, int resultCode, Intent data )
11 by edam
- renamed ImportVCF class to ConfigureVCF
67
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
68
		if( resultCode == RESULT_OK ) {
69
			setResult( RESULT_OK );
70
			finish();
71
		}
11 by edam
- renamed ImportVCF class to ConfigureVCF
72
	}
73
10 by edam
- made behaviour of next button overridable
74
	protected void onNext()
75
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
76
		// create bundle with back enabled state
77
		Bundle bundle = new Bundle();
78
		bundle.putBoolean( "back-enabled", true );
79
		Intent i = new Intent( this, _nextClass );
80
		i.putExtras( bundle );
81
82
		// start next activity
83
		startActivityForResult( i, 0 );
84
	}
85
86
	protected void onBack()
87
	{
88
		setResult( RESULT_CANCELED );
89
		finish();
90
	}
91
92
	protected void setNextActivity( Class< ? > cls )
93
	{
94
		_nextClass = cls;
95
96
		// enable next button
1 by edam
Initial import
97
		( (Button)findViewById( R.id.next ) ).setEnabled( true );
98
	}
99
100
	public SharedPreferences getSharedPreferences()
101
	{
102
		return super.getSharedPreferences( "ImportContacts", 0 );
103
	}
26 by edam
- take over orientation and keyboard hiden/shown config changes, to prevent our activities being restarted
104
105
	@Override
106
	public void onConfigurationChanged( Configuration newConfig ) {
107
		super.onConfigurationChanged( newConfig );
108
	}
13 by edam
- converted project to use Android 1.5 SDK
109
}