2
2
* WizardActivity.java
4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
4
* Copyright (C) 2009 Tim Marston <tim@ed.am>
6
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
7
* to as "this program"). For more information, see
8
* http://ed.am/dev/android/import-contacts
10
10
* This program is free software: you can redistribute it and/or modify
11
11
* it under the terms of the GNU General Public License as published by
21
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
package org.waxworlds.importcontacts;
24
package am.ed.importcontacts;
26
26
import android.app.Activity;
27
27
import android.content.Intent;
28
28
import android.content.SharedPreferences;
29
import android.content.res.Configuration;
29
30
import android.os.Bundle;
30
31
import android.view.View;
31
32
import android.widget.Button;
33
34
public class WizardActivity extends Activity
35
private int _nextState = 0;
36
private Class< ? > _next_class;
38
protected void onCreate(Bundle savedInstanceState)
39
protected void onCreate( Bundle saved_instance_state )
40
super.onCreate(savedInstanceState);
41
super.onCreate( saved_instance_state );
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 );
42
48
// set up next button
43
49
Button next = (Button)findViewById( R.id.next );
51
57
Button back = (Button)findViewById( R.id.back );
52
58
back.setOnClickListener( new View.OnClickListener() {
53
59
public void onClick( View view ) {
54
setResult( RESULT_OK );
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 );
66
protected void onActivityResult( int request_code, int result_code,
69
if( result_code == RESULT_OK ) {
70
setResult( RESULT_OK );
68
75
protected void onNext()
70
switchToState( _nextState );
73
protected void setNextState( int nextState )
75
// set next state and enable button
76
_nextState = nextState;
77
// create bundle with back enabled state
78
Bundle bundle = new Bundle();
79
bundle.putBoolean( "back-enabled", true );
80
Intent i = new Intent( this, _next_class );
81
i.putExtras( bundle );
83
// start next activity
84
startActivityForResult( i, 0 );
87
protected void onBack()
89
setResult( RESULT_CANCELED );
93
protected void setNextActivity( Class< ? > cls )
77
98
( (Button)findViewById( R.id.next ) ).setEnabled( true );
80
private void switchToState( int newState )
84
// create result data bundle
85
Bundle bundle = new Bundle();
86
bundle.putInt( "nextstate", newState );
88
// create response intent and finish
89
Intent i = new Intent();
90
i.putExtras( bundle );
91
setResult( RESULT_OK, i );
96
101
public SharedPreferences getSharedPreferences()
98
103
return super.getSharedPreferences( "ImportContacts", 0 );
b'\\ No newline at end of file'
107
public void onConfigurationChanged( Configuration new_config ) {
108
super.onConfigurationChanged( new_config );