68
68
public final static int NEXT_BEGIN = 0;
69
69
public final static int NEXT_CLOSE = 1;
71
private boolean _started_progress;
72
private int _max_progress;
73
private int _tmp_progress;
71
private boolean _startedProgress;
72
private int _maxProgress;
73
private int _tmpProgress;
74
74
private int _progress;
75
protected String _dialog_message;
76
private Dialog _merge_prompt_dialog;
77
private boolean _merge_prompt_always_selected;
78
private int _next_action;
79
private int _current_dialog_id;
75
protected String _dialogMessage;
76
private Dialog _mergePromptDialog;
77
private boolean _mergePromptAlwaysSelected;
78
private int _nextAction;
79
private int _currentDialogId;
81
private int _count_overwrites;
82
private int _count_creates;
83
private int _count_merges;
84
private int _count_skips;
81
private int _countOverwrites;
82
private int _countCreates;
83
private int _countMerges;
84
private int _countSkips;
86
86
protected Importer _importer = null;
99
99
( (Button)findViewById( R.id.back ) ).setEnabled( false );
100
100
updateNext( NEXT_CLOSE );
101
101
findViewById( R.id.doit_abort_disp ).setVisibility(
104
104
case MESSAGE_ABORT:
107
107
case MESSAGE_ERROR:
108
_dialog_message = (String)msg.obj;
108
_dialogMessage = (String)msg.obj;
109
109
showDialog( DIALOG_ERROR );
111
111
case MESSAGE_CONTINUEORABORT:
112
_dialog_message = (String)msg.obj;
112
_dialogMessage = (String)msg.obj;
113
113
showDialog( DIALOG_CONTINUEORABORT );
115
115
case MESSAGE_SETPROGRESSMESSAGE:
116
116
( (TextView)findViewById( R.id.doit_percentage ) ).
117
setText( (String)msg.obj );
117
setText( (String)msg.obj );
119
119
case MESSAGE_SETMAXPROGRESS:
120
if( _max_progress > 0 ) {
121
if( _tmp_progress == _max_progress - 1 )
122
_tmp_progress = (Integer)msg.obj;
123
if( _progress == _max_progress - 1 )
120
if( _maxProgress > 0 ) {
121
if( _tmpProgress == _maxProgress - 1 )
122
_tmpProgress = (Integer)msg.obj;
123
if( _progress == _maxProgress - 1 )
124
124
_progress = (Integer)msg.obj;
126
_max_progress = (Integer)msg.obj;
126
_maxProgress = (Integer)msg.obj;
127
127
updateProgress();
129
129
case MESSAGE_SETTMPPROGRESS:
130
_tmp_progress = (Integer)msg.obj;
130
_tmpProgress = (Integer)msg.obj;
131
131
updateProgress();
133
133
case MESSAGE_SETPROGRESS:
134
_started_progress = true;
134
_startedProgress = true;
135
135
_progress = (Integer)msg.obj;
136
136
updateProgress();
138
138
case MESSAGE_MERGEPROMPT:
139
_dialog_message = (String)msg.obj;
139
_dialogMessage = (String)msg.obj;
140
140
showDialog( DIALOG_MERGEPROMPT );
142
142
case MESSAGE_CONTACTOVERWRITTEN:
146
146
case MESSAGE_CONTACTCREATED:
150
150
case MESSAGE_CONTACTMERGED:
154
154
case MESSAGE_CONTACTSKIPPED:
233
232
.setMessage( "" )
234
233
.setPositiveButton( R.string.error_continue,
235
234
new DialogInterface.OnClickListener() {
236
public void onClick( DialogInterface dialog,
235
public void onClick(DialogInterface dialog,
239
if( Doit.this != null )
240
Doit.this._importer.wake(
241
Importer.RESPONSE_POSITIVE );
238
Doit.this._importer.wake(
239
Importer.RESPONSE_POSITIVE );
244
242
.setNegativeButton( R.string.error_abort,
245
243
new DialogInterface.OnClickListener() {
246
public void onClick( DialogInterface dialog,
244
public void onClick(DialogInterface dialog,
249
if( Doit.this != null )
250
Doit.this._importer.wake(
251
Importer.RESPONSE_NEGATIVE );
247
Doit.this._importer.wake(
248
Importer.RESPONSE_NEGATIVE );
254
.setOnCancelListener( _dialog_on_cancel_listener )
251
.setOnCancelListener( _dialogOnCancelListener )
256
253
case DIALOG_MERGEPROMPT:
257
254
// custom layout in an AlertDialog
258
255
LayoutInflater factory = LayoutInflater.from( this );
259
final View dialog_view = factory.inflate(
256
final View dialogView = factory.inflate(
260
257
R.layout.mergeprompt, null );
261
( (CheckBox)dialog_view.findViewById( R.id.mergeprompt_always ) ).
258
( (CheckBox)dialogView.findViewById( R.id.mergeprompt_always ) ).
262
259
setOnCheckedChangeListener(
263
260
new CompoundButton.OnCheckedChangeListener() {
264
public void onCheckedChanged(
265
CompoundButton button_view, boolean is_checked )
261
public void onCheckedChanged( CompoundButton buttonView,
267
if( Doit.this != null )
268
Doit.this._merge_prompt_always_selected =
264
Doit.this._mergePromptAlwaysSelected = isChecked;
272
( (Button)dialog_view.findViewById( R.id.merge_keep ) ).
273
setOnClickListener( _merge_prompt_button_listener );
274
( (Button)dialog_view.findViewById( R.id.merge_overwrite ) ).
275
setOnClickListener( _merge_prompt_button_listener );
276
( (Button)dialog_view.findViewById( R.id.merge_merge ) ).
277
setOnClickListener( _merge_prompt_button_listener );
278
( (Button)dialog_view.findViewById( R.id.abort ) ).
279
setOnClickListener( _merge_prompt_button_listener );
280
_merge_prompt_always_selected = false;
267
( (Button)dialogView.findViewById( R.id.merge_keep ) ).
268
setOnClickListener( _mergePromptButtonListener );
269
( (Button)dialogView.findViewById( R.id.merge_overwrite ) ).
270
setOnClickListener( _mergePromptButtonListener );
271
( (Button)dialogView.findViewById( R.id.merge_merge ) ).
272
setOnClickListener( _mergePromptButtonListener );
273
( (Button)dialogView.findViewById( R.id.abort ) ).
274
setOnClickListener( _mergePromptButtonListener );
275
_mergePromptAlwaysSelected = false;
281
276
return new AlertDialog.Builder( this )
282
277
.setIcon( R.drawable.alert_dialog_icon )
283
278
.setTitle( R.string.mergeprompt_title )
284
.setView( dialog_view )
285
.setOnCancelListener( _dialog_on_cancel_listener )
279
.setView( dialogView )
280
.setOnCancelListener( _dialogOnCancelListener )
291
private OnClickListener _merge_prompt_button_listener =
292
new OnClickListener()
286
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
294
287
public void onClick( View view )
296
if( Doit.this == null ) return;
299
290
if( view.getId() == R.id.abort )
302
293
// else, response (just check we haven't aborted already!)
303
294
else if( Doit.this._importer != null ) {
304
int response_extra = _merge_prompt_always_selected?
305
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
295
int responseExtra = _mergePromptAlwaysSelected?
296
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
306
297
Doit.this._importer.wake( convertIdToAction( view.getId() ),
310
301
// close dialog and free (don't keep a reference)
311
Doit.this._merge_prompt_dialog.dismiss();
312
Doit.this._merge_prompt_dialog = null;
302
Doit.this._mergePromptDialog.dismiss();
303
Doit.this._mergePromptDialog = null;
399
protected void onActivityResult( int request_code, int result_code,
388
protected void onActivityResult( int requestCode, int resultCode,
402
391
// if we're cancelling, abort any import
403
if( result_code == RESULT_CANCELED )
392
if( resultCode == RESULT_CANCELED )
404
393
abortImport( true );
408
protected void onPrepareDialog( int id, Dialog dialog )
397
protected void onPrepareDialog(int id, Dialog dialog)
410
_current_dialog_id = id;
399
_currentDialogId = id;
414
403
case DIALOG_ERROR: // fall through
415
404
case DIALOG_CONTINUEORABORT:
416
405
// set dialog message
417
( (AlertDialog)dialog ).setMessage( _dialog_message );
406
( (AlertDialog)dialog ).setMessage( _dialogMessage );
419
408
case DIALOG_MERGEPROMPT:
420
409
// set contact's name
421
( (TextView)dialog.findViewById( R.id.mergeprompt_name ) )
422
.setText( _dialog_message );
410
( (TextView)dialog.findViewById( R.id.mergeprompt_name ) ).setText(
423
412
// and set up reference to dialog
424
_merge_prompt_dialog = dialog;
413
_mergePromptDialog = dialog;
447
436
private void updateProgress()
449
438
ProgressBar bar = (ProgressBar)findViewById( R.id.doit_progress );
450
TextView out_of = (TextView)findViewById( R.id.doit_outof );
439
TextView outOf = (TextView)findViewById( R.id.doit_outof );
452
if( _max_progress > 0 )
441
if( _maxProgress > 0 )
454
bar.setMax( _max_progress );
455
bar.setSecondaryProgress( _tmp_progress );
443
bar.setMax( _maxProgress );
444
bar.setSecondaryProgress( _tmpProgress );
457
if( _started_progress )
446
if( _startedProgress )
459
448
( (TextView)findViewById( R.id.doit_percentage ) ).setText(
460
(int)Math.round( 100 * _progress / _max_progress ) + "%" );
461
out_of.setText( _progress + "/" + _max_progress );
449
(int)Math.round( 100 * _progress / _maxProgress ) + "%" );
450
outOf.setText( _progress + "/" + _maxProgress );
462
451
bar.setProgress( _progress );