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;
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< ? > _nextClass;
38
protected void onCreate(Bundle savedInstanceState)
39
protected void onCreate( Bundle savedInstanceState )
40
super.onCreate(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 );
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 requestCode, int resultCode, Intent data )
68
if( resultCode == RESULT_OK ) {
69
setResult( RESULT_OK );
68
74
protected void onNext()
70
switchToState( _nextState );
73
protected void setNextState( int nextState )
75
// set next state and enable button
76
_nextState = nextState;
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 )
77
97
( (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
100
public SharedPreferences getSharedPreferences()
98
102
return super.getSharedPreferences( "ImportContacts", 0 );
b'\\ No newline at end of file'
106
public void onConfigurationChanged( Configuration newConfig ) {
107
super.onConfigurationChanged( newConfig );