1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Change import/export completion Toasts to Dialogs.

This commit is contained in:
danapple 2011-03-01 21:21:00 -06:00
parent 8a3e1336e0
commit 9cd5f61539
3 changed files with 43 additions and 14 deletions

View File

@ -1040,6 +1040,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="settings_import_success_single">Imported 1 account from <xliff:g id="filename">%s</xliff:g></string>
<string name="settings_export_failure">Failed to export settings: <xliff:g id="reason">%s</xliff:g></string>
<string name="settings_import_failure">Failed from import settings from <xliff:g id="filename">%s</xliff:g>:<xliff:g id="reason">%s</xliff:g></string>
<string name="settings_export_success_header">Export succeeded</string>
<string name="settings_export_failed_header">Export failed</string>
<string name="settings_import_success_header">Import succeeded</string>
<string name="settings_import_failed_header">Import failed</string>
</resources>

View File

@ -1,6 +1,7 @@
package com.fsck.k9.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
@ -815,9 +816,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public void run()
{
mHandler.progress(false);
String toastText = Accounts.this.getString(R.string.settings_import_failure, fileName, message );
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
toast.show();
showDialog(Accounts.this, R.string.settings_import_failed_header, Accounts.this.getString(R.string.settings_import_failure, fileName, message));
}
});
}
@ -829,12 +828,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public void run()
{
mHandler.progress(false);
String toastText =
String messageText =
numAccounts != 1
? Accounts.this.getString(R.string.settings_import_success_multiple, numAccounts, fileName )
: Accounts.this.getString(R.string.settings_import_success_single, fileName );
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
toast.show();
showDialog(Accounts.this, R.string.settings_import_success_header, messageText);
refresh();
}
});
@ -855,6 +853,22 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
toast.show();
}
}
private static void showDialog(final Activity activity, int headerRes, String message)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(headerRes);
builder.setMessage(message);
builder.setPositiveButton(R.string.okay_action,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
class AccountsAdapter extends ArrayAdapter<BaseAccount> {
public AccountsAdapter(BaseAccount[] accounts) {

View File

@ -1,6 +1,8 @@
package com.fsck.k9.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Toast;
import com.fsck.k9.Account;
@ -25,9 +27,7 @@ public class ExportHelper {
activity.runOnUiThread(new Runnable() {
public void run() {
progressable.setProgress(false);
String toastText = activity.getString(R.string.settings_export_failure, message);
Toast toast = Toast.makeText(activity.getApplication(), toastText, Toast.LENGTH_LONG);
toast.show();
showDialog(activity, R.string.settings_export_failed_header, activity.getString(R.string.settings_export_failure, message));
}
});
}
@ -36,9 +36,7 @@ public class ExportHelper {
activity.runOnUiThread(new Runnable() {
public void run() {
progressable.setProgress(false);
String toastText = activity.getString(R.string.settings_export_success, fileName);
Toast toast = Toast.makeText(activity.getApplication(), toastText, Toast.LENGTH_LONG);
toast.show();
showDialog(activity, R.string.settings_export_success_header, activity.getString(R.string.settings_export_success, fileName));
}
});
}
@ -50,5 +48,19 @@ public class ExportHelper {
});
dialog.show();
}
private static void showDialog(final Activity activity, int headerRes, String message)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(headerRes);
builder.setMessage(message);
builder.setPositiveButton(R.string.okay_action,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
}