1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-18 05:42:15 -05:00

Use the Androiod framework for the file manager error dialog

This will automatically recreate the dialog on configuration changes
(e.g. orientation change).
This commit is contained in:
cketti 2012-02-16 14:43:38 +01:00
parent ddbd46666a
commit 3ee0889529

View File

@ -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_REMOVE_ACCOUNT = 1;
private static final int DIALOG_CLEAR_ACCOUNT = 2; private static final int DIALOG_CLEAR_ACCOUNT = 2;
private static final int DIALOG_RECREATE_ACCOUNT = 3; private static final int DIALOG_RECREATE_ACCOUNT = 3;
private static final int DIALOG_NO_FILE_MANAGER = 4;
private ConcurrentHashMap<String, AccountStats> accountStats = new ConcurrentHashMap<String, AccountStats>(); private ConcurrentHashMap<String, AccountStats> accountStats = new ConcurrentHashMap<String, AccountStats>();
private ConcurrentHashMap<BaseAccount, String> pendingWork = new ConcurrentHashMap<BaseAccount, String>(); private ConcurrentHashMap<BaseAccount, String> pendingWork = new ConcurrentHashMap<BaseAccount, String>();
@ -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); 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, alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt,
mSelectedContextAccount.getDescription())); mSelectedContextAccount.getDescription()));
break; break;
case DIALOG_NO_FILE_MANAGER:
alert.setMessage(getString(R.string.import_dialog_error_message));
break;
} }
super.onPrepareDialog(id, d); super.onPrepareDialog(id, d);
@ -1270,24 +1289,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
startActivityForResult(Intent.createChooser(i, null), startActivityForResult(Intent.createChooser(i, null),
ACTIVITY_REQUEST_PICK_SETTINGS_FILE); ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
} else { } else {
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { showDialog(DIALOG_NO_FILE_MANAGER);
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();
} }
} }