36
36
import android.widget.Button;
37
37
import android.widget.CheckBox;
38
38
import android.widget.CompoundButton;
39
import android.widget.LinearLayout;
40
39
import android.widget.ProgressBar;
41
40
import android.widget.TextView;
42
41
import android.widget.Toast;
62
61
public final static int MESSAGE_CONTACTMERGED = 12;
63
62
public final static int MESSAGE_CONTACTSKIPPED = 13;
64
public final static int ACTION_PROMPT = 0;
65
public final static int ACTION_KEEP = 1;
66
public final static int ACTION_MERGE_MERGE = 2;
67
public final static int ACTION_OVERWRITE = 3;
69
public final static int NEXT_BEGIN = 0;
70
public final static int NEXT_CLOSE = 1;
65
72
private boolean _startedProgress;
66
73
private int _maxProgress;
67
74
private int _tmpProgress;
90
98
setVisibility( View.VISIBLE );
92
100
case MESSAGE_FINISHED:
93
( (LinearLayout)findViewById( R.id.doit_closedisplay ) ).
94
setVisibility( View.VISIBLE );
101
updateNext( NEXT_CLOSE );
102
findViewById( R.id.doit_abort_disp ).setVisibility(
96
105
case MESSAGE_FINISHED_GOBACK:
97
106
( (Button)findViewById( R.id.back ) ).setEnabled( true );
107
findViewById( R.id.doit_abort_disp ).setVisibility(
99
110
case MESSAGE_ERROR:
100
111
Doit.this._dialogMessage = (String)msg.obj;
111
122
case MESSAGE_SETMAXPROGRESS:
112
123
if( _maxProgress > 0 ) {
113
if( _tmpProgress == _maxProgress )
124
if( _tmpProgress == _maxProgress - 1 )
114
125
_tmpProgress = (Integer)msg.obj;
115
if( _progress == _maxProgress )
126
if( _progress == _maxProgress - 1 )
116
127
_progress = (Integer)msg.obj;
118
129
_maxProgress = (Integer)msg.obj;
163
174
( findViewById( R.id.doit_page_2 ) ).setVisibility( View.GONE );
165
// set up begin button
166
Button begin = (Button)findViewById( R.id.doit_begin );
176
// set up abort button
177
Button begin = (Button)findViewById( R.id.abort );
167
178
begin.setOnClickListener( new View.OnClickListener() {
168
179
public void onClick( View view ) {
173
// set up close button
174
Button close = (Button)findViewById( R.id.doit_close );
175
close.setOnClickListener( new View.OnClickListener() {
176
public void onClick( View view ) {
177
setResult( RESULT_CANCELED );
268
268
setOnClickListener( _mergePromptButtonListener );
269
269
( (Button)dialogView.findViewById( R.id.merge_merge ) ).
270
270
setOnClickListener( _mergePromptButtonListener );
271
( (Button)dialogView.findViewById( R.id.abort ) ).
272
setOnClickListener( _mergePromptButtonListener );
271
273
_mergePromptAlwaysSelected = false;
272
274
return new AlertDialog.Builder( this )
273
275
.setIcon( R.drawable.alert_dialog_icon )
282
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
283
public void onClick( View view ) {
284
int responseExtra = _mergePromptAlwaysSelected?
285
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
284
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
285
public void onClick( View view )
288
if( view.getId() == R.id.abort )
293
int responseExtra = _mergePromptAlwaysSelected?
294
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
295
Doit.this._importer.wake( convertIdToAction( view.getId() ),
299
// close dialog and free (don't keep a reference)
286
300
Doit.this._mergePromptDialog.dismiss();
287
Doit.this._mergePromptDialog = null; // dont keep a reference!
288
Doit.this._importer.wake( view.getId(), responseExtra );
301
Doit.this._mergePromptDialog = null;
306
protected void onNext()
308
Button next = (Button)findViewById( R.id.next );
309
next.setEnabled( false );
311
switch( _nextAction )
317
setResult( RESULT_CANCELED );
323
private void manualAbort()
325
abortImport( false );
326
updateNext( NEXT_CLOSE );
327
( (Button)findViewById( R.id.back ) ).setEnabled( true );
328
findViewById( R.id.doit_abort_disp ).setVisibility( View.GONE );
331
private void updateNext( int nextAction )
333
Button next = (Button)findViewById( R.id.next );
334
switch( nextAction ) {
335
case NEXT_BEGIN: next.setText( R.string.doit_begin ); break;
336
case NEXT_CLOSE: next.setText( R.string.doit_close ); break;
338
next.setEnabled( true );
339
_nextAction = nextAction;
342
public static int convertIdToAction( int id ) {
344
case R.id.merge_keep: return ACTION_KEEP;
345
case R.id.merge_merge: return ACTION_MERGE_MERGE;
346
case R.id.merge_overwrite: return ACTION_OVERWRITE;
347
default: return ACTION_PROMPT;
351
public static int convertActionToId( int action ) {
353
case ACTION_KEEP: return R.id.merge_keep;
354
case ACTION_MERGE_MERGE:return R.id.merge_merge;
355
case ACTION_OVERWRITE: return R.id.merge_overwrite;
356
default: return R.id.merge_prompt;
292
360
private DialogInterface.OnCancelListener _dialogOnCancelListener =
293
361
new DialogInterface.OnCancelListener() {
294
362
public void onCancel( DialogInterface dialog ) {
395
463
// notify the user
396
Toast.makeText( this, R.string.doit_importaborted,
397
Toast.LENGTH_LONG ).show();
464
if( showToasterPopup )
465
Toast.makeText( this, R.string.doit_importaborted,
466
Toast.LENGTH_LONG ).show();
470
// destroy some stuff