203
// close any open dialogs
205
dismissDialog( _currentDialogId );
207
catch( Exception e ) {
210
207
// saving the state of an import sounds complicated! Lets just abort!
210
// destroy some stuff
215
protected Dialog onCreateDialog( int id )
216
protected Dialog onCreateDialog(int id)
219
220
case DIALOG_ERROR:
220
221
return new AlertDialog.Builder( this )
221
.setIcon( R.drawable.alert_dialog_icon )
222
.setTitle( R.string.error_title )
224
.setPositiveButton( R.string.error_ok,
225
new DialogInterface.OnClickListener() {
222
.setIcon( R.drawable.alert_dialog_icon )
223
.setTitle( R.string.error_title )
225
.setPositiveButton( R.string.error_ok,
226
new DialogInterface.OnClickListener() {
226
227
public void onClick(DialogInterface dialog,
229
229
Doit.this._importer.wake();
232
.setOnCancelListener( _dialogOnCancelListener )
232
.setOnCancelListener( _dialogOnCancelListener )
234
234
case DIALOG_CONTINUEORABORT:
235
235
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,
244
Doit.this._importer.wake(
245
Importer.RESPONSE_POSITIVE );
248
.setNegativeButton( R.string.error_abort,
249
new DialogInterface.OnClickListener() {
250
public void onClick(DialogInterface dialog,
253
Doit.this._importer.wake(
254
Importer.RESPONSE_NEGATIVE );
257
.setOnCancelListener( _dialogOnCancelListener )
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 )
259
257
case DIALOG_MERGEPROMPT:
260
258
// custom layout in an AlertDialog
261
259
LayoutInflater factory = LayoutInflater.from( this );
262
260
final View dialogView = factory.inflate(
263
R.layout.mergeprompt, null );
261
R.layout.mergeprompt, null );
264
262
( (CheckBox)dialogView.findViewById( R.id.mergeprompt_always ) ).
265
setOnCheckedChangeListener(
266
new CompoundButton.OnCheckedChangeListener() {
267
public void onCheckedChanged( CompoundButton buttonView,
270
Doit.this._mergePromptAlwaysSelected = isChecked;
263
setOnCheckedChangeListener(
264
new CompoundButton.OnCheckedChangeListener() {
265
public void onCheckedChanged( CompoundButton buttonView,
266
boolean isChecked ) {
267
Doit.this._mergePromptAlwaysSelected = isChecked;
273
270
( (Button)dialogView.findViewById( R.id.merge_keep ) ).
274
setOnClickListener( _mergePromptButtonListener );
271
setOnClickListener( _mergePromptButtonListener );
275
272
( (Button)dialogView.findViewById( R.id.merge_overwrite ) ).
276
setOnClickListener( _mergePromptButtonListener );
273
setOnClickListener( _mergePromptButtonListener );
277
274
( (Button)dialogView.findViewById( R.id.merge_merge ) ).
278
setOnClickListener( _mergePromptButtonListener );
279
( (Button)dialogView.findViewById( R.id.abort ) ).
280
setOnClickListener( _mergePromptButtonListener );
275
setOnClickListener( _mergePromptButtonListener );
281
276
_mergePromptAlwaysSelected = false;
282
277
return new AlertDialog.Builder( this )
283
.setIcon( R.drawable.alert_dialog_icon )
284
.setTitle( R.string.mergeprompt_title )
285
.setView( dialogView )
286
.setOnCancelListener( _dialogOnCancelListener )
278
.setIcon( R.drawable.alert_dialog_icon )
279
.setTitle( R.string.mergeprompt_title )
280
.setView( dialogView )
281
.setOnCancelListener( _dialogOnCancelListener )
292
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
293
public void onClick( View view )
296
if( view.getId() == R.id.abort )
301
int responseExtra = _mergePromptAlwaysSelected?
302
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
303
Doit.this._importer.wake( convertIdToAction( view.getId() ),
307
// close dialog and free (don't keep a reference)
287
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
288
public void onClick( View view ) {
289
int responseExtra = _mergePromptAlwaysSelected?
290
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
308
291
Doit.this._mergePromptDialog.dismiss();
309
Doit.this._mergePromptDialog = null;
292
Doit.this._mergePromptDialog = null; // don't keep a reference!
293
Doit.this._importer.wake( convertIdToAction( view.getId() ),
314
protected void onNext()
316
Button next = (Button)findViewById( R.id.next );
317
next.setEnabled( false );
319
switch( _nextAction )
325
setResult( RESULT_OK );
331
private void manualAbort()
333
manualAbort( false );
336
private void manualAbort( boolean showToasterPopup )
338
abortImport( showToasterPopup );
340
updateNext( NEXT_CLOSE );
341
( (Button)findViewById( R.id.back ) ).setEnabled( true );
342
findViewById( R.id.doit_abort_disp ).setVisibility( View.GONE );
343
( (TextView)findViewById( R.id.doit_aborted ) ).
344
setVisibility( View.VISIBLE );
345
( (TextView)findViewById( R.id.doit_alldone ) ).
346
setVisibility( View.GONE );
349
private void updateNext( int nextAction )
351
Button next = (Button)findViewById( R.id.next );
352
switch( nextAction ) {
353
case NEXT_BEGIN: next.setText( R.string.doit_begin ); break;
354
case NEXT_CLOSE: next.setText( R.string.doit_close ); break;
356
next.setEnabled( true );
357
_nextAction = nextAction;
360
298
public static int convertIdToAction( int id ) {
362
300
case R.id.merge_keep: return ACTION_KEEP;