From 3ee0889529737bfb2d6207164367a1444aba8999 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 16 Feb 2012 14:43:38 +0100 Subject: [PATCH] Use the Androiod framework for the file manager error dialog This will automatically recreate the dialog on configuration changes (e.g. orientation change). --- src/com/fsck/k9/activity/Accounts.java | 38 ++++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 9ac2a5926..031785e62 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -120,6 +120,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC private static final int DIALOG_REMOVE_ACCOUNT = 1; private static final int DIALOG_CLEAR_ACCOUNT = 2; private static final int DIALOG_RECREATE_ACCOUNT = 3; + private static final int DIALOG_NO_FILE_MANAGER = 4; + private ConcurrentHashMap accountStats = new ConcurrentHashMap(); private ConcurrentHashMap pendingWork = new ConcurrentHashMap(); @@ -986,6 +988,20 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC } } }); + case DIALOG_NO_FILE_MANAGER: + return ConfirmationDialog.create(this, id, + R.string.import_dialog_error_title, + getString(R.string.import_dialog_error_message), + R.string.open_market, + R.string.close, + new Runnable() { + @Override + public void run() { + Uri uri = Uri.parse(ANDROID_MARKET_URL); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + } + }); } return super.onCreateDialog(id); } @@ -1007,6 +1023,9 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt, mSelectedContextAccount.getDescription())); break; + case DIALOG_NO_FILE_MANAGER: + alert.setMessage(getString(R.string.import_dialog_error_message)); + break; } super.onPrepareDialog(id, d); @@ -1270,24 +1289,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE); } else { - DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int button) { - if (button == DialogInterface.BUTTON_POSITIVE) { - Uri uri = Uri.parse(ANDROID_MARKET_URL); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(intent); - } else if (button == DialogInterface.BUTTON_NEGATIVE) { - dialog.dismiss(); - } - } - }; - - new AlertDialog.Builder(this) - .setTitle(getString(R.string.import_dialog_error_title)) - .setMessage(getString(R.string.import_dialog_error_message)) - .setPositiveButton(getString(R.string.open_market), listener) - .setNegativeButton(getString(R.string.close), listener) - .show(); + showDialog(DIALOG_NO_FILE_MANAGER); } }