/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/org/waxworlds/importcontacts/WizardActivity.java

  • Committer: edam
  • Date: 2009-01-10 16:14:11 UTC
  • Revision ID: edam@waxworlds.org-20090110161411-4d17l9hs9d6j277q
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.waxworlds.importcontacts;
 
2
 
 
3
import android.app.Activity;
 
4
import android.content.Intent;
 
5
import android.content.SharedPreferences;
 
6
import android.os.Bundle;
 
7
import android.view.View;
 
8
import android.widget.Button;
 
9
 
 
10
public class WizardActivity extends Activity
 
11
{
 
12
        private int _nextState = 0;
 
13
 
 
14
        @Override
 
15
        protected void onCreate(Bundle savedInstanceState)
 
16
        {
 
17
                super.onCreate(savedInstanceState);
 
18
 
 
19
                // set up next button
 
20
                Button next = (Button)findViewById( R.id.next );
 
21
                next.setOnClickListener( new View.OnClickListener() {
 
22
                        public void onClick( View view ) {
 
23
                                switchToState( _nextState );
 
24
                        }
 
25
                } );
 
26
 
 
27
                // set up back button
 
28
                Button back = (Button)findViewById( R.id.back );
 
29
                back.setOnClickListener( new View.OnClickListener() {
 
30
                        public void onClick( View view ) {
 
31
                                setResult( RESULT_OK );
 
32
                                finish();
 
33
                        }
 
34
                } );
 
35
 
 
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 );
 
42
                }
 
43
        }
 
44
 
 
45
        protected void setNextState( int nextState )
 
46
        {
 
47
                // set next state and enable button
 
48
                _nextState = nextState;
 
49
                ( (Button)findViewById( R.id.next ) ).setEnabled( true );
 
50
        }
 
51
 
 
52
        private void switchToState( int newState )
 
53
        {
 
54
                if( newState != 0 )
 
55
                {
 
56
                        // create result data bundle
 
57
                        Bundle bundle = new Bundle();
 
58
                        bundle.putInt( "nextstate", newState );
 
59
 
 
60
                        // create response intent and finish
 
61
                        Intent i = new Intent();
 
62
                        i.putExtras( bundle );
 
63
                        setResult( RESULT_OK, i );
 
64
                        finish();
 
65
                }
 
66
        }
 
67
 
 
68
        public SharedPreferences getSharedPreferences()
 
69
        {
 
70
                return super.getSharedPreferences( "ImportContacts", 0 );
 
71
        }
 
72
}
 
 
b'\\ No newline at end of file'