4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
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
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.
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.
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/>.
24
package org.waxworlds.edam.importcontacts;
1
package org.waxworlds.importcontacts;
26
3
import android.app.Activity;
27
4
import android.content.Intent;
28
5
import android.content.SharedPreferences;
29
import android.content.res.Configuration;
30
6
import android.os.Bundle;
31
7
import android.view.View;
32
8
import android.widget.Button;
34
10
public class WizardActivity extends Activity
36
private Class< ? > _nextClass;
12
private int _nextState = 0;
39
protected void onCreate( Bundle savedInstanceState )
15
protected void onCreate(Bundle savedInstanceState)
41
super.onCreate( savedInstanceState );
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 );
17
super.onCreate(savedInstanceState);
48
19
// set up next button
49
20
Button next = (Button)findViewById( R.id.next );
50
21
next.setOnClickListener( new View.OnClickListener() {
51
22
public void onClick( View view ) {
23
switchToState( _nextState );
57
28
Button back = (Button)findViewById( R.id.back );
58
29
back.setOnClickListener( new View.OnClickListener() {
59
30
public void onClick( View view ) {
31
setResult( RESULT_OK );
66
protected void onActivityResult( int requestCode, int resultCode, Intent data )
68
if( resultCode == RESULT_OK ) {
69
setResult( RESULT_OK );
36
// enable back button?
37
Bundle extras = getIntent().getExtras();
38
if( extras != null ) {
39
Boolean backstate = extras.getBoolean( "backstate" );
40
if( backstate != null )
41
( (Button)findViewById( R.id.back ) ).setEnabled( true );
45
protected void setNextState( int nextState )
47
// set next state and enable button
48
_nextState = nextState;
49
( (Button)findViewById( R.id.next ) ).setEnabled( true );
52
private void switchToState( int newState )
56
// create result data bundle
57
Bundle bundle = new Bundle();
58
bundle.putInt( "nextstate", newState );
60
// create response intent and finish
61
Intent i = new Intent();
62
i.putExtras( bundle );
63
setResult( RESULT_OK, i );
74
protected void onNext()
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 );
82
// start next activity
83
startActivityForResult( i, 0 );
86
protected void onBack()
88
setResult( RESULT_CANCELED );
92
protected void setNextActivity( Class< ? > cls )
97
( (Button)findViewById( R.id.next ) ).setEnabled( true );
100
68
public SharedPreferences getSharedPreferences()
102
70
return super.getSharedPreferences( "ImportContacts", 0 );
106
public void onConfigurationChanged( Configuration newConfig ) {
107
super.onConfigurationChanged( newConfig );
b'\\ No newline at end of file'