fix exporting to file, close #195

This commit is contained in:
Dominik Schürmann 2014-01-14 22:07:28 +01:00
parent 0caa4de4fe
commit 16b753acca

View file

@ -80,13 +80,7 @@ public class ExportHelper {
Bundle data = message.getData(); Bundle data = message.getData();
mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME);
long keyRingRowId = Long.valueOf(dataUri.getLastPathSegment()); exportKeys(dataUri, keyType);
// TODO?
long keyRingMasterKeyId = ProviderHelper.getSecretMasterKeyId(activity,
keyRingRowId);
exportKeys(keyRingMasterKeyId, keyType);
} }
} }
}; };
@ -97,11 +91,12 @@ public class ExportHelper {
DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() {
public void run() { public void run() {
String title = null; String title = null;
if (dataUri != null) { if (dataUri == null) {
// single key export // export all keys
title = activity.getString(R.string.title_export_key);
} else {
title = activity.getString(R.string.title_export_keys); title = activity.getString(R.string.title_export_keys);
} else {
// export only key specified at data uri
title = activity.getString(R.string.title_export_key);
} }
String message = null; String message = null;
@ -125,7 +120,7 @@ public class ExportHelper {
* @param keyRingMasterKeyId * @param keyRingMasterKeyId
* if -1 export all keys * if -1 export all keys
*/ */
public void exportKeys(long keyRingMasterKeyId, int keyType) { public void exportKeys(Uri dataUri, int keyType) {
Log.d(Constants.TAG, "exportKeys started"); Log.d(Constants.TAG, "exportKeys started");
// Send all information needed to service to export key in other thread // Send all information needed to service to export key in other thread
@ -139,9 +134,12 @@ public class ExportHelper {
data.putString(KeychainIntentService.EXPORT_FILENAME, mExportFilename); data.putString(KeychainIntentService.EXPORT_FILENAME, mExportFilename);
data.putInt(KeychainIntentService.EXPORT_KEY_TYPE, keyType); data.putInt(KeychainIntentService.EXPORT_KEY_TYPE, keyType);
if (keyRingMasterKeyId == -1) { if (dataUri == null) {
data.putBoolean(KeychainIntentService.EXPORT_ALL, true); data.putBoolean(KeychainIntentService.EXPORT_ALL, true);
} else { } else {
// TODO: put data uri into service???
long keyRingMasterKeyId = ProviderHelper.getMasterKeyId(activity, dataUri);
data.putLong(KeychainIntentService.EXPORT_KEY_RING_MASTER_KEY_ID, keyRingMasterKeyId); data.putLong(KeychainIntentService.EXPORT_KEY_RING_MASTER_KEY_ID, keyRingMasterKeyId);
} }