/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/Doit.java

  • Committer: edam
  • Date: 2009-01-13 06:35:26 UTC
  • Revision ID: edam@waxworlds.org-20090113063526-l9t1s9git4bav60a
- new contact's phone numebrs and email addresses are added to the caches after those contacts are updated to account for the situation where the same contact is imported again from another file (or the contact exists twice in the same file!?)

Show diffs side-by-side

added added

removed removed

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