/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts
6 by edam
- added GPL header comments to all files
1
/*
2
 * Doit.java
3
 *
4
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
5
 *
6
 * This file is part of the Import Contacts program (hereafter referred
7
 * to as "this program"). For more information, see
8
 * http://www.waxworlds.org/edam/software/android/import-contacts
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
24
package org.waxworlds.edam.importcontacts;
1 by edam
Initial import
25
26
import android.app.AlertDialog;
27
import android.app.Dialog;
28
import android.content.DialogInterface;
29
import android.content.Intent;
30
import android.os.Bundle;
31
import android.os.Handler;
32
import android.os.Message;
33
import android.view.LayoutInflater;
34
import android.view.View;
35
import android.view.View.OnClickListener;
36
import android.widget.Button;
37
import android.widget.CheckBox;
38
import android.widget.CompoundButton;
39
import android.widget.ProgressBar;
40
import android.widget.TextView;
2 by edam
- added toaster message about import abortion in onPause()
41
import android.widget.Toast;
1 by edam
Initial import
42
43
public class Doit extends WizardActivity
44
{
45
	private final static int DIALOG_ERROR = 0;
46
	private final static int DIALOG_CONTINUEORABORT = 1;
47
	private final static int DIALOG_MERGEPROMPT = 2;
48
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
49
	public final static int MESSAGE_ALLDONE = 0;
50
	public final static int MESSAGE_ABORT = 1;
3 by edam
- added "all done" message
51
	public final static int MESSAGE_ERROR = 3;
52
	public final static int MESSAGE_CONTINUEORABORT = 4;
53
	public final static int MESSAGE_SETPROGRESSMESSAGE = 5;
54
	public final static int MESSAGE_SETMAXPROGRESS = 6;
55
	public final static int MESSAGE_SETTMPPROGRESS = 7;
56
	public final static int MESSAGE_SETPROGRESS = 8;
57
	public final static int MESSAGE_MERGEPROMPT = 9;
58
	public final static int MESSAGE_CONTACTOVERWRITTEN = 10;
59
	public final static int MESSAGE_CONTACTCREATED = 11;
60
	public final static int MESSAGE_CONTACTMERGED = 12;
61
	public final static int MESSAGE_CONTACTSKIPPED = 13;
62
9 by edam
- added scroll view to all layouts
63
	public final static int ACTION_PROMPT = 0;
64
	public final static int ACTION_KEEP = 1;
65
	public final static int ACTION_MERGE_MERGE = 2;
66
	public final static int ACTION_OVERWRITE = 3;
67
10 by edam
- made behaviour of next button overridable
68
	public final static int NEXT_BEGIN = 0;
69
	public final static int NEXT_CLOSE = 1;
70
41 by edam
- updated TODO
71
	private boolean _started_progress;
72
	private int _max_progress;
73
	private int _tmp_progress;
1 by edam
Initial import
74
	private int _progress;
41 by edam
- updated TODO
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;
1 by edam
Initial import
80
41 by edam
- updated TODO
81
	private int _count_overwrites;
82
	private int _count_creates;
83
	private int _count_merges;
84
	private int _count_skips;
1 by edam
Initial import
85
3 by edam
- added "all done" message
86
	protected Importer _importer = null;
1 by edam
Initial import
87
88
	public Handler _handler;
89
90
	public class DoitHandler extends Handler
91
	{
92
		@Override
93
		public void handleMessage( Message msg ) {
94
			switch( msg.what )
95
			{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
96
			case MESSAGE_ALLDONE:
3 by edam
- added "all done" message
97
				( (TextView)findViewById( R.id.doit_alldone ) ).
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
98
					setVisibility( View.VISIBLE );
99
				( (Button)findViewById( R.id.back ) ).setEnabled( false );
10 by edam
- made behaviour of next button overridable
100
				updateNext( NEXT_CLOSE );
101
				findViewById( R.id.doit_abort_disp ).setVisibility(
36 by edam
- formatting: removed some double-indents on overrunning lines
102
					View.GONE );
1 by edam
Initial import
103
				break;
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
104
			case MESSAGE_ABORT:
105
				manualAbort();
1 by edam
Initial import
106
				break;
3 by edam
- added "all done" message
107
			case MESSAGE_ERROR:
41 by edam
- updated TODO
108
				_dialog_message = (String)msg.obj;
1 by edam
Initial import
109
				showDialog( DIALOG_ERROR );
110
				break;
3 by edam
- added "all done" message
111
			case MESSAGE_CONTINUEORABORT:
41 by edam
- updated TODO
112
				_dialog_message = (String)msg.obj;
1 by edam
Initial import
113
				showDialog( DIALOG_CONTINUEORABORT );
114
				break;
3 by edam
- added "all done" message
115
			case MESSAGE_SETPROGRESSMESSAGE:
1 by edam
Initial import
116
				( (TextView)findViewById( R.id.doit_percentage ) ).
36 by edam
- formatting: removed some double-indents on overrunning lines
117
					setText( (String)msg.obj );
1 by edam
Initial import
118
				break;
3 by edam
- added "all done" message
119
			case MESSAGE_SETMAXPROGRESS:
41 by edam
- updated TODO
120
				if( _max_progress > 0 ) {
121
					if( _tmp_progress == _max_progress - 1 )
122
						_tmp_progress = (Integer)msg.obj;
123
					if( _progress == _max_progress - 1 )
1 by edam
Initial import
124
						_progress = (Integer)msg.obj;
125
				}
41 by edam
- updated TODO
126
				_max_progress = (Integer)msg.obj;
1 by edam
Initial import
127
				updateProgress();
128
				break;
3 by edam
- added "all done" message
129
			case MESSAGE_SETTMPPROGRESS:
41 by edam
- updated TODO
130
				_tmp_progress = (Integer)msg.obj;
1 by edam
Initial import
131
				updateProgress();
132
				break;
3 by edam
- added "all done" message
133
			case MESSAGE_SETPROGRESS:
41 by edam
- updated TODO
134
				_started_progress = true;
1 by edam
Initial import
135
				_progress = (Integer)msg.obj;
136
				updateProgress();
137
				break;
3 by edam
- added "all done" message
138
			case MESSAGE_MERGEPROMPT:
41 by edam
- updated TODO
139
				_dialog_message = (String)msg.obj;
1 by edam
Initial import
140
				showDialog( DIALOG_MERGEPROMPT );
141
				break;
3 by edam
- added "all done" message
142
			case MESSAGE_CONTACTOVERWRITTEN:
41 by edam
- updated TODO
143
				_count_overwrites++;
1 by edam
Initial import
144
				updateStats();
145
				break;
3 by edam
- added "all done" message
146
			case MESSAGE_CONTACTCREATED:
41 by edam
- updated TODO
147
				_count_creates++;
1 by edam
Initial import
148
				updateStats();
149
				break;
3 by edam
- added "all done" message
150
			case MESSAGE_CONTACTMERGED:
41 by edam
- updated TODO
151
				_count_merges++;
1 by edam
Initial import
152
				updateStats();
153
				break;
3 by edam
- added "all done" message
154
			case MESSAGE_CONTACTSKIPPED:
41 by edam
- updated TODO
155
				_count_skips++;
1 by edam
Initial import
156
				updateStats();
157
				break;
158
			default:
159
				super.handleMessage( msg );
160
			}
161
		}
162
	}
163
164
	@Override
41 by edam
- updated TODO
165
	protected void onCreate(Bundle saved_instance_state)
1 by edam
Initial import
166
	{
167
		setContentView( R.layout.doit );
41 by edam
- updated TODO
168
		super.onCreate( saved_instance_state );
1 by edam
Initial import
169
170
		// hide page 2
171
		( findViewById( R.id.doit_page_2 ) ).setVisibility( View.GONE );
172
10 by edam
- made behaviour of next button overridable
173
		// set up abort button
174
		Button begin = (Button)findViewById( R.id.abort );
1 by edam
Initial import
175
		begin.setOnClickListener( new View.OnClickListener() {
176
			public void onClick( View view ) {
10 by edam
- made behaviour of next button overridable
177
				manualAbort();
1 by edam
Initial import
178
			}
179
		} );
180
41 by edam
- updated TODO
181
		_started_progress = false;
182
		_max_progress = 0;
183
		_tmp_progress = 0;
1 by edam
Initial import
184
		_progress = 0;
185
		_handler = new DoitHandler();
186
41 by edam
- updated TODO
187
		_count_overwrites = 0;
188
		_count_creates = 0;
189
		_count_merges = 0;
190
		_count_skips = 0;
1 by edam
Initial import
191
10 by edam
- made behaviour of next button overridable
192
		updateNext( NEXT_BEGIN );
193
1 by edam
Initial import
194
		updateProgress();
195
		updateStats();
196
	}
197
198
	@Override
199
	protected void onPause()
200
	{
201
		super.onPause();
202
2 by edam
- added toaster message about import abortion in onPause()
203
		// saving the state of an import sounds complicated! Lets just abort!
41 by edam
- updated TODO
204
		if( _next_action != NEXT_CLOSE )
19 by edam
- added file chooser
205
			manualAbort( true );
1 by edam
Initial import
206
	}
207
208
	@Override
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
209
	protected Dialog onCreateDialog( int id )
1 by edam
Initial import
210
	{
211
		switch( id )
212
		{
213
		case DIALOG_ERROR:
214
			return new AlertDialog.Builder( this )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
215
				.setIcon( R.drawable.alert_dialog_icon )
216
				.setTitle( R.string.error_title )
217
				.setMessage( "" )
218
				.setPositiveButton( R.string.error_ok,
219
					new DialogInterface.OnClickListener() {
41 by edam
- updated TODO
220
						public void onClick( DialogInterface dialog,
221
							int whichButton )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
222
						{
1 by edam
Initial import
223
							Doit.this._importer.wake();
224
						}
225
					} )
41 by edam
- updated TODO
226
				.setOnCancelListener( _dialog_on_cancel_listener )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
227
				.create();
1 by edam
Initial import
228
		case DIALOG_CONTINUEORABORT:
229
			return new AlertDialog.Builder( this )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
230
				.setIcon( R.drawable.alert_dialog_icon )
231
				.setTitle( R.string.error_title )
232
				.setMessage( "" )
233
				.setPositiveButton( R.string.error_continue,
234
					new DialogInterface.OnClickListener() {
41 by edam
- updated TODO
235
						public void onClick( DialogInterface dialog,
236
							int which_button )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
237
						{
238
							Doit.this._importer.wake(
239
								Importer.RESPONSE_POSITIVE );
240
						}
241
					} )
242
				.setNegativeButton( R.string.error_abort,
243
					new DialogInterface.OnClickListener() {
41 by edam
- updated TODO
244
						public void onClick( DialogInterface dialog,
245
							int which_button )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
246
						{
247
							Doit.this._importer.wake(
248
								Importer.RESPONSE_NEGATIVE );
249
						}
250
					} )
41 by edam
- updated TODO
251
				.setOnCancelListener( _dialog_on_cancel_listener )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
252
				.create();
1 by edam
Initial import
253
		case DIALOG_MERGEPROMPT:
254
			// custom layout in an AlertDialog
255
			LayoutInflater factory = LayoutInflater.from( this );
41 by edam
- updated TODO
256
			final View dialog_view = factory.inflate(
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
257
				R.layout.mergeprompt, null );
41 by edam
- updated TODO
258
			( (CheckBox)dialog_view.findViewById( R.id.mergeprompt_always ) ).
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
259
				setOnCheckedChangeListener(
260
					new CompoundButton.OnCheckedChangeListener() {
41 by edam
- updated TODO
261
						public void onCheckedChanged(
262
							CompoundButton button_view, boolean is_checked )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
263
						{
41 by edam
- updated TODO
264
							Doit.this._merge_prompt_always_selected =
265
								is_checked;
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
266
						}
267
					} );
41 by edam
- updated TODO
268
			( (Button)dialog_view.findViewById( R.id.merge_keep ) ).
269
				setOnClickListener( _merge_prompt_button_listener );
270
			( (Button)dialog_view.findViewById( R.id.merge_overwrite ) ).
271
				setOnClickListener( _merge_prompt_button_listener );
272
			( (Button)dialog_view.findViewById( R.id.merge_merge ) ).
273
				setOnClickListener( _merge_prompt_button_listener );
274
			( (Button)dialog_view.findViewById( R.id.abort ) ).
275
				setOnClickListener( _merge_prompt_button_listener );
276
			_merge_prompt_always_selected = false;
1 by edam
Initial import
277
			return new AlertDialog.Builder( this )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
278
				.setIcon( R.drawable.alert_dialog_icon )
279
				.setTitle( R.string.mergeprompt_title )
41 by edam
- updated TODO
280
				.setView( dialog_view )
281
				.setOnCancelListener( _dialog_on_cancel_listener )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
282
				.create();
1 by edam
Initial import
283
		}
284
		return null;
285
	}
286
41 by edam
- updated TODO
287
	private OnClickListener _merge_prompt_button_listener =
288
		new OnClickListener()
289
	{
10 by edam
- made behaviour of next button overridable
290
		public void onClick( View view )
291
		{
292
			// handle abort
293
			if( view.getId() == R.id.abort )
294
				manualAbort();
295
19 by edam
- added file chooser
296
			// else, response (just check we haven't aborted already!)
297
			else if( Doit.this._importer != null ) {
41 by edam
- updated TODO
298
				int response_extra = _merge_prompt_always_selected?
36 by edam
- formatting: removed some double-indents on overrunning lines
299
					Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
10 by edam
- made behaviour of next button overridable
300
				Doit.this._importer.wake( convertIdToAction( view.getId() ),
41 by edam
- updated TODO
301
					response_extra );
10 by edam
- made behaviour of next button overridable
302
			}
303
304
			// close dialog and free (don't keep a reference)
41 by edam
- updated TODO
305
			Doit.this._merge_prompt_dialog.dismiss();
306
			Doit.this._merge_prompt_dialog = null;
1 by edam
Initial import
307
		}
308
	};
309
10 by edam
- made behaviour of next button overridable
310
	@Override
311
	protected void onNext()
312
	{
313
		Button next = (Button)findViewById( R.id.next );
314
		next.setEnabled( false );
315
41 by edam
- updated TODO
316
		switch( _next_action )
10 by edam
- made behaviour of next button overridable
317
		{
318
		case NEXT_BEGIN:
319
			importContacts();
320
			break;
321
		case NEXT_CLOSE:
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
322
			setResult( RESULT_OK );
10 by edam
- made behaviour of next button overridable
323
			finish();
324
			break;
325
		}
326
	}
327
328
	private void manualAbort()
329
	{
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
330
		manualAbort( false );
331
	}
332
41 by edam
- updated TODO
333
	private void manualAbort( boolean show_toaster_popup )
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
334
	{
41 by edam
- updated TODO
335
		abortImport( show_toaster_popup );
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
336
10 by edam
- made behaviour of next button overridable
337
		updateNext( NEXT_CLOSE );
338
		( (Button)findViewById( R.id.back ) ).setEnabled( true );
339
		findViewById( R.id.doit_abort_disp ).setVisibility( View.GONE );
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
340
		( (TextView)findViewById( R.id.doit_aborted ) ).
341
			setVisibility( View.VISIBLE );
342
		( (TextView)findViewById( R.id.doit_alldone ) ).
343
			setVisibility( View.GONE );
19 by edam
- added file chooser
344
345
		// close any open dialogs
346
		try {
41 by edam
- updated TODO
347
			dismissDialog( _current_dialog_id );
19 by edam
- added file chooser
348
		}
349
		catch( Exception e ) {
36 by edam
- formatting: removed some double-indents on overrunning lines
350
			// ignore errors
19 by edam
- added file chooser
351
		}
10 by edam
- made behaviour of next button overridable
352
	}
353
41 by edam
- updated TODO
354
	private void updateNext( int next_action )
10 by edam
- made behaviour of next button overridable
355
	{
356
		Button next = (Button)findViewById( R.id.next );
41 by edam
- updated TODO
357
		switch( next_action ) {
10 by edam
- made behaviour of next button overridable
358
		case NEXT_BEGIN:	next.setText( R.string.doit_begin ); break;
359
		case NEXT_CLOSE:	next.setText( R.string.doit_close ); break;
360
		}
361
		next.setEnabled( true );
41 by edam
- updated TODO
362
		_next_action = next_action;
10 by edam
- made behaviour of next button overridable
363
	}
364
9 by edam
- added scroll view to all layouts
365
	public static int convertIdToAction( int id ) {
366
		switch( id ) {
367
		case R.id.merge_keep:		return ACTION_KEEP;
368
		case R.id.merge_merge:		return ACTION_MERGE_MERGE;
369
		case R.id.merge_overwrite:	return ACTION_OVERWRITE;
370
		default: return ACTION_PROMPT;
371
		}
372
	}
373
374
	public static int convertActionToId( int action ) {
375
		switch( action ) {
376
		case ACTION_KEEP:		return R.id.merge_keep;
377
		case ACTION_MERGE_MERGE:return R.id.merge_merge;
378
		case ACTION_OVERWRITE:	return R.id.merge_overwrite;
379
		default: return R.id.merge_prompt;
380
		}
381
	}
382
41 by edam
- updated TODO
383
	private DialogInterface.OnCancelListener _dialog_on_cancel_listener =
384
		new DialogInterface.OnCancelListener()
385
	{
1 by edam
Initial import
386
		public void onCancel( DialogInterface dialog ) {
19 by edam
- added file chooser
387
			manualAbort();
1 by edam
Initial import
388
		}
389
	};
390
19 by edam
- added file chooser
391
1 by edam
Initial import
392
	@Override
41 by edam
- updated TODO
393
	protected void onActivityResult( int request_code, int result_code,
394
		Intent data )
1 by edam
Initial import
395
	{
2 by edam
- added toaster message about import abortion in onPause()
396
		// if we're cancelling, abort any import
41 by edam
- updated TODO
397
		if( result_code == RESULT_CANCELED )
10 by edam
- made behaviour of next button overridable
398
			abortImport( true );
1 by edam
Initial import
399
	}
400
401
	@Override
41 by edam
- updated TODO
402
	protected void onPrepareDialog( int id, Dialog dialog )
1 by edam
Initial import
403
	{
41 by edam
- updated TODO
404
		_current_dialog_id = id;
14 by edam
- got rid of the pretend ImportContacts activity alltogether (and made the Intro activity the startup one)
405
1 by edam
Initial import
406
		switch( id )
407
		{
408
		case DIALOG_ERROR:	// fall through
409
		case DIALOG_CONTINUEORABORT:
410
			// set dialog message
41 by edam
- updated TODO
411
			( (AlertDialog)dialog ).setMessage( _dialog_message );
1 by edam
Initial import
412
			break;
413
		case DIALOG_MERGEPROMPT:
414
			// set contact's name
41 by edam
- updated TODO
415
			( (TextView)dialog.findViewById( R.id.mergeprompt_name ) )
416
				.setText( _dialog_message );
1 by edam
Initial import
417
			// and set up reference to dialog
41 by edam
- updated TODO
418
			_merge_prompt_dialog = dialog;
1 by edam
Initial import
419
			break;
420
		}
421
422
		super.onPrepareDialog( id, dialog );
423
	}
424
425
	private void importContacts()
426
	{
427
		// switch interfaces
428
		( findViewById( R.id.doit_page_1 ) ).setVisibility( View.GONE );
429
		( findViewById( R.id.doit_page_2 ) ).setVisibility( View.VISIBLE );
430
431
		// disable back button
432
		( (Button)findViewById( R.id.back ) ).setEnabled( false );
433
434
		// create importer
435
		_importer = new VCFImporter( this );
436
437
		// start the service's thread
438
		_importer.start();
439
	}
440
441
	private void updateProgress()
442
	{
443
		ProgressBar bar = (ProgressBar)findViewById( R.id.doit_progress );
41 by edam
- updated TODO
444
		TextView out_of = (TextView)findViewById( R.id.doit_outof );
1 by edam
Initial import
445
41 by edam
- updated TODO
446
		if( _max_progress > 0 )
1 by edam
Initial import
447
		{
41 by edam
- updated TODO
448
			bar.setMax( _max_progress );
449
			bar.setSecondaryProgress( _tmp_progress );
1 by edam
Initial import
450
41 by edam
- updated TODO
451
			if( _started_progress )
1 by edam
Initial import
452
			{
453
				( (TextView)findViewById( R.id.doit_percentage ) ).setText(
41 by edam
- updated TODO
454
					(int)Math.round( 100 * _progress / _max_progress ) + "%" );
455
				out_of.setText( _progress + "/" + _max_progress );
1 by edam
Initial import
456
				bar.setProgress( _progress );
457
			}
458
		}
459
	}
460
461
	private void updateStats()
462
	{
463
		( (TextView)findViewById( R.id.doit_overwrites ) ).setText(
41 by edam
- updated TODO
464
			"" + _count_overwrites );
1 by edam
Initial import
465
		( (TextView)findViewById( R.id.doit_creates ) ).setText(
41 by edam
- updated TODO
466
			"" + _count_creates );
1 by edam
Initial import
467
		( (TextView)findViewById( R.id.doit_merges ) ).setText(
41 by edam
- updated TODO
468
			"" + _count_merges );
1 by edam
Initial import
469
		( (TextView)findViewById( R.id.doit_skips ) ).setText(
41 by edam
- updated TODO
470
			"" + _count_skips );
1 by edam
Initial import
471
	}
472
41 by edam
- updated TODO
473
	private void abortImport( boolean show_toaster_popup )
1 by edam
Initial import
474
	{
475
		if( _importer != null )
476
		{
3 by edam
- added "all done" message
477
			// try and flag worker thread - did we need to?
478
			if( _importer.setAbort() )
479
			{
480
				// wait for worker thread to end
481
				while( true ) {
482
					try {
483
						_importer.join();
484
						break;
485
					}
486
					catch( InterruptedException e ) {}
1 by edam
Initial import
487
				}
3 by edam
- added "all done" message
488
489
				// notify the user
41 by edam
- updated TODO
490
				if( show_toaster_popup )
10 by edam
- made behaviour of next button overridable
491
					Toast.makeText( this, R.string.doit_importaborted,
36 by edam
- formatting: removed some double-indents on overrunning lines
492
						Toast.LENGTH_LONG ).show();
1 by edam
Initial import
493
			}
494
		}
10 by edam
- made behaviour of next button overridable
495
496
		// destroy some stuff
497
		_importer = null;
498
		_handler = null;
1 by edam
Initial import
499
	}
500
}