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

  • Committer: edam
  • Date: 2010-10-17 18:43:13 UTC
  • Revision ID: edam@waxworlds.org-20101017184313-y2m6gsdzctjq5wtl
- changed case on charset and encoding warning strings (it looked bad)
- properly handle quoted-printable unencoding (including multi-line values)
- ignore blank lines in vCard
- ignore empty properties in vCard

Show diffs side-by-side

added added

removed removed

99
99
                                ( (Button)findViewById( R.id.back ) ).setEnabled( false );
100
100
                                updateNext( NEXT_CLOSE );
101
101
                                findViewById( R.id.doit_abort_disp ).setVisibility(
102
 
                                        View.GONE );
 
102
                                                View.GONE );
103
103
                                break;
104
104
                        case MESSAGE_ABORT:
105
105
                                manualAbort();
114
114
                                break;
115
115
                        case MESSAGE_SETPROGRESSMESSAGE:
116
116
                                ( (TextView)findViewById( R.id.doit_percentage ) ).
117
 
                                        setText( (String)msg.obj );
 
117
                                                setText( (String)msg.obj );
118
118
                                break;
119
119
                        case MESSAGE_SETMAXPROGRESS:
120
120
                                if( _maxProgress > 0 ) {
200
200
        {
201
201
                super.onPause();
202
202
 
 
203
                // close any open dialogs
 
204
                try {
 
205
                        dismissDialog( _currentDialogId );
 
206
                }
 
207
                catch( Exception e ) {
 
208
                }
 
209
 
203
210
                // saving the state of an import sounds complicated! Lets just abort!
204
 
                if( _nextAction != NEXT_CLOSE )
205
 
                        manualAbort( true );
 
211
                manualAbort( true );
206
212
        }
207
213
 
208
214
        @Override
290
296
                        if( view.getId() == R.id.abort )
291
297
                                manualAbort();
292
298
 
293
 
                        // else, response (just check we haven't aborted already!)
294
 
                        else if( Doit.this._importer != null ) {
 
299
                        // else, response
 
300
                        else {
295
301
                                int responseExtra = _mergePromptAlwaysSelected?
296
 
                                        Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
 
302
                                                Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
297
303
                                Doit.this._importer.wake( convertIdToAction( view.getId() ),
298
 
                                        responseExtra );
 
304
                                                responseExtra );
299
305
                        }
300
306
 
301
307
                        // close dialog and free (don't keep a reference)
338
344
                        setVisibility( View.VISIBLE );
339
345
                ( (TextView)findViewById( R.id.doit_alldone ) ).
340
346
                        setVisibility( View.GONE );
341
 
 
342
 
                // close any open dialogs
343
 
                try {
344
 
                        dismissDialog( _currentDialogId );
345
 
                }
346
 
                catch( Exception e ) {
347
 
                        // ignore errors
348
 
                }
349
347
        }
350
348
 
351
349
        private void updateNext( int nextAction )
380
378
        private DialogInterface.OnCancelListener _dialogOnCancelListener =
381
379
                        new DialogInterface.OnCancelListener() {
382
380
                public void onCancel( DialogInterface dialog ) {
383
 
                        manualAbort();
 
381
                        setResult( RESULT_CANCELED );
 
382
                        finish();
384
383
                }
385
384
        };
386
385
 
387
 
 
388
386
        @Override
389
387
        protected void onActivityResult( int requestCode, int resultCode,
390
388
                        Intent data )
409
407
                case DIALOG_MERGEPROMPT:
410
408
                        // set contact's name
411
409
                        ( (TextView)dialog.findViewById( R.id.mergeprompt_name ) ).setText(
412
 
                                _dialogMessage );
 
410
                                        _dialogMessage );
413
411
                        // and set up reference to dialog
414
412
                        _mergePromptDialog = dialog;
415
413
                        break;
447
445
                        if( _startedProgress )
448
446
                        {
449
447
                                ( (TextView)findViewById( R.id.doit_percentage ) ).setText(
450
 
                                        (int)Math.round( 100 * _progress / _maxProgress ) + "%" );
 
448
                                                (int)Math.round( 100 * _progress / _maxProgress ) + "%" );
451
449
                                outOf.setText( _progress + "/" + _maxProgress );
452
450
                                bar.setProgress( _progress );
453
451
                        }
457
455
        private void updateStats()
458
456
        {
459
457
                ( (TextView)findViewById( R.id.doit_overwrites ) ).setText(
460
 
                        "" + _countOverwrites );
 
458
                                "" + _countOverwrites );
461
459
                ( (TextView)findViewById( R.id.doit_creates ) ).setText(
462
 
                        "" + _countCreates );
 
460
                                "" + _countCreates );
463
461
                ( (TextView)findViewById( R.id.doit_merges ) ).setText(
464
 
                        "" + _countMerges );
 
462
                                "" + _countMerges );
465
463
                ( (TextView)findViewById( R.id.doit_skips ) ).setText(
466
 
                        "" + _countSkips );
 
464
                                "" + _countSkips );
467
465
        }
468
466
 
469
467
        private void abortImport( boolean showToasterPopup )
485
483
                                // notify the user
486
484
                                if( showToasterPopup )
487
485
                                        Toast.makeText( this, R.string.doit_importaborted,
488
 
                                                Toast.LENGTH_LONG ).show();
 
486
                                                        Toast.LENGTH_LONG ).show();
489
487
                        }
490
488
                }
491
489