1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Kill off ExportHelper. It had become clutter that was only used once

This commit is contained in:
Jesse Vincent 2011-03-27 13:09:26 +08:00
parent b3b8302c52
commit 0bded12843
2 changed files with 20 additions and 87 deletions

View File

@ -61,6 +61,8 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.view.ColorChip;
import com.fsck.k9.preferences.StorageFormat;
public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener {
@ -1119,7 +1121,9 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
accountUuids.add(account.getUuid());
}
ExportHelper.exportSettings(this, includeGlobals, accountUuids, new ExportListener() {
// Once there are more file formats, build a UI to select which one to use. For now, use the encrypted/encoded format:
String storageFormat = StorageFormat.ENCRYPTED_XML_FILE;
AsyncUIProcessor.getInstance(this.getApplication()).exportSettings(this, storageFormat, includeGlobals, accountUuids, new ExportListener() {
@Override
public void canceled() {
@ -1129,23 +1133,38 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override
public void failure(String message, Exception e) {
setProgress(false);
showDialog(Accounts.this, R.string.settings_export_failed_header, Accounts.this.getString(R.string.settings_export_failure, message));
}
@Override
public void started() {
setProgress(true);
runOnUiThread(new Runnable() {
@Override
public void run() {
String toastText = Accounts.this.getString(R.string.settings_exporting);
Toast toast = Toast.makeText(Accounts.this, toastText, Toast.LENGTH_SHORT);
toast.show();
}
});
}
@Override
public void success(String fileName) {
setProgress(false);
showDialog(Accounts.this, R.string.settings_export_success_header, Accounts.this.getString(R.string.settings_export_success, fileName));
}
@Override
public void success() {
// This one should never be called here because the AsyncUIProcessor will generate a filename
setProgress(false);
}
});
}
}

View File

@ -1,86 +0,0 @@
package com.fsck.k9.activity;
import java.util.Set;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Toast;
import com.fsck.k9.R;
import com.fsck.k9.preferences.StorageFormat;
public class ExportHelper {
public static void exportSettings(final Activity activity, final boolean includeGlobals, final Set<String> accountUuids, final ExportListener listener) {
// Once there are more file formats, build a UI to select which one to use. For now, use the encrypted/encoded format:
String storageFormat = StorageFormat.ENCRYPTED_XML_FILE;
AsyncUIProcessor.getInstance(activity.getApplication()).exportSettings(activity, storageFormat, includeGlobals, accountUuids, new ExportListener() {
@Override
public void canceled() {
if (listener != null) {
listener.canceled();
}
}
@Override
public void failure(String message, Exception e) {
if (listener != null) {
listener.failure(message, e);
}
showDialog(activity, R.string.settings_export_failed_header, activity.getString(R.string.settings_export_failure, message));
}
@Override
public void started() {
if (listener != null) {
listener.started();
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
String toastText = activity.getString(R.string.settings_exporting);
Toast toast = Toast.makeText(activity, toastText, Toast.LENGTH_SHORT);
toast.show();
}
});
}
@Override
public void success(String fileName) {
if (listener != null) {
listener.success(fileName);
}
showDialog(activity, R.string.settings_export_success_header, activity.getString(R.string.settings_export_success, fileName));
}
@Override
public void success() {
// This one should never be called here because the AsyncUIProcessor will generate a filename
}
});
}
private static void showDialog(final Activity activity, final int headerRes, final String message) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
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();
}
});
}
}