203
// close any open dialogs
205
dismissDialog( _currentDialogId );
207
catch( Exception e ) {
210
179
// saving the state of an import sounds complicated! Lets just abort!
182
// destroy some stuff
215
protected Dialog onCreateDialog( int id )
188
protected Dialog onCreateDialog(int id)
219
192
case DIALOG_ERROR:
220
193
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() {
194
.setIcon( R.drawable.alert_dialog_icon )
195
.setTitle( R.string.error_title )
197
.setPositiveButton( R.string.error_ok,
198
new DialogInterface.OnClickListener() {
226
199
public void onClick(DialogInterface dialog,
229
201
Doit.this._importer.wake();
232
.setOnCancelListener( _dialogOnCancelListener )
204
.setOnCancelListener( _dialogOnCancelListener )
234
206
case DIALOG_CONTINUEORABORT:
235
207
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 )
208
.setIcon( R.drawable.alert_dialog_icon )
209
.setTitle( R.string.error_title )
211
.setPositiveButton( R.string.error_continue,
212
new DialogInterface.OnClickListener() {
213
public void onClick(DialogInterface dialog,
215
Doit.this._importer.wake(
216
Importer.RESPONSE_POSITIVE );
219
.setNegativeButton( R.string.error_abort,
220
new DialogInterface.OnClickListener() {
221
public void onClick(DialogInterface dialog,
223
Doit.this._importer.wake(
224
Importer.RESPONSE_NEGATIVE );
227
.setOnCancelListener( _dialogOnCancelListener )
259
229
case DIALOG_MERGEPROMPT:
260
230
// custom layout in an AlertDialog
261
231
LayoutInflater factory = LayoutInflater.from( this );
262
232
final View dialogView = factory.inflate(
263
R.layout.mergeprompt, null );
233
R.layout.mergeprompt, null );
264
234
( (CheckBox)dialogView.findViewById( R.id.mergeprompt_always ) ).
265
setOnCheckedChangeListener(
266
new CompoundButton.OnCheckedChangeListener() {
267
public void onCheckedChanged( CompoundButton buttonView,
270
Doit.this._mergePromptAlwaysSelected = isChecked;
235
setOnCheckedChangeListener(
236
new CompoundButton.OnCheckedChangeListener() {
237
public void onCheckedChanged( CompoundButton buttonView,
238
boolean isChecked ) {
239
Doit.this._mergePromptAlwaysSelected = isChecked;
273
242
( (Button)dialogView.findViewById( R.id.merge_keep ) ).
274
setOnClickListener( _mergePromptButtonListener );
243
setOnClickListener( _mergePromptButtonListener );
275
244
( (Button)dialogView.findViewById( R.id.merge_overwrite ) ).
276
setOnClickListener( _mergePromptButtonListener );
245
setOnClickListener( _mergePromptButtonListener );
277
246
( (Button)dialogView.findViewById( R.id.merge_merge ) ).
278
setOnClickListener( _mergePromptButtonListener );
279
( (Button)dialogView.findViewById( R.id.abort ) ).
280
setOnClickListener( _mergePromptButtonListener );
247
setOnClickListener( _mergePromptButtonListener );
281
248
_mergePromptAlwaysSelected = false;
282
249
return new AlertDialog.Builder( this )
283
.setIcon( R.drawable.alert_dialog_icon )
284
.setTitle( R.string.mergeprompt_title )
285
.setView( dialogView )
286
.setOnCancelListener( _dialogOnCancelListener )
250
.setIcon( R.drawable.alert_dialog_icon )
251
.setTitle( R.string.mergeprompt_title )
252
.setView( dialogView )
253
.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)
259
private OnClickListener _mergePromptButtonListener = new OnClickListener() {
260
public void onClick( View view ) {
261
int responseExtra = _mergePromptAlwaysSelected?
262
Importer.RESPONSEEXTRA_ALWAYS : Importer.RESPONSEEXTRA_NONE;
308
263
Doit.this._mergePromptDialog.dismiss();
309
Doit.this._mergePromptDialog = null;
264
Doit.this._mergePromptDialog = null; // dont keep a reference!
265
Doit.this._importer.wake( view.getId(), responseExtra );
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
public static int convertIdToAction( int id ) {
362
case R.id.merge_keep: return ACTION_KEEP;
363
case R.id.merge_merge: return ACTION_MERGE_MERGE;
364
case R.id.merge_overwrite: return ACTION_OVERWRITE;
365
default: return ACTION_PROMPT;
369
public static int convertActionToId( int action ) {
371
case ACTION_KEEP: return R.id.merge_keep;
372
case ACTION_MERGE_MERGE:return R.id.merge_merge;
373
case ACTION_OVERWRITE: return R.id.merge_overwrite;
374
default: return R.id.merge_prompt;
378
269
private DialogInterface.OnCancelListener _dialogOnCancelListener =
379
270
new DialogInterface.OnCancelListener() {
380
271
public void onCancel( DialogInterface dialog ) {