From 077524b41aab453ea5895eff4bc394fec7430671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 15 Aug 2013 18:56:04 +0200 Subject: AlertDialog for failed downloads. The dialog shows only an "OK" button to dismiss it, and the reason why the download failed. Right now, this dialog appears if a download is not successful. If it's too intrusive, I can remove some cases. Let's try how it feels. --- src/se/leap/bitmaskclient/ConfigurationWizard.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/se/leap/bitmaskclient/ConfigurationWizard.java') diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java index a0ac1bc2..92e637b8 100644 --- a/src/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java @@ -124,8 +124,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn //Toast.makeText(this, getResources().getString(R.string.config_error_parsing), Toast.LENGTH_LONG); setResult(RESULT_CANCELED, mConfigState); } - } + } else if(resultCode == ProviderAPI.INCORRECTLY_UPDATED_PROVIDER_DOT_JSON) { + String reason_to_fail = resultData.getString(ProviderAPI.ERRORS); + showDownloadFailedDialog(getCurrentFocus(), reason_to_fail); mProgressDialog.dismiss(); setResult(RESULT_CANCELED, mConfigState); } @@ -142,8 +144,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn } } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_JSON_FILES) { - //Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_json_files_message, Toast.LENGTH_LONG).show(); - mProgressDialog.dismiss(); + //Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_json_files_message, Toast.LENGTH_LONG).show(); + mProgressDialog.dismiss(); + String reason_to_fail = resultData.getString(ProviderAPI.ERRORS); + showDownloadFailedDialog(getCurrentFocus(), reason_to_fail); setResult(RESULT_CANCELED, mConfigState); } else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) { @@ -314,6 +318,25 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn newFragment.show(fragment_transaction, NewProviderDialog.TAG); } + /** + * Once selected a provider, this fragment offers the user to log in, + * use it anonymously (if possible) + * or cancel his/her election pressing the back button. + * @param view + * @param reason_to_fail + */ + public void showDownloadFailedDialog(View view, String reason_to_fail) { + FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction(); + Fragment previous_provider_details_dialog = getFragmentManager().findFragmentByTag(DownloadFailedDialog.TAG); + if (previous_provider_details_dialog != null) { + fragment_transaction.remove(previous_provider_details_dialog); + } + fragment_transaction.addToBackStack(null); + + DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail); + newFragment.show(fragment_transaction, DownloadFailedDialog.TAG); + } + /** * Once selected a provider, this fragment offers the user to log in, * use it anonymously (if possible) -- cgit v1.2.3 From cc794fbbb09b2ff9fdcaaf199dbaa4816a92df87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 3 Oct 2013 11:23:29 +0200 Subject: Fixed a typo in the rebase. --- src/se/leap/bitmaskclient/ConfigurationWizard.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/se/leap/bitmaskclient/ConfigurationWizard.java') diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java index 92e637b8..c03d7c9e 100644 --- a/src/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java @@ -145,7 +145,6 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_JSON_FILES) { //Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_json_files_message, Toast.LENGTH_LONG).show(); - mProgressDialog.dismiss(); String reason_to_fail = resultData.getString(ProviderAPI.ERRORS); showDownloadFailedDialog(getCurrentFocus(), reason_to_fail); setResult(RESULT_CANCELED, mConfigState); -- cgit v1.2.3