aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-08-27 16:34:08 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-08-27 16:34:08 +0200
commite7991e8dc883087ffba802bb1ed97e93664636e2 (patch)
treef55e3e0412485bb890ab4135eb7cd6069e7707ca /OpenKeychain
parent9e3c0415497eb72b66bf7300df72966732f036c6 (diff)
downloadopen-keychain-e7991e8dc883087ffba802bb1ed97e93664636e2.tar.gz
open-keychain-e7991e8dc883087ffba802bb1ed97e93664636e2.tar.bz2
open-keychain-e7991e8dc883087ffba802bb1ed97e93664636e2.zip
use nicer filenames during export
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupFragment.java22
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java4
2 files changed, 22 insertions, 4 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupFragment.java
index 2f935008a..a3ea8ad9a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/BackupFragment.java
@@ -18,7 +18,11 @@
package org.sufficientlysecure.keychain.ui;
+import java.io.File;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.Locale;
import android.app.Activity;
import android.content.ContentResolver;
@@ -93,7 +97,7 @@ public class BackupFragment extends Fragment {
}
if (!includeSecretKeys) {
- mExportHelper.showExportKeysDialog(null, Constants.Path.APP_DIR_FILE, false);
+ startBackup(false);
return;
}
@@ -148,7 +152,7 @@ public class BackupFragment extends Fragment {
return;
}
- mExportHelper.showExportKeysDialog(null, Constants.Path.APP_DIR_FILE, true);
+ startBackup(true);
}
}.execute(activity.getContentResolver());
@@ -178,7 +182,19 @@ public class BackupFragment extends Fragment {
return;
}
- mExportHelper.showExportKeysDialog(null, Constants.Path.APP_DIR_FILE, true);
+ startBackup(true);
}
}
+
+ private void startBackup(boolean exportSecret) {
+ File filename;
+ String date = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date());
+ if (exportSecret) {
+ filename = new File(Constants.Path.APP_DIR, "keys_" + date + ".asc");
+ } else {
+ filename = new File(Constants.Path.APP_DIR, "keys_" + date + ".pub.asc");
+ }
+ mExportHelper.showExportKeysDialog(null, filename, exportSecret);
+ }
+
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index 1d0e085da..8ca4f021c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -80,6 +80,7 @@ import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.NfcHelper;
import org.sufficientlysecure.keychain.util.Preferences;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -413,7 +414,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
private void backupToFile() {
new ExportHelper(this).showExportKeysDialog(
- mMasterKeyId, Constants.Path.APP_DIR_FILE, true);
+ mMasterKeyId, new File(Constants.Path.APP_DIR,
+ KeyFormattingUtils.convertKeyIdToHex(mMasterKeyId) + ".sec.asc"), true);
}
private void deleteKey() {