90
93
public void handleMessage( Message msg ) {
93
case MESSAGE_FINISHED_ALLDONE:
94
97
( (TextView)findViewById( R.id.doit_alldone ) ).
95
setVisibility( View.VISIBLE );
97
case MESSAGE_FINISHED:
98
( (LinearLayout)findViewById( R.id.doit_closedisplay ) ).
99
setVisibility( View.VISIBLE );
98
setVisibility( View.VISIBLE );
99
( (Button)findViewById( R.id.back ) ).setEnabled( false );
100
updateNext( NEXT_CLOSE );
101
findViewById( R.id.doit_abort_disp ).setVisibility(
101
case MESSAGE_FINISHED_GOBACK:
102
( (Button)findViewById( R.id.back ) ).setEnabled( true );
104
107
case MESSAGE_ERROR:
105
Doit.this._dialogMessage = (String)msg.obj;
108
_dialogMessage = (String)msg.obj;
106
109
showDialog( DIALOG_ERROR );
108
111
case MESSAGE_CONTINUEORABORT:
109
Doit.this._dialogMessage = (String)msg.obj;
112
_dialogMessage = (String)msg.obj;
110
113
showDialog( DIALOG_CONTINUEORABORT );
112
115
case MESSAGE_SETPROGRESSMESSAGE:
113
116
( (TextView)findViewById( R.id.doit_percentage ) ).
114
setText( (String)msg.obj );
117
setText( (String)msg.obj );
116
119
case MESSAGE_SETMAXPROGRESS:
117
120
if( _maxProgress > 0 ) {
118
if( _tmpProgress == _maxProgress )
121
if( _tmpProgress == _maxProgress - 1 )
119
122
_tmpProgress = (Integer)msg.obj;
120
if( _progress == _maxProgress )
123
if( _progress == _maxProgress - 1 )
121
124
_progress = (Integer)msg.obj;
123
126
_maxProgress = (Integer)msg.obj;
207
203
// saving the state of an import sounds complicated! Lets just abort!
210
// destroy some stuff
204
if( _nextAction != NEXT_CLOSE )
216
protected Dialog onCreateDialog(int id)
209
protected Dialog onCreateDialog( int id )
220
213
case DIALOG_ERROR:
221
214
return new AlertDialog.Builder( this )
222
.setIcon( R.drawable.alert_dialog_icon )
223
.setTitle( R.string.error_title )
225
.setPositiveButton( R.string.error_ok,
226
new DialogInterface.OnClickListener() {
215
.setIcon( R.drawable.alert_dialog_icon )
216
.setTitle( R.string.error_title )
218
.setPositiveButton( R.string.error_ok,
219
new DialogInterface.OnClickListener() {
227
220
public void onClick(DialogInterface dialog,
229
223
Doit.this._importer.wake();
232
.setOnCancelListener( _dialogOnCancelListener )
226
.setOnCancelListener( _dialogOnCancelListener )
234
228
case DIALOG_CONTINUEORABORT:
235
229
return new AlertDialog.Builder( this )
236
.setIcon( R.drawable.alert_dialog_icon )
237
.setTitle( R.string.error_title )
239
.setPositiveButton( R.string.error_continue,
240
new DialogInterface.OnClickListener() {
241
public void onClick(DialogInterface dialog,
243
Doit.this._importer.wake(
244
Importer.RESPONSE_POSITIVE );
247
.setNegativeButton( R.string.error_abort,
248
new DialogInterface.OnClickListener() {
249
public void onClick(DialogInterface dialog,
251
Doit.this._importer.wake(
252
Importer.RESPONSE_NEGATIVE );
255
.setOnCancelListener( _dialogOnCancelListener )
230
.setIcon( R.drawable.alert_dialog_icon )
231
.setTitle( R.string.error_title )
233
.setPositiveButton( R.string.error_continue,
234
new DialogInterface.OnClickListener() {
235
public void onClick(DialogInterface dialog,
238
Doit.this._importer.wake(
239
Importer.RESPONSE_POSITIVE );
242
.setNegativeButton( R.string.error_abort,
243
new DialogInterface.OnClickListener() {
244
public void onClick(DialogInterface dialog,
247
Doit.this._importer.wake(
248
Importer.RESPONSE_NEGATIVE );
251
.setOnCancelListener( _dialogOnCancelListener )
257
253
case DIALOG_MERGEPROMPT:
258
254
// custom layout in an AlertDialog
259
255
LayoutInflater factory = LayoutInflater.from( this );
260
256
final View dialogView = factory.inflate(
261
R.layout.mergeprompt, null );
257
R.layout.mergeprompt, null );
262
258
( (CheckBox)dialogView.findViewById( R.id.mergeprompt_always ) ).
263
setOnCheckedChangeListener(
264
new CompoundButton.OnCheckedChangeListener() {
265
public void onCheckedChanged( CompoundButton buttonView,
266
boolean isChecked ) {
267
Doit.this._mergePromptAlwaysSelected = isChecked;
259
setOnCheckedChangeListener(
260
new CompoundButton.OnCheckedChangeListener() {
261
public void onCheckedChanged( CompoundButton buttonView,
264
Doit.this._mergePromptAlwaysSelected = isChecked;
270
267
( (Button)dialogView.findViewById( R.id.merge_keep ) ).
271
setOnClickListener( _mergePromptButtonListener );
268
setOnClickListener( _mergePromptButtonListener );
272
269
( (Button)dialogView.findViewById( R.id.merge_overwrite ) ).
273
setOnClickListener( _mergePromptButtonListener );
270
setOnClickListener( _mergePromptButtonListener );
274
271
( (Button)dialogView.findViewById( R.id.merge_merge ) ).
275
setOnClickListener( _mergePromptButtonListener );
272
setOnClickListener( _mergePromptButtonListener );
273
( (Button)dialogView.findViewById( R.id.abort ) ).
274
setOnClickListener( _mergePromptButtonListener );
276
275
_mergePromptAlwaysSelected = false;
277
276
return new AlertDialog.Builder( this )
278
.setIcon( R.drawable.alert_dialog_icon )
279
.setTitle( R.string.mergeprompt_title )
280
.setView( dialogView )
281
.setOnCancelListener( _dialogOnCancelListener )
277
.setIcon( R.drawable.alert_dialog_icon )
278
.setTitle( R.string.mergeprompt_title )
279
.setView( dialogView )
280
.setOnCancelListener( _dialogOnCancelListener )
287
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
288
public void onClick( View view ) {
289
int responseExtra = _mergePromptAlwaysSelected?
286
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
287
public void onClick( View view )
290
if( view.getId() == R.id.abort )
293
// else, response (just check we haven't aborted already!)
294
else if( Doit.this._importer != null ) {
295
int responseExtra = _mergePromptAlwaysSelected?
290
296
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
297
Doit.this._importer.wake( convertIdToAction( view.getId() ),
301
// close dialog and free (don't keep a reference)
291
302
Doit.this._mergePromptDialog.dismiss();
292
Doit.this._mergePromptDialog = null; // don't keep a reference!
293
Doit.this._importer.wake( convertIdToAction( view.getId() ),
303
Doit.this._mergePromptDialog = null;
308
protected void onNext()
310
Button next = (Button)findViewById( R.id.next );
311
next.setEnabled( false );
313
switch( _nextAction )
319
setResult( RESULT_OK );
325
private void manualAbort()
327
manualAbort( false );
330
private void manualAbort( boolean showToasterPopup )
332
abortImport( showToasterPopup );
334
updateNext( NEXT_CLOSE );
335
( (Button)findViewById( R.id.back ) ).setEnabled( true );
336
findViewById( R.id.doit_abort_disp ).setVisibility( View.GONE );
337
( (TextView)findViewById( R.id.doit_aborted ) ).
338
setVisibility( View.VISIBLE );
339
( (TextView)findViewById( R.id.doit_alldone ) ).
340
setVisibility( View.GONE );
342
// close any open dialogs
344
dismissDialog( _currentDialogId );
346
catch( Exception e ) {
351
private void updateNext( int nextAction )
353
Button next = (Button)findViewById( R.id.next );
354
switch( nextAction ) {
355
case NEXT_BEGIN: next.setText( R.string.doit_begin ); break;
356
case NEXT_CLOSE: next.setText( R.string.doit_close ); break;
358
next.setEnabled( true );
359
_nextAction = nextAction;
298
362
public static int convertIdToAction( int id ) {
300
364
case R.id.merge_keep: return ACTION_KEEP;