21
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
package org.waxworlds.importcontacts;
24
package org.waxworlds.edam.importcontacts;
26
26
import android.app.Activity;
27
27
import android.content.Intent;
33
33
public class WizardActivity extends Activity
35
private int _nextState = 0;
35
private Class< ? > _nextClass;
38
protected void onCreate(Bundle savedInstanceState)
38
protected void onCreate( Bundle savedInstanceState )
40
super.onCreate(savedInstanceState);
40
super.onCreate( savedInstanceState );
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 );
42
47
// set up next button
43
48
Button next = (Button)findViewById( R.id.next );
51
56
Button back = (Button)findViewById( R.id.back );
52
57
back.setOnClickListener( new View.OnClickListener() {
53
58
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 );
65
protected void onActivityResult( int requestCode, int resultCode, Intent data )
67
if( resultCode == RESULT_OK ) {
68
setResult( RESULT_OK );
68
73
protected void onNext()
70
switchToState( _nextState );
73
protected void setNextState( int nextState )
75
// set next state and enable button
76
_nextState = nextState;
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 );
81
// start next activity
82
startActivityForResult( i, 0 );
85
protected void onBack()
87
setResult( RESULT_CANCELED );
91
protected void setNextActivity( Class< ? > cls )
77
96
( (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
99
public SharedPreferences getSharedPreferences()
98
101
return super.getSharedPreferences( "ImportContacts", 0 );
b'\\ No newline at end of file'